Handler for keyboards and keyboard-alike devices like bar code scanners, RFID readers.
You will find some reusable base classes and few example classes handling data reading from USB bar code scanner and RFID reader that emulate keyboards.
The keyboard_alike folder holds a re-usable Reader class. In most case you will be able to use it just by passing correct arguments.
There are device examples:
If you have matching device - connect it and run the code. Under Linux will have to run the code as root/sudo or give your user permission to access given device.
The pyqt_example.py is an example PyQt4 desktop application using the RFID reader. It will add IDs of read tags to the list widget.
The code flow is quite simple:
Sometimes pyusb/Reader class will throw exceptions, more often at start when it may read some leftover data (will throw "Got X bytes instead of Y"). Some devices support resetting, which seems to prevent any weird reads (Lindy bar code scanner works with reset, while the RFID reader stops working if reset is called).
Lack of permissions will also cause exceptions. The code will have to run as root/sudo or you will have to use udev rules to add permissions for given device.
Sometimes unknown exceptions may show up. In many cases retrying to run the code works. In some other the device must be re-connected. Example:
keyboard_alike.reader.DeviceException: Could not set configuration: [Errno None] Unknown error
If you want to handle your device then at start some experimenting/debugging is required to get to know the device.
0, 0, 31, 0, 0, 0,
0, 0, 27, 0, 0, 0
You got your device up and running? Provide a basic example with a pull request or send me a link to your blog post :)
You can visit my sites for more tutorials and stuff: