Writing pins to the RS232
Nick Craig-Wood
nick at craig-wood.com
Tue Nov 29 12:30:03 EST 2005
Richard Brodie <R.Brodie at rl.ac.uk> wrote:
> If you just need one or two signals, then it might be practical to use one
> of the control lines, and PySerial supports this (UPS monitoring software
> often works this way).
I've done this many times (not with PySerial) for misc sensors.
With PySerial you can read 4 pins (ie 4 inputs)
getCD(self)
Read terminal status line: Carrier Detect
getCTS(self)
Read terminal status line: Clear To Send
getDSR(self)
Read terminal status line: Data Set Ready
getRI(self)
Read terminal status line: Ring Indicator
and set two outputs
setDTR(self, on=1)
Set terminal status line: Data Terminal Ready
setRTS(self, on=1)
Set terminal status line: Request To Send
Other than those 6 that you have Rx, Tx and Ground which you can't use
for logic, on a standard 9-way PC serial port.
You need to set the serial port up not to do automatic handshaking
first (eg setDsrDtr() & setRtsCts())
RS232 levels are +/- 12V, though a lot of computers only generate +/-
5V. The threshold is +/- 3V IIRC.
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list