Skip to contentSkip to conversation

bindings: python: properly pass event clock settings

PATCH Applied Bartosz Golaszewski 2 participants 5 messages Jul 31, 2024 – Aug 1, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bindings: python: properly pass event clock settings

From: Benjamin Cabé <[email protected]>

Python binding was ignoring event_clock line setting.

---
 bindings/python/gpiod/ext/line-settings.c | 4 ++++
 1 file changed, 4 insertions(+)
bindings/python/gpiod/ext/line-settings.c +4 -0
index 2cacbef..650235e 100644
@@ -79,6 +79,10 @@ line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs)
 	if (ret)
 		return set_error();
 
+	ret = gpiod_line_settings_set_event_clock(self->settings, event_clock);
+	if (ret)
+		return set_error();
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 bindings: python: tests: check that event clock is property set in request

From: Bartosz Golaszewski <[email protected]>

We currently only have a test-case that checks if the event clock property is correctly set in the LineSettings object but not whether it is actually passed to the line request. Extend the existing test-case for line requests to account for event clocks as well.

---
 bindings/python/tests/tests_line_request.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
bindings/python/tests/tests_line_request.py +5 -2
index c79a324..dce5941 100644
@@ -5,7 +5,7 @@ import errno
 import gpiod
 
 from . import gpiosim
-from gpiod.line import Direction, Drive, Edge, Value
+from gpiod.line import Clock, Direction, Drive, Edge, Value
 from unittest import TestCase
 
 Pull = gpiosim.Chip.Pull
@@ -302,12 +302,15 @@ class LineRequestComplexConfig(TestCase):
                         direction=Direction.OUTPUT, output_value=Value.ACTIVE
                     ),
                     (1, 3, 5): gpiod.LineSettings(
-                        direction=Direction.INPUT, edge_detection=Edge.BOTH
+                        direction=Direction.INPUT,
+                        edge_detection=Edge.BOTH,
+                        event_clock=Clock.REALTIME,
                     ),
                 },
             ) as req:
                 self.assertEqual(chip.get_line_info(2).direction, Direction.OUTPUT)
                 self.assertEqual(chip.get_line_info(3).edge_detection, Edge.BOTH)
+                self.assertEqual(chip.get_line_info(5).event_clock, Clock.REALTIME)
 
 
 class LineRequestMixedConfigByName(TestCase):
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 15 lines · Bartosz Golaszewski

From: Benjamin Cabé <[email protected]>

Python binding was ignoring event_clock line setting.

---
 bindings/python/gpiod/ext/line-settings.c | 4 ++++
 1 file changed, 4 insertions(+)
bindings/python/gpiod/ext/line-settings.c +0 -0
index 2cacbef..650235e 100644

bindings/python/gpiod/ext/line-settings.c line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs) · line 88

Quoted 10 lines
bindings/python/gpiod/ext/line-settings.c +4 -0
@@ -79,6 +79,10 @@ line_settings_init(line_settings_object *self, PyObject *args, PyObject *kwargs)
 	if (ret)
 		return set_error();
 
+	ret = gpiod_line_settings_set_event_clock(self->settings, event_clock);
+	if (ret)
+		return set_error();
+
 	return 0;
 }
 

I'm ok with this series, but the gap this identifies in test coverage bothers me - are there any other attributes that are not round-trip tested? Debounce immediately springs to mind. Bias? Drive? Even active_low? Maybe add or extend a test case to excerise those in a separate patch?

#3 lore raw
Quoted 7 lines · Kent Gibson

I'm ok with this series, but the gap this identifies in test coverage bothers me - are there any other attributes that are not round-trip tested? Debounce immediately springs to mind. Bias? Drive? Even active_low? Maybe add or extend a test case to excerise those in a separate patch?

Yeah, it definitely needs doing. I've added it to my TODO list, though not with the highest priority I admit.

Bart

author Applied
#4 lore raw
In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Quoted 3 lines · Bartosz Golaszewski

Python binding was ignoring event_clock line setting.

Applied, thanks!

[1/2] bindings: python: properly pass event clock settings

      commit: 2f38f92ae27b1427508cf014815ad33029fa6af3
[2/2] bindings: python: tests: check that event clock is property set in request
      commit: 025693a045f82c9c6cefa6b3d91d15ed05721915

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>