Skip to content
Permalink
Browse files

driver/sigrok: support voltage and current limits as parameters

This offers some protection against accidental hardware damage cause by
incorrect client code.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information...
jluebbe committed Oct 11, 2019
1 parent 263f2e7 commit 529992f12cf68ffc369ebab5c37936840261f1ce
Showing with 20 additions and 0 deletions.
  1. +4 −0 doc/configuration.rst
  2. +16 −0 labgrid/driver/sigrokdriver.py
@@ -1517,6 +1517,10 @@ Implements:
Arguments:
- delay (float): optional delay in seconds between off and on, defaults to
3.0
- max_voltage (float): maximum allowed voltage for protection against
accidental damage (optional, in volts)
- max_current (float): maximum allowed current for protection against
accidental damage (optional, in ampere)

USBSDMuxDriver
~~~~~~~~~~~~~~
@@ -255,6 +255,16 @@ class SigrokPowerDriver(SigrokCommon, PowerResetMixin, PowerProtocol):
"sigrok": {SigrokUSBSerialDevice, NetworkSigrokUSBSerialDevice},
}
delay = attr.ib(default=3.0, validator=attr.validators.instance_of(float))
max_voltage = attr.ib(
default=None,
converter=attr.converters.optional(float),
validator=attr.validators.optional(attr.validators.instance_of(float)),
)
max_current = attr.ib(
default=None,
converter=attr.converters.optional(float),
validator=attr.validators.optional(attr.validators.instance_of(float)),
)

@Driver.check_active
@step()
@@ -280,13 +290,19 @@ def cycle(self):
@Driver.check_active
@step(args=["value"])
def set_voltage_target(self, value):
if self.max_voltage is not None and value > self.max_voltage:
raise ValueError(
"Requested voltage target({}) is higher than configured maximum ({})".format(value, self.max_voltage))
processwrapper.check_output(
self._get_sigrok_prefix() + ["--config", "voltage_target={:f}".format(value), "--set"]
)

@Driver.check_active
@step(args=["value"])
def set_current_limit(self, value):
if self.max_current is not None and value > self.max_current:
raise ValueError(
"Requested current limit ({}) is higher than configured maximum ({})".format(value, self.max_current))
processwrapper.check_output(
self._get_sigrok_prefix() + ["--config", "current_limit={:f}".format(value), "--set"]
)

0 comments on commit 529992f

Please sign in to comment.
You can’t perform that action at this time.