On 2013.09.21 00:21, Kano wrote: > Hi, > I've been using usb for about a year on many devices but only using a > single interface. > Finally got some hardware that has 2 interfaces and the code I've written > works on linux but fails on windows. > Anyone know if there are special rules required for windows?
Please have a look at the xusb sample. Especially, if you replace the VID:PID for the -j option for the ones of your device, and for a device with 2 interfaces, you should get something like: -------------------------------------------------------------------------- D:\libusbx\Win32\Debug\examples>xusb -j Using libusbx v1.0.17.10830 Opening device 15BA:0004... Reading device descriptor: length: 18 device class: 0 S/N: 0 VID:PID: 15BA:0004 bcdDevice: 0500 iMan:iProd:iSer: 1:2:0 nb confs: 1 Reading BOS descriptor: no descriptor Reading first configuration descriptor: nb interfaces: 2 interface[0]: id = 0 interface[0].altsetting[0]: num endpoints = 2 Class.SubClass.Protocol: FF.FF.FF endpoint[0].address: 81 max packet size: 0040 polling interval: 00 endpoint[1].address: 02 max packet size: 0040 polling interval: 00 interface[1]: id = 1 interface[1].altsetting[0]: num endpoints = 2 Class.SubClass.Protocol: FF.FF.FF endpoint[0].address: 83 max packet size: 0040 polling interval: 00 endpoint[1].address: 04 max packet size: 0040 polling interval: 00 Claiming interface 0... Claiming interface 1... Reading string descriptors: String (0x01): "Olimex" String (0x02): "Olimex OpenOCD JTAG TINY" Releasing interface 0... Releasing interface 1... Closing device... -------------------------------------------------------------------------- > Of course I'm using Zadig to set the windows driver to WinUSB. And your driver installation looks OK to me. > The first interface open is of course working. > > The code is basically: > For a single interface chip (that always works on many linux/windows) it is: > libusb_get_device_list > libusb_get_device_descriptor > libusb_open > libusb_claim_interface 0 > > Instead for a chip with multiple interfaces I am: > libusb_get_device_list > libusb_get_device_descriptor > libusb_open > libusb_claim_interface 0 > libusb_get_device(interface 0 handle) > libusb_open > (libusb_claim_interface 1) <- never gets here I'd have to look at the code, but I seem to recall that we are trying to mimic Linux here and, despite having separate drivers installed for each interface (and the underlying OS seeing these as separate devices) pretend it is still a single device. Therefore, I agree with Xiaofan down below, and don't believe you should be attempting to open what is essentially the same device, as far as libusb is concerned, twice. Does the code above with the double open work on Linux? > This works on linux but fails on windows on the 2nd open (before claiming > the 2nd interface) with: > [ 1.209821] [00000f94] libusbx: debug [libusb_open] open 2.2 > [ 1.209821] [00000f94] libusbx: error [winusbx_open] could not open device > \\.\USB#VID_0403&PID_8350&MI_00#6&2CE4DD9F&0&0000#{C8D1AB34-4B5C-488A-8194-08C26C1A05DA} > (interface 0): [5] Access is denied. Access denied is pretty much what I'd expect if the above is correct. Please try to write your code as if you were dealing with a single device, instead of two, and see if that help. Regards, /Pete ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel