I am stuck at a very unusual problem. I am making a project in which i am using two USB ports of RaspberryPi for attaching a GPS module and a S2 Xbee. The code of python i am using is using both the GPS and the S2 Xbee. The biggest problem i am facing is whenever i switch off my raspberryPi and start it again, the ports gets interchanged. Basically, for GPS i am using USB0 and for Xbee i am using USB1, but they gets interchanged. Please suggest me some solution. I searched a lot but could not find much.
Asked
Active
Viewed 201 times
0
-
Not a programming problem. Look if there are usable device symlinks somewhere in `/dev/`. If not, configure udev to create them. – Klaus D. Mar 22 '19 at 02:41
-
1I know this sir, but because of this problem my graduation project is not working. – Manu Mar 22 '19 at 03:18
-
1Agree, not a programming problem, but I also have a suggestion: instead of hard coding usb device IDs, why not scan for them (maybe `lsusb` or the system it uses)? – erik258 Mar 22 '19 at 03:30
-
Sir, can you elaborate it with some sample code or link. I am using python. – Manu Mar 22 '19 at 03:44
1 Answers
0
Each USB device has a unique vendor id and product id combination. The command 'lsusb -v' or 'udevadm info --query=all -n /dev/bus/usb/001/00x' x = [1..4] on raspi, will identify the device name where they are mounted by the raspi.
Here is another way without starting linux commands from python:

ElDuderino
- 33
- 4
-
How Sir. lsusb gives all the things attached at usb ports. In python code, i am using statements like PORT = "/dev/ttyUSB1" BAUD_RATE = 9600 device = XBeeDevice(PORT, BAUD_RATE). Should i replace ttyUSB1 with lsusb. – Manu Mar 22 '19 at 04:34