12/6/2017 10:26 AM | |
Posts: 37 Rating: (3) |
Hi HugoD,
When the barcode scanner acts like an USB keyboard, there won't be any ttyUSB device, because keyboards are of the HID USB device class (HID=human input device) and you will find them under /dev/input. ttys have multiple purposes in Linux, one is to use them for communication to a physical device (like the ttyUSB), but they are also used for logical consoles, e.g. the text consoles. Every console has an input and an output device, for local consoles the output is typically the screen and the input is the keyboard. The keyboard is only connected to such a console as long as it has the input focus. When a program like Node-Red is started from an interactive shell, it is attached to the tty of that shell, but normally Node-Red is started as background process without a console. You can change this by starting Node-Red with openvt and assign it directly to a specific console. A pretty good article about ttys can be found here: http://www.linusakesson.net/programming/tty/ You can try is to attach your "barcode keyboard" to one specific (newly created) tty and use this tty from Node-Red. I haven't found the way how to do this, maybe you will find the answer when looking for the following terms: openvt, attach, keyboard, tty, input device. Alternatively you can directly use the input device /dev/input/by-path/* and not a tty, but that is harder because you go one abstraction level deeper. A starting point for the ladder might be these node: https://flows.nodered.org/node/node-red-contrib-autokey https://github.com/MattGyver/node-red-contrib-dev-input The following node will require that Node-Red has the input focus and is not started as background process without any terminal: https://www.npmjs.com/package/node-red-contrib-keypress To use this node assign a tty to Node-Red. This requires the installation of the "kbd" package which contains the openvt tool. Then adapt the/etc/init.d/launch_node-red.sh to look like this:
Using this command should also make it possible to use "/dev/tty" (with no number!) in combination with the serial node. I haven't tested this now, but I used it some years ago with vdr and lirc which had the same problem. Michael |
Last edited by: turner42 at: 12/6/2017 11:17:43 AMLast edited by: turner42 at: 12/6/2017 2:46:53 PMLast edited by: turner42 at: 12/6/2017 2:49:42 PMLast edited by: turner42 at: 12/6/2017 9:20:37 PM |
|
This contribution was helpful to2 thankful Users |
Follow us on