National Instruments 320682C Musical Toy Instrument User Manual


 
RS-232 Library Chapter 5
LabWindows/CVI Standard Libraries 5-6 © National Instruments Corporation
application. Refer to the Hardware Handshaking section later in this chapter for more
information about using the lines 4, 5, 6, and 20.
Another area that requires special attention is the gender of the connectors of your serial cable.
The serial cable plugs into sockets in the PC and the serial device just as a lamp cord plugs into a
wall socket. Both the connector and the socket can be male, with pins (like a lamp plug), or
female, with holes (like an outlet). If your serial cable connector and PC socket are the same
gender, you cannot plug the cable into the socket. You can change this by attaching a small
device called a gender changer to your cable. One type of gender changer converts a female
connector to a male connector and the other type converts a male connector to a female
connector.
The size of the connector on your serial cable can also differ from the size of the socket. Most
serial ports require a 25-pin connector. However, some serial ports require a 9-pin connector.
To resolve this incompatibility, you must either change the connector on your serial cable or
attach a small device that converts from a 25-pin connector to a 9-pin connector.
Handshaking
A common error condition in RS-232 communications is that the receiver appears to lose data
transmitted by the sender. This condition typically results from the input queue of the receiver
not being emptied quickly enough.
Handshaking prevents overflow of the input queue that occurs when the receiver is unable to
empty its input queue as quickly as the sender is able to fill it. The RS-232 Library has two types
of handshaking: software handshaking and hardware handshaking. You should enable one or the
other if you want to ensure that your application program synchronizes its data transfers with
other serial devices that perform handshaking.
Software Handshaking
The SetXMode function enables software handshaking. You can use software handshaking
when you are transferring ASCII data or text and your serial device uses software handshaking.
The RS-232 Library performs software handshaking by sending and monitoring incoming data
for special data bytes (XON and XOFF, or decimal 17 and 19). These bytes indicate whether the
receiver is ready to receive data.
You must not enable software handshaking when transmitting binary data because the special
XON/XOFF characters can occur as part of the data stream and are mistaken as control codes.
However, you can enable hardware handshaking regardless of the type of data transferred.
No special cable configuration is required to perform software handshaking.