1

I'm working with an embedded device that has a display with a touch screen, but to this point, no keyboard. There is a console that is accessible via a connector that isn't user accessible. The device also has a USB port to which I've connected a barcode scanner that enumerates as a CDC/ACM class device, creating /dev/ttyACM0. On the console, I can 'cat ttyACM0', scan a barcode, and see the result print out on the console. Of course, the actual application code is a bit more complex, but the essentials are the same: open /dev/ttyACM0, read it, pass the data to the UI.

Now I have a magnetic card reader which quite successfully enumerates as a USB HID Keyboard. If plugged into Windows, I can open Notepad, swipe a card, and see the data show up as if I'd typed it on my keyboard. To this point though, I've been unable to find a way as simple as for my barcode scanner to see the keyboard data.

I do see /dev/input/event1 show up when the card reader enumerates. If I cat it (actually od -x it), I see the events that I'd expect and could write an interpreter. The drivers/tty/vt/keyboard.c code also sees those events since I was able to write a module that did a register_keyboard_notifier(). My callback is invoked and I'm given KBD_KEYSYM messages where SHIFT keys are handled and scancodes have been interpreted and turned into ASCII characters. I could further enhhance my module to create my own "/dev/keyboard" entry etc. But I keep feeling that I shouldn't have to do any of that work and that there's something simple and straightforward I could do in my userland code to see those ASCII keystrokes in the same way that my userland code opens and then reads from /dev/ttyACM0 to see the barcode scanner output.

UPDATE: "Time and tide wait for no man.", nor does my program manager. Essentially this same question has been asked by others in several other forums without answer, so maybe there is none? In any case, I just went ahead and wrote a driver so there's now a /dev/magcard which I can read just fine.

  • A serial console? Also, how are you accessing it right now? – phk Jan 31 '17 at 19:17
  • The console is serial -- one of the UART ports on the processor chip. It's the same UART that's used to talk to U-Boot. The UART port is conveyed by U-Boot to the kernel via the command line (console=ttyO0,115200n8). There's a special connector behind the battery into which a USB/Serial converter is plugged and thence to my development PC running a terminal emulator. – David H Olson Jan 31 '17 at 19:28

Your Answer

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

Browse other questions tagged or ask your own question.