Discussion:
[libusb] libusb_open issue
Steve Donovan
2017-04-02 19:16:31 UTC
Permalink
Hi,

I have used libusb on Windows 7 for a while now to communicate with an HID 5437CK card reader in "Custom Report Mode" using USB. Everything works fine on Windows 7.

We upgraded to libusb Vs 1.0.21 and retested the code on Windows 7 which again works fine.

But when we try and use the same code on Windows 10, libusb_open fails with an "unrecognized device driver" error.

In both systems the HID reader appears in Windows Device Manager as:-

USB Input Device under "Human Interface Devices"
using the hidclass.sys, hidparse.sys and hidusb.sys drivers.

USB Composite Device under "Universal Serial Bus Controllers".
using the usbccgp.sys driver.

The drivers in both systems are the latest versions and are not reporting any errors.

I would guess that an issue exists in the drivers I am using in Windows 10, but they appear very similar to the Windows 7 ones. Yes when libusb_open does the open it appears that it does not use the composite_open and then the hid_open as it does in Windows 7, presumably because the libusb_get_device_list when identifying the HID reader '\\.\USB#VID_076B&PID_5428&MI_00#7&2D77688A&1&0000' it does not fill in the driver details in the same way as it dos on Windows 7 as the logs I have listed below show.,

WINDOWS 10 Fail Log
==================
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.007011] [000014b0] libusb: debug [libusb_get_device_list]
[ 0.011016] [000014b0] libusb: debug [windows_get_device_list] allocating new device for session [2C6]
[ 0.016022] [000014b0] libusb: debug [get_api_type] driver(s): USBHUB3
[ 0.017030] [000014b0] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.021031] [000014b0] libusb: debug [windows_get_device_list] allocating new device for session [29D]
[ 0.024035] [000014b0] libusb: debug [get_api_type] driver(s): USBHUB3
[ 0.025036] [000014b0] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.025036] [000014b0] libusb: debug [windows_get_device_list] allocating new device for session [76]
[ 0.028037] [000014b0] libusb: debug [windows_get_device_list] allocating new device for session [301]
[ 0.028037] [000014b0] libusb: debug [init_device] got bus number from ancestor #4
[ 0.029038] [000014b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.031044] [000014b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 57 bytes)
[ 0.032048] [000014b0] libusb: debug [init_device] (bus: 1, addr: 5, depth: 1, port: 4): '\\.\USB#VID_076B&PID_5428&MI_00#7&2D77688A&1&0000'
[ 0.033047] [000014b0] libusb: debug [windows_get_device_list] found existing device for session [29D] (0.0)
[ 0.033047] [000014b0] libusb: debug [init_device] (bus: 1, addr: 1, depth: 0, port: 0): '\\.\USB#ROOT_HUB30#4&2FFBA145&0&0'
[ 0.035049] [000014b0] libusb: debug [windows_get_device_list] allocating new device for session [3F4]
[ 0.036054] [000014b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.036054] [000014b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 57 bytes)
[ 0.036054] [000014b0] libusb: debug [init_device] (bus: 1, addr: 5, depth: 1, port: 4): '\\.\USB#VID_076B&PID_5428#01010053305630373501183914133631'
[ 0.038055] [000014b0] libusb: debug [windows_get_device_list] found existing device for session [76] (1.0)
[ 0.039060] [000014b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.039060] [000014b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.039060] [000014b0] libusb: debug [init_device] (bus: 1, addr: 2, depth: 1, port: 1): '\\.\USB#VID_05E3&PID_0608#5&7391BD4&0&1'
[ 0.048069] [000014b0] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.056079] [000014b0] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.058085] [000014b0] libusb: debug [windows_get_device_list] found existing device for session [3F4] (1.5)
[ 0.062088] [000014b0] libusb: debug [windows_get_device_list] unlisted ancestor for '\\.\HID#GDIX1001&COL01#4&33E4E74F&1&0000' (non USB HID, newly connected, etc.) - ignoring
[ 0.063089] [000014b0] libusb: debug [windows_get_device_list] unlisted ancestor for '\\.\HID#GDIX1001&COL02#4&33E4E74F&1&0001' (non USB HID, newly connected, etc.) - ignoring
[ 0.068098] [000014b0] libusb: debug [windows_get_device_list] unlisted ancestor for '\\.\HID#INTCFD9&COL01#3&2B7A34A4&0&0000' (non USB HID, newly connected, etc.) - ignoring
[ 0.070100] [000014b0] libusb: debug [windows_get_device_list] unlisted ancestor for '\\.\HID#INTCFD9&COL02#3&2B7A34A4&0&0001' (non USB HID, newly connected, etc.) - ignoring
[ 0.073105] [000014b0] libusb: debug [windows_get_device_list] unlisted ancestor for '\\.\HID#INTCFD9&COL03#3&2B7A34A4&0&0002' (non USB HID, newly connected, etc.) - ignoring
[ 0.081134] [000014b0] libusb: debug [libusb_get_device_descriptor]

**************************************************************************************************************[ 0.083639] [000014b0] libusb: debug [libusb_open] open 1.5
[ 0.086644] [000014b0] libusb: debug [unsupported_open] unsupported API call for 'open' (unrecognized device driver)
[ 0.089148] [000014b0] libusb: debug [libusb_open] open 1.5 returns -12
[ 0.098170] [000014b0] libusb: debug [libusb_unref_device] destroy device 1.5
[ 0.102177] [000014b0] libusb: debug [libusb_unref_device] destroy device 1.5
[ 0.109187] [000014b0] libusb: debug [libusb_unref_device] destroy device 1.2
[ 0.112190] [000014b0] libusb: debug [libusb_unref_device] destroy device 1.1
[ 0.115196] [000014b0] libusb: debug [libusb_unref_device] destroy device 1.0
Object::connect: No such slot SELFSERV::NoInputHandler() in .\ui\qt_selfserv.cpp:242
Object::connect: No such slot SELFSERV::refreshPOS() in .\ui\qt_selfserv.cpp:300
**************************************************************************************************************

WINDOWS 7 working log
====================
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.031200] [000004f4] libusb: debug [libusb_get_device_list]
[ 0.031200] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [280]
[ 0.031200] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [C5]
[ 0.031200] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [2CD]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): iusb3hub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [66]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [232]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [2A2]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [BB]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [DE]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [1C4]
[ 0.046800] [000004f4] libusb: debug [get_api_type] driver(s): usbhub
[ 0.046800] [000004f4] libusb: debug [get_api_type] matched driver name against HUB API
[ 0.046800] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [174]
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [232] (0.0)
[ 0.062400] [000004f4] libusb: debug [init_device] (bus: 1, addr: 1, depth: 0, port: 0): '\\.\USB#ROOT_HUB20#4&39E0BA7F&0'
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [2A2] (0.0)
[ 0.062400] [000004f4] libusb: debug [init_device] (bus: 2, addr: 1, depth: 0, port: 0): '\\.\USB#ROOT_HUB20#4&E426A26&0'
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [BB] (0.0)
[ 0.062400] [000004f4] libusb: debug [init_device] got bus number from ancestor #2
[ 0.062400] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.062400] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 41 bytes)
[ 0.062400] [000004f4] libusb: debug [init_device] (bus: 1, addr: 3, depth: 1, port: 8): '\\.\USB#VID_0424&PID_2512#6&210A22D8&0&8'
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [3F2]
[ 0.062400] [000004f4] libusb: debug [init_device] got bus number from ancestor #2
[ 0.062400] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.062400] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 84 bytes)
[ 0.062400] [000004f4] libusb: debug [init_device] (bus: 3, addr: 3, depth: 1, port: 2): '\\.\USB#VID_046D&PID_C52B#5&5CF71E0&0&2'
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [1EE]
[ 0.062400] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.062400] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 84 bytes)
[ 0.062400] [000004f4] libusb: debug [init_device] (bus: 1, addr: 5, depth: 2, port: 2): '\\.\USB#VID_05AC&PID_0262#7&2D109B5F&0&2'
[ 0.062400] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [2C1]
[ 0.062400] [000004f4] libusb: debug [init_device] got bus number from ancestor #2
[ 0.234000] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.234000] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 216 bytes)
[ 0.234000] [000004f4] libusb: debug [init_device] (bus: 1, addr: 8, depth: 1, port: 3): '\\.\USB#VID_05AC&PID_8286#8&244746E8&0&3'
[ 0.234000] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [2DD]
[ 0.234000] [000004f4] libusb: debug [init_device] got bus number from ancestor #2
[ 0.234000] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.234000] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 740 bytes)
[ 0.234000] [000004f4] libusb: debug [init_device] (bus: 2, addr: 3, depth: 1, port: 1): '\\.\USB#VID_05AC&PID_8510#CC2CB701QKDN9KE0'
[ 0.234000] [000004f4] libusb: debug [windows_get_device_list] allocating new device for session [3F4]
[ 0.234000] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.234000] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 57 bytes)
[ 0.234000] [000004f4] libusb: debug [init_device] (bus: 3, addr: 2, depth: 1, port: 1): '\\.\USB#VID_076B&PID_5428#01010053305630373501183914133631'
[ 0.249600] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [DE] (1.0)
[ 0.249600] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.249600] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.249600] [000004f4] libusb: debug [init_device] (bus: 1, addr: 4, depth: 2, port: 1): '\\.\USB#VID_0A5C&PID_4500#7&2D109B5F&0&1'
[ 0.249600] [000004f4] libusb: debug [discovered_devs_append] need to increase capacity
[ 0.249600] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [1C4] (1.0)
[ 0.249600] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.249600] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.249600] [000004f4] libusb: debug [init_device] (bus: 1, addr: 2, depth: 1, port: 1): '\\.\USB#VID_8087&PID_0024#5&23385C8&0&1'
[ 0.249600] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [174] (2.0)
[ 0.249600] [000004f4] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.249600] [000004f4] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.249600] [000004f4] libusb: debug [init_device] (bus: 2, addr: 2, depth: 1, port: 1): '\\.\USB#VID_8087&PID_0024#5&26A55F68&0&1'
[ 0.249600] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [66] (3.0)
[ 0.249600] [000004f4] libusb: debug [init_device] (bus: 3, addr: 1, depth: 0, port: 0): '\\.\IUSB3#ROOT_HUB30#4&3089B9DF&0'
[ 0.265200] [000004f4] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.265200] [000004f4] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [3F2] (3.3)
[ 0.265200] [000004f4] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.265200] [000004f4] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [1EE] (1.5)
[ 0.265200] [000004f4] libusb: debug [get_api_type] driver(s): BTHUSB
[ 0.265200] [000004f4] libusb: debug [get_api_type] lower filter driver(s): AppleBtBc
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [2C1] (1.8)
[ 0.265200] [000004f4] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.265200] [000004f4] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [2DD] (2.3)
[ 0.265200] [000004f4] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.265200] [000004f4] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] found existing device for session [3F4] (3.2)
[ 0.265200] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[0] = \\.\HID#VID_046D&PID_C52B&MI_00#7&623A864&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[1] = \\.\HID#VID_046D&PID_C52B&MI_01&COL01#7&1DB3955E&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[1] already set - ignoring HID collection: \\.\HID#VID_046D&PID_C52B&MI_01&COL02#7&1DB3955E&0&0001
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[1] already set - ignoring HID collection: \\.\HID#VID_046D&PID_C52B&MI_01&COL03#7&1DB3955E&0&0002
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[1] already set - ignoring HID collection: \\.\HID#VID_046D&PID_C52B&MI_01&COL04#7&1DB3955E&0&0003
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[2] = \\.\HID#VID_046D&PID_C52B&MI_02&COL01#7&5F00919&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[2] already set - ignoring HID collection: \\.\HID#VID_046D&PID_C52B&MI_02&COL02#7&5F00919&0&0001
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F2]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[2] already set - ignoring HID collection: \\.\HID#VID_046D&PID_C52B&MI_02&COL03#7&5F00919&0&0002
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [1EE]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[0] = \\.\HID#VID_05AC&PID_0262&MI_00&COL01#9&3D8E865&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [1EE]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[0] already set - ignoring HID collection: \\.\HID#VID_05AC&PID_0262&MI_00&COL02#9&3D8E865&0&0001
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [1EE]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[1] = \\.\HID#VID_05AC&PID_0262&MI_01&COL02#9&1B9C74AA&0&0001#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [windows_get_device_list] setting composite interface for [3F4]:
[ 0.280800] [000004f4] libusb: debug [set_composite_interface] interface[0] = \\.\HID#VID_076B&PID_5428&MI_00#7&2BFA57C7&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]
[ 0.280800] [000004f4] libusb: debug [libusb_get_device_descriptor]

**************************************************************************************************************[ 0.280800] [000004f4] libusb: debug [libusb_open] open 3.2
[ 0.280800] [000004f4] libusb: debug [hid_open] set maximum input buffer size to 512
[ 0.280800] [000004f4] libusb: debug [hid_open] 0 HID input report value(s) found
[ 0.280800] [000004f4] libusb: debug [hid_open] 0 HID output report value(s) found
[ 0.280800] [000004f4] libusb: debug [hid_open] 0 HID feature report value(s) found
[ 0.296400] [000004f4] libusb: debug [libusb_alloc_transfer] transfer 00C279BC
[ 0.296400] [000004f4] libusb: debug [libusb_submit_transfer] transfer 00C279BC
[ 0.296400] [000004f4] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.296400] [000004f4] libusb: debug [libusb_claim_interface] interface 0
[ 0.296400] [000004f4] libusb: debug [hid_claim_interface] claimed interface 0
[ 0.296400] [000004f4] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 83 to interface 0
**************************************************************************************************************

Could you tell me what I am doing wrong or which driver I am missing from Windows 10.

Many thanks

Steve Donovan

Way2Pay | load.spend.earn. | @Way2PayUK | www.countersolutions.com<http://www.countersolutions.com>
Peter Stuge
2017-04-02 21:38:10 UTC
Permalink
Post by Steve Donovan
I have used libusb on Windows 7 for a while now to communicate with
an HID 5437CK card reader
..
Post by Steve Donovan
Windows 10
..
Post by Steve Donovan
using the hidclass.sys, hidparse.sys and hidusb.sys drivers.
libusb is not intended for HID class devices. I strongly recommend
using HIDAPI instead, which is not only written specifically for HID
class devices, but also offers much more permissive license options,
and integrates into your project better than an external library.

http://www.signal11.us/oss/hidapi/
https://github.com/signal11/hidapi.git


Converting existing code should only take a couple of hours, so don't
hesitate to explore HIDAPI as an option. It's the best tool for this task.

And because it uses native HID APIs on each platform it is quite
likely to keep working for a long time, as platforms evolve.


//Peter

Loading...