![National Instruments PCMCIA Series Getting Started Download Page 33](http://html1.mh-extra.com/html/national-instruments/pcmcia-series/pcmcia-series_getting-started_709070033.webp)
Chapter 4
Using Your Serial Hardware
PCMCIA Serial for Windows 95
4-4
©
National Instruments Corporation
Setting the Transceiver Mode with DeviceIoControl
The NI Serial software extends the Windows function
DeviceIoControl
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
. Use the defined control
code value listed in Step 1 to set the transceiver mode, and the input
buffer values (unsigned long) listed in Table 4-3 for programming
different transceiver modes.
For example, to set two-wire
auto control mode, use the
following call:
ULONG TranceiverMode = 131;
DeviceIoControl(
hDevice
,
IOCTL_SERIAL_SET_TRANSCEIVER_MODE,(PVOID)
&TransceiverMode,sizeof(ULONG),
lpOutBuffer
,
nOutBufferSize
,
lpBytesReturned
,
lpOverlapped
);
Table 4-3.
DeviceIoControl Function Input Values
Transceiver Mode
DeviceIoControl
Function Input Value
Four-wire mode
128
Two-wire mode:
with echo
129
Two-wire mode:
controlled
130
Two-wire mode:
auto control
131
DTR
DTR
TXRDY
TXRDY