问题
Scenario:
- I have an usb-RFID reader
- attaching it to notebook it works as an newly attached USB keyboard, e.g. without needing to install any drivers
- when touching the reader with RFID tag
- it enters into my current window (for example terminal/shell) the RFID number (like
0009339384\n
) - e.g. it even sends the\n
. - so, it works exactly as if I had typed the numbers in my notebook's keyboard
The questions are:
- is it possible read the RFID reader directly without some kernel-level drivers, e.g. something like
cat /dev/keyboard1
... - in other words, how can I determine from which "keyboard" the characters are coming?
- using OS X, but would be nice to know the solution for Linux too.
Moreover, I want attach two readers - so I definitely need to clearly differentiate between the two readers. And I want use the rfid-reader in a bash (perl) script, so I'm definitely looking for a solution without compiling some "drivers"... It is possible?
The OS X identifies it as:
SYC ID&IC USB Reader:
Product ID: 0x0035
Vendor ID: 0xffff
Version: 1.00
Serial Number: 08FF20140315
Speed: Up to 1.5 Mb/sec
Manufacturer: Sycreader RFID Technology Co., Ltd
Location ID: 0x14100000 / 18
Current Available (mA): 500
Current Required (mA): 100
Extra Operating Current (mA): 0
EDIT Okay, looks like in Linux it can be done - just found
- this https://unix.stackexchange.com/questions/72483/how-to-distinguish-input-from-different-keyboards
- also Accessing multiple keyboards input by C++ (or python) in linux
For OS X - exact duplicate on unix: https://unix.stackexchange.com/questions/228413/route-keyboard-through-only-dev-ttys000-on-mac-os-x - unfortunately, closed without any answer :(
回答1:
Ok, so - easily solvable in Linux. As in edits in the question - here are already many similar questions like this.
The solution is: reading the particular /dev/input/eventN
device(s).
In my case, me using the Linux::Input perl module. Works perfectly.
It is pointless adding code here, the package comes with the evtest.pl - so anyone could easily check how it works.
Still need solve one issue - e.g. even when reading the device and nicely getting all events from the rfid reader (4 events for one number), the rfid-code still is inserted into the active window, like it coming from a keyboard. (This will be an another question).
For OS X i haven't an easy solution yet, but now focusing for the Linux variant. :)
回答2:
There is one thing that might help you solve this problem without resorting to programming in C. It is called multiseat. I didn't do it myself I just know it exists. In general it is a way how multiple people can work on same computer at the same time just using multiple keyboards, mice and monitors. It is not exactly what you are looking for but there might be possible way.
来源:https://stackoverflow.com/questions/44542203/how-to-determine-from-which-keyboard-the-input-comes