
Chapter6 UsingYour Serial Hardware
SerialHardware and Software for Windows 6-4 ni.com
Thescratch register is located at offset 7 from the base address of the port.
Forexample, if COM2 were located at base address 0x3F8, and you want
to set thebo ard to two-wiremode with DTR control, you would write a
0x02 to address 0x3FF.The board would immediately switch to the
two-wire mode with DTR control.
Windows NT
To set the transceiver control mode, use the serial configuration utility.
For instructions on how to use the utility, refer to chapter with installation
instructions for your hardware platform. The mode you select in the
configuration utility is automatically configured when you open a port on
aserial interface.
Setting the TransceiverMode with DeviceIoControlTheNI-Serial software extends the DeviceIoControl Windows funct ion
forprogramming the transceiver control mode. To program the transceiver
control mode using DeviceIoControl, complete the following steps:
1. Add the followinglines to your source code:
#include <winioctl.h>
#define IOCTL_SERIAL_SET_TRANSCEIVER_MODE
CTL_CODE(FILE_DEVICE_SERIAL_PORT,37,
METHOD_BUFFERED,FILE_ANY_ACCESS)
2. Use the Win32function DeviceIoControl, as follows:
a. Use the defined control code value listed in step 1 to set the
transceivermode.
b. Usethe input buffer values (unsigned long) listed in Table 6-3 for
programming differenttransceiver modes.
Table6-2. Transceiver Mode Control Bytes
TransceiverMode ControlByte
Four-wiremode 0x00
Two-wiremode: DTR with echo 0x01
Two-wiremode: DTR controlled 0x02
Two-wiremode: TXRDY auto control 0x03