USB Host Shield and Barcode Scanner only outputs debug hex on Multimedia Keyboard sketch

I've got a HiLetgo USB HostShield on an Uno R3, after much, much consternation about connecting Vbus power correctly (pretty sure my 1.6mm solder and ancient Weller soldering iron were too big for this board) I have passing diagnostics on the boardqc Sketch:

17:25:22.174 -> Checking USB device communication.
17:25:22.734 ->
17:25:22.734 -> Reset complete. Waiting for the first SOF...
17:25:23.454 -> Getting device descriptor
17:25:23.454 -> Descriptor Length: 12
17:25:23.454 -> Descriptor type: 01
17:25:23.454 -> USB version: 0200
17:25:23.454 -> Device class: 00
17:25:23.454 -> Device Subclass: 00
17:25:23.454 -> Device Protocol: 00
17:25:23.454 -> Max.packet size: 40
17:25:23.454 -> Vendor ID: 0C2E
17:25:23.454 -> Product ID: 0901
17:25:23.494 -> Revision ID: 0100
17:25:23.494 -> Mfg.string index: 01
17:25:23.494 -> Prod.string index: 02
17:25:23.494 -> Serial number index: 03
17:25:23.494 -> Number of conf.: 01
17:25:23.494 ->

and it recognizes the device, a WoneNice WN3300 HID barcode scanner, on the usb_desc example sketch:
Output from USB_Desc:
17:40:29.238 -> BM Init
17:40:29.559 -> Addr:01
17:40:29.559 -> NC:01
17:40:29.559 -> HID_PROTOCOL_KEYBOARD
17:40:29.559 -> bNumEP:01
17:40:29.559 -> D1

However, the USBHIDBootKbd sketch just gets stuck on "Start", no output can be parsed.

The weird thing is when I go to the USB HID Multimedia Keyboard sketch, I get a stream of zeros until I scan something, at which point it appears to be feeding me hex one character at a time.

Output from USBHIDMultimediaKbd
18:31:20.811 -> 0 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 0000 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 0⸮⸮⸮0 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 00 00 00 00 00 00
18:31:20.811 -> 00 00 0⸮⸮⸮Start
18:31:22.841 -> HU Init
18:31:23.121 -> Addr:01
18:31:23.121 -> NC:01
18:31:23.121 -> Cnf:01
18:31:23.121 -> NumIface:01
18:31:23.121 -> SetIdle:00
18:31:23.121 -> HU configured
18:31:23.121 ->
18:31:23.121 -> 00 00 00 00 00 00 00 00
18:31:23.121 -> 00 00 00 00 00 00 00 00
18:31:23.121 -> 00 00 00 00 00 00 00 00
18:31:23.121 -> 00 00 00 00 00 00 00 00
18:31:23.121 -> 00 00 00 00 00 00 00 00
18:31:23.121 -> 00 00 00 00 00 00 00 00
[bunch of zeros until I scan "X001FPNNZT":]
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 02 00 1B 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 00 00 27 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 00 00 27 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 00 00 1E 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 02 00 09 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 02 00 13 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 02 00 11 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.843 -> 02 00 11 00 00 00 00 00
18:31:30.843 -> 00 00 00 00 00 00 00 00
18:31:30.883 -> 02 00 1D 00 00 00 00 00
18:31:30.883 -> 00 00 00 00 00 00 00 00
18:31:30.883 -> 02 00 17 00 00 00 00 00
18:31:30.883 -> 00 00 00 00 00 00 00 00
18:31:30.883 -> 00 00 28 00 00 00 00 00

This is tied to the UsbDEBUGlvl value; setting this to zero gives me nothing but "START" for output.

That seems to be tied to the hexdump.h file and some code:
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
if(!byteCount) {
PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
E_Notify(PSTR(": "), 0x80);
}
PrintHex<uint8_t > (pbuf[j], 0x80);
E_Notify(PSTR(" "), 0x80);

Anyone know a good primer/documentation to look at so I can intercept whatever this is doing and try converting the Hex numbers back to human numbers and letters?

This explains the USB HID keyboard report format. USB Human Interface Devices - OSDev Wiki

I annotated a few lines of the hex keybard output.

[bunch of zeros until I scan "X001FPNNZT":]
18:31:30.843 -> 00 00 00 00 00 00 00 00	// all keys released
18:31:30.843 -> 02 00 1B 00 00 00 00 00	// shift key + 'X' key pressed therefore capital 'X'
18:31:30.843 -> 00 00 00 00 00 00 00 00 // all keys released
18:31:30.843 -> 00 00 27 00 00 00 00 00	// '0' key pressed
18:31:30.843 -> 00 00 00 00 00 00 00 00	// all keys released
18:31:30.843 -> 00 00 27 00 00 00 00 00	// '0' key pressed
18:31:30.843 -> 00 00 00 00 00 00 00 00	// all keys released

The example USBHIDBookKbd.ino converts the USB keycodes to ASCII by calling OemToAscii. OemToAscii is implemented in hidboot.cpp. You should be able to merge code from this example into the multimedia keyboard example.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.