lsusb
To get more information about the USB buses and connected devices.
Is there a way to relate these two results (or an alternative) to figure out what I need? For instance, in the pictures above "/dev/ttyUSB0" is "Bus 001 Device 008: ID 1a86:...", but how can I find that out through software (preferably using Python, but a shell script could work too)?
Since you mentioned that you want to do it from Python, pyudev
has the following example code to access everything udev
knows about a device identified by a device file:
from pyudev import Context, Devicecontext = Context()device = Devices.from_device_file(context, '/dev/sda')
I believe that should work very nicely with /dev/ttyUSB0
as well.
See https://pyudev.readthedocs.io/en/latest/api/pyudev.html#pyudev.Devices.from_device_file
Once you have the device udev instance in Python, you can access device.attributes
and device.properties
to get a wealth of information including VID, PID, string descriptors, and so on. The documentation says that
all well-known dictionary methods and operators (e.g.
.keys()
,.items()
,in
) are available to access device properties.