nyholku / purejavahidapi

Other
122 stars 69 forks source link

add support for hid barcode scanner in windows backend #70

Open slatequarry opened 4 years ago

slatequarry commented 4 years ago

some honeywell barcode scanner use "BarcodeScanner" as driver class name

nyholku commented 4 years ago

Hi, thanks for the PR. Interesting. So even though the Honeywell barcode scanner is HID it does not use HID driver? What API they expect people to use with it then?

tresf commented 4 years ago

I'm curious too. Reference: https://github.com/nyholku/purejavahidapi/issues/50#issuecomment-376718412

I actually bought one of these for a client and had to use Usage Page to find out the endpoint, but eventually got it working.

@slatequarry are there steps you can offer for me to reproduce or does this problem only occur with a specific model?

slatequarry commented 4 years ago

I'm tested with 2 devices. First Honeywell Xenon 1900 HD has only one endpoint with class "BarcodeScanner":

    +++++++++++++++++ Device Information ++++++++++++++++++

Device Description : USB-Eingabegerät Device Path : \?\usb#vid_0c2e&pid_0907#19247b3c56#{a5dcbf10-6530-11d2-901f-00c04fb951ed} Device ID : USB\VID_0C2E&PID_0907\19247B3C56 Hardware IDs : USB\VID_0C2E&PID_0907&REV_0962 USB\VID_0C2E&PID_0907 Driver KeyName : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0051 (GUID_DEVCLASS_HIDCLASS) Driver : \SystemRoot\System32\drivers\hidusb.sys (Version: 10.0.18362.175 Date: 2019-12-09) Driver Inf : C:\WINDOWS\inf\input.inf Legacy BusType : PNPBus Class : HIDClass Class GUID : {745a17a0-74d3-11d0-b6fe-00a0c90f57da} (GUID_DEVCLASS_HIDCLASS) Interface GUID : {a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USBDEVICE) Service : HidUsb Enumerator : USB Location Info : Port#0008.Hub_#0001 Location IDs : PCIROOT(0)#PCI(0103)#PCI(0000)#USBROOT(0)#USB(8), ACPI(SB)#ACPI(PCI0)#ACPI(GPP2)#ACPI(PTXH)#ACPI(RHUB)#ACPI(POT8) Container ID : {0a0809ab-3246-513f-86e6-e445160917f8} Manufacturer Info : (Standardsystemgeräte) Capabilities : 0x94 (Removable, UniqueID, SurpriseRemovalOK) Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER) Problem Code : 0 EnhancedPowerMgmtEnabled : 1 Power State : D0 (supported: D0, D1, D2, D3, wake from D0, wake from D1, wake from D2) Child Device 1 : POS-HID-Barcodescanner DevicePath : \?\hid#vid_0c2e&pid_0907#7&2d195ee&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} KernelName : \Device\000000a3 Device ID : HID\VID_0C2E&PID_0907\7&2D195EE&0&0000 Class : BarcodeScanner

Second Honeywell 1950 HD has two endpoints with classes "BarcodeScanner" and "HIDClass":

    +++++++++++++++++ Device Information ++++++++++++++++++

Device Description : USB-Verbundgerät Device Path : \?\usb#vid_0c2e&pid_1007#19211b7a76#{a5dcbf10-6530-11d2-901f-00c04fb951ed} Device ID : USB\VID_0C2E&PID_1007\19211B7A76 Hardware IDs : USB\VID_0C2E&PID_1007&REV_0052 USB\VID_0C2E&PID_1007 Driver KeyName : {36fc9e60-c465-11cf-8056-444553540000}\0033 (GUID_DEVCLASS_USB) Driver : \SystemRoot\System32\drivers\usbccgp.sys (Version: 10.0.18362.1 Date: 2019-03-19) Driver Inf : C:\WINDOWS\inf\usb.inf Legacy BusType : PNPBus Class : USB Class GUID : {36fc9e60-c465-11cf-8056-444553540000} (GUID_DEVCLASS_USB) Interface GUID : {a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USBDEVICE) Service : usbccgp Enumerator : USB Location Info : Port#0007.Hub_#0001 Location IDs : PCIROOT(0)#PCI(0103)#PCI(0000)#USBROOT(0)#USB(7), ACPI(SB)#ACPI(PCI0)#ACPI(GPP2)#ACPI(PTXH)#ACPI(RHUB)#ACPI(POT7) Container ID : {70082056-c4ad-560e-b95b-794a24109bf8} Manufacturer Info : (Standard-USB-Hostcontroller) Capabilities : 0x94 (Removable, UniqueID, SurpriseRemovalOK) Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER) Problem Code : 0 Address : 7 Power State : D0 (supported: D0, D1, D2, D3, wake from D0, wake from D1, wake from D2) Child Device 1 : USB-Eingabegerät Device ID : USB\VID_0C2E&PID_1007&MI_00\7&D2A56C9&0&0000 Class : HIDClass Child Device 1 : POS-HID-Barcodescanner DevicePath : \?\hid#vid_0c2e&pid_1007&mi_00#8&a7833ae&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} KernelName : \Device\000000a7 Device ID : HID\VID_0C2E&PID_1007&MI_00\8&A7833AE&0&0000 Class : BarcodeScanner Child Device 2 : USB-Eingabegerät Device ID : USB\VID_0C2E&PID_1007&MI_01\7&D2A56C9&0&0001 Class : HIDClass Child Device 1 : HID-konformes, vom Hersteller definiertes Gerät DevicePath : \?\hid#vid_0c2e&pid_1007&mi_01#8&1da84fec&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} KernelName : \Device\000000a8 Device ID : HID\VID_0C2E&PID_1007&MI_01\8&1DA84FEC&0&0000 Class : HIDClass

tresf commented 4 years ago

Page 21 of the user's manual has a barcode for putting the scanner into HID mode...

image

This barcode is identical between the user guides for the 1900 and 1950 units. It's also provided on a small booklet with the hardware (as well as other functions, like continuous scanning, RS232, keyboard wedge mode, etc).

When scanning this barcode, does it change the endpoints at all?

slatequarry commented 4 years ago

I already know this configuration code! This does not change anything. The cause is a new Windows 10 driver from Microsoft.

Please refer

  1. https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/hid-clients-supported-in-windows
  2. https://honeywellsps.my.salesforce.com/sfc/p/#00000000SK3U/a/A0000000HoDf/7uYvDgiFdEzp4BiJV8rtXhs1ct8nkUjYSxzKkkxbfxE
tresf commented 4 years ago

@slatequarry this information is very helpful. I assume you're able to communicate with the device as if it's an HID device with this code change? If so, would it make sense to add support for all shared-type devices from Microsoft's page?

Note, I'm not a developer of this library, but rather someone with an interest in keeping up with device support like you are.

Usage Page Usage Windows 7 Windows 8 Windows 10 Notes Access Mode
0x0001 0x0004 - 0x0005 Yes Yes Yes Game Controllers Shared
0x0001 0x000C No Yes Yes Flight Mode Switch Shared
0x0001 0x0080 Yes Yes Yes System Controls (Power) Shared
0x000C 0x0001 Yes Yes Yes(For both Windows 10 and Windows 10 Mobile) Consumer Controls Shared(For both Windows 10 and Windows 10 Mobile)
0x0020 *Multiple No Yes Yes Sensors Shared
0x0084 0x004 Yes Yes Yes HID UPS Battery Shared
0x008C 0x0002 No Yes(Windows 8.1 and later) Yes Barcode Scanner (hidscanner.dll) Shared
slatequarry commented 4 years ago

Yes, the communication behaves the same as with generic HID devices. Of course it would make sense to support all other device classes. However, the exact class names are unknown to me.

tresf commented 4 years ago

I dug around on the UWP docs and found some of them... or at least I think I did. In addition to BarcodeScanner I can see the Gamepad, FlightSwitch and Sensor as being the most valuable for most programmers.

Class name guess:

Class name is unknown: