views:

176

answers:

2

Is it possible to set one pin of the serial port continuously high using python (or C)? If yes, how?

+1  A: 

Yes it is possible using pySerial.

TheMachineCharmer
A: 

If you open the port, the Tx line should go to the voltage high state, and if you never send data it should stay in that state (see here). I've never actually tried this though. You might find you need to enable one of the control lines instead, like CTR.

As for software, TheMachineCharmer's suggestion of pySerial is the most platform independent way of doing it. If you're on Windows, the Win32 API calls are summarized here. Look for CreateFile and (if you need to set control lines) GetCommState and SetCommState. Note that the filename you pass to CreateFile should look like "\\\\.\\COM1". The .NET way of doing is is summarized here. You'll need to construct a SerialPort object, then access its properties to set control lines.

mtrw