RS-232 is a standard for serial data communication between a DTE (Data Terminal Equipment) and a DCE (Data communication Equipment). This originally meant a dumb terminal and a modem; it was only later that personal computers, printers, and other devices started to make use of the standard.
RS-232 serial connections on PCs are gradually being superseded by USB which is faster and has connectors that are simpler to connect and use; overall USB equipment is more difficult to build and therefore more expensive.
Using asynchronous communication, characters are send one by one, commonly each character is marked by a single start bit, seven or eight data bits, possibly a "parity" bit, and a stop bit. The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels, the standard transmission speeds and connector types.
Typical RS-232 devices include external modems; some printers (most modern printers are parallel, USB, or network); device communications or statistics ports (for example, PBX SMDR or router configuration).
The standard specifies 25 different signal connections and a 25-pin "DB" connector was commonly used. Most of these pins were unused by many devices, however, so it was common for machines to save money by using smaller connectors. The IBM PC was released with 9-pin serial connectors, and that became the de facto standard of today for PCs; most host devices still use 25-pin connectors. Male and female connectors are used--often cable ends are male and device connectors are female; but not always; m-m and f-f "gender changers" are available.
For configuring and diagnosing problems with RS-232 cables, a "breakout box" may be used. This device normally has a female and male RS-232 connector and is meant to attach in-line; it then has lights for each pin.
RS-232 cables may be built with connectors commonly available at electronics stores. The cables may be between 3 and 25 pins; typically 4- or 6-pin wires are used. Flat RJ (phone-style) cables may be used with special RJ-RS232 connectors, which are the easiest to configure (since the wires are parallel and not twisted, the cables may not be able to support a signal over longer distances).
Signals are normally + or - 5 volts.
There are three types of signals carried by these wires: ground, transmit/receive, and handshake. There are standard codes for these signals, for example:
SG or GND - Ground
TD or TX - Transmit Data
RD or RX - Receive Data
DTR - Data Terminal Ready
DSR - Data Set Ready
RTS - Ready to Send
CTS - Clear to send
DCD - Data Carrier Detect
RI - Ring Indicator
FG - Frame Ground
RS-232 devices may be classified as DTE (Data Terminal Equipment) or DCE (Data Communications Equipment)--this defines which wires will be sending and recieving each signal. However, these definitions are not always adhered to strictly; normally it's necessary to consult documentation or test connections with a breakout box to determine signals required.
The ground signal is meant to ground the other connections. It is reqired. However, if the equipment is far enough apart or on separate power systems, the ground will degrade between the two devices and communications will fail; this is a difficult condition to trace. For 25-pin connectors, pin 7 is normally ground (pin 1, chassis ground, is rarely used).
For 25-pin connectors, pin 2 and 3 are the normal transmit/receive pins. One device will be sending on 2 and receiving on 3; the other should be the reverse (if not, the reverse is done in the cable end as with a null modem adapter). If you're wiring a connection, check with the breakout box on each device to see which pin it's transmitting on. Strictly speaking, only one device need be transmitting (if no handshakes or duplex communication is required)--for example a simple printer that does not report status back to the computer. But normally both TX and RX are required.
Other "handshakes" may be required by one or the other device. For example, pin 20 is commonly used to indicate "device ready". Pins may also be "jumpered" or routed back within the connector. For example a pin saying "are you ready?" from device A might be wired to the pin saying "I'm ready" on device A if device B did not transmit such a signal. Common handshake pins are 20, 8, 4, and 6.
Software-wise there are a multitude of settings for serial connections. Most common settings are speed, parity, and stop bits.
Speed is bit speed from one device to another in bits per second (bps). (Note that bits-per-second is not generally the same as baud; when techniques like Quadrature Amplitude Modulation are employed, more than one bit can be transmitted per baud. In most RS-232 applications, only very low bitrates have one bit per baud.) Common bit rates per second are 300, 1200, 2400, 9600, 19200, etc. Typically both devices must be set to the same speed but some devices (such as modems) may be set to autodetect speed.
Parity is a method of verifying accuracy of data. Parity is either none (not used), odd, or even. Parity works by modifying the data in each byte sent (or restricting the bytes sent if you like). Parity none is simple, the data is not changed. In even parity the data is arranged so that the number of 1 bits (that is, the total count of them in a binary byte) is an even number; this is arranged by setting the parity bit (usually the most significant bit) to be a 0 or 1 accordingly. In odd parity the number of 1 bits is an odd number. Parity can be used by the receiver to detect transmission errors - if a byte is received with the wrong number of 1 bits, then it must have been corrupted.
Stop bits are sent at the end of every byte transmitted in order to help the signal hardware at either end of the link resynchronise.
There is a D/P/S conventional notation for specifying the software setup of a serial connection. 8/N/1 (very common) specifies 8 data bits, no parity, 1 stop bit. The number of data bits can be 7, 8, or (sometimes) 9. Parity can be none (N), odd (O), or even (E); the parity bit is borrowed from the data bits, so 8/E/1 means that one of the 8 data bits is used as the parity bit. There can be 1 or 2 stop bits (occasionally 0 I think).
Other settings define when pins will send handshake signals, or other data integrity checks. The most common of these is XON/XOFF. The XON character tells the receiver that the sender is ready to receive more data. The XOFF character tells the receiver to stop sending characters. The use of XON/XOFF is deprecated, it is preferable to use RTS/CTS flow control instead.
There are a couple signaling "standards" often called RS-232, but really aren't. TTL-level RS-232 uses +5V for high, and 0V for low. CMOS-level RS-232 uses +3.3V for high, and 0V for low. Typically, these signal levels are used between two devices on the same circuit board.