Hi everybody.
I'm a beginner when it comes to programming but since this is a pretty *nix specific problem I choose to post this topic here.
I have bought a cheap magnet card reader and I simply want to assign a variable in a program to a number which is read of from a card.
The thing is that when I plug in the reader into my computer (debian) it interprets it as a usb keyboard and if I swipe a card it behaves just like if it was a keyboard (it prints out the information from the card out wherever I happen to have to have the marker).
The bottom line is that I would like to "catch the signal" from the reader and restrict the outputs and reading to my program only. I don't want the outputs of information anywhere else. Can this be done? If so, is it hard to accomplish?
I figured that this has been done by somebody else but my google skills let me down becuase I'm not really sure about what I should search for.
Can this be done? How would you do it? Any help or recommendations on how to solving this would be great.
I don't know if it might help but here's the dmesg I get when I connect the reader:
[78298.288803] usbcore: registered new interface driver usbhid
[78298.288808] usbhid: USB HID core driver
[78309.888141] usb 7-2: USB disconnect, address 2
[78327.580089] usb 7-2: new full speed USB device using uhci_hcd and address 3
[78327.735148] usb 7-2: New USB device found, idVendor=f725, idProduct=f834
[78327.735157] usb 7-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[78327.743120] usb 7-2: ctrl urb status -75 received
[78327.744412] input: HID f725:f834 as /devices/pci0000:00/0000:00:1d.2/usb7/7-2/7-2:1.0/input/input12
[78327.744750] generic-usb 0003:F725:F834.0002: input,hidraw0: USB HID v1.10 Keyboard [HID f725:f834] on usb-0000:00:1d.2-2/input0
Almost certainly, your magnet card reader is a keyboard. It's a very common way that sort of thing is built to ensure near universal compatibility without the need for any additional software. It's possible that it wraps the keystrokes it sends in some constant key sequence to mark it out, but often they don't.
That said, you question becomes "how can I get the input from the keyboard", and I expect you already know the answer to that.