mirror of
https://github.com/google/bumble.git
synced 2026-05-09 04:08:02 +00:00
usb: Add usb path moniker
Add a new moniker for usb and pyusb driver allowing to select the usb device using its bus id and port path like `usb:3-3.4.1`.
This commit is contained in:
committed by
David Duarte
parent
a2caf1deb2
commit
16d5cf6770
@@ -216,6 +216,15 @@ async def open_pyusb_transport(spec: str) -> Transport:
|
||||
if ':' in spec:
|
||||
vendor_id, product_id = spec.split(':')
|
||||
device = usb_find(idVendor=int(vendor_id, 16), idProduct=int(product_id, 16))
|
||||
elif '-' in spec:
|
||||
|
||||
def device_path(device):
|
||||
if device.port_numbers:
|
||||
return f'{device.bus}-{".".join(map(str, device.port_numbers))}'
|
||||
else:
|
||||
return str(device.bus)
|
||||
|
||||
device = usb_find(custom_match=lambda device: device_path(device) == spec)
|
||||
else:
|
||||
device_index = int(spec)
|
||||
devices = list(
|
||||
|
||||
Reference in New Issue
Block a user