Hi, I use libusb1.0.14/WinUSB (v6.1.7600.16385) This is a simple program which can reproduce the problem (output is in the last) :
#include <stdio.h> #include "libusb.h" struct device_descriptor { uint16_t vid; uint16_t pid; }; static struct device_descriptor managed_devices[] = { { 0x0525, 0xA4A0 }, }; int main(int argc, char* argv[]) { libusb_device **devs; int r, card_count = 0; ssize_t cnt; libusb_device *dev; int i = 0; libusb_context* context; libusb_device_handle* handle1, *handle2; r = libusb_init(&context); if (r < 0) return r; libusb_set_debug(context, 3); cnt = libusb_get_device_list(context, &devs); if (cnt < 0) return (int) cnt; while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; int r = libusb_get_device_descriptor(dev, &desc); if (r < 0) { fprintf(stderr, "failed to get device descriptor"); return -1; } printf("%04x:%04x (bus %d, device %d)\n", desc.idVendor, desc.idProduct, libusb_get_bus_number(dev), libusb_get_device_address(dev)); if((managed_devices[0].vid == desc.idVendor) && (managed_devices[0].pid == desc.idProduct)){ card_count++; break; } } /*first open*/ r = libusb_open(dev, &handle1); Sleep(1000); /*first close*/ libusb_close(handle1); Sleep(1000); /*second open : failed -3*/ r = libusb_open(dev, &handle2); /* here i have always -3 error in return code */ Sleep(1000); if(!r) libusb_close(handle2); libusb_free_device_list(devs, 1); libusb_exit(context); return 0; } /*output of the program */ /* 8086:27c9 (bus 3, device 1) 8086:27cb (bus 5, device 1) 8086:27c8 (bus 2, device 1) 8086:27ca (bus 4, device 1) 1414:0004 (bus 1, device 1) 8086:27cc (bus 6, device 1) 0461:4d81 (bus 4, device 2) 0525:a4a0 (bus 6, device 3) libusbx: error [winusbx_open] could not open device \\.\USB#VID_0525&PID_A4A0#1_00000000#{A5DCBF10-6530-11D2-901F-00C04FB951ED} (interface 0): [5] Access denied */ Regards, Mohamed On Wed, Jan 2, 2013 at 7:16 AM, Xiaofan Chen <xiaof...@gmail.com> wrote: > On Tue, Jan 1, 2013 at 8:21 PM, Mohamed HAMZAOUI <requin...@gmail.com> wrote: >> I have just describe for you the summary of the sequence of actions in >> a large program ... > > Could you reproduce the issue with a simpler program and post > the debug log? > >> There are various purposes for which you can open and close a dev and >> then open it another time... (managing licenses saved on the card in >> my case...), but in general there is no restriction on the >> documentation ! > > This should be okay. It would be good if you can post more > debug logs to help debug the issue. > > BTW, do you have libusbK installed in your system? Are you > using WinUSB driver or other driver? Just want to get rid of more > variables. > > -- > Xiaofan > > ------------------------------------------------------------------------------ > Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery > and much more. Keep your Java skills current with LearnJavaNow - > 200+ hours of step-by-step video tutorials by Java experts. > SALE $49.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122612 > _______________________________________________ > libusbx-devel mailing list > libusbx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libusbx-devel ------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel