views:

188

answers:

2

I'm trying to write a POS-style application for a Sheevaplug that does the following:

  1. Captures input from a card reader (as I understand, most mag card readers emulate keyboard input, so basically I'm looking to capture that)
  2. Doesn't require X
  3. Runs in the background (daemon)

I've seen examples of code that will wait for STDIN, but that won't work because this is a background process with no login, not even a monitor actually.

I also found this snippet elsewhere on this site:

from struct import unpack
port = open("/dev/input/event1","rb")    

while 1:    
    a,b,c,d = unpack("4B",port.read(4))    
    print a,b,c,d

Which, while being the closest thing to what I need so far, only generates a series of numbers, all of which are different with no way that I know of to translate them into useful values.

Clearly, I'm missing something here, but I don't know what it is. Can someone please how to get the rest of the way?

A: 

the format is explained in the kernel documentation in section 5. Event Interface.

Otto Allmendinger
+1  A: 

Section 5 of the Linux kernel input documentation describes what each of the values in the event interface means.

Ignacio Vazquez-Abrams
Very interesting! Thanks so much for your help, this should be enough to get me started.
Daniel Quinn