Skip to contentSkip to conversation

Behavior of serial usb driver when unplugged

DISCUSSION Byron Stanoszek 2 participants 2 messages Jun 8, 2004 – Jun 9, 2004

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm currently using Linux (2.6.7-rc3) in an embedded system with a 8-port Sealevel SeaLink 2802 USB device. This is a 8-port RS-232/422 device that allocates /dev/ttyUSB0 through /dev/ttyUSB7 when plugged in.

If I have a process talking to one of the ports, e.g. 'cat < /dev/ttyUSB0', and I unplug the USB hub, all ports except ttyUSB0 unregister properly.

Without killing the 'cat' process, plugging the hub back in will make it allocate /dev/ttyUSB1 through /dev/ttyUSB8, thereby offsetting each USB port# by 1.

When killing the 'cat' process at this point, the kernel reports:

drivers/usb/serial/ftdi_sio.c: error from flowcontrol urb drivers/usb/serial/ftdi_sio.c: Error from DTR LOW urb drivers/usb/serial/ftdi_sio.c: Error from RTS LOW urb

and then unregisters /dev/ttyUSB0.

Is there a way to allow "hotplug" of a USB device to reuse /dev/ttyUSB0 regardless if an application still has that particular tty open?

If not, is there a way I could make the serial subsystem can send an EIO errno or some other notification when the serial device is disconnected?

Thanks for your help,
-Byron

--

Byron Stanoszek                         Ph: (330) 644-3059
Systems Programmer                      Fax: (330) 644-8110
Commercial Timesharing Inc.             Email: [email protected]
#1 lore raw
Quoted 9 lines · Byron Stanoszek

Hi all,

I'm currently using Linux (2.6.7-rc3) in an embedded system with a 8-port Sealevel SeaLink 2802 USB device. This is a 8-port RS-232/422 device that allocates /dev/ttyUSB0 through /dev/ttyUSB7 when plugged in.

If I have a process talking to one of the ports, e.g. 'cat < /dev/ttyUSB0', and
I unplug the USB hub, all ports except ttyUSB0 unregister properly.

That's because userspace still has that port open.

Quoted 3 lines

Without killing the 'cat' process, plugging the hub back in will make it allocate /dev/ttyUSB1 through /dev/ttyUSB8, thereby offsetting each USB port# by 1.

Yup, glad it's all working properly for you.

Quoted 7 lines

When killing the 'cat' process at this point, the kernel reports:

drivers/usb/serial/ftdi_sio.c: error from flowcontrol urb drivers/usb/serial/ftdi_sio.c: Error from DTR LOW urb drivers/usb/serial/ftdi_sio.c: Error from RTS LOW urb

and then unregisters /dev/ttyUSB0.

Nice.

Quoted 2 lines

Is there a way to allow "hotplug" of a USB device to reuse /dev/ttyUSB0 regardless if an application still has that particular tty open?

Nope. Why would you want to do such a thing?

Quoted 3 lines

If not, is there a way I could make the serial subsystem can send an EIO errno or some other notification when the serial device is disconnected?

It's been discussed that the tty_hangup() should be done for the port when this happens. I haven't messed with it to test it out, as no one has complained in the 5+ years of usb-serial drivers being in the kernel :)

Also, you could use something like udev to make the name always show up the same for the device node no matter if it was called ttyUSB0 or ttyUSB1, which might solve some of your problems (but not others it sounds like.)

thanks,

greg k-h