Source code for labgrid.driver.usbsdmuxdriver

import subprocess

import attr

from .common import Driver
from ..factory import target_factory
from ..step import step
from .exception import ExecutionError
from ..util.helper import processwrapper

[docs] @target_factory.reg_driver @attr.s(eq=False) class USBSDMuxDriver(Driver): """The USBSDMuxDriver uses the usbsdmux tool ( to control the USB-SD-Mux hardware Args: bindings (dict): driver to use with usbsdmux """ bindings = { "mux": {"USBSDMuxDevice", "NetworkUSBSDMuxDevice"}, }
[docs] def __attrs_post_init__(self): super().__attrs_post_init__() if self.tool ='usbsdmux') else: self.tool = 'usbsdmux'
[docs] @Driver.check_active @step(title='sdmux_set', args=['mode']) def set_mode(self, mode): if not mode.lower() in ['dut', 'host', 'off', 'client']: raise ExecutionError(f"Setting mode '{mode}' not supported by USBSDMuxDriver") cmd = self.mux.command_prefix + [ self.tool, self.mux.control_path, mode.lower() ] processwrapper.check_output(cmd)
[docs] @Driver.check_active @step(title='sdmux_get') def get_mode(self): cmd = self.mux.command_prefix + [ self.tool, self.mux.control_path, "get" ] proc = cmd, stdout=subprocess.PIPE, check=True ) return proc.stdout.strip().decode()