I am completely stuck. I have a reasonably standard USB bar code scanner that I have plugged into my Pi. It creates a /dev/hidraw0. The bar code scanner comes up as a "keyboard" on a computer (tried on several). What I want to do is have a program running in the background that reads the bar code scanner as a "keyboard" without having a terminal open.
The code that I am using is below. I found this type of thing on another board.
Code: Select all
import sys fp = open('/dev/hidraw0', 'rb') while True: buffer = fp.read(8) for c in buffer: if ord(c) > 0: print ord(c) print "\n"
When I run the code and scan the book I get:
I am really confused. I was hoping that somehow I could get a string, or the ASCII code of the ISBN. I am honestly not sure what the codes above are as they don't appear to coincide with the ISBN number.
Any help or thoughts would be greatly appreciated.