kkjkearney
Posts: 14
Joined: Wed Dec 23, 2015 3:16 pm

Separating USB Input

Thu Sep 22, 2016 8:39 pm

I'm using a Raspberry Pi 3 Model B. I'm running Jessie and programming with Python. I have two USB devices that give me data input. They act like keyboards, "typing" numbers and then sending a "carriage return". Problem is, I need to discern which device is sending which information. Is there any way, in Python, to separate the USB keyboard inputs, so that I can have one variable listening for input from device 1, and another variable listening for input from device 2?

User avatar
topguy
Posts: 5762
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Separating USB Input

Fri Sep 23, 2016 11:40 pm

How identical are your two devices ? Are they the same make/model ? What are they ? RFID or Barcode readers ?

There are something called "udev-rules" which can be used to give devices different names and use the same name on each boot.
If the two devices have different "product/vendor" ids when you list them with "lsusb" its usually easy to create these rules. If they are identical then you have to look at serialnumbers etc. and that can be a little tougher.

Also if your application only read input from what we call "standard input" then those devices are mixed into one stream and there is no way to differentiate them. (as far as I know ) Your application probably need to read from devices in "/dev/input", and open them separately.

This thread http://stackoverflow.com/questions/6990 ... input-stre contain some tips on how to identify different input devices. So you might not need to use udev rules to create unique names for them.

Return to “Python”