2

I'm trying to get an old handhold barcode reader to work under Linux Mint 19.1, which is connected over PS/2 as a keyboard. Every time you scan a barcode it send the barcode text like you entered it on the keyboard.

The barcode reader works at boot time, e.g. in the Grub command line, but is not generating any output when Linux got booted. However, it displays to me that it could send its buffer to the PC, because otherwise it would not be ready to scan again, which it is. So some connection must be already there. For comparison: I tried it under Windows 10 on the same PC as well and there the scanner gets stuck as it cannot flush its buffer at all.

I already learnt that the i8042 driver is responsible for PS/2 the dmesg is as follows. I already tried to get it running by adding boot parameters but that did not helped.

# dmesg | grep i8042
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-43-generic root=UUID=dfc4afd2-a995-48d8-8538-355cba9f9eda ro atkbd.reset i8042.nomux=1 i8042.reset quiet splash vt.handoff=1
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-43-generic root=UUID=dfc4afd2-a995-48d8-8538-355cba9f9eda ro atkbd.reset i8042.nomux=1 i8042.reset quiet splash vt.handoff=1
[    0.827672] i8042: PNP: No PS/2 controller found.
[    0.827673] i8042: Probing ports directly.
[    0.832411] serio: i8042 KBD port at 0x60,0x64 irq 1
[    0.832414] serio: i8042 AUX port at 0x60,0x64 irq 12

There is no entry for the PS/2 device under /dev/input.

Kernel is:

Linux version 4.15.0-43-generic (buildd@lgw01-amd64-001) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 (Ubuntu 4.15.0-43.46-generic 4.15.18)

This seems to very similar to the abandoned question PS/2 keyboard only works up to GRUB, not after OS fully booted just with Linux Mint instead of Arch.


Further info:

Motherboard & UEFI Version: ASRock Z77 Pro3 P1.30
PS/2 is on the motherboard and reader is connected before boot.

Full dmesg after boot: https://pastebin.com/Pse6aCUE
I noted several atkbd serio0: keyboard reset failed on isa0060/serio0 there.

evtest:

No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:  Power Button
/dev/input/event1:  Power Button
/dev/input/event2:  Video Bus
/dev/input/event3:  Logitech USB Receiver
/dev/input/event4:  Logitech USB Receiver
/dev/input/event5:  Logitech M705
/dev/input/event6:  Logitech K360
/dev/input/event7:  Logitech Logitech G35 Headset
/dev/input/event8:  HDA Intel PCH Front Mic
/dev/input/event9:  HDA Intel PCH Rear Mic
/dev/input/event10: HDA Intel PCH Line
/dev/input/event11: HDA Intel PCH Line Out Front
/dev/input/event12: HDA Intel PCH Line Out Surround
/dev/input/event13: HDA Intel PCH Line Out CLFE
/dev/input/event14: HDA Intel PCH Line Out Side
/dev/input/event15: HDA Intel PCH Front Headphone
/dev/input/event16: HDA NVidia HDMI/DP,pcm=3
/dev/input/event17: HDA NVidia HDMI/DP,pcm=7
/dev/input/event18: HDA NVidia HDMI/DP,pcm=8
/dev/input/event19: HDA NVidia HDMI/DP,pcm=9

lsusb:

Bus 002 Device 003: ID 046d:c531 Logitech, Inc. C-U0007 [Unifying Receiver]
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 2109:0812 VIA Labs, Inc. VL812 Hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 003: ID 2109:2812 VIA Labs, Inc. VL812 Hub
Bus 005 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 8087:0a2b Intel Corp. 
Bus 001 Device 003: ID 05e3:0745 Genesys Logic, Inc. Logilink CR0012
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 003 Device 004: ID 046d:0a15 Logitech, Inc. 
Bus 003 Device 002: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Inside /sys/devices/platform/i8042/ I get power, serio0 and serio1 subdirectories.

  • Grepping log hides nearly all important information. Instead, read the log, and look what it says around the i8042: Any error messages? Does it show a /device/platform/i8042/... entry a short time later? Have you run evtest without parameters as root, and is there any /dev/input/eventX device which looks like a keyboard or barcode reader, or which you can't identify otherwise? – dirkt Jan 19 '19 at 14:01
  • you probably have some BIOS/EFI setting on whether usb mice and kbds should emulate PS/2. Try turning it on and off. And please post more complete info. It may well be that the PS/2 port is hooked via an adapter to an internal usb hub. – pizdelect Jan 19 '19 at 14:23
  • @dirkt: Thanks for the response. I posted a link to the full dmesg above. It shows some repeated messages about atkbd not able to reset serio0. evtest and /dev/input/event* all look like they belong to my USB mouse and keyboard etc. None of them looks like the reader. – Martin Scharrer Jan 19 '19 at 15:37
  • @pizdelect: My UEFI bios does not have such an option. I posted more information now into the question. – Martin Scharrer Jan 19 '19 at 15:38
  • Try again without your custom kernel options, and see what changes in the dmesg. It doesn't seem to work with these particular options (the resets fail). – dirkt Jan 19 '19 at 15:41
2

Partial answer:

As it works in the BIOS and the i8042 hardware is recognized, the bottom driver stack layers should be fine. On top of the i8042 there's the serio kernel module, source code in drivers/input/serio. Possibly this expects a "real" keyboard and doesn't recognize the scanner.

However, you can also use raw PS/2 port access with serio_raw. Do

echo -n "serio_raw" > /sys/bus/serio/devices/serio0/drvctl

and you should get a /dev/psaux device (watch dmesg, also for errors). hexdump -C /dev/psaux and see if you get something when you use the barcode reader (keep in mind it buffers lines, or modify command for single bytes per line).

If that works, you can either use it with the raw protocol (decode on your own), or you can start trying to go through the serio source code and try to figure out why it doesn't like your barcode reader (with help of the protocol stuff you saw with serio_raw).

If it doesn't work, we've narrowed down the point of failure further, but I'm not sure how to go on in this case.

And for people reading this with a working serio driver who want to play with serio_raw, you can attach the serio driver again with

echo -n "rescan" > /sys/bus/serio/devices/serio0/drvctl

Edit

These are "make" (keypress) and "break" (keyrelease) scan codes. For example, 1e 9e is the make and break for the A key.

Note that these are assigned to the keys themselves, and Shift etc. also have make and break codes. So you get "fake" codes for these if the barcode scanner reads upper- and lowercase characters, etc.

See e.g. here or here for details.

Normally, the atkbd module would process those, and forward them to the kernel input layer, where they'd show up in a /dev/input/eventX device node. Looking at the atkbd_probe routine, it reads the keyboard ID, and if that fails, tries to reset the LEDs. If that also fails, it decides that it's not a keyboard. Similarly, if the ID doesn't match known keyboard ids, it also decides it's not a keyboard.

So I guess the barcode reader fails those tests. You can verify this by sending your own commands in the raw serio device.

  • Thank you a lot. I did that and it works, just the device created is /dev/serio_raw0 in my case. The /dev/psaux is already there before and the hexdump of it shows data when I move my USB mouse for some reason. On /dev/serio_raw0 I get e.g. 2a 20 a0 1e 9e 14 94 1e 9e 26 a6 18 98 22 a2 17 97 2e ae aa 1c 9c when I scan a barcode which encodes the string DATALOGIC\n, i.e. 44 41 54 41 4c 4f 47 49 43 0a. Any idea on how to decode the PS/2 raw bytes to this data? – Martin Scharrer Jan 20 '19 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.