Quantcast

Multiple interface issues

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multiple interface issues

Steve Soloski
Hi,

I've got a device that uses a FT2232H chip; and our application uses
both interfaces - INTF1 to control the device (I2C and GPIO), and INTF0
to send image data to the host. I'm doing some unit testing under Win8.1
x64, and am using the WinUSB driver with an INF file generated from
libusbK-inf-wizard.

My test is fairly simple - open and close the device 50 times. The logic
is very straightforward (error checking removed for clarity):

     for (i=0; i<50; i++) {
         struct ftdi_context *dev = ftdi_new();
         ftdi_set_interface(dev, INTERFACE_B);

         ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
         ftdi_usb_close(dev);
         ftdi_free(dev);
     }

Depending on how my WinUSB driver is configured, different things happen:

- 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.

The problem I'm having is that if the WinUSB driver is configured with
two interfaces, then I can't access both interfaces simultaneously - the
only way I've been able to do that is to have the driver configured for
the composite device.

Is this a bug, or am I missing something in how to configure and talk to
two interface?

Any help or ideas would be appreciated!

Steve

PS - for full disclosure, in our real code I'm using libMPSSE to open
Interface B for controlling the device, then using libFTDI to open
Interface A when I start capturing images. In troubleshooting, I've
narrowed the issue down to the code shown above... and I'm not sure if
it's an issue with libFTDI or libUSB or me!



--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]> wrote:
> My test is fairly simple - open and close the device 50 times. The logic is
> very straightforward (error checking removed for clarity):
>
>     for (i=0; i<50; i++) {
>         struct ftdi_context *dev = ftdi_new();
>         ftdi_set_interface(dev, INTERFACE_B);
>
>         ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);

I believe you need to reverse the order of the previous two
calls. You need to open the device and then set_interface.

>         ftdi_usb_close(dev);
>         ftdi_free(dev);
>     }

--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Anders Larsen
Hi,

On 2014-05-30 07:03, Xiaofan Chen wrote:
> On Thu, May 29, 2014 at 7:18 AM, Steve Soloski  
> <[hidden email]> wrote:
> >         ftdi_set_interface(dev, INTERFACE_B);
> >         ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>
> I believe you need to reverse the order of the previous two
> calls. You need to open the device and then set_interface.

no, the order is correct.

With the order reversed ftdi_set_interface() errors out with:
"Interface can not be changed on an already open device"

Cheers
Anders
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Fri, May 30, 2014 at 4:02 PM, Anders Larsen <[hidden email]> wrote:

> Hi,
>
>
> On 2014-05-30 07:03, Xiaofan Chen wrote:
>>
>> On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]>
>> wrote:
>> >         ftdi_set_interface(dev, INTERFACE_B);
>> >         ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>>
>> I believe you need to reverse the order of the previous two
>> calls. You need to open the device and then set_interface.
>
>
> no, the order is correct.
>
> With the order reversed ftdi_set_interface() errors out with:
> "Interface can not be changed on an already open device"
>

I see. I mixed it up with libusb where you need to open
the device first.

--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
On 05/30/2014 10:02 AM, Xiaofan Chen wrote:

> On Fri, May 30, 2014 at 4:02 PM, Anders Larsen <[hidden email]> wrote:
>> Hi,
>>
>>
>> On 2014-05-30 07:03, Xiaofan Chen wrote:
>>> On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]>
>>> wrote:
>>>>          ftdi_set_interface(dev, INTERFACE_B);
>>>>          ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>>> I believe you need to reverse the order of the previous two
>>> calls. You need to open the device and then set_interface.
>>
>> no, the order is correct.
>>
>> With the order reversed ftdi_set_interface() errors out with:
>> "Interface can not be changed on an already open device"
>>
> I see. I mixed it up with libusb where you need to open
> the device first.
>

Well, after banging my head against the wall all day yesterday, I've
figured out what's happening...

In all of my installing/uninstalling of the USB driver - trying both
libusbK-inf-wizard and zadig - I eneded up with both libusb0.dll and
libusbK.dll on my system, in addition to the WinUSB that I wanted. Not
quite sure how they all got installed, but when I deleted both of them
(and only used the WinUSB driver) then this issue went away. Not sure
what was causing the issue, but at least it's resolved!

Thanks for looking at this!

Steve


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Fri, May 30, 2014 at 10:17 PM, Steve Soloski <[hidden email]> wrote:

> Well, after banging my head against the wall all day yesterday, I've figured
> out what's happening...
>
> In all of my installing/uninstalling of the USB driver - trying both
> libusbK-inf-wizard and zadig - I eneded up with both libusb0.dll and
> libusbK.dll on my system, in addition to the WinUSB that I wanted. Not quite
> sure how they all got installed, but when I deleted both of them (and only
> used the WinUSB driver) then this issue went away. Not sure what was causing
> the issue, but at least it's resolved!
>

Hmm, that is strange. libusbk-inf-wizard and Zadig both install libusb0.dll
and libusbK.dll to be compatible with libusb-win32 and libusbK.

As for libusb Winodws backend, it will work either with libusbK.dll (to
support libusb0.sys, libusbK.sys and WinUSB) or without libusbK.dll
(only works with WinUSB). The code path will be a bit different.

Are you using the latest release version of libusb (1.0.18)?



--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
On 5/30/2014 9:32 PM, Xiaofan Chen wrote:

> On Fri, May 30, 2014 at 10:17 PM, Steve Soloski <[hidden email]> wrote:
>> Well, after banging my head against the wall all day yesterday, I've figured
>> out what's happening...
>>
>> In all of my installing/uninstalling of the USB driver - trying both
>> libusbK-inf-wizard and zadig - I eneded up with both libusb0.dll and
>> libusbK.dll on my system, in addition to the WinUSB that I wanted. Not quite
>> sure how they all got installed, but when I deleted both of them (and only
>> used the WinUSB driver) then this issue went away. Not sure what was causing
>> the issue, but at least it's resolved!
>>
> Hmm, that is strange. libusbk-inf-wizard and Zadig both install libusb0.dll
> and libusbK.dll to be compatible with libusb-win32 and libusbK.
>
> As for libusb Winodws backend, it will work either with libusbK.dll (to
> support libusb0.sys, libusbK.sys and WinUSB) or without libusbK.dll
> (only works with WinUSB). The code path will be a bit different.
>
> Are you using the latest release version of libusb (1.0.18)?
>
>
>
Actually right now I'm using the latest snapshot of libusb (1.0.19-rc1)
since I saw that it had some changes for better Win8 support. But I'm
pretty sure I saw the same issues with 1.0.18... but honestly, right now
I can't remember. When I get back into the office on Monday I'll revert
back to 1.0.18 and post my results.



--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
In reply to this post by Xiaofan Chen
On 05/30/2014 09:32 PM, Xiaofan Chen wrote:

> On Fri, May 30, 2014 at 10:17 PM, Steve Soloski <[hidden email]> wrote:
>> Well, after banging my head against the wall all day yesterday, I've figured
>> out what's happening...
>>
>> In all of my installing/uninstalling of the USB driver - trying both
>> libusbK-inf-wizard and zadig - I eneded up with both libusb0.dll and
>> libusbK.dll on my system, in addition to the WinUSB that I wanted. Not quite
>> sure how they all got installed, but when I deleted both of them (and only
>> used the WinUSB driver) then this issue went away. Not sure what was causing
>> the issue, but at least it's resolved!
>>
> Hmm, that is strange. libusbk-inf-wizard and Zadig both install libusb0.dll
> and libusbK.dll to be compatible with libusb-win32 and libusbK.
>
> As for libusb Winodws backend, it will work either with libusbK.dll (to
> support libusb0.sys, libusbK.sys and WinUSB) or without libusbK.dll
> (only works with WinUSB). The code path will be a bit different.
>
> Are you using the latest release version of libusb (1.0.18)?
>
>
>

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! ;)


Steve


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Sun, Jun 1, 2014 at 3:52 AM, Steve Soloski <[hidden email]> 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 [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
In reply to this post by Steve Soloski
On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]> wrote:

> Hi,
>
> I've got a device that uses a FT2232H chip; and our application uses both
> interfaces - INTF1 to control the device (I2C and GPIO), and INTF0 to send
> image data to the host. I'm doing some unit testing under Win8.1 x64, and am
> using the WinUSB driver with an INF file generated from libusbK-inf-wizard.
>
> My test is fairly simple - open and close the device 50 times. The logic is
> very straightforward (error checking removed for clarity):
>
>     for (i=0; i<50; i++) {
>         struct ftdi_context *dev = ftdi_new();
>         ftdi_set_interface(dev, INTERFACE_B);
>
>         ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>         ftdi_usb_close(dev);
>         ftdi_free(dev);
>     }
>
> Depending on how my WinUSB driver is configured, different things happen:
>
> - 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.
>
> The problem I'm having is that if the WinUSB driver is configured with two
> interfaces, then I can't access both interfaces simultaneously - the only
> way I've been able to do that is to have the driver configured for the
> composite device.
>
> Is this a bug, or am I missing something in how to configure and talk to two
> interface?
>
> Any help or ideas would be appreciated!
>

BTW, I can not reproduce your issue under Windows 8 with libusb-1.0.18
and libusbK 3.0.7.0 (both latest relese version) with your minimum
program under Windows 8.1 x64 using MinGW-w64 compiler.

The minimum program does not have USB I/O communication
so that you do not need even need to install a supported driver in order
for it to work under Windows (even using the Vendor driver will work).
And no matter how I install the driver (libusbk.sys or winusb,
composite device parent or individual interface), it will work.

Are you sure you are seeing the issue with the above minimum
code snippets?


$ cd /c/work/libftdi/test/

$ ls
maketest.sh  testlibftdi  testlibftdi.c  testlibftdi.exe

$ cat testlibftdi.c

#include <stdio.h>
#include <stdlib.h>
#include <ftdi.h>

int main(void)
{
        int i;
        for (i=0; i<50; i++) {
        struct ftdi_context *dev = ftdi_new();
        ftdi_set_interface(dev, 1);
                fprintf(stderr, "opening device %d of 50...\n", i);
        ftdi_usb_open(dev, 0x0403, 0xcff8);
        ftdi_usb_close(dev);
        ftdi_free(dev);
    }
}


$ cat maketest.sh
gcc $(pkg-config --cflags libftdi1) $(pkg-config --libs libftdi1)  -o
testlibftdi testlibftdi.c


$ ./testlibftdi.exe
opening device 0 of 50...
opening device 1 of 50...
opening device 2 of 50...
opening device 3 of 50...
opening device 4 of 50...
opening device 5 of 50...
opening device 6 of 50...
opening device 7 of 50...
opening device 8 of 50...
opening device 9 of 50...
opening device 10 of 50...
opening device 11 of 50...
opening device 12 of 50...
opening device 13 of 50...
opening device 14 of 50...
opening device 15 of 50...
opening device 16 of 50...
opening device 17 of 50...
opening device 18 of 50...
opening device 19 of 50...
opening device 20 of 50...
opening device 21 of 50...
opening device 22 of 50...
opening device 23 of 50...
opening device 24 of 50...
opening device 25 of 50...
opening device 26 of 50...
opening device 27 of 50...
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...
opening device 33 of 50...
opening device 34 of 50...
opening device 35 of 50...
opening device 36 of 50...
opening device 37 of 50...
opening device 38 of 50...
opening device 39 of 50...
opening device 40 of 50...
opening device 41 of 50...
opening device 42 of 50...
opening device 43 of 50...
opening device 44 of 50...
opening device 45 of 50...
opening device 46 of 50...
opening device 47 of 50...
opening device 48 of 50...
opening device 49 of 50...

$ uname
MINGW32_NT-6.2

--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
In reply to this post by Xiaofan Chen
On 5/31/2014 8:10 PM, Xiaofan Chen wrote:

> On Sun, Jun 1, 2014 at 3:52 AM, Steve Soloski <[hidden email]> 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).
>
>

Hmmm... but these errors are happening when libusbK is present (ie in
windows\system32 and windows\syswow64), and if I remove libusbK then the
errors go away. So I can run the above code with just WinUSB (no
libusbK.dll) and it works fine; however if libusbK.dll is present then
it fails. The reason the errors were happening before was due to the
fact that libusbK was present.

I'll double check everything just to make sure I didn't screw something
up... it sounds like libusbK would really make my life easier; but I
just need to make sure I understand why this issue is happening. and I'm
sure it's something on my side, I just don't know what it could be. I'll
take another look at things tomorrow...

Steve





--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
In reply to this post by Xiaofan Chen
On 5/31/2014 9:06 PM, Xiaofan Chen wrote:

> On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]> wrote:
>> Hi,
>>
>> I've got a device that uses a FT2232H chip; and our application uses both
>> interfaces - INTF1 to control the device (I2C and GPIO), and INTF0 to send
>> image data to the host. I'm doing some unit testing under Win8.1 x64, and am
>> using the WinUSB driver with an INF file generated from libusbK-inf-wizard.
>>
>> My test is fairly simple - open and close the device 50 times. The logic is
>> very straightforward (error checking removed for clarity):
>>
>>      for (i=0; i<50; i++) {
>>          struct ftdi_context *dev = ftdi_new();
>>          ftdi_set_interface(dev, INTERFACE_B);
>>
>>          ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>>          ftdi_usb_close(dev);
>>          ftdi_free(dev);
>>      }
>>
>> Depending on how my WinUSB driver is configured, different things happen:
>>
>> - 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.
>>
>> The problem I'm having is that if the WinUSB driver is configured with two
>> interfaces, then I can't access both interfaces simultaneously - the only
>> way I've been able to do that is to have the driver configured for the
>> composite device.
>>
>> Is this a bug, or am I missing something in how to configure and talk to two
>> interface?
>>
>> Any help or ideas would be appreciated!
>>
> BTW, I can not reproduce your issue under Windows 8 with libusb-1.0.18
> and libusbK 3.0.7.0 (both latest relese version) with your minimum
> program under Windows 8.1 x64 using MinGW-w64 compiler.
>
> The minimum program does not have USB I/O communication
> so that you do not need even need to install a supported driver in order
> for it to work under Windows (even using the Vendor driver will work).
> And no matter how I install the driver (libusbk.sys or winusb,
> composite device parent or individual interface), it will work.
>
> Are you sure you are seeing the issue with the above minimum
> code snippets?
>
>
> $ cd /c/work/libftdi/test/
>
> $ ls
> maketest.sh  testlibftdi  testlibftdi.c  testlibftdi.exe
>
> $ cat testlibftdi.c
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <ftdi.h>
>
> int main(void)
> {
>          int i;
>          for (i=0; i<50; i++) {
>          struct ftdi_context *dev = ftdi_new();
>          ftdi_set_interface(dev, 1);
>                  fprintf(stderr, "opening device %d of 50...\n", i);
>          ftdi_usb_open(dev, 0x0403, 0xcff8);
>          ftdi_usb_close(dev);
>          ftdi_free(dev);
>      }
> }
>
>
> $ cat maketest.sh
> gcc $(pkg-config --cflags libftdi1) $(pkg-config --libs libftdi1)  -o
> testlibftdi testlibftdi.c
>
>
> $ ./testlibftdi.exe
> opening device 0 of 50...
> opening device 1 of 50...
> opening device 2 of 50...
> opening device 3 of 50...
> opening device 4 of 50...
> opening device 5 of 50...
> opening device 6 of 50...
> opening device 7 of 50...
> opening device 8 of 50...
> opening device 9 of 50...
> opening device 10 of 50...
> opening device 11 of 50...
> opening device 12 of 50...
> opening device 13 of 50...
> opening device 14 of 50...
> opening device 15 of 50...
> opening device 16 of 50...
> opening device 17 of 50...
> opening device 18 of 50...
> opening device 19 of 50...
> opening device 20 of 50...
> opening device 21 of 50...
> opening device 22 of 50...
> opening device 23 of 50...
> opening device 24 of 50...
> opening device 25 of 50...
> opening device 26 of 50...
> opening device 27 of 50...
> 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...
> opening device 33 of 50...
> opening device 34 of 50...
> opening device 35 of 50...
> opening device 36 of 50...
> opening device 37 of 50...
> opening device 38 of 50...
> opening device 39 of 50...
> opening device 40 of 50...
> opening device 41 of 50...
> opening device 42 of 50...
> opening device 43 of 50...
> opening device 44 of 50...
> opening device 45 of 50...
> opening device 46 of 50...
> opening device 47 of 50...
> opening device 48 of 50...
> opening device 49 of 50...
>
> $ uname
> MINGW32_NT-6.2
>

First off - many thanks for looking into this! If you can't get it to
fail, then there is obviously something wrong with my build and/or
configuration. I rebuilt everything today, however it's possible I got
something out of whack. I'll do another double-check tomorrow and try to
nail down where I've messed up...

Thanks again for checking this out!

Steve


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
In reply to this post by Xiaofan Chen
On Sun, Jun 1, 2014 at 8:10 AM, Xiaofan Chen <[hidden email]> wrote:

> 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).

This may not be correct. libusb Windows backen will try to
auto-claim the default interface.


--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
Finally managed to get my simple open app to run... and I'm embarrassed
to sya what the issue was.

Turns out I was running with libusbK v3.0.6.0, not the latest version -
I checked all the versions of the other dlls, but not that one. Doh!

However, thanks to all your help I think I can now move forward.

Many, many thanks again!

Steve

On 05/31/2014 11:28 PM, Xiaofan Chen wrote:

> On Sun, Jun 1, 2014 at 8:10 AM, Xiaofan Chen <[hidden email]> wrote:
>> 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).
> This may not be correct. libusb Windows backen will try to
> auto-claim the default interface.
>
>


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
In reply to this post by Xiaofan Chen
Sigh... I spoke too soon - my test code was opening Interface A instead
of Interface B.

Verified all of my files and versions - latest libusbK (3.0.7.0);
libFTDI (1.1) and libusb (1.0.18).

The Windows driver installed is libusbK on the composite device.

Trying to open my device on Interface B greater than 32 times still fails.

Note that in your code snippet below, you're opening Interface A and not
Interface B.

Can you try opening Interface B instead and see if it works?

Steve



On 05/31/2014 09:06 PM, Xiaofan Chen wrote:

> On Thu, May 29, 2014 at 7:18 AM, Steve Soloski <[hidden email]> wrote:
>> Hi,
>>
>> I've got a device that uses a FT2232H chip; and our application uses both
>> interfaces - INTF1 to control the device (I2C and GPIO), and INTF0 to send
>> image data to the host. I'm doing some unit testing under Win8.1 x64, and am
>> using the WinUSB driver with an INF file generated from libusbK-inf-wizard.
>>
>> My test is fairly simple - open and close the device 50 times. The logic is
>> very straightforward (error checking removed for clarity):
>>
>>      for (i=0; i<50; i++) {
>>          struct ftdi_context *dev = ftdi_new();
>>          ftdi_set_interface(dev, INTERFACE_B);
>>
>>          ftdi_usb_open(dev, PICAM_USB_VID, PICAM_USB_PID);
>>          ftdi_usb_close(dev);
>>          ftdi_free(dev);
>>      }
>>
>> Depending on how my WinUSB driver is configured, different things happen:
>>
>> - 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.
>>
>> The problem I'm having is that if the WinUSB driver is configured with two
>> interfaces, then I can't access both interfaces simultaneously - the only
>> way I've been able to do that is to have the driver configured for the
>> composite device.
>>
>> Is this a bug, or am I missing something in how to configure and talk to two
>> interface?
>>
>> Any help or ideas would be appreciated!
>>
> BTW, I can not reproduce your issue under Windows 8 with libusb-1.0.18
> and libusbK 3.0.7.0 (both latest relese version) with your minimum
> program under Windows 8.1 x64 using MinGW-w64 compiler.
>
> The minimum program does not have USB I/O communication
> so that you do not need even need to install a supported driver in order
> for it to work under Windows (even using the Vendor driver will work).
> And no matter how I install the driver (libusbk.sys or winusb,
> composite device parent or individual interface), it will work.
>
> Are you sure you are seeing the issue with the above minimum
> code snippets?
>
>
> $ cd /c/work/libftdi/test/
>
> $ ls
> maketest.sh  testlibftdi  testlibftdi.c  testlibftdi.exe
>
> $ cat testlibftdi.c
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <ftdi.h>
>
> int main(void)
> {
>          int i;
>          for (i=0; i<50; i++) {
>          struct ftdi_context *dev = ftdi_new();
>          ftdi_set_interface(dev, 1);
>                  fprintf(stderr, "opening device %d of 50...\n", i);
>          ftdi_usb_open(dev, 0x0403, 0xcff8);
>          ftdi_usb_close(dev);
>          ftdi_free(dev);
>      }
> }
>
>
> $ cat maketest.sh
> gcc $(pkg-config --cflags libftdi1) $(pkg-config --libs libftdi1)  -o
> testlibftdi testlibftdi.c
>
>
> $ ./testlibftdi.exe
> opening device 0 of 50...
> opening device 1 of 50...
> opening device 2 of 50...
> opening device 3 of 50...
> opening device 4 of 50...
> opening device 5 of 50...
> opening device 6 of 50...
> opening device 7 of 50...
> opening device 8 of 50...
> opening device 9 of 50...
> opening device 10 of 50...
> opening device 11 of 50...
> opening device 12 of 50...
> opening device 13 of 50...
> opening device 14 of 50...
> opening device 15 of 50...
> opening device 16 of 50...
> opening device 17 of 50...
> opening device 18 of 50...
> opening device 19 of 50...
> opening device 20 of 50...
> opening device 21 of 50...
> opening device 22 of 50...
> opening device 23 of 50...
> opening device 24 of 50...
> opening device 25 of 50...
> opening device 26 of 50...
> opening device 27 of 50...
> 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...
> opening device 33 of 50...
> opening device 34 of 50...
> opening device 35 of 50...
> opening device 36 of 50...
> opening device 37 of 50...
> opening device 38 of 50...
> opening device 39 of 50...
> opening device 40 of 50...
> opening device 41 of 50...
> opening device 42 of 50...
> opening device 43 of 50...
> opening device 44 of 50...
> opening device 45 of 50...
> opening device 46 of 50...
> opening device 47 of 50...
> opening device 48 of 50...
> opening device 49 of 50...
>
> $ uname
> MINGW32_NT-6.2
>


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Mon, Jun 2, 2014 at 3:53 AM, Steve Soloski <[hidden email]> wrote:

> Sigh... I spoke too soon - my test code was opening Interface A instead of
> Interface B.
>
> Verified all of my files and versions - latest libusbK (3.0.7.0); libFTDI
> (1.1) and libusb (1.0.18).
>
> The Windows driver installed is libusbK on the composite device.
>
> Trying to open my device on Interface B greater than 32 times still fails.
>
> Note that in your code snippet below, you're opening Interface A and not
> Interface B.
>
> Can you try opening Interface B instead and see if it works?
>

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.



--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Mon, Jun 2, 2014 at 8:22 PM, Xiaofan Chen <[hidden email]> 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)

--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Steve Soloski
On 06/02/2014 09:38 AM, Xiaofan Chen wrote:

> On Mon, Jun 2, 2014 at 8:22 PM, Xiaofan Chen <[hidden email]> 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)
>
Thanks for verifying this - at least now I know my setup is correct and
I'm not crazy! :)

I'm pretty sure this isn't a libFTDI issue; today I'm going to try to
recreate it down at the libusb level. If that fails the same way - which
I think it will - I'll submit an issue with them.

Once again, thanks for your help tracking this down!

Steve


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Mon, Jun 2, 2014 at 9:41 PM, Steve Soloski <[hidden email]> wrote:
> Thanks for verifying this - at least now I know my setup is correct and I'm
> not crazy! :)
>
> I'm pretty sure this isn't a libFTDI issue; today I'm going to try to
> recreate it down at the libusb level. If that fails the same way - which I
> think it will - I'll submit an issue with them.

That will be great. Thanks.

> Once again, thanks for your help tracking this down!
>

You are welcome. I am part of the libusb admin team as a matter of fact.
But I am not a developer, I am more on the testing and supporting
side. I am also the admin of libusb-win32 and libusbK project
(again, not a developer, but help testing and support) so
no matter it is a libusb problem or libusbK problem, I will
be involved.


--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple interface issues

Xiaofan Chen
On Mon, Jun 2, 2014 at 9:49 PM, Xiaofan Chen <[hidden email]> wrote:
> On Mon, Jun 2, 2014 at 9:41 PM, Steve Soloski <[hidden email]> wrote:
>> I'm pretty sure this isn't a libFTDI issue; today I'm going to try to
>> recreate it down at the libusb level. If that fails the same way - which I
>> think it will - I'll submit an issue with them.
>
> That will be great. Thanks.

Just a follow-up, ticket created in libusb by Steve.
https://github.com/libusb/libusb/issues/16


--
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Loading...