SettingtheRS-485ProgrammaticallyControlledBias
ResistorswithDeviceIoControl
TheNI-Serialsoftwareusesprogrammaticcontrolcodesandthe
DeviceIoControlWindowsfunctionforprogrammingtheRS-485bias
resistormode.TosetandretrievetheRS-485biasresistormode,
completethefollowingsteps:
1. Addthefollowinglinestoyoursourcecode:
#include<winioctl.h>
#include<NiSerial.h>
NoteTheheaderfileNiSerial.hisincludedonyourNI-
SerialsoftwareCD.YoualsocanfinditintheNI-Serial
folderwhereyouinstalledyourNationalInstruments
software(typically,C:\ProgramFiles\NationalInstruments\NI-
Serial).
2. TheSERIAL_RS485_BIASattributecanhavethefollowingvalues:
RS485_BIAS_OFF
RS485_BIAS_ON
3. TosettheRS-485biasresistormode,use
NISERIAL_SET_RS485_BIASandDeviceIoControl.Forexample,
toenableprogrammaticallycontrolledRS-485biasresistors,use
thefollowingcode:
SERIAL_RS485_BIASl_SerialRs485Bias=RS485_BIAS_ON;
DWORDl_ByteCount;
DeviceIoControl(
PortHandle,
NISERIAL_SET_RS485_BIAS,
(LPVOID)&l_SerialRs485Bias,
sizeof(l_SerialRs485Bias),
(LPVOID)NULL,
0,