National Instruments 320682C Musical Toy Instrument User Manual


 
Chapter 5 RS-232 Library
© National Instruments Corporation 5-7 LabWindows/CVI Standard Libraries
Hardware Handshaking
The SetCTSMode function enables hardware handshaking. For hardware handshaking to work,
two conditions must exist. First, the serial devices must follow the same or similar hardware
handshake protocols (they must use the same lines for the handshake and assign the same
meanings to those lines). Second, the serial cable connecting the two devices must include the
lines required to support the protocol. Because no single well-defined hardware handshake
protocol exists, resolve any differences between the LabWindows/CVI hardware handshake
protocol and the one your device uses.
Most serial devices primarily rely on the CTS and RTS lines to perform hardware handshaking,
and the DTR line is used to signal its online presence to the other device. Some serial devices
also may use the DTR line for hardware handshaking similarly to the CTS line. The
SetCTSMode function has two different modes to handle either case.
This SetCTSMode function employs the following line behaviors for each mode.
Note: Under UNIX, changes to the DTR line have no effect on the communication port.
LWRS_HWHANDSHAKE_OFF
The RTS and DTR lines are raised when opening the port and lowered when closing the port.
Data is sent out the port regardless of the status of CTS.
Note: Under Windows, the SetComEscape function can be used to change the value of
the RTS and DTR lines.
LWRS_HWHANDSHAKE_CTS_RTS
When the PC is the receiver:
If the port is opened, the library raises RTS and DTR.
If the input queue of the port is nearly full, the library lowers RTS.
If the input queue of the port is nearly empty, the library raises RTS.
If the port is closed, the library lowers RTS and DTR.
When the PC is the sender:
The RS-232 library must detect that its CTS line is high before sending data out the port.
LWRS_HWHANDSHAKE_CTS_RTS_DTR
When the PC is the receiver:
If the port is opened, the library raises RTS and DTR.