Barcode scanners behaves like a usb keyboard device and my case was no different at the beginning. I opened a nano
screen, plugged the scanner through usb port, read a barcode and saw the string what is written right under the barcode.
I don't know how, but right now it doesn't work that way. The scanner (the keyboard-like device) sends some garbage to the system.
I wrote a simple NodeJS code that dumps what is captured:
data: <Buffer 04 00 62 60 5b 00 00 00> string: b`[
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 5f 5b 00 00 00> string: b_[
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 60 62 00 00 00> string: b`b
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 5c 5d 00 00 00> string: b\]
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 5d 5a 00 00 00> string: b]Z
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 5c 5d 00 00 00> string: b\]
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 04 00 62 5c 61 00 00 00> string: b\a
data: <Buffer 00 00 00 00 00 00 00 00> string:
data: <Buffer 00 00 28 00 00 00 00 00> string: (
data: <Buffer 00 00 00 00 00 00 00 00> string:
I was expecting a string, like SIP-4-1
. (Here is the showkey
output of the same barcode)
Same scanner works correctly on Windows. I guess it's related with a keyboard mode or something. How can I change the mode for a specific USB keyboard device?