Package: lsudt
lsudtlsudt (list USB device tree) is a utility for listing USB devices as a tree
including associated dev nodes and other information from udev.This makes it much easier to understand the topology of a USB tree and the
relationship between device nodes and the USB devices they originate from.The utility provides filtering capabilities allowing you to filter by
device path, port path, udev tag and udev ID_PATH.Example Usage# Filter by USB port path$lsudt-p1-10
Port1-10:Hub(2109:2813/1-10)Port1:Hub(1a40:101/1-10.1)Port1:Device(67b:2303/1-10.1.1)/dev/ttyUSB0Port4:Device(bda:8152/1-10.1.4)Net:enx00e04c360033Port4:Device(5e3:749/1-10.4)/dev/sda/dev/sda1/dev/sda2/dev/sda3/dev/sda4/dev/sda5/dev/sda6/dev/sda7/dev/sda8/dev/bsg/6:0:0:0/dev/sg0# Filter by device path$lsudt-d/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4Port1-4:Device(46d:843/1-4)/dev/input/event5/dev/media0/dev/video0/dev/video1/dev/snd/pcmC1D0c/dev/snd/controlC1# Filter by ID_PATH$lsudt-ipci-0000:00:14.0-usb-0:5
Port1-5:Device(b0e:348/1-5)/dev/snd/pcmC3D0c/dev/snd/pcmC3D0p/dev/snd/controlC3/dev/hidraw2/dev/input/event22/dev/usb/hiddev1# Filter by udev TAG$lsudt-tpower-switch
Port1-4:(1-4)/dev/input/event5

Port1-5:(1-5)/dev/input/event22

Port1-7:(1-7)/dev/input/event3

Port1-9:(1-9)/dev/input/event7/dev/input/event9/dev/input/event8# Show more information$lsudt-p1-10.1-u-s-e-l
Port1:Hub(1a40:101/1-10.1)/dev/bus/usb/001/085(pci-0000:00:14.0-usb-0:10.1)Port1:Device(67b:2303/1-10.1.1)/dev/bus/usb/001/109(pci-0000:00:14.0-usb-0:10.1.1)/dev/ttyUSB0(pci-0000:00:14.0-usb-0:10.1.1:1.0):/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0:/dev/serial/by-path/pci-0000:00:14.0-usb-0:10.1.1:1.0-port0Port4:Device(bda:8152/1-10.1.4)/dev/bus/usb/001/086(pci-0000:00:14.0-usb-0:10.1.4)Net:enx00e04c360033(pci-0000:00:14.0-usb-0:10.1.4:1.0)# Show help$lsudt-h
usage:lsudt[-h][--version][--show-devusb][--show-idpath][--show-empty-hubs][--show-device-links][--device-pathDEVICE_PATH][--port-pathPORT_PATH][--udev-tagTAG][--udev-idpathID_PATH]ViewconnectedUSBdevicesanddevicenodes

optionalarguments:-h,--helpshowthishelpmessageandexit--versionshowprogram'sversionnumberandexit--show-devusb,-ushow/dev/usb/devicenodes--show-idpath,-sshowudevID_PATHnexttodevices--show-empty-hubs,-eshowemptyhubs--show-device-links,-lshowdevicelinks--device-pathDEVICE_PATH,-dDEVICE_PATHlimitoutputtodevicescontainedwithinapathstartingwith/sys/devices/--port-pathPORT_PATH,-pPORT_PATHlimitoutputtodevicesdownstreamofaparticularportpath--labelLABEL,-bLABELlimitoutputtodevicesdownstreamofaparticularlabel--udev-tagTAG,-tTAGlimitoutputtodeviceswithudevtag--udev-idpathID_PATH,-iID_PATHlimitoutputtodeviceswithaparentstartingwithgivenidpathInstallationThe easiest way to install lsudt is to use pip, as follows:$pip3installlsudtAlternatively you can clone the Github repo and install it as follows:$gitclonehttps://github.com/The-Good-Penguin/lsudt.git
$cdlsudt
$pip3install.LabelsThe USB tree can be better visualised by using labels. A user may create a
configuration file that assigns text labels to specific devices.For example consider the following USB tree:$lsudt-p1-10
Port1-10:Hub(2109:2813/1-10)Port2:Hub(45b:209/1-10.2)Port3:Device(67b:2303/1-10.2.3)/dev/ttyUSB0Port4:Hub(1a40:101/1-10.2.4)Port3:Device(67b:2303/1-10.2.4.3)/dev/ttyUSB1Port4:Device(bda:8152/1-10.2.4.4)Net:enx00e04c360033The same tree can be better visualised when using labels:$./lsudt.py-p1-10
Port1-10:Hub(2109:2813/1-10)Port2:HubusedforRaspberryPi(45b:209/1-10.2)Port3:RaspberryPiUART(67b:2303/1-10.2.3)/dev/ttyUSB0Port4:Additionalhub(1a40:101/1-10.2.4)Port3:USBrelay(Pipowercontrol)(67b:2303/1-10.2.4.3)/dev/ttyUSB1Port4:HubbuiltinEthernet(connectedtoPi)(bda:8152/1-10.2.4.4)Net:enx00e04c360033The configuration file for these labels is shown below:segments:-identifier:raspberry_pilabel:HubusedforRaspberryPiports:-port:1label:UART-port:3label:RaspberryPiUART-port:4label:Additionalhub-port:4.3label:USBrelay(Pipowercontrol)-port:4.4label:HubbuiltinEthernet(connectedtoPi)mappings:-identifier:raspberry_piport:1-10.2A segment represents a fixed portion of the USB topology and consists
of an identifier, label and set of labels for child ports.The segment is accompanied with a mapping that describes where the
segment lives in the overall USB tree. In this way, the port path of
the ports in a segment are relative to the port path in the mapping.This is useful as the segment can represent a fixed set of devices
(e.g. a board in a board farm) and the mapping describes where it is
(e.g. making it easier to move a board in a board farm).The configuration can be split across any number of files. lsudt will
scan for any files ending with the .yml suffix in the ~/.lsudt/ directory.Finally a segment identifier can be used to filter the output of lsudt,
e.g.$./lsudt.py-braspberry_pi
Port2:HubusedforRaspberryPi(45b:209/1-10.2)Port3:RaspberryPiUART(67b:2303/1-10.2.3)/dev/ttyUSB0Port4:Additionalhub(1a40:101/1-10.2.4)Port3:USBrelay(Pipowercontrol)(67b:2303/1-10.2.4.3)/dev/ttyUSB1Port4:HubbuiltinEthernet(connectedtoPi)(bda:8152/1-10.2.4.4)Net:enx00e04c360033