Hi,
I bumped into an issue when initializing a device.
The device (FTDI chip) offers up to four similar UART/serial ports,
each port is tied to a USB interface.
I use the following piece of code:
dev = usb.core.find(idVendor=vendor, idProduct=product)
if not dev:
raise IOError('Device not found')
for configuration in dev:
for interface in configuration:
ifnum = interface.bInterfaceNumber
if not dev.is_kernel_driver_active(ifnum):
continue
try:
print "detach %s: %s" % (dev, ifnum)
dev.detach_kernel_driver(ifnum)
except usb.core.USBError, e:
pass
dev.set_configuration()
I need to detach *all* the interfaces from the (Linux) kernel, or I
sometime get an error (not a big deal for my use case)
I also need to call dev.set_configuration() to configure the device.
Nothing unusual I guess.
The troubles happen when I need to open two serial ports, that is two
interfaces from the same USB device.
On the second initialization call, when dev.set_configuration() is
called for the second time, the first open interface gets in trouble:
Exception: UsbError: No such device (it may have been disconnected)
It seems set_configuration() cannot be called another time if an
interface is already being actively used.
I don't know how to avoid calling set_configuration() more that once,
as I don't know how to identify that the USB device has already been
configured.
Each call to usb.core.find() returns a different instance even when it
manages the same device, and I don't see any way to detect the
physical device has been already configured or not.
Any idea?
Thanks,
Manu
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users