Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm building an application that will be using a magnetic card reader as the only interface: no keyboard, no mouse, no screen for that matter. Now as I understand it, most MCRs these days support keyboard emulation so I can just zip the card through and it'll send keystrokes right to /dev/input/eventN. But now I have a few questions:
How do I capture the keystrokes given that this app has to run at boot time?
Do I need a keylogger?
Can't I just use an HID driver of some kind? How would that work?
Is there a preferred model out there for people to do stuff like this?
My app will be written in Python and run on a Sheevaplug, so yeah, I'm working with odd hardware to begin with.
You may want to do some research into /dev/, or how it operates and sees things- you're approaching this all wrong. Play on another box with a mouse attached; play with /dev/input. How can you get the mouse signals? What are devices in Linux?
There is a single line solution in python for this, and you'll kick yourself when you figure out how /dev/ works; simple code you should have used a bazillion times
Actually, I know how to capture input both via STDIN and at a prompt. What I'm doing here though won't work with either of those options. This computer doesn't have a keyboard, or a mouse. There will be no one in front of the machine to login and start the app waiting for input.
I need this program to start at run-time and capture all input from the cardreader without any user input. Are you suggesting that I can just have Python run a script that waits for input without logging in?
Nope, simpler still. Why not read the stream directly off the device? Series of open( "", 'r' ).read()s. You can either have your python script run as a boot runlevel script (as a gentoo user, you'll know how to do this too) or run the box as a single user environment and have that run it.
I suppose, though, it depends on what the project is for; a commercial environment where you want robustness, you may want to use something like HAL/Dbus. A quick project or proof of concept, yeah- read it off the device like you would a pipe or a socket.
Okay, you didn't say you'd got that far. Well, then now you decode it, or map it to values you already know. You'll want to find the developer docs for your card reader for more information, though, if you want to do more than read data from it.
The "device" in this case though is a keyboard (I haven't bought a card reader yet). Are you saying that every keyboard sends different data to /dev/input/eventN? Is there no way to easily translate the binary data coming out of /dev/input/eventN into the ASCII that're actually coming through?