Hi,
I installed balenaOS on a Raspberry Pi 4.
I’m trying to read data from a QR code reader that acts as keyboard. Dmesg gives me the following info:
[13392.153101] usb 1-1.4: USB disconnect, device number 6
[13429.093031] usb 1-1.4: new full-speed USB device number 7 using xhci_hcd
[13429.198220] usb 1-1.4: New USB device found, idVendor=1eab, idProduct=1303, bcdDevice= 1.00
[13429.198243] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[13429.198261] usb 1-1.4: Product: NLS IOTC PRDs HID KBW
[13429.198277] usb 1-1.4: Manufacturer: Newland Auto-ID
[13429.198292] usb 1-1.4: SerialNumber: FC9C2544
[13429.207139] input: Newland Auto-ID NLS IOTC PRDs HID KBW as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:1EAB:1303.0005/input/input4
[13429.266238] hid-generic 0003:1EAB:1303.0005: input,hidraw0: USB HID v1.00 Keyboard [Newland Auto-ID NLS IOTC PRDs HID KBW] on usb-0000:01:00.0-1.4/input0
Here’s my docker-compose file:
version: '2'
services:
rpi.bash:
build: ./rpi.bash
privileged: true
labels:
io.balena.features.supervisor-api: '1'
python-evdev2mqtt:
build: ./python-evdev2mqtt
privileged: true
python-evdev2mqtt is copied from here with input_device set to “/dev/input/event0”. It receives the events from the event device 0.
Here is my docker file:
FROM balenalib/raspberrypi3-node:10.18
WORKDIR /app
COPY ./script.sh ./script.sh
RUN chmod +x ./script.sh
ENV UDEV=on
ENTRYPOINT ["bash", "./script.sh"]
Here is script.sh:
#!/bin/bash
while read line
do
echo "$line"
done < "${1:-/dev/tty1}"
When I scan some QR codes I sometimes don’t see all the characters in the rpi.bash service while the python-evdev2mqtt does always give me the correct characters.
When I ran this script in a terminal on default raspbian it works flawlessly. Is somebody else reading from /dev/tty1? I would like to treat this device as simple keyboard than rely on an event device to keep it on a very high level.
I scanned this QR code:
https://images-na.ssl-images-amazon.com/images/I/31Umxl57vfL.SY355.png which contains the following content:
https://itunes.apple.com/us/app/qr-code-reader-open-tap-and-go/id938721461?ls=1&mt=8
^[[B
However when I scanned this QR codes I got the following output from the two services:
https://pastebin.com/201Na4fL
The python-evdev2mqtt service gives the correct events, but rpi.bash gives the wrong output (https//itunes.apple.com/us/app/qr-coe-rader-oentapandgo/id3872461?l=1&t=8).
Is the input too fast, is some other process reading from /dev/tty1, …? I’m kinda out of ideas, any help would be very welcome!
Thanks in advance!
Ben
