Skip to content

Commit 528312a

Browse files
committed
SysfsGpio: add active_low attribute to the SysfsGPIO resources
The resources SysfsGPIO, NetworkSysfsGPIO and MatchedSysfsGPIO have been modified to have an additional optional 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 853cc09 commit 528312a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

labgrid/resource/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ 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+
active_low (bool) : set to True if active_low should be used. Default False"""
4647
index = attr.ib(default=None, validator=attr.validators.instance_of(int))
48+
active_low = attr.ib(default=False,
49+
validator=attr.validators.instance_of(bool))

labgrid/resource/remote.py

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

333333
"""The NetworkSysfsGPIO describes a remotely accessible gpio line"""
334+
334335
index = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(int)))
336+
active_low = attr.ib(default=False, validator=attr.validators.instance_of(bool))
335337
def __attrs_post_init__(self):
336338
self.timeout = 10.0
337339
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+
active_low (bool): set to True if active_low should be used. Default False"""
762763
pin = attr.ib(default=None, validator=attr.validators.instance_of(int))
764+
active_low = 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)