Import
There are two ways to control USB ports:Module Functions
| Function | Description |
|---|---|
enable(net_name) | Enable (power on) USB port |
disable(net_name) | Disable (power off) USB port |
toggle(net_name) | Toggle USB port power state |
Exception Classes
| Exception | Description |
|---|---|
USBBackendError | Base class for USB hub errors |
LibraryMissingError | Required vendor SDK not installed |
DeviceNotFoundError | USB hub not found |
PortStateError | Error changing port state |
Function Reference
enable(net_name)
Enable (power on) a USB port.
| Parameter | Type | Description |
|---|---|---|
net_name | str | Name of the USB net |
disable(net_name)
Disable (power off) a USB port.
| Parameter | Type | Description |
|---|---|---|
net_name | str | Name of the USB net |
toggle(net_name)
Toggle the power state of a USB port.
| Parameter | Type | Description |
|---|---|---|
net_name | str | Name of the USB net |
Net-Based API
You can also use the Net abstraction for USB control:Examples
Basic Power Control
Power Cycle Device
Error Handling
Automated Test Setup
USB Device Reset
Toggle for Quick State Change
Supported Hardware
| Hardware | Features |
|---|---|
| Acroname BrainStem USB Hub | Individual port power control, current monitoring |
| YKUSH USB Hub | Per-port power switching |
Notes
- USB nets must be configured on the Lager Box with hub serial number and port mapping
- Power state changes take effect immediately
- Allow time for USB enumeration after powering on (~1-3 seconds)
- Power cycling can be useful for device reset/recovery
- The
toggle()function is useful for quick state changes - Use exception handling for robust error recovery

