使用libusb 1.2.6
我试图枚举Windows 7 x64上的所有设备。
MinGW是我的IDE,项目链接到gcc/libusb.a
。不确定这个是否可以在x64
上完成工作。
这是代码,取自示例:
usb_init(); /* initialize the library */
usb_find_busses(); /* find all busses */
usb_find_devices(); /* find all connected devices */
struct usb_bus *busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next) {
struct usb_device *dev;
for (dev = bus->devices; dev; dev = dev->next) {
/* Check if this device is a printer */
if (dev->descriptor.bDeviceClass == 7) {
/* Open the device, claim the interface and do your processing */
}
/* Loop through all of the configurations */
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
/* Loop through all of the interfaces */
for (i = 0; i < dev->config[c].bNumInterfaces; i++) {
/* Loop through all of the alternate settings */
for (a = 0; a < dev->config[c].interface[i].num_altsetting; a++) {
/* Check if this interface is a printer */
if (dev->config[c].interface[i].altsetting[a].bInterfaceClass == 7) {
/* Open the device, set the alternate setting, claim the interface and do your processing */
}
}
}
}
}
}
它可以找到1个总线,但是没有设备。我期待看到所有连接的设备。
最终我想要的是在已经有驱动程序的特定设备上建立批量传输。