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

Vicki Stanfield vicki at thepenguin.org
Mon Sep 22 15:24:31 EDT 2003


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



More information about the Tutor mailing list