pyserial vs. Linux power save hibernate/resume - program hangs

Ned Deily nad at acm.org
Sun Nov 8 21:21:13 CET 2009


In article <4af71b7e$0$1645$742ec2ed at news.sonic.net>,
 John Nagle <nagle at animats.com> wrote:
>     I have an application running with pyserial talking to a USB to serial
> converter on a Linux EeePC 2G Surf.  This works.  Until the lid on the PC is
> closed and the device suspends.
> 
>     The application has /dev/ttyUSB0 open, and has a read pending
> with a 1 second timeout.   When the device comes out of suspend,
> the USB devices are enumerated again.  The serial device moves
> to /dev/ttyUSB1, and the application continues to poll /dev/ttyUSB0.
> No error results from polling the removed device.  So the
> application is stuck and doesn't know it.
> 
>     An attempt to write to the disconnected serial port produces
> an IOError exception, but the read side doesn't seem to notice.

If your Linux is new enough, you should be able to create a permanent 
device name for the serial converter using a udev rule.   Then your code 
won't need to be dependent on the /dev/ttyUSBx device name.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list