linux-automation / meta-lxatac

Build your own LXA TAC images and bundles
MIT License
5 stars 15 forks source link

meta-lxatac-software/labgrid: Export USB-Ports as Power Switches #40

Closed SmithChart closed 1 year ago

SmithChart commented 1 year ago

All three USB ports on the LXA TAC are power switchable (e.g. using uhubctl). labgrid already has a driver that can handle ports where power can be switched: USBPowerPort.

With this change we'll export the three USB ports as power ports. This way they can be used to switch DUTs on or off.

The resources exported will look something like this:

$ labgrid-client r
lxatac-00013/dut_power/NetworkPowerPort
lxatac-00013/lxatac-usb-ports-power-p1/NetworkUSBPowerPort  # <-- new
lxatac-00013/lxatac-usb-ports-power-p2/NetworkUSBPowerPort  # <-- new
lxatac-00013/lxatac-usb-ports-power-p3/NetworkUSBPowerPort  # <-- new
lxatac-00013/serial/NetworkSerialPort
hnez commented 1 year ago

I've always assumed that we would implement this using the HTTP API of the tacd but it does not have to be that way. Using uhubctl is perfectly fine, as it uses the same kernel API as the tacd to do the switching and the tacd notices the change eventually via periodic polling.

SmithChart commented 1 year ago

Implementing this using the HTTP API shouldn't be any more difficult than using the USBPowerPort. But a polling interval of 1s still feels quite responsive.