usbhubctl
usbhubctl extends uhubctl.
State of this project
Still alpha. The concept/solution seems fine.
To be improved
- Much too slow (
uhubctlmay take seconds just to switch one plug) - Implementation to complicated (uses
lsusb -tv,uhubctl, root rights, ...)
Use Case
I would like to switch on power on plug 3 on my RSH_A16 hub.
Problem
uhubctl allows me to do this - but I have to know which usb device id corresponds to plug 3.
- I have to first figure out the topology (internal structure) of my RSH_A16 hub. Spoiler: there are 5 hubs chips with 4 ports each.
- Now I have to figure out, which port is connected to each plug.
- When I reconnect the RSH_A16 to another USB connected on my compunter, the whole assignement changes again.
Now I can issue uhubctl -l 3-4.6.1 -p 3 --action on.
Solution with usbhubctl/uhbuctl
This is the topology of the RSH_A16.
rsh_a16 = Hub(
manufacturer="RSHTECH",
model="RSH-A16",
comment="",
plug_count=16,
hub_chip=HubChip(
"0bda:5411",
plug_or_chip=[
1,
2,
HubChip(
"0bda:5411",
plug_or_chip=[
7,
8,
HubChip("0bda:5411", plug_or_chip=[13, 14, 15, 16]),
HubChip("0bda:5411", plug_or_chip=[9, 10, 11, 12]),
],
),
HubChip("0bda:5411", plug_or_chip=[3, 4, 5, 6]),
],
),
)
Here you see the 5 internal hub-chips and to which usb-plugs the are connected.
This code will power on usb-plug number 3:
from usbhubctl.known_hubs import rsh_a10, rsh_a16
# Call `lsusb -tv` and find all connected RSH_A16
hubs = rsh_a16.find_connected_hubs()
if len(hubs) > 1:
print("More than one RSH_A16 hub detected: unambiguously")
return
if len(hubs) == 0:
print("No RSH_A16 hub detected")
return
hub = hubs.hubs[0]
# Finally power on
# Internally, this will call `uhubctl -l 3-4.6.1 -p 3 --action on`
hub.get_plug(3).on()
Benefit
No matter, where you connected the RSH-A16 hub, the method find_connected_hubs will find it and call uhubctl -l 3-4.6.1 -p 3 --action on with the correct parameters.
Metadata
Release files for usbhubctl 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| usbhubctl-0.0.1.tar.gz | 16.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usbhubctl-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.9 kB
Release files / usbhubctl-0.0.1.tar.gz
| Download URL | usbhubctl-0.0.1.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10ec8e8ee35cad161826109b22afab8645b670a49ed6a794b3de9f69d4567f2e
|
|
BLAKE2b-256 checksum How to use checksums |
78ec8242e6082e62b4776afc88e30206a874c4fc746146d0ef1d623857d8236a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / usbhubctl-0.0.1-py3-none-any.whl
| Download URL | usbhubctl-0.0.1-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f55573498cd05d22236cfb558cbd5e0b9b8d1e654f446e82ca463d0d2b107ff2
|
|
BLAKE2b-256 checksum How to use checksums |
40ea39c5673342aaaba790e4f47f52069627b3e8f7e025e28de208754132d693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Security for usbhubctl 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.