Sponsored Content
Full Discussion: Serial Lines Explained
Top Forums UNIX for Dummies Questions & Answers Serial Lines Explained Post 302911909 by bakunin on Monday 4th of August 2014 12:02:02 PM
Old 08-04-2014
Let us start with some hardware first: you want to transmit signals (zeroes and ones) in both directions between two nodes. What do you need? Basically, you need 3 wires: one ground, to even out all potentials, one "transmit" line and one "receive" line. The "transmit" line is connected to the "receive" line on the other side and vice versa:

Code:
GND   -----  GND
XMIT  -----  RECV
RECV  -----  XMIT

This is the most basic pinout of a serial line. In a RS232 connection usually D-Sub 9 or D-Sub 25 connectors are used where only pin 2, 3 and 7 are connected. Find out more about RS-232 (or, as it is also called, "V.24") here.

What could affect the transmission of data in such lines? First, of course, the speed of light. Although it is pretty high it is not unlimited and the longer the line the more the time it takes the signal to travel influences the transmission. The second problem is worse: the serial cable is three thin wires running from sender to receiver. As the cables are not insulated at all they are prone to be influenced by electric fields from outside. In basic RS-232 the voltage is measured to determine if a pin is "high" ("1") or "low" ("0"). Fields from the outside can (and do) influence this voltage therefore the longer the line gets the more unreliable as a means of transport it is. There is an upper length limit for RS-232 connections therefore.

There is another technique to overcome this limitation: the "current loop" (also called "20mA interface"). It works like RS-232, but instead of measuring the voltage of one pin you measure the difference in potential between the two pins. Because the two lines go in parallel and what affects one will most probably affect the other equally it is more robust to outside electric influence.

So much for the technique. What can one do with it? Serial lines are used in all sorts of communications: modems are basically a converter from a serial line to telephone line (which works similar to a serial line itself) and back. Another usage was the transmission of data between computers before the advent of switched packet networks. The pinout above is also called "Nullmodem", because you can connect two computers via it pretending to have a modem line in between where the modem is simply missing.

Another prominent usage was to connect terminals (and other sorts of hardware) to computers. A "terminal" is: a keyboard and a screen, connected via a serial line to a computer. One would plug the serial cable into a serial connector and whatever gets typed is sent via the cable to the computer, which processes it and sends something back which goes to the screen.

The most fundamental tenet of a UNIX system is "everything is a file". YOu probably have already heard that. How does it apply here? Each terminal (its line connector, respectively) is represented by a "device file" (a file representing a piece of hardware). Write into this file and - in case of our terminal - something would appear on the screen of it. Read from this file and you get what is typed into the keyboard of it.

Basically, this is it. The kernel will recognize a newly connected terminal and create a device file for it ("/dev/ttyXX", where "XX" is some number). There is a specialized process in a UNIX system, called "getty", which scans all the terminals and, if necessary, initiates a login process. This process is what you see when you connect to a system and are presented the "login:" dialog. Once you authenticate with a user name and password and the login process ha verified you are allowed to log on your user session is started on the terminal. You enter commands, etc. (see above - the shell reads from / writes to the tty-device file) until you end your session, i.e. by issuing "logout".

Now the "getty" process kicks in again, finds an otherwise empty terminal, initiates a "login"-process there, which will wait for a username and password, and so on. If you disconnect the terminal (pull out the serial connector) the device file representing it is deleted and the "login"-process terminated for this terminal.

I hope this helps.

bakunin

Last edited by bakunin; 08-04-2014 at 01:29 PM..
This User Gave Thanks to bakunin For This Post:
 

We Also Found This Discussion For You

1. Ubuntu

Ubuntu 9.04 Serial application to telnet to serial device

Hello! I am working on an application which reads environmental instruments which have serial ports. The application requires a serial port to be present to talk to the device (i.e. /dev/ttyS0 ). In some instances the environmental devices will be 100's of yards away from the computer, so a... (5 Replies)
Discussion started by: mvona
5 Replies
All times are GMT -4. The time now is 11:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy