4

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?

Community
  • 1
  • 1
Daniel Quinn
  • 6,010
  • 6
  • 38
  • 61

2 Answers2

2

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

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

Otto Allmendinger
  • 27,448
  • 7
  • 68
  • 79