Serial Communication Interview Questions and Answers
Serial Communication Interview Questions and Answers
Serial Communication Interview Questions and Answers
What is Handshaking?
The method used by RS-232 for communication allows for a simple connection of three lines: TX,
RX, and ground.
For the data to be transmitted, both sides have to be clocking the data at the same baud rate.
Although, this method is sufficient for most applications, it is limited in being able to respond to
problems such as the receiver getting overloaded. This is where serial handshaking can help.
In this section we will discuss three of the most popular forms of handshaking with RS-232:
Software Handshaking, Hardware Handshaking, and Xmodem.
Software Handshaking:
The first form of handshaking we will discuss is software handshaking. This style uses actual data
bytes as control characters, similar to the way GPIB uses command strings.
The lines necessary are still the simple three line set of TX, RX, and round since the control
characters are sent over the transmission line like regular data. The function SetXMode allows the
user to enable or disable the use of two control characters, XON and XOFF.
These characters are sent by the receiver of the data to pause the transmitter during
communication.As an example, assume that the transmitter begins to transmit data at a high baud
rate.
During the transmission, the receiver finds that the input buffer is becoming full due to the CPU
being busy with other duties. To temporarily pause the transmission, the receiver sends XOFF,
typically decimal 19 or hex 13, until the input buffer has been emptied.
Once the receiver is ready for more data it sends XON, typically decimal 17 or hex 11, to resume
communication. LabWindows will send XOFF when its input buffer becomes half full.
In addition, in case the XOFF transmission was corrupted, LabWindows will also transmit XOFF
when the buffer has reached 75% and 90% capacity.
Obviously, the transmitter must also be following this protocol for it to succeed.The biggest
drawback to this method is also the most important fact to keep in mind: decimal 17 and 19 are
now off limits for data values.
In ASCII transmissions this typically does not matter since these values are non-character values;
however, if the data is being transmitted via binary, it is very likely that these values could be
transmitted as data and the transmission would fail.
Hardware Handshaking:
The second method of handshaking is to use actual hardware lines. Like the TX and RX lines, the
RTS/CTS and DTR/DSR lines work together with one being the output and the other 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 will assert the RTS line indicating it is ready to receive data.
This is then 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).
These lines are used mainly for modem communication. They allow the serial port and the modem
to communicate their status.
For example, when the modem is ready for data to be sent from the PC, 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 that the DTR/DSR lines are used to indicate that the system is ready
for communication where the RTS/CTS lines are used for individual packets of data.
USB Communication
USB handles communication between a single host – a computer in most cases – and a variety of
nodes (peripherals with particular functions), and hubs (which repeat the USB signaling to allow
more nodes to be connected to the host).
You can add more USB devices by adding a hub to an available port. You can connect up to 127
devices, with no more than five hubs between any given node and the host.
When you plug a USB device into an active host, the host immediately queries the device for its
characteristics.
Based on those characteristics, the host USB driver loads device-specific drivers to control the
device.
Those drivers complete the initialization process and set up any pipes, or communication
channels, that applications may need to use.
A device can have multiple interfaces so that different applications can communicate with it in
different ways. The device connects to the host pipes through endpoints, which are unidirectional
ports for data transfer.
Each endpoint has certain characteristics that define its functionality. USB does not have a
standard for communication as RS232/485 does.
USB versus RS232/485 Speed
With the older USB 1.1 specification, throughput reaches a maximum of 1.5 Mbytes/s.
The current generation of USB products incorporates the USB 2.0 specification which further
increases the bus throughput up to 60 Mbytes/s.
The speed of serial communication is determined by the baud rate (related to bits per second or
b/s). Typically, the fastest possible baud rate is 115.2 kbytes/s, but with the correct hardware
speeds, up to 1 Mbytes/s is possible.
USB – Plug-and-Play Compatible
Because the USB is a plug-and-play technology, the USB host automatically detects when a new
device has been added, queries the device for its identification, and configures the device drivers
appropriately.
Thus USB devices are “hot swappable,” which means you can plug in or disconnect the device
without the having to power down.
Devices that are connected to an RS232/485 port are not plug-and-play compatible; they are
configured manually every time you connect them to a PC.
RS232 vs RS485 Communication