Serial port
The Television & Movie Wiki: for TV, celebrities, and movies.
Image:Serialport.jpg In computing, a serial port is an interface on a computer system with which information is transferred in or out one bit at a time (contrast parallel port). Throughout most of the history of personal computers, this was accomplished using the RS-232 standard over simple cables connecting the computer to a device such as a terminal or modem. Mice, keyboards, and other devices were also connected this way.
While such interfaces as Ethernet networks, FireWire, USB all send data as a serial stream, the term "serial port" is usually meant to identify hardware intended to interface with a modem or similar communication devices.
Contents |
Hardware
Some computers, such as the IBM PC, used an integrated circuit called a UART, that converted characters to (and from) serial form, and automatically looked after the timing and framing of data. Very low cost systems, such as some early home computers, would instead use the CPU to send the data through an output pin, using the so-called bit-banging technique.
While RS-232 originally specified a 25-pin D-type connector, many personal computer designers chose to implement only a subset of the full standard. Compatibility with the standard was exchanged for use of less costly and more compact connectors, (in particular the DE-9 version used by the original IBM PC-AT). Presence of a D-subminiature connector is neither necessary nor sufficient to indicate use of a serial port.
On many models of Macintosh the related RS-422 standard was popular, and often used German DIN connectors.
In recent years, advanced electronics has made economical higher-speed serial communications, so RS-232 is being supplanted by newer serial communication standards such as USB and FireWire. These make it possible to connect devices that would not have been feasible over slower serial connections, such as storage devices, sound, and video devices.
In Linux, the serial port devices are usually called /dev/ttyS* where * is a number starting with 0. In Microsoft MS-DOS and Windows serial ports are referred to as COM1, COM2, etc.
Settings
There is a multitude of software settings for serial connections. Most common settings are speed, parity, and stop bits. One of the simplifications made in such standards as Ethernet, Fire Wire, and USB is to fix many of these parameters so that user configuration is not required.
Speed
Speed is bit speed from one device to another in bits per second (bit/s). Common bit rates per second for asynchronous start/stop communication are 300, 1200, 2400, 9600, 19200 bit/s, etc. The port speed and device speed must match, though some devices may automatically detect the speed of the serial port. Though the RS 232 standard is formally limited to 20,000 bits per second, serial ports on popular personal computers allow settings up to 115,000 bits per second, though not all bit rates are possible with all serial port clock generators.
Parity
Parity is a method of detecting some errors in transmission. Where parity is used with a serial port, an extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1 bits, then it must have been corrupted. If parity is correct there may have been no errors or an even number of errors. A single parity bit does not allow implementation of error correction on each character, and communication protocols working over serial data links have higher-level checksums to ensure data validity and request retransmission of data that has been incorrectly received.
Stop bits
Stop bits are sent at the end of every byte transmitted in order to allow the receiving signal hardware to resynchronise. Electronic devices usually use one stop bit. Occasionally, and especially if electromechanical devices are used such as printers, one-and-one half or two stop bits are required.
Conventional notation
The D/P/S conventional notation specifies the framing of a serial connection. The most common usage on microcomputers is 8/N/1 (8N1). This specifies 8 data bits, no parity, 1 stop bit. The number of data bits can be 7, 8, or (sometimes) 9. Parity is specified as none (N), odd (O), or even (E), with some systems supporting mark (M) or space (S) to denote a constant 1 or 0 bit for parity.
In this notation, the parity bit is not included in the data bits. 7/E/1 (7E1) means that an even parity bit is added to the seven data bits for a total of eight bits between the start and stop bits. If a receiver of a 7/E/1 stream is expecting an 8/N/1 stream, half the possible bytes will be interpreted as having the high bit set.
Flow control
A serial port may use signals in the interface to pause and resume the transmission of data. For example, a slow printer might need to handshake with the serial port to indicate that data should be paused while the mechanism advances a line. Common hardware handshake signals use the RS 232 RTS/CTS, DTR/DSR signal circuits.
An alternative method of flow control may use special characters such as XON/XOFF to control the flow of data. The XON/XOFF characters are sent by the receiver to the sender to control when the sender will send data, that is, these characters go in the opposite direction to the data being sent. The XON character tells the sender that the receiver is ready for more data. The XOFF character tells the sender to stop sending characters until the receiver is ready again.
XON/XOFF is an in-band method that works between the endpoints, but both ends must support the protocol, and there is the potential for confusion in starting up. If the control characters are part of the data stream, they must be sent as part of an escape sequence to prevent data from being interpreted as flow control. Since no extra signal ciruits are required, XON/XOFF flow control can be done on a 3 wire interface.
RTS/CTS was originally intended to allow the teletype and the modem to coordinate half-duplex links where only one modem could transmit at a time. The terminal would raise Request To Send and wait for the modem to respond with Clear To Send. RTS/CTS is a hardware handshake, but it does have advantages.
See separate article transmit flow control.
See also
- RS-232 This page contains more of the technical details including pin assignments.
- parallel portnl:Seriële poort
