On Mon, Jun 2, 2014 at 8:22 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
My test code was not correct, and now I can reproduce your issue
with either libusbk.sys or WinUSB.
And you are also right without libusbk.dll and only use WinUSB,
the test code will not fail.
On the other hand, usually you should not need to
open the device multiple times under libusb, you only
need to do it once.
Here is the test code.
Mcuee@Win8X64VM /c/work/libftdi/test
$ cat testlibftdi.c
#include <stdio.h>
#include <stdlib.h>
#include <ftdi.h>
int main(void)
{
int i, ret;
for (i=0; i<50; i++) {
struct ftdi_context *dev = ftdi_new();
ftdi_set_interface(dev, INTERFACE_B);
fprintf(stderr, "opening device %d of 50...\n", i);
ret=ftdi_usb_open(dev, 0x0403, 0xcff8);
if(ret)
fprintf(stderr, "opening device failed\n");
ftdi_usb_close(dev);
ftdi_free(dev);
}
}
Here is the debug output. It seems to me there is a problem with
libusb Windows backend.
If possible, please help to translate the above program to pure libusb
(I am not a programmer myself) and reproduce the issue to confirm
that libftdi is not the problem.
$ export LIBUSB_DEBUG=2
With libusbK.dll
$ ./testlibftdi.exe
opening device 0 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
opening device 1 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
...
opening device 31 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0 (required to
claim 1 with WinUSB)
opening device 32 of 50...
libusb: warning [winusbx_claim_interface] failed to auto-claim
interface 0 (required to claim 1 with WinUSB): [84] Storage to process
this request is not available.
opening device failed
opening device 33 of 50...
libusb: warning [winusbx_claim_interface] failed to auto-claim
interface 0 (required to claim 1 with WinUSB): [84] Storage to process
this request is not available.
opening device failed
...
opening device 49 of 50...
libusb: warning [winusbx_claim_interface] failed to auto-claim
interface 0 (required to claim 1 with WinUSB): [84] Storage to process
this request is not available.
opening device failed
Without libusbK.dll
$ ./testlibftdi.exe
opening device 0 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
opening device 1 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
...
opening device 31 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
opening device 32 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)
...
opening device 49 of 50...
libusb: warning [winusbx_claim_interface] auto-claimed interface 0
(required to claim 1 with WinUSB)