[Tutor] pyserial question

Stanfield, Vicki {D167~Indianapolis} VICKI.STANFIELD at ROCHE.COM
Tue Sep 23 15:32:31 EDT 2003


Actually it is not the device is it? If the device is off, I won't get anything back from it at all. If I don't get anything back for 1 minute, I want to presume it is off. I just need to be able to try to read and, if I get no response, throw an error. Is this possible?

--vicki

-----Original Message-----
From: Lloyd Kvam [mailto:pythontutor at venix.com]
Sent: Tuesday, September 23, 2003 2:29 PM
To: Stanfield, Vicki {D167~Indianapolis}
Cc: Vicki Stanfield; tutor at python.org
Subject: Re: [Tutor] pyserial question


Serial Communications never standardized on a software protocol for
these kinds of issues.  The wiring spec is often abused as well.

Essentially you throw bits onto the wire without any way of knowing
if the other end is listening.  A valid response means that all is
well.  An invalid response at least tells you that you've made
contact with the device.  Silence just means that something is wrong.

A break signal could indicate a connection problem. serialposix.py provides
a function for sending a break (sendBreak), I did not see any support
for detecting a break.

You probably need to consult your device documentation to determine
what is available for signalling and troubleshooting.


Stanfield, Vicki {D167~Indianapolis} wrote:

> Actually this functionality is just what I need, but it doesn't work in my application (always returns 0). I am using an infrared dongle, does that not meet your second spec of using a cable that actually carries the signals? If not, how can I accomplish the same thing with a read or write or something else?
> 
> --vicki
> 
> -----Original Message-----
> From: Lloyd Kvam [mailto:pythontutor at venix.com]
> Sent: Tuesday, September 23, 2003 10:45 AM
> To: Vicki Stanfield
> Cc: tutor at python.org
> Subject: Re: [Tutor] pyserial question
> 
> 
> I downloaded the current pyserial (1.20).  I looked at the serialposix.py
> file.
> 
> dev = Serial(rtscts=1,#plus other necessary parameters)
> dev.getDSR()	# should be true if device is turned on
> dev.getCTS()	# should be true if device is ready to receive data
> 
> This only works if the device actually supports hardware flow
> control signalling AND if you are using a cable that actually carries
> the signals.
> 
> The timeout will only affect commands that read from the device.
> 
> Vicki Stanfield wrote:
> 
> 
>>I am still unable to figure out how to test whether or not the device on
>>the other end of the serial connection is on. Is there a simple way to do
>>a conditional read that times out with an error after some given amount of
>>time. I am using pyserial version 1.18. When I open the port, I specify a
>>timeout of 1 second, but that doesn't seem to do what I expect it to.
>>Maybe I have to do something different with the write command to look for
>>an error code? Right now, it is simply:
>>
>>port.write('\x09')
>>
>>I don't see anything documented.
>>
>>
>>--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