Skip to content

Commit

Permalink
driver/sigrokdriver: add channel-group parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Labriet <[email protected]>
  • Loading branch information
nlabriet committed Nov 4, 2024
1 parent 0304ec6 commit d6c5973
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
14 changes: 10 additions & 4 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ specific device from all connected supported devices use the
Arguments:
- driver (str): name of the sigrok driver to use
- channels (str): optional, channel mapping as described in the sigrok-cli
man page
- channels (str): optional, channel mapping as described in the
``sigrok-cli`` man page
- channel_group (str): optional, channel group as described in the
``sigrok-cli`` man page

Used by:
- `SigrokDriver`_
Expand Down Expand Up @@ -896,8 +898,10 @@ A :any:`SigrokUSBDevice` resource describes a *Sigrok* USB device.
Arguments:
- driver (str): name of the sigrok driver to use
- channels (str): optional, channel mapping as described in the sigrok-cli
man page
- channels (str): optional, channel mapping as described in the
``sigrok-cli`` man page
- channel_group (str): optional, channel group as described in the
``sigrok-cli`` man page
- match (dict): key and value pairs for a udev match, see `udev Matching`_

Used by:
Expand Down Expand Up @@ -926,6 +930,8 @@ Arguments:
- driver (str): name of the sigrok driver to use
- channels (str): optional, channel mapping as described in the
``sigrok-cli`` man page
- channel_group (str): optional, channel group as described in the
``sigrok-cli`` man page
- match (dict): key and value pairs for a udev match, see `udev Matching`_

Used by:
Expand Down
4 changes: 4 additions & 0 deletions labgrid/driver/sigrokdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def _get_sigrok_prefix(self):
prefix += ["-d", self.sigrok.driver]
if self.sigrok.channels:
prefix += ["-C", self.sigrok.channels]
if self.sigrok.channel_group:
prefix += ["-g", self.sigrok.channel_group]
return self.sigrok.command_prefix + prefix

@Driver.check_active
Expand All @@ -109,6 +111,8 @@ def _call(self, *args):
combined = self.sigrok.command_prefix + [self.tool]
if self.sigrok.channels:
combined += ["-C", self.sigrok.channels]
if self.sigrok.channel_group:
combined += ["-g", self.sigrok.channel_group]
combined += list(args)
self.logger.debug("Combined command: %s", combined)
self._process = subprocess.Popen(
Expand Down
1 change: 1 addition & 0 deletions labgrid/remote/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def _get_params(self):
"model_id": self.local.model_id,
"driver": self.local.driver,
"channels": self.local.channels,
"channel_group": self.local.channel_group,
}


Expand Down
9 changes: 7 additions & 2 deletions labgrid/resource/sigrok.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
@target_factory.reg_resource
@attr.s(eq=False)
class SigrokDevice(Resource):
"""The SigrokDevice describes an attached sigrok device with driver and
channel mapping
"""The SigrokDevice describes an attached sigrok device with driver,
channel mapping and channel group
Args:
driver (str): driver to use with sigrok
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
"""
driver = attr.ib(default="demo")
channels = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)
channel_group = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)
11 changes: 11 additions & 0 deletions labgrid/resource/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ class SigrokUSBDevice(USBResource):
Args:
driver (str): driver to use with sigrok
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
"""
driver = attr.ib(
default=None,
Expand All @@ -406,6 +407,11 @@ class SigrokUSBDevice(USBResource):
validator=attr.validators.optional(attr.validators.instance_of(str))
)

channel_group = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)

def __attrs_post_init__(self):
self.match['@SUBSYSTEM'] = 'usb'
super().__attrs_post_init__()
Expand All @@ -421,6 +427,7 @@ class SigrokUSBSerialDevice(USBResource):
Args:
driver (str): driver to use with sigrok
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
"""
driver = attr.ib(
default=None,
Expand All @@ -430,6 +437,10 @@ class SigrokUSBSerialDevice(USBResource):
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)
channel_group = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)

def __attrs_post_init__(self):
self.match['SUBSYSTEM'] = 'tty'
Expand Down

0 comments on commit d6c5973

Please sign in to comment.