Skip to content

Commit 110e7f5

Browse files
committed
SysfsGpio: add invert attribute (active-low) to the SysfsGPIO resources
The resources SysfsGPIO, NetworkSysfsGPIO and MatchedSysfsGPIO have been modified to have an additional optional invert (active-low) attribute (default False) which can be used to invert the logical value used on the gpio line. Signed-off-by: Perry Melange <[email protected]>
1 parent 0d570b3 commit 110e7f5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

labgrid/resource/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ class SysfsGPIO(Resource):
4242
"""The basic SysfsGPIO contains an index
4343
4444
Args:
45-
index (int): index of target gpio line."""
45+
index (int): index of target gpio line.
46+
invert (bool) : optional, whether the logic level is inverted (active-low)"""
4647
index = attr.ib(default=None, validator=attr.validators.instance_of(int))
48+
invert = attr.ib(default=False, validator=attr.validators.instance_of(bool))

labgrid/resource/remote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ class NetworkSysfsGPIO(NetworkResource, ManagedResource):
339339
manager_cls = RemotePlaceManager
340340

341341
"""The NetworkSysfsGPIO describes a remotely accessible gpio line"""
342+
342343
index = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(int)))
344+
invert = attr.ib(default=False, validator=attr.validators.instance_of(bool))
343345
def __attrs_post_init__(self):
344346
self.timeout = 10.0
345347
super().__attrs_post_init__()

labgrid/resource/udev.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,10 @@ class MatchedSysfsGPIO(USBResource):
758758
"""The MatchedSysfsGPIO described a SysfsGPIO matched by Udev
759759
760760
Args:
761-
pin (int): gpio pin number within the matched gpiochip."""
761+
pin (int): gpio pin number within the matched gpiochip.
762+
invert (bool): optional, whether the logic level is inverted (active-low)"""
762763
pin = attr.ib(default=None, validator=attr.validators.instance_of(int))
764+
invert = attr.ib(default=False, validator=attr.validators.instance_of(bool))
763765
index = None
764766

765767
def __attrs_post_init__(self):

0 commit comments

Comments
 (0)