Reputation: 4049
Hello geniuses i want to only detect the event generated by a usb device attached to it like barcode scanner.Now want that a barcode scanner is plugged in to a usb port of a raspberry pi.now when it scan then how can my rpi detect that a usb device has generated a event.
Upvotes: 1
Views: 4375
Reputation: 23500
Hopefully PyUSB works, and in that case you can follow this guide
If for whatever reason that doesn't work, you could open the /dev/tty
device direclty with a standard:
with open('/dev/tty4', 'rb') as fh:
for event in fh.read(8)
Note that /dev/tty
is just a out-of-the-hat example, your device might end up somewhere else. Check dmsg
and lsusb
to determine where your device got mounted, if at all mounted or discovered. You might need specific drivers for your scanner.
Upvotes: 0