esptest.devices.usb_topology module
Read the Linux USB topology from /sys/bus/usb/devices.
This is a focused, line-based port of the topology viewer in huby. It builds a root-hub/port/device tree (no root privileges needed for viewing) so it can be used to:
ls– print the current USB tree, including the/dev/tty*nodes and the location string (e.g.1-6.1.2) that can be fed straight into theesp-uhubctlpower commands.monitor– poll the tree and report plug/unplug events.
It is Linux specific (sysfs); on other platforms scan_usb returns an empty
snapshot with an error message.
- class esptest.devices.usb_topology.UsbDevice(name: str, bus: int, port_path: Tuple[int, ...], parent_name: str | None, product: str | None = None, manufacturer: str | None = None, serial: str | None = None, id_vendor: str | None = None, id_product: str | None = None, speed: str | None = None, maxchild: int = 0, device_class: str | None = None, dev_nodes: Tuple[str, ...] = ())[source]
Bases:
object- Parameters:
- class esptest.devices.usb_topology.UsbSnapshot(devices: Dict[str, esptest.devices.usb_topology.UsbDevice] = <factory>, children: Dict[str, List[str]] = <factory>, errors: Tuple[str, ...] = ())[source]
Bases:
object
- esptest.devices.usb_topology.scan_usb(sysfs=PosixPath('/sys/bus/usb/devices'))[source]
Scan
sysfsand return aUsbSnapshotof the USB tree.- Parameters:
sysfs (Path)
- Return type:
- esptest.devices.usb_topology.format_tree(snapshot, show_empty=False)[source]
Render the snapshot as an indented tree (one line per port/device).
- Parameters:
snapshot (UsbSnapshot)
show_empty (bool)
- Return type:
- esptest.devices.usb_topology.diff_snapshots(old, new)[source]
Return
(added, removed)device names between two snapshots.- Parameters:
old (UsbSnapshot)
new (UsbSnapshot)
- Return type: