Skip to content

Commit 98a7138

Browse files
committed
Add examples for enumeration
This adds an example on how to use the new port enumeration feature of Hub() Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
1 parent 203459d commit 98a7138

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ for hub in hubs:
1818
print(f" Found port: {port}")
1919
```
2020

21+
## Create hub and enumerate attached ports
22+
```python
23+
import uhubctl
24+
25+
hub = Hub("1-1", enumerate=True)
26+
27+
# Iterate all ports
28+
for port in hub.ports:
29+
print(f"Found port: {port}")
30+
31+
# Get port by port number
32+
port_2 = hub.find_port(2)
33+
print(f"The status of port 2 is {port_2.status}")
34+
```
35+
2136
## Manually specify hub and port
2237

2338
```python

0 commit comments

Comments
 (0)