I'm working on a program for a Raspberry Pi (one of the cool new ones with
the quad-core CPU and a gigabyte of RAM).  The program will run as a daemon
and this unit is headless - there's no keyboard plugged in.  Just a USB
Mifare HID card reader that outputs 8 hex characters when a card is in
proximity, then an 'Enter.'

It's actually outputting scan codes, but I figure I can convert them to the
appropriate hex codes.

I understand if I was running on the console, tapping a card on the reader
would cause the hex string to be input wherever my cursor is.  I'd love to
be able to redirect that input to my program, but I'm clueless on how
that's done.  My google-fu isn't working for me here either.

The card reader does show up as /dev/input/event0 and if I cat that, it
outputs a bunch of binary stuff.  I can send it to a file and a hex dump of
part of that file looks like this:

00000000: eba1 e355 6032 0600 0400 0400 *27*00 0700  ...U`2......'...
00000010: eba1 e355 6032 0600 0100 0b00 0100 0000  ...U`2..........
00000020: eba1 e355 6032 0600 0000 0000 0000 0000  ...U`2..........
00000030: eba1 e355 7251 0600 0400 0400 *27*00 0700  ...UrQ......'...
00000040: eba1 e355 7251 0600 0100 0b00 0000 0000  ...UrQ..........
00000050: eba1 e355 7251 0600 0000 0000 0000 0000  ...UrQ..........
00000060: eba1 e355 ad70 0600 0400 0400 *1f*00 0700  ...U.p..........
00000070: eba1 e355 ad70 0600 0100 0300 0100 0000  ...U.p..........
00000080: eba1 e355 ad70 0600 0000 0000 0000 0000  ...U.p..........
00000090: eba1 e355 e48f 0600 0400 0400 *1f*00 0700  ...U............
000000a0: eba1 e355 e48f 0600 0100 0300 0000 0000  ...U............
000000b0: eba1 e355 e48f 0600 0000 0000 0000 0000  ...U............
000000c0: eba1 e355 26af 0600 0400 0400 *24*00 0700  ...U&.......$...
000000d0: eba1 e355 26af 0600 0100 0800 0100 0000  ...U&...........
000000e0: eba1 e355 26af 0600 0000 0000 0000 0000  ...U&...........
000000f0: eba1 e355 64ce 0600 0400 0400 *24*00 0700  ...Ud.......$...
00000100: eba1 e355 64ce 0600 0100 0800 0000 0000  ...Ud...........
00000110: eba1 e355 64ce 0600 0000 0000 0000 0000  ...Ud...........

Don't know if the formatting will display properly, but I've bolded a few
bytes.  The 0x27 is '0' and we see keypress and key release.  This is
followed by 0x1F (2) and 0x24 (7) - we march through the rest of the string
and finally arrive at the 0x28 Enter key:

00000300: eba1 e355 3626 0800 0400 0400 *28*00 0700  ...U6&......(...
00000310: eba1 e355 3626 0800 0100 1c00 0100 0000  ...U6&..........
00000320: eba1 e355 3626 0800 0000 0000 0000 0000  ...U6&..........
00000330: eba1 e355 9145 0800 0400 0400 *28*00 0700  ...U.E......(...
00000340: eba1 e355 9145 0800 0100 1c00 0000 0000  ...U.E..........
00000350: eba1 e355 9145 0800 0000 0000 0000 0000  ...U.E..........

I don't pretend to understand scan codes, but 48 bytes for keypress and
another 48 for key release?  Seems excessive, but it can be handled.  The
hex 0x01 below the scan code is keypress, the 0x00 below the other scan
codes is key release.

Questions:  Can this data be grabbed from some convenient place in the OS,
preferably as a nice 8-character string?  What does the OS do with HID
input when the Pi is running headless?  The current plan says there will
never be a real keyboard plugged in, just the card reader.

Does anyone know what Linux does with input from an HID device when there's
no session running from the console?  Does it get intercepted by a login
screen?

OS is Raspbian Wheezy, apparently version 7 on a 3.18.11 kernel.

TIA

Curt

-- 
-- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nlug-talk?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to