Discussion:
Disconnect by usbfs, /dev/ttyUSB0 disappears when using libftdi
Michael Soire
2011-06-03 08:08:34 UTC
Permalink
Hello,



I am using a 4 port ftdi chip TYPE_4232H. When I plug in my ftdi4232H
hardware I see 4 new devices, /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 and
/dev/ttyUSB3.



After I run an application using libftdi such as the example "simple.c" I
find /dev/ttyUSB0 has disappear. If I unplug, then plugin the ftdi4232H
hardware all four /dev/ttyUSBn device come back.



Dmesg shows:

ftdi_sio 2-2.2:1.0: disconnect by usbfs

ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from
ttyUSB0

ftdi_sio 2-2.2:1.0: device disconnected



How do I use libftdi without disconnecting the serial device convertor from
ttyUSB0?



Regards

Michael





--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com
Michael Plante
2011-06-03 11:45:11 UTC
Permalink
Post by Michael Soire
I am using a 4 port ftdi chip TYPE_4232H. When I plug in my ftdi4232H
hardware I see 4 new devices, /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 and
/dev/ttyUSB3.
Post by Michael Soire
After I run an application using libftdi such as the example "simple.c" I
find /dev/ttyUSB0 has disappear. If I unplug, then plugin the ftdi4232H
hardware all four /dev/ttyUSBn device come back.
Post by Michael Soire
ftdi_sio 2-2.2:1.0: disconnect by usbfs
ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from
ttyUSB0
Post by Michael Soire
ftdi_sio 2-2.2:1.0: device disconnected
How do I use libftdi without disconnecting the serial device convertor
from ttyUSB0?


libftdi detaches ftdi_sio so it can use libusb which uses usbfs.
ftdi_usb_open_dev() calls libusb_detach_kernel_driver() in libftdi-1 and
usb_detach_kernel_driver_np() in libftdi-0. Maybe the corresponding
reattach call will help at the end of your program, after you close the
device. Alternatively, I think there might be something you can do from the
shell in /proc or /sys or something if you don't want to modify your code or
if it crashes before it can clean up, but I don't remember what. ftdi_sio
is responsible for /dev/ttyUSB* on ftdi devices.

Incidentally, while searching, I noticed the comments above
ftdi_usb_open_dev() in libusb-1 have a typo:

-\retval -11: libusb_etach_kernel_driver() failed
+\retval -11: libusb_detach_kernel_driver() failed

Regards,
Michael


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com
Thomas Jarosch
2011-06-14 13:31:58 UTC
Permalink
Post by Michael Plante
libftdi detaches ftdi_sio so it can use libusb which uses usbfs.
ftdi_usb_open_dev() calls libusb_detach_kernel_driver() in libftdi-1 and
usb_detach_kernel_driver_np() in libftdi-0. Maybe the corresponding
reattach call will help at the end of your program, after you close the
device. Alternatively, I think there might be something you can do from
the shell in /proc or /sys or something if you don't want to modify your
code or if it crashes before it can clean up, but I don't remember what.
ftdi_sio is responsible for /dev/ttyUSB* on ftdi devices.
Maybe Thomas Klose's new AUTO_DETACH_SIO_MODULE feature
might be of help here. I just forward-ported it to libftdi 1.x,
so it's now part of both libftdi git trees.

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+***@developer.intra2net.com
Loading...