WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
142 stars 35 forks source link

Issue sending Output Report to cash drawer #99

Closed davisford closed 2 years ago

davisford commented 2 years ago

I'm working on hacking together a very simple driver for a cash drawer (for a web based POS implementation). It has two output report commands. One to get the status of the drawer (open/closed), and another to open the drawer if the status is closed.

The manufacturer of the drawer has provided a simple Windows application that I can run to execute those commands. I have used USBpCap to capture the USBHID traffic when running that app.

The input report id is identified as 0 (zero). The command to open the drawer is 0x01 0x01. Capturing the traffic from the Windows app in USBpCap and opening it Wireshark shows the following request (which works, and opens the drawer successfully)

Screen Shot 2022-07-18 at 4 16 59 PM

Note the data fragment in the screenshot is 0101 (the command to open the drawer).

Trying from USB Web HID interface I am not having luck. I am able to pair with the device and open it successfully. I am able to subscribe to input reports. I receive callbacks when input reports fire. It basically has two input reports, one that fires when the drawer opens, and I get them just fine when the drawer state changes.

When I try to send the output report command to open the drawer, and also capture the USB traffic in USBpCap, it always sends the data as 0x00 0x00 and not 0x01 0x01.

Here's the code used (device is already paired and opened):

await device.sendReport(0x00, new Uint8Array(0x01, 0x01));

The command succeeds, and I'm returned a callback on an input report which just states the drawer is closed, but the USBHID protocol capture shows the following:

Screen Shot 2022-07-18 at 3 36 19 PM

The response is success:

Screen Shot 2022-07-18 at 3 36 33 PM

What I'm trying to understand is what I'm doing wrong here? If I send the data on an output report as 0x01 0x01 it seems to be sent over the wire instead as 0x00 0x00.

I have checked the Chrome black list for vendor/product ids and so forth and this device does not appear to be restricted.

Any ideas?

davisford commented 2 years ago

I was able to resolve the issue.