![National Instruments ENET-232 Series User Manual Download Page 50](http://html2.mh-extra.com/html/national-instruments/enet-232-series/enet-232-series_user-manual_3450879050.webp)
Chapter 6
Using Your Serial Device Server
©
National Instruments Corporation
6-9
ENET-232 and ENET-485 Series User Manual
Setting the Transceiver Control Mode
Windows 2000/NT 4.0
To set the transceiver control mode, use the NI Ports serial configuration
utility. For instructions on how to use the utility, refer to Chapter 4,
. The mode you select in the configuration utility is
automatically configured when you open a port on a serial interface. You
can also set the mode programmatically using
DeviceIoControl()
.
Setting the Transceiver Mode with DeviceIoControl()
The serial server software extends the
DeviceIoControl()
Windows
function for programming the transceiver control mode. To program the
transceiver control mode using
DeviceIoControl()
, complete the
following steps:
1.
Add the following lines 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 Win32 function
DeviceIoControl()
, as follows:
a.
Use the defined control code value listed in step 1 to set the
transceiver mode.
b.
Use the input buffer values (unsigned long) listed in Table 6-2 for
programming different transceiver modes.
For example, to set two-wire Auto Control mode, use the following code:
ULONG TranceiverMode = 131;
ULONG dummy;
DeviceIoControl(
hDevice
,
IOCTL_SERIAL_SET_TRANSCEIVER_MODE,(PVOID)
&TransceiverMode,sizeof(ULONG),
NULL
,
0
,
&dummy
,
NULL
);
Table 6-2.
DeviceIoControl() Function Input Values
Transceiver Mode
DeviceIoControl()
Function Input Value
Four-wire mode
128
Two-wire mode: DTR with echo
129
Two-wire mode: DTR controlled
130
Two-wire mode: Auto Control
131