Daniel Mošmondor
Daniel Mošmondor

Reputation: 19956

Raising or lowering RTS on serial port (C++)

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.

Upvotes: 2

Views: 2929

Answers (3)

dbasnett
dbasnett

Reputation: 11773

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

Upvotes: 1

Thomas Matthews
Thomas Matthews

Reputation: 57728

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.

Upvotes: 1

avakar
avakar

Reputation: 32635

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.

Upvotes: 7

Related Questions