Search code examples
pythonusbraspberry-pi4

How to Finding USB port Address with dev/tty/usb.. format in raspberry pi 4 ver.b?


I had a problem for searching USB Address Port in Raspberry Pi. I'm using RIGOL DSE1102E Digital Oscilloscope, to acquiring data to my Raspberry Pi 4 Ver. b.

So, i'm connecting from Raspberry Pi 4 to my Oscilloscope USB Slave's port and i'm checking in my Raspberry terminal. So i'm typing

pi@raspberrypi:~$ lsusb

so, it returned

Bus 002 Device 001 : ID 1d6b Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1ab1:0588 Rigol Technologies DS1000 SERIES
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

so i'm assumed my Raspberry is connected to my instrument because appearance of this line

Bus 001 Device 003: ID 1ab1:0588 Rigol Technologies DS1000 SERIES

so, based on this case how to know this

Bus 001 Device 003: ID 1ab1:0588 Rigol Technologies DS1000 SERIES

address in format

dev/tty/usb...

because i want to code it using pyos library from Python


Solution

  • Instead of using /dev/ttyUSB0 I recommend using the symlinks provided by the kernel in /dev/serial/by-id. They contain a lot of info about the USB device, including the vendor ID and product ID, so you can be sure you are opening the right device. They also should be pretty stable, not depending on the USB port you use or the order the devices are plugged in. Run ls -l /dev/serial/by-id to explore the options.