libftdi Archives

Subject: Re: Multiple interface issues

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sun, 1 Jun 2014 08:10:02 +0800
On Sun, Jun 1, 2014 at 3:52 AM, Steve Soloski <ssoloski@xxxxxxxxxxxxxx> wrote:
> Just rebuilt libusb (1.0.18) and libFTDI (1.1) from the tarballs; cross
> compiling on Linux using x86_64-w64-mingw32.
>
> Same result when running under Win8 x64 - if libusbK.dll is in my path then
> I get the following error when trying to open the device more than 32 times:
>
> opening device 28 of 50...
> opening device 29 of 50...
> opening device 30 of 50...
> opening device 31 of 50...
> opening device 32 of 50...
> ftdi_usb_open failed: -5 (unable to claim usb device. Make sure the default
> FTDI driver is not in use)
>
> However, I noticed something interesting...
>
> When I try to connect to my device I always use Interface B first (it's my
> control channel and needed to init my device); Interface A is only used (in
> a separate thread) when trying to capture images. So, trying to open my
> device like this:
>
>
>     for (i=0; i<50; i++) {
>       struct ftdi_context *ftdi = ftdi_new();
>       ftdi_set_interface(ftdi, INTERFACE_B);
>
>       fprintf(stderr, "opening device %d of 50...\n", i);
>       ret = ftdi_usb_open(ftdi, 0x0403, 0x7C38);
>         ...
>       ret = ftdi_usb_close(ftdi);
>       ftdi_free(ftdi);
>     }
>
>
> will fail after 32 open/closes with the error above.
>
> However, I just tried not setting the interface to B and it works fine and
> doesn't fail - even with libusbK.dll! Seems like there's something about not
> having Interface A claimed that is causing issues... of course, since I
> always open with B that doesn't do me much good! ;)
>

I think you hit one of WinUSB's limitation.

- with WinUSB configured to point to my composite device
(ie DeviceID = "VID_0403&PID_7C38"), this fails after 32 iterations
(way down in the guts of libusb - basically after 32 iterations it runs
out of valid interfaces).

- with WinUSB configured with two interfaces (ie DeviceID_0 =
"VID_0403&PID_7C38&MI_00" and DeviceID_1 =
"VID_0403&PID_7C38&MI_01"), this run without any issues.

To use WinUSB as the driver for the USB composite device parent,
you have to claim the first interface first (interface 0, or channel A).
Ref: 
http://msdn.microsoft.com/en-us/library/windows/hardware/ff540245(v=vs.85).aspx

Again, libusbk.sys does not have such limitation, you should
try libusbk.sys instead (you will need libusbK.dll).


-- 
Xiaofan

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

Current Thread