I have a barcode scanner that acts as a keyboard interface, running on a RPi3. I’m running a multi container setup, where my Scanner service is supposed to read the input from the USB device which acts as a keyboard interface. For some reason, the container doesn’t seem to be receiving anything over stdin. My docker-compose.yml is setup as follows:
version: ‘2’
services:
scanner:
build:
context: ./apps/scanner
dockerfile: Dockerfile.template
privileged: true
stdin_open: true
tty: true
Anyone tackled similar issues to this? I’ve followed the discussion in this forum post: Input keyboard stdin but nothing from there solved my problems…
Are you able to try deploying this sample project to confirm that the device is configured properly? This test should help us understand if there is a problem with the device or rather your application container.
Please let us know if you receive input while testing that application!
If you change the first line of the Dockerfile.template like so (dropping -slim from the base image), you should be able to build & test that project. I will make sure that project is fixed up as well, thanks for pointing it out!
I just successfully deployed that project to a device I have here locally, could you share exactly how you are running the build? Is it via a git remote or balenaCLI? If via our CLI, please provide the version if you could!
I have reproduced your error locally. If you use the node v6 base image rather than node v10, you should be able to compile the test project successfully.
I just tested that end to end with a Raspberry Pi 3 application and only the changes I mentioned above.
@Craigson, I see that @xginn8 updated the balena-io-playground/node-keyboard-input project yesterday following this conversation, and I note the following difference between the Dockerfiles your were experimenting with, and the one currently in the node-keyboard-input project:
.
.
Your Dockerfile:
FROM resin/%%BALENA_MACHINE_NAME%%-node:6 FROM balenalib/%%BALENA_MACHINE_NAME%%-node:10-run
node-keyboard-input:
FROM balenalib/%%BALENA_MACHINE_NAME%%-node:6-run
I was successful(*) in running the following commands:
(*) Well, kind of successful. After deploying the project to an RPi 3, the keyboard wasn’t really working… I’m trying to figure out why. But at least it got past the image build phase without errors.
Thanks @pdcastro, I’ve also successfully managed to build and deploy to the Pi, but I have a feeling I’m running into the same issue as you, with the HID lib:
14.06.19 16:26:56 (-0400) main > @ start /usr/src/app
14.06.19 16:26:56 (-0400) main > node server.js
14.06.19 16:26:56 (-0400) main
14.06.19 16:26:58 (-0400) main /usr/src/app/node_modules/node-hid-stream/node_modules/node-hid/nodehid.js:24
14.06.19 16:26:58 (-0400) main this._raw = new (Function.prototype.bind.apply(binding.HID,
14.06.19 16:26:58 (-0400) main ^
14.06.19 16:26:58 (-0400) main
14.06.19 16:26:58 (-0400) main Error: cannot open device with vendor id 0xf39 and product id 0x877
14.06.19 16:26:58 (-0400) main at Error (native)
14.06.19 16:26:58 (-0400) main at new HID (/usr/src/app/node_modules/node-hid-stream/node_modules/node-hid/nodehid.js:24:17)
14.06.19 16:26:58 (-0400) main at newHidDevice (/usr/src/app/node_modules/node-hid-stream/lib/hidstream.js:55:10)
14.06.19 16:26:58 (-0400) main at Hidstream (/usr/src/app/node_modules/node-hid-stream/lib/hidstream.js:21:19)
14.06.19 16:26:58 (-0400) main at KeyboardBase (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-base.js:9:19)
14.06.19 16:26:58 (-0400) main at Keyboard (/usr/src/app/node_modules/node-hid-stream/lib/keyboard.js:9:5)
14.06.19 16:26:58 (-0400) main at KeyboardBase (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-base.js:9:19)
14.06.19 16:26:58 (-0400) main at KeyboardCharacters (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-characters.js:8:5)
14.06.19 16:26:58 (-0400) main at Object.<anonymous> (/usr/src/app/server.js:5:18)
14.06.19 16:26:58 (-0400) main at Module._compile (module.js:577:32)
14.06.19 16:26:58 (-0400) main
14.06.19 16:26:58 (-0400) main npm ERR! Linux 4.14.98
14.06.19 16:26:58 (-0400) main npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
14.06.19 16:26:58 (-0400) main npm ERR! node v6.16.0
14.06.19 16:26:58 (-0400) main npm ERR! npm v3.10.10
14.06.19 16:26:58 (-0400) main npm ERR! code ELIFECYCLE
14.06.19 16:26:58 (-0400) main npm ERR! @ start: `node server.js`
14.06.19 16:26:58 (-0400) main npm ERR! Exit status 1
14.06.19 16:26:58 (-0400) main npm ERR!
14.06.19 16:26:58 (-0400) main npm ERR! Failed at the @ start script 'node server.js'.
14.06.19 16:26:58 (-0400) main npm ERR! Make sure you have the latest version of node.js and npm installed.
14.06.19 16:26:58 (-0400) main npm ERR! If you do, this is most likely a problem with the package,
14.06.19 16:26:58 (-0400) main npm ERR! not with npm itself.
14.06.19 16:26:58 (-0400) main npm ERR! Tell the author that this fails on your system:
14.06.19 16:26:58 (-0400) main npm ERR! node server.js
14.06.19 16:26:58 (-0400) main npm ERR! You can get information on how to open an issue for this project with:
14.06.19 16:26:58 (-0400) main npm ERR! npm bugs
14.06.19 16:26:58 (-0400) main npm ERR! Or if that isn't available, you can get their info via:
14.06.19 16:26:58 (-0400) main npm ERR! npm owner ls
14.06.19 16:26:58 (-0400) main npm ERR! There is likely additional logging output above.
14.06.19 16:26:58 (-0400) main
14.06.19 16:26:58 (-0400) main npm ERR! Please include the following file with any support request:
14.06.19 16:26:58 (-0400) main npm ERR! /usr/src/app/npm-debug.log
14.06.19 16:27:00 (-0400) Service exited 'main sha256:c38071422bc4aff923896c0193d63410dbf71e18305bb7b588c221f98e26ba4c'
14.06.19 16:27:02 (-0400) Restarting service 'main sha256:c38071422bc4aff923896c0193d63410dbf71e18305bb7b588c221f98e26ba4c'
14.06.19 16:26:59 (-0400) main 2019-06-14T20:27:04.853700000Z [..................] - :
14.06.19 16:27:04 (-0400) main > @ start /usr/src/app
14.06.19 16:27:04 (-0400) main > node server.js
14.06.19 16:27:04 (-0400) main
14.06.19 16:27:06 (-0400) main /usr/src/app/node_modules/node-hid-stream/node_modules/node-hid/nodehid.js:24
14.06.19 16:27:06 (-0400) main this._raw = new (Function.prototype.bind.apply(binding.HID,
14.06.19 16:27:06 (-0400) main ^
14.06.19 16:27:06 (-0400) main
14.06.19 16:27:06 (-0400) main Error: cannot open device with vendor id 0xf39 and product id 0x877
14.06.19 16:27:06 (-0400) main at Error (native)
14.06.19 16:27:06 (-0400) main at new HID (/usr/src/app/node_modules/node-hid-stream/node_modules/node-hid/nodehid.js:24:17)
14.06.19 16:27:06 (-0400) main at newHidDevice (/usr/src/app/node_modules/node-hid-stream/lib/hidstream.js:55:10)
14.06.19 16:27:06 (-0400) main at Hidstream (/usr/src/app/node_modules/node-hid-stream/lib/hidstream.js:21:19)
14.06.19 16:27:06 (-0400) main at KeyboardBase (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-base.js:9:19)
14.06.19 16:27:06 (-0400) main at Keyboard (/usr/src/app/node_modules/node-hid-stream/lib/keyboard.js:9:5)
14.06.19 16:27:06 (-0400) main at KeyboardBase (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-base.js:9:19)
14.06.19 16:27:06 (-0400) main at KeyboardCharacters (/usr/src/app/node_modules/node-hid-stream/lib/keyboard-characters.js:8:5)
14.06.19 16:27:06 (-0400) main at Object.<anonymous> (/usr/src/app/server.js:5:18)
14.06.19 16:27:06 (-0400) main at Module._compile (module.js:577:32)
14.06.19 16:27:06 (-0400) main
I’ve changed to the correct product and Vendor ID, but still no dice.
@Craigson, indeed when running the project on an RPi 3, I was getting the same error you posted above, “cannot open device with vendor id 0xf39 and product id 0x877”. Then I saw in the project’s README that I should edit the server.js file to use my keyboard’s ID, and I got it to work with the following steps:
On a device’s Host OS terminal (which can be opened via the web dashboard), I used the lsusb command to get my USB keyboard’s vendorId (0x04f2) and productId (0x0402):
$ lsusb
...
Bus 001 Device 007: ID 04f2:0402 Chicony Electronics Co., Ltd Genius LuxeMate i200 Keyboard
Edited the following line in server.js:
var characters = new KeyboardCharacters({ vendorId: 0x04f2, productId: 0x0402 });
On the device’s web dashboard, enabled “PUBLIC DEVICE URL”. Clicked on the link, which opened this page on a browser:
https://<long-device-UUID>.balena-devices.com/
Typed on they keyboard, watched characters being displayed on the web page and got incomprehensibly happy about it.
So, it sounds like your issue was either in getting the correct hardware ID, or perhaps forgetting to commit the changes? Let us know how you get on with it.
Thanks @pdcastro, in a very strange turn of events the productId was different between my local environment and on the device, which requires further investigation. However I managed to get the sample to run, thank you for your assistance.