Import
Methods
| Method | Description |
|---|---|
enable() | Enable (power on) USB port |
disable() | Disable (power off) USB port |
toggle() | Toggle USB port power state; returns the resulting state (True=enabled) |
state() | Read the current power state without changing it (True=enabled) |
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 |
Method Reference
Net.get(name, type=NetType.Usb)
Get a USB net by name.
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the USB net |
type | NetType | Must be NetType.Usb |
enable()
Enable (power on) the USB port.
disable()
Disable (power off) the USB port.
toggle()
Toggle the power state of the USB port. Returns the resulting state
(True if now enabled, False if now disabled).
state()
Read the current power state of the USB port without changing it. Returns
True if the port is currently enabled (powered on), False if disabled. The
value is read live from the hub, so it always reflects the real port state.
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

