Handshaking in Serial Communication

This EIA-232 communication method allows for a simple connection of three lines – Tx, Rx, and ground. However, for the data to be transmitted, both sides must be clocking the data at the same baud rate. Although this method is sufficient for most applications, it is limited in responding to problems such as overloaded receivers. This is where serial handshaking can help. Three of the most popular forms of handshaking with EIA-232 are software handshaking, hardware handshaking, and Xmodem.

Software Handshaking

This method uses data bytes as control characters similar to the way GPIB uses command strings. It also incorporates the simple three-line set of Tx, Rx, and ground because the control characters are sent over the transmission line like regular data. With the SetXMode function, you can enable or disable the use of two control characters, XON and XOFF. The data receiver sends these characters to pause the transmitter during communication.

The biggest drawback to this method is also the most important fact to keep in mind – decimal 17 and 19 are no longer available for data values. This typically does not matter in ASCII transmissions because these values are noncharacter values; however, if you transmit the data via binary, it is very likely you could transmit these values as data and the transmission would fail.

Hardware Handshaking

This method uses actual hardware lines. Like the Tx and Rx lines, the RTS/CTS and DTR/DSR lines work together. One is the output and the other is the input.

The first set of lines are RTS (Request to Send) and CTS (Clear to Send). When a receiver is ready for data, it asserts the RTS line, indicating it is ready to receive data. This is read by the sender at the CTS input, indicating it is clear to send the data.

The next set of lines are DTR (Data Terminal Ready) and DSR (Data Set Ready). Engineers use these lines mainly for modem communication because they allow the serial port and the modem to communicate their status. For example, when the modem is ready for the PC to send data, it will assert the DTR line, indicating that a connection has been made across the phone line. This is read in through the DSR line, and the PC can begin to send data. The general rule of thumb is to use the DTR/DSR lines to indicate the system is ready for communication and the RTS/CTS lines for individual frames of data.