[Tutor] Serial Com Question (How to detect non-response)

Lloyd Kvam pythontutor at venix.com
Mon Sep 22 15:41:32 EDT 2003


If your device provides hardware handshaking signals,
and if your cable is carrying them across to your computer,
and if serial supports examining the signals
then you can check DataSetReady (DSR) which would be pin 6 on a 25 pin connector.
DSR indicates that it is powered on and in a ready state as opposed to a
a test or stand-by state (or off).

Your computer would normally be a DTE serial pinout.  Your device is
a DCE pinout if works with a "regular" modem cable.

ClearToSend (CTS) could be used to indicate that the device is ready for your
program to send data.

Vicki Stanfield wrote:

> In the project I am working on, which is coming along nicely thanks to
> this list, my Python program establishes serial communication with a
> device which may be turned on or off. How would I detect whether the
> device is off? When I establish the serial port with:
> 
> port = serial.Serial(0, 9600, 8, 'N', 2, timeout=60)
> 
> The program has no way of knowing whether or not the device on the other
> end is on or off, correct? If I attempt to send a command to the device, I
> get no response (obviously) if the device is off, but my program keeps
> trying. Is there a way to tell it to attempt to send a command but to stop
> after a few seconds and throw up an error? Or is there already a standard
> way to do this?
> 
> --vicki
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582




More information about the Tutor mailing list