DE2120 barcode scanner and Belgian Keyboard

Hi,

I tried setting up the DE2120 Barcode scanner with a Belgian Keyboard layout Raspbian.

I’m using these scan codes: https://cdn.sparkfun.com/assets/b/5/0/e … 4.6___.pdf

Scanning works just fine when I set the keyboard layout to US.

When scanning the barcode for Belgian layout though, it still keeps sending out the lowercase characters of the keyboard instead of the numeral. If I keep the shift-key pressed, I’m getting the right code.

So first off, I’m scanning the USB KBW Mode (code PORKBD - page 18)

Next, I’m picking the Belgian keyboard layout (code KDCTY8 - page 19)

I’m not getting digits when scanning a barcode (EAN13 or other one only containing digits)

When pressing shift, it does work correctly. (Note that CAPS LOCK doesn’t toggle the digits in the upper row on the keyboard either. This is normal behavior in Keyb BE).

Also, it’s not really clear what USB-COM; USB-HID mode and the virtual keyboard emulation are. Could you explain a little bit more what the differences are between these modes?

jurgeng:
Also, it’s not really clear what USB-COM; USB-HID mode and the virtual keyboard emulation are. Could you explain a little bit more what the differences are between these modes?

USB peripherals have different *profiles*. When you plug in a peripheral (for example keyboard, mouse, thumbdrive, webcam, musical instrument, printer, USB-serial adapter, etc), there is a bit of communication between the device (the peripheral) and the host (ie PC) and the host's operating system loads the drivers required and sorts out where and how to direct data to and from the USB port. This is why you can unplug, say, a USB gaming headset and plug in a USB-ethernet adapter into the same physical port and everything works without interaction with the user.

USB-com is a virtual comm port and is used for converting digital signals and communicating to and from with another device or instrument. It could be RS232, RS485, TTL, any of a lot of things.

USB-HID is a Human Interface Device which is what we use to interact with our computers. The mouse, keyboard & touchscreen are some everyday examples. In the case of a barcode scanner which mounts up as an HID, it appears to the host as a (virtually emulated) keyboard. On a PC, the cursor indicates where keystrokes are expected so a scanned barcode’s data will appear there, too.

Hi Brow,

thanks for those replies. The part that you’re explaining, was where my understanding ended.

By now, I kinda figured out I can get information in a terminal emulator when the keyboard is in USB-COM mode. This allows to recieve the correct data in the terminal (but it adds complexity when you want to run it in for example a spreadsheet)

I also understand how a HID is a human interface device (like keyboard, mouse or even a game controller). I still don’t get the difference between USB-HID mode (p. 22, bottom), USB-KBW mode (p. 18) and “virtual keyboard enablation” (p. 22, top)

Page references are pointing to this document:

https://cdn.sparkfun.com/assets/b/5/0/e … 4.6___.pdf

The problem I’m having, is that in my local keyboard layout (BE), I’m not getting the numerals, but the lowercase characters under the digits. Contrary to most keyboard layouts, Belgian keyboard defaults to these characters (and you need to press Shift to reach the digits).

So when scanning barcodes in any of the keyboard modes, the device sends in the scan codes for the specific keycaps (keypress code). This is why a keyboard doesn’t care what characters are printed on the caps - they keyboard layout translates a scan code to the appropriate character assigned to that key position in that language setting.

So there basically are 2 options (where the first one to be the most obvious as this is my first encounter with this device):

  1. I’m doing something wrong, causing me to fail setting the keyboard layout of the barcode scanner to behave like a Belgian keyboard

  2. This is a bug in the keyboard driver.

In either case, I was hoping the experts in here could help me further (and/or maybe improve some documentation for dummies like me)

It’s always fun if you succeed in answering your own questions (partly) after discovering that you didn’t research the documentation enough. I’ll be documenting it here for others to stumble upon.

So I learned that USB-HID mode is taking in the raw (unprocessed) data from the HID device. Normally this is something the OS takes care of, but in specific cases this can be useful as it will allow to improve speed.

More documentation: https://www.kernel.org/doc/html/latest/hid/hidraw.html

It also has a python library to the HID API: https://github.com/libusb/hidapi

Still haven’t figured out what the virtual keyboard emulation means.