views:

321

answers:

3

I have a piece of code that can read current state of serial port CTS line, and application then goes into appropriate mode bases on value there.

Using null-modem cable described here:

http://www.lammertbies.nl/comm/info/RS-232_null_modem.html#full

i can detect RTS line on some other port that is connected via that null-modem cable.

Is there a way of programmatic raising or lowering RTS line?

Platform is Win32, c++, but any info on when is RTS line raised or lowered would be helpful.

+6  A: 

Take a look at EscapeCommFunction.

EscapeCommFunction(hPort, SETRTS);

The hardware handshaking must be disabled, i.e. dcb.fRtsControl should be set to something other than RTS_CONTROL_HANDSHAKE when calling SetCommState.

avakar
+1  A: 

This issue is highly dependent on the specific platform, not just OS. If the RTS line is connect to the machine as an output, then it can be raised.

The lowest level hardware must provide access to the line. Some serial interfaces don't allow software access to this line, but handle it automatically through H/W handshaking.

The operating system must allow access to this resource to the user application. In some OSes, the serial port may be restricted to Kernel or super-user privilege.

Thomas Matthews
+1  A: 

In .Net it is the .RtsEnable property of the serialport.

dbasnett