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

J

John Nagle

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.

Any ideas?

John Nagle
 
N

Ned Deily

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top