Skip to content

Commit d4d8370

Browse files
authored
Merge pull request #1536 from nlabriet/sigrok_groups
driver/sigrokdriver: add channel group parameter
2 parents 9923f40 + d6c5973 commit d4d8370

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

doc/configuration.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,10 @@ specific device from all connected supported devices use the
655655
656656
Arguments:
657657
- driver (str): name of the sigrok driver to use
658-
- channels (str): optional, channel mapping as described in the sigrok-cli
659-
man page
658+
- channels (str): optional, channel mapping as described in the
659+
``sigrok-cli`` man page
660+
- channel_group (str): optional, channel group as described in the
661+
``sigrok-cli`` man page
660662

661663
Used by:
662664
- `SigrokDriver`_
@@ -896,8 +898,10 @@ A :any:`SigrokUSBDevice` resource describes a *Sigrok* USB device.
896898
897899
Arguments:
898900
- driver (str): name of the sigrok driver to use
899-
- channels (str): optional, channel mapping as described in the sigrok-cli
900-
man page
901+
- channels (str): optional, channel mapping as described in the
902+
``sigrok-cli`` man page
903+
- channel_group (str): optional, channel group as described in the
904+
``sigrok-cli`` man page
901905
- match (dict): key and value pairs for a udev match, see `udev Matching`_
902906

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

931937
Used by:

labgrid/driver/sigrokdriver.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def _get_sigrok_prefix(self):
8989
prefix += ["-d", self.sigrok.driver]
9090
if self.sigrok.channels:
9191
prefix += ["-C", self.sigrok.channels]
92+
if self.sigrok.channel_group:
93+
prefix += ["-g", self.sigrok.channel_group]
9294
return self.sigrok.command_prefix + prefix
9395

9496
@Driver.check_active
@@ -109,6 +111,8 @@ def _call(self, *args):
109111
combined = self.sigrok.command_prefix + [self.tool]
110112
if self.sigrok.channels:
111113
combined += ["-C", self.sigrok.channels]
114+
if self.sigrok.channel_group:
115+
combined += ["-g", self.sigrok.channel_group]
112116
combined += list(args)
113117
self.logger.debug("Combined command: %s", combined)
114118
self._process = subprocess.Popen(

labgrid/remote/exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def _get_params(self):
373373
"model_id": self.local.model_id,
374374
"driver": self.local.driver,
375375
"channels": self.local.channels,
376+
"channel_group": self.local.channel_group,
376377
}
377378

378379

labgrid/resource/sigrok.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
@target_factory.reg_resource
77
@attr.s(eq=False)
88
class SigrokDevice(Resource):
9-
"""The SigrokDevice describes an attached sigrok device with driver and
10-
channel mapping
9+
"""The SigrokDevice describes an attached sigrok device with driver,
10+
channel mapping and channel group
1111
1212
Args:
1313
driver (str): driver to use with sigrok
1414
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
15+
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
1516
"""
1617
driver = attr.ib(default="demo")
1718
channels = attr.ib(
1819
default=None,
1920
validator=attr.validators.optional(attr.validators.instance_of(str))
2021
)
22+
channel_group = attr.ib(
23+
default=None,
24+
validator=attr.validators.optional(attr.validators.instance_of(str))
25+
)

labgrid/resource/udev.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class SigrokUSBDevice(USBResource):
396396
Args:
397397
driver (str): driver to use with sigrok
398398
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
399+
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
399400
"""
400401
driver = attr.ib(
401402
default=None,
@@ -406,6 +407,11 @@ class SigrokUSBDevice(USBResource):
406407
validator=attr.validators.optional(attr.validators.instance_of(str))
407408
)
408409

410+
channel_group = attr.ib(
411+
default=None,
412+
validator=attr.validators.optional(attr.validators.instance_of(str))
413+
)
414+
409415
def __attrs_post_init__(self):
410416
self.match['@SUBSYSTEM'] = 'usb'
411417
super().__attrs_post_init__()
@@ -421,6 +427,7 @@ class SigrokUSBSerialDevice(USBResource):
421427
Args:
422428
driver (str): driver to use with sigrok
423429
channels (str): a sigrok channel mapping as described in the sigrok-cli man page
430+
channel_group (str): a sigrok channel group as described in the sigrok-cli man page
424431
"""
425432
driver = attr.ib(
426433
default=None,
@@ -430,6 +437,10 @@ class SigrokUSBSerialDevice(USBResource):
430437
default=None,
431438
validator=attr.validators.optional(attr.validators.instance_of(str))
432439
)
440+
channel_group = attr.ib(
441+
default=None,
442+
validator=attr.validators.optional(attr.validators.instance_of(str))
443+
)
433444

434445
def __attrs_post_init__(self):
435446
self.match['SUBSYSTEM'] = 'tty'

0 commit comments

Comments
 (0)