Cut and restore power to one port of a programmable USB hub, which is how a test
forces a DUT to re-enumerate or simulates a cable pull.
Handle
Methods
Method Reference
enable() -> Result<()> and disable() -> Result<()>
Power the port on or off.
toggle() -> Result<bool>
Invert the port’s power state.
Returns: true if the port is now enabled, false if now disabled — the
state after the toggle, not before.
state() -> Result<bool>
Read whether the port is powered.
Returns: true when enabled.
state() needs box software 0.29.0 or newer. Older boxes reject the action, and
the crate turns that specific rejection into Error::UnsupportedByBox with the
message the 'state' action on /usb/command requires box software >= 0.29.0; update the box or use toggle/enable/disable.
Examples
Force a DUT to re-enumerate and wait for it to come back
Supported Hardware
Notes
- One net is one port. Cycling
usb1 leaves the hub’s other ports alone.
- The port’s
devnum on the bus changes across a re-enumeration. Match a device by
serial or vid/pid, never by devnum, when checking that it came back.
- Powering a port down removes the device the box may be using for another net. A
debug probe or serial adapter behind that port will disappear mid-test.