Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions labgrid/driver/usbsdmuxdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@ def get_mode(self):
cmd = self.mux.command_prefix + [self.tool, self.mux.control_path, "get"]
proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
return proc.stdout.strip().decode()

@Driver.check_active
@step(title="sdmux_gpio_get", args=["gpio"])
def get_gpio(self, gpio):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using the DigitalOutputProtocol here means that we can't make use of the IOs in the client and discoverability is difficult (since the function is named differently)

But the DigitalOutputProtocol requires that the index of the GPIO is set beforehand.

@Bastian-Krause @jluebbe do you have a better idea here?

if gpio not in [0, 1]:
raise ExecutionError(f"GPIO '{gpio}' not supported by USBSDMuxDriver")
cmd = self.mux.command_prefix + [self.tool, self.mux.control_path, "gpio", str(gpio), "get"]
proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
return proc.stdout.strip().decode()

@Driver.check_active
@step(title="sdmux_gpio_set", args=["gpio", "value"])
def set_gpio(self, gpio, value):
if gpio not in [0, 1]:
raise ExecutionError(f"GPIO '{gpio}' not supported by USBSDMuxDriver")
if value.lower() not in ["high", "1", "low", "0"]:
raise ExecutionError(f"GPIO value '{value}' not supported by USBSDMuxDriver")
cmd = self.mux.command_prefix + [self.tool, self.mux.control_path, "gpio", str(gpio), value.lower()]
processwrapper.check_output(cmd)