treewide: use plural 'events' in read_edge_event() functions
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 30 Nov 2022 12:42:23 +0000 (13:42 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 7 Dec 2022 08:51:57 +0000 (09:51 +0100)
The read_edge_event() family of functions should actually be called
read_edge_events() as they universally allow to read more than one
event. We're converting wait_edge_event() too for consistency.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
19 files changed:
bindings/cxx/edge-event-buffer.cpp
bindings/cxx/examples/gpiomoncxx.cpp
bindings/cxx/gpiodcxx/line-request.hpp
bindings/cxx/line-request.cpp
bindings/cxx/tests/tests-edge-event.cpp
bindings/python/examples/gpiomon.py
bindings/python/gpiod/ext/request.c
bindings/python/gpiod/line_request.py
bindings/python/tests/tests_edge_event.py
bindings/rust/libgpiod/examples/gpio_events.rs
bindings/rust/libgpiod/examples/gpiomon.rs
bindings/rust/libgpiod/src/event_buffer.rs
bindings/rust/libgpiod/src/line_request.rs
bindings/rust/libgpiod/tests/edge_event.rs
bindings/rust/libgpiod/tests/line_request.rs
include/gpiod.h
lib/line-request.c
tests/tests-edge-event.c
tools/gpiomon.c

index ff398f16b70224c5e7be5dd428c1cc21ebd1f80d..3c551dfdc86f05abaf211727f241f9a1e1c0a774 100644 (file)
@@ -36,7 +36,7 @@ edge_event_buffer::impl::impl(unsigned int capacity)
 
 int edge_event_buffer::impl::read_events(const line_request_ptr& request, unsigned int max_events)
 {
-       int ret = ::gpiod_line_request_read_edge_event(request.get(),
+       int ret = ::gpiod_line_request_read_edge_events(request.get(),
                                                       this->buffer.get(), max_events);
        if (ret < 0)
                throw_from_errno("error reading edge events from file descriptor");
index c351567733ca0e093181815c5197c48cd80a43f3..4f765badef9651759b570afe1a05c759d8f9a18c 100644 (file)
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
        ::gpiod::edge_event_buffer buffer;
 
        for (;;) {
-               request.read_edge_event(buffer);
+               request.read_edge_events(buffer);
 
                for (const auto& event: buffer)
                        print_event(event);
index 659251bd09b59c477846d3dfed14fce8df3ec01b..f9f0322de9cfe422097916618eff58a4df657c3c 100644 (file)
@@ -180,7 +180,7 @@ public:
         * @return True if at least one event is ready to be read. False if the
         *         wait timed out.
         */
-       bool wait_edge_event(const ::std::chrono::nanoseconds& timeout) const;
+       bool wait_edge_events(const ::std::chrono::nanoseconds& timeout) const;
 
        /**
         * @brief Read a number of edge events from this request up to the
@@ -188,7 +188,7 @@ public:
         * @param buffer Edge event buffer to read events into.
         * @return Number of events read.
         */
-       ::std::size_t read_edge_event(edge_event_buffer& buffer);
+       ::std::size_t read_edge_events(edge_event_buffer& buffer);
 
        /**
         * @brief Read a number of edge events from this request.
@@ -197,7 +197,7 @@ public:
         *                   capacity of the buffer.
         * @return Number of events read.
         */
-       ::std::size_t read_edge_event(edge_event_buffer& buffer, ::std::size_t max_events);
+       ::std::size_t read_edge_events(edge_event_buffer& buffer, ::std::size_t max_events);
 
 private:
 
index be0bac5a191dfa2d095a85f689ab0a1c4c28e4a3..34c585096867d281abb0de38e9810158298e20ee 100644 (file)
@@ -192,11 +192,11 @@ GPIOD_CXX_API int line_request::fd() const
        return ::gpiod_line_request_get_fd(this->_m_priv->request.get());
 }
 
-GPIOD_CXX_API bool line_request::wait_edge_event(const ::std::chrono::nanoseconds& timeout) const
+GPIOD_CXX_API bool line_request::wait_edge_events(const ::std::chrono::nanoseconds& timeout) const
 {
        this->_m_priv->throw_if_released();
 
-       int ret = ::gpiod_line_request_wait_edge_event(this->_m_priv->request.get(),
+       int ret = ::gpiod_line_request_wait_edge_events(this->_m_priv->request.get(),
                                                       timeout.count());
        if (ret < 0)
                throw_from_errno("error waiting for edge events");
@@ -204,13 +204,13 @@ GPIOD_CXX_API bool line_request::wait_edge_event(const ::std::chrono::nanosecond
        return ret;
 }
 
-GPIOD_CXX_API ::std::size_t line_request::read_edge_event(edge_event_buffer& buffer)
+GPIOD_CXX_API ::std::size_t line_request::read_edge_events(edge_event_buffer& buffer)
 {
-       return this->read_edge_event(buffer, buffer.capacity());
+       return this->read_edge_events(buffer, buffer.capacity());
 }
 
 GPIOD_CXX_API ::std::size_t
-line_request::read_edge_event(edge_event_buffer& buffer, ::std::size_t max_events)
+line_request::read_edge_events(edge_event_buffer& buffer, ::std::size_t max_events)
 {
        this->_m_priv->throw_if_released();
 
index ca42c42b479675df7e256e1c57f5434074903f1d..19a6ab3bdcddf7cbc61b80755ce5e0461648f4e0 100644 (file)
@@ -51,7 +51,7 @@ TEST_CASE("edge_event wait timeout", "[edge-event]")
                )
                .do_request();
 
-       REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+       REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 }
 
 TEST_CASE("output mode and edge detection don't work together", "[edge-event]")
@@ -113,23 +113,23 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
                ::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 2);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                auto event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::RISING_EDGE);
                REQUIRE(event.line_offset() == 2);
                ts_rising = event.timestamp_ns();
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::FALLING_EDGE);
                REQUIRE(event.line_offset() == 2);
                ts_falling = event.timestamp_ns();
 
-               REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+               REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
                thread.join();
 
@@ -149,14 +149,14 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
                ::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 6);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                auto event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::RISING_EDGE);
                REQUIRE(event.line_offset() == 6);
 
-               REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+               REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
                thread.join();
        }
@@ -174,14 +174,14 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
                ::std::thread thread(trigger_falling_and_rising_edge, ::std::ref(sim), 7);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                auto event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::FALLING_EDGE);
                REQUIRE(event.line_offset() == 7);
 
-               REQUIRE_FALSE(request.wait_edge_event(::std::chrono::milliseconds(100)));
+               REQUIRE_FALSE(request.wait_edge_events(::std::chrono::milliseconds(100)));
 
                thread.join();
        }
@@ -199,8 +199,8 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
 
                ::std::thread thread(trigger_rising_edge_events_on_two_offsets, ::std::ref(sim), 0, 1);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                auto event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::RISING_EDGE);
@@ -208,8 +208,8 @@ TEST_CASE("waiting for and reading edge events works", "[edge-event]")
                REQUIRE(event.global_seqno() == 1);
                REQUIRE(event.line_seqno() == 1);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer, 1) == 1);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer, 1) == 1);
                REQUIRE(buffer.num_events() == 1);
                event = buffer.get_event(0);
                REQUIRE(event.type() == event_type::RISING_EDGE);
@@ -251,8 +251,8 @@ TEST_CASE("reading multiple events", "[edge-event]")
        {
                ::gpiod::edge_event_buffer buffer;
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer) == 3);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer) == 3);
                REQUIRE(buffer.num_events() == 3);
 
                for (const auto& event: buffer) {
@@ -266,8 +266,8 @@ TEST_CASE("reading multiple events", "[edge-event]")
        {
                ::gpiod::edge_event_buffer buffer(2);
 
-               REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-               REQUIRE(request.read_edge_event(buffer) == 2);
+               REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+               REQUIRE(request.read_edge_events(buffer) == 2);
                REQUIRE(buffer.num_events() == 2);
        }
 }
@@ -300,8 +300,8 @@ TEST_CASE("edge_event_buffer can be moved", "[edge-event]")
 
        ::std::this_thread::sleep_for(::std::chrono::milliseconds(500));
 
-       REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-       REQUIRE(request.read_edge_event(buffer) == 3);
+       REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+       REQUIRE(request.read_edge_events(buffer) == 3);
 
        SECTION("move constructor works")
        {
@@ -337,14 +337,14 @@ TEST_CASE("edge_event can be copied and moved", "[edge-event]")
 
        sim.set_pull(0, pull::PULL_UP);
        ::std::this_thread::sleep_for(::std::chrono::milliseconds(10));
-       REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-       REQUIRE(request.read_edge_event(buffer) == 1);
+       REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+       REQUIRE(request.read_edge_events(buffer) == 1);
        auto event = buffer.get_event(0);
 
        sim.set_pull(0, pull::PULL_DOWN);
        ::std::this_thread::sleep_for(::std::chrono::milliseconds(10));
-       REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-       REQUIRE(request.read_edge_event(buffer) == 1);
+       REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+       REQUIRE(request.read_edge_events(buffer) == 1);
        auto copy = buffer.get_event(0);
 
        SECTION("copy constructor works")
@@ -406,8 +406,8 @@ TEST_CASE("stream insertion operators work for edge_event and edge_event_buffer"
        sim.set_pull(0, pull::PULL_DOWN);
        ::std::this_thread::sleep_for(::std::chrono::milliseconds(30));
 
-       REQUIRE(request.wait_edge_event(::std::chrono::seconds(1)));
-       REQUIRE(request.read_edge_event(buffer) == 2);
+       REQUIRE(request.wait_edge_events(::std::chrono::seconds(1)));
+       REQUIRE(request.read_edge_events(buffer) == 2);
 
        sbuf << buffer;
 
index 58d47a58cf4873a1040d527f7268c65c5c5a4d57..702d7c83887f6c89c50a8f38a7753149e89c494e 100755 (executable)
@@ -22,5 +22,5 @@ if __name__ == "__main__":
         config={tuple(lines): gpiod.LineSettings(edge_detection=Edge.BOTH)},
     ) as request:
         while True:
-            for event in request.read_edge_event():
+            for event in request.read_edge_events():
                 print(event)
index 62378f5558604eb5a9aca122e1269d5dc51eac5e..d3e144800a637a3f4751c6b5d94b4761d7fa4eae 100644 (file)
@@ -249,7 +249,7 @@ static PyObject *request_reconfigure_lines(request_object *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *request_read_edge_event(request_object *self, PyObject *args)
+static PyObject *request_read_edge_events(request_object *self, PyObject *args)
 {
        PyObject *max_events_obj, *event_obj, *events, *type;
        size_t max_events, num_events, i;
@@ -273,7 +273,7 @@ static PyObject *request_read_edge_event(request_object *self, PyObject *args)
                return NULL;
 
        Py_BEGIN_ALLOW_THREADS;
-       ret = gpiod_line_request_read_edge_event(self->request,
+       ret = gpiod_line_request_read_edge_events(self->request,
                                                 self->buffer, max_events);
        Py_END_ALLOW_THREADS;
        if (ret < 0)
@@ -336,8 +336,8 @@ static PyMethodDef request_methods[] = {
                .ml_flags = METH_VARARGS,
        },
        {
-               .ml_name = "read_edge_event",
-               .ml_meth = (PyCFunction)request_read_edge_event,
+               .ml_name = "read_edge_events",
+               .ml_meth = (PyCFunction)request_read_edge_events,
                .ml_flags = METH_VARARGS,
        },
        { }
index 1796069ec2fc920ce38c664140a70224bbfde1da..a0f97b73903953887f01c433af83ac06d05e9636 100644 (file)
@@ -169,7 +169,7 @@ class LineRequest:
 
         self._req.reconfigure_lines(line_cfg)
 
-    def wait_edge_event(
+    def wait_edge_events(
         self, timeout: Optional[Union[timedelta, float]] = None
     ) -> bool:
         """
@@ -187,7 +187,7 @@ class LineRequest:
 
         return poll_fd(self.fd, timeout)
 
-    def read_edge_event(self, max_events: Optional[int] = None) -> list[EdgeEvent]:
+    def read_edge_events(self, max_events: Optional[int] = None) -> list[EdgeEvent]:
         """
         Read a number of edge events from a line request.
 
@@ -200,7 +200,7 @@ class LineRequest:
         """
         self._check_released()
 
-        return self._req.read_edge_event(max_events)
+        return self._req.read_edge_events(max_events)
 
     def __str__(self):
         """
index c443772553bb4b1e7ed476c11f9524ff0b3d8086..430b27de733036cbf11e1ec46bcc6a05ecf28433 100644 (file)
@@ -23,7 +23,7 @@ class EdgeEventWaitTimeout(TestCase):
             sim.dev_path,
             {0: gpiod.LineSettings(edge_detection=Edge.BOTH)},
         ) as req:
-            self.assertEqual(req.wait_edge_event(timedelta(microseconds=10000)), False)
+            self.assertEqual(req.wait_edge_events(timedelta(microseconds=10000)), False)
 
     def test_event_wait_timeout_float(self):
         sim = gpiosim.Chip()
@@ -32,7 +32,7 @@ class EdgeEventWaitTimeout(TestCase):
             sim.dev_path,
             {0: gpiod.LineSettings(edge_detection=Edge.BOTH)},
         ) as req:
-            self.assertEqual(req.wait_edge_event(0.01), False)
+            self.assertEqual(req.wait_edge_events(0.01), False)
 
 
 class EdgeEventInvalidConfig(TestCase):
@@ -82,16 +82,16 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 2)
             ts_rising = event.timestamp_ns
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.FALLING_EDGE)
@@ -109,14 +109,14 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
-            self.assertFalse(req.wait_edge_event(timedelta(microseconds=10000)))
+            self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
 
     def test_rising_edge_event(self):
         with gpiod.request_lines(
@@ -127,14 +127,14 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.FALLING_EDGE)
             self.assertEqual(event.line_offset, 6)
 
-            self.assertFalse(req.wait_edge_event(timedelta(microseconds=10000)))
+            self.assertFalse(req.wait_edge_events(timedelta(microseconds=10000)))
 
     def test_sequence_numbers(self):
         with gpiod.request_lines(
@@ -145,8 +145,8 @@ class WaitingForEdgeEvents(TestCase):
             )
             self.thread.start()
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
@@ -154,8 +154,8 @@ class WaitingForEdgeEvents(TestCase):
             self.assertEqual(event.global_seqno, 1)
             self.assertEqual(event.line_seqno, 1)
 
-            self.assertTrue(req.wait_edge_event(timedelta(seconds=1)))
-            events = req.read_edge_event()
+            self.assertTrue(req.wait_edge_events(timedelta(seconds=1)))
+            events = req.read_edge_events()
             self.assertEqual(len(events), 1)
             event = events[0]
             self.assertEqual(event.event_type, EventType.RISING_EDGE)
@@ -185,8 +185,8 @@ class ReadingMultipleEdgeEvents(TestCase):
         del self.sim
 
     def test_read_multiple_events(self):
-        self.assertTrue(self.request.wait_edge_event(timedelta(seconds=1)))
-        events = self.request.read_edge_event()
+        self.assertTrue(self.request.wait_edge_events(timedelta(seconds=1)))
+        events = self.request.read_edge_events()
         self.assertEqual(len(events), 3)
 
         for event in events:
@@ -205,7 +205,7 @@ class EdgeEventStringRepresentation(TestCase):
             path=sim.dev_path, config={0: gpiod.LineSettings(edge_detection=Edge.BOTH)}
         ) as req:
             sim.set_pull(0, Pull.UP)
-            event = req.read_edge_event()[0]
+            event = req.read_edge_events()[0]
             self.assertRegex(
                 str(event),
                 "<EdgeEvent type=Type\.RISING_EDGE timestamp_ns=[0-9]+ line_offset=0 global_seqno=1 line_seqno=1>",
index 981005043d55b8d4c2bfaaa885f8a1b707286bf3..04267d9d39c7b2370eb7579fa87d5683fdaacc48 100644 (file)
@@ -45,7 +45,7 @@ fn main() -> Result<()> {
     let request = chip.request_lines(&rconfig, &lconfig)?;
 
     loop {
-        match request.wait_edge_event(None) {
+        match request.wait_edge_events(None) {
             Err(x) => {
                 println!("{:?}", x);
                 return Err(Error::InvalidArguments);
index c38652c1deff5b11cd97cd4869844ed1d54a2230..f17a81f3c23d487a453a96e670586b3ff9ea4137 100644 (file)
@@ -44,7 +44,7 @@ fn main() -> Result<()> {
     let request = chip.request_lines(&rconfig, &lconfig)?;
 
     loop {
-        match request.wait_edge_event(None) {
+        match request.wait_edge_events(None) {
             Err(x) => {
                 println!("{:?}", x);
                 return Err(Error::InvalidArguments);
index b56be9a27dc0e6d4e305022945e90bf339266f26..5a72ddb197ace1357e6ebf128012cd2d051a8d5a 100644 (file)
@@ -106,7 +106,7 @@ impl Buffer {
 
         // SAFETY: `gpiod_line_request` is guaranteed to be valid here.
         let ret = unsafe {
-            gpiod::gpiod_line_request_read_edge_event(
+            gpiod::gpiod_line_request_read_edge_events(
                 request.request,
                 self.buffer,
                 self.events.len().try_into().unwrap(),
index 3215ab816434a359a77084309c33ce63c0d4ca88..c16ec9fb7dbffcba3d5ef8f4d1b3f75c97f2a68c 100644 (file)
@@ -178,7 +178,7 @@ impl Request {
     }
 
     /// Wait for edge events on any of the lines associated with the request.
-    pub fn wait_edge_event(&self, timeout: Option<Duration>) -> Result<bool> {
+    pub fn wait_edge_events(&self, timeout: Option<Duration>) -> Result<bool> {
         let timeout = match timeout {
             Some(x) => x.as_nanos() as i64,
             // Block indefinitely
@@ -186,7 +186,7 @@ impl Request {
         };
 
         // SAFETY: `gpiod_line_request` is guaranteed to be valid here.
-        let ret = unsafe { gpiod::gpiod_line_request_wait_edge_event(self.request, timeout) };
+        let ret = unsafe { gpiod::gpiod_line_request_wait_edge_events(self.request, timeout) };
 
         match ret {
             -1 => Err(Error::OperationFailed(
index 571e574fa15ec2a75d37dc6414bc9d5a5fb3d136..45c1cfc0902292f4a3bef05c934e514d71faf550 100644 (file)
@@ -89,7 +89,7 @@ mod edge_event {
             // Rising event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -103,7 +103,7 @@ mod edge_event {
             // Falling event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -117,7 +117,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
 
             assert!(ts_falling > ts_rising);
@@ -138,7 +138,7 @@ mod edge_event {
             // Rising event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -151,7 +151,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -170,7 +170,7 @@ mod edge_event {
             // Falling event
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -183,7 +183,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -202,7 +202,7 @@ mod edge_event {
             let mut buf = request::Buffer::new(0).unwrap();
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -217,7 +217,7 @@ mod edge_event {
             // Rising event GPIO 1
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let mut events = config.request().read_edge_events(&mut buf).unwrap();
@@ -232,7 +232,7 @@ mod edge_event {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
 
@@ -251,7 +251,7 @@ mod edge_event {
             // Read multiple events
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let events = config.request().read_edge_events(&mut buf).unwrap();
@@ -287,7 +287,7 @@ mod edge_event {
             // Read multiple events
             assert!(config
                 .request()
-                .wait_edge_event(Some(Duration::from_secs(1)))
+                .wait_edge_events(Some(Duration::from_secs(1)))
                 .unwrap());
 
             let events = config.request().read_edge_events(&mut buf).unwrap();
index 286cd6ca67229d95ac8a8391e526c3ec21e4fe31..c3fc37b36b644a0097912d89f57ce51df541710c 100644 (file)
@@ -231,7 +231,7 @@ mod line_request {
             // No events available
             assert!(!config
                 .request()
-                .wait_edge_event(Some(Duration::from_millis(100)))
+                .wait_edge_events(Some(Duration::from_millis(100)))
                 .unwrap());
         }
     }
index f4bb5f20c646ab0ffddf0a627b6e8ac5ec7fbafc..fc9d4c0e3fe8adcb48c4c141a4a75e4e60f0f344 100644 (file)
@@ -1008,8 +1008,8 @@ int gpiod_line_request_get_fd(struct gpiod_line_request *request);
  * Lines must have edge detection set for edge events to be emitted.
  * By default edge detection is disabled.
  */
-int gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
-                                      int64_t timeout_ns);
+int gpiod_line_request_wait_edge_events(struct gpiod_line_request *request,
+                                       int64_t timeout_ns);
 
 /**
  * @brief Read a number of edge events from a line request.
@@ -1022,9 +1022,9 @@ int gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
  * @note Any exising events in the buffer are overwritten.  This is not an
  *       append operation.
  */
-int gpiod_line_request_read_edge_event(struct gpiod_line_request *request,
-                                      struct gpiod_edge_event_buffer *buffer,
-                                      size_t max_events);
+int gpiod_line_request_read_edge_events(struct gpiod_line_request *request,
+                                       struct gpiod_edge_event_buffer *buffer,
+                                       size_t max_events);
 
 /**
  * @}
index 5936593cda1e8a41f0699a6bb947e15aee1cbb4c..58dc3c98de5a711f11ed16faa05a274baf34e8d2 100644 (file)
@@ -223,16 +223,16 @@ GPIOD_API int gpiod_line_request_get_fd(struct gpiod_line_request *request)
 }
 
 GPIOD_API int
-gpiod_line_request_wait_edge_event(struct gpiod_line_request *request,
-                                  int64_t timeout_ns)
+gpiod_line_request_wait_edge_events(struct gpiod_line_request *request,
+                                   int64_t timeout_ns)
 {
        return gpiod_poll_fd(request->fd, timeout_ns);
 }
 
 GPIOD_API int
-gpiod_line_request_read_edge_event(struct gpiod_line_request *request,
-                                  struct gpiod_edge_event_buffer *buffer,
-                                  size_t max_events)
+gpiod_line_request_read_edge_events(struct gpiod_line_request *request,
+                                   struct gpiod_edge_event_buffer *buffer,
+                                   size_t max_events)
 {
        return gpiod_edge_event_buffer_read_fd(request->fd, buffer, max_events);
 }
index dad6af4c65d070527c2f74e2dc09d421f8a97c18..237c007dc65f28409225b50917dc2b8d4ff420d1 100644 (file)
@@ -51,7 +51,7 @@ GPIOD_TEST_CASE(edge_event_wait_timeout)
 
        request = gpiod_test_request_lines_or_fail(chip, NULL, line_cfg);
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000);
        g_assert_cmpint(ret, ==, 0);
 }
 
@@ -130,11 +130,11 @@ GPIOD_TEST_CASE(read_both_events)
 
        /* First event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -150,11 +150,11 @@ GPIOD_TEST_CASE(read_both_events)
 
        /* Second event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -207,11 +207,11 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 
        /* First event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -226,7 +226,7 @@ GPIOD_TEST_CASE(read_rising_edge_event)
 
        /* Second event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000);
        g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
        g_thread_join(thread);
@@ -266,11 +266,11 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 
        /* First event is the second generated. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -285,7 +285,7 @@ GPIOD_TEST_CASE(read_falling_edge_event)
 
        /* No more events. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000);
        g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
        g_thread_join(thread);
@@ -340,7 +340,7 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -355,7 +355,7 @@ GPIOD_TEST_CASE(read_rising_edge_event_polled)
 
        /* Second event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000);
        g_assert_cmpint(ret, ==, 0); /* Time-out. */
 
        g_thread_join(thread);
@@ -399,7 +399,7 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 
        /* First event. */
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -414,7 +414,7 @@ GPIOD_TEST_CASE(read_both_events_blocking)
 
        /* Second event. */
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -478,11 +478,11 @@ GPIOD_TEST_CASE(seqno)
 
        /* First event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -497,11 +497,11 @@ GPIOD_TEST_CASE(seqno)
 
        /* Second event. */
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_join_thread_and_return_if_failed(thread);
 
@@ -547,11 +547,11 @@ GPIOD_TEST_CASE(event_copy)
 
        g_gpiosim_chip_set_pull(sim, 2, G_GPIOSIM_PULL_UP);
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000000000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000000000);
        g_assert_cmpint(ret, >, 0);
        gpiod_test_return_if_failed();
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 1);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 1);
        g_assert_cmpint(ret, ==, 1);
        gpiod_test_return_if_failed();
 
@@ -605,11 +605,11 @@ GPIOD_TEST_CASE(reading_more_events_than_the_queue_contains_doesnt_block)
        g_gpiosim_chip_set_pull(sim, 2, G_GPIOSIM_PULL_UP);
        g_usleep(500);
 
-       ret = gpiod_line_request_read_edge_event(request, buffer, 12);
+       ret = gpiod_line_request_read_edge_events(request, buffer, 12);
        g_assert_cmpint(ret, ==, 7);
        gpiod_test_return_if_failed();
 
-       ret = gpiod_line_request_wait_edge_event(request, 1000);
+       ret = gpiod_line_request_wait_edge_events(request, 1000);
        g_assert_cmpint(ret, ==, 0);
        gpiod_test_return_if_failed();
 }
index ba457e4e0d18f3b05d893c6e1d0f06db428d1f1a..0bc057ad791ed7235db634f555057b3a7e4ac3e7 100644 (file)
@@ -451,7 +451,7 @@ int main(int argc, char **argv)
                        if (pollfds[i].revents == 0)
                                continue;
 
-                       ret = gpiod_line_request_read_edge_event(requests[i],
+                       ret = gpiod_line_request_read_edge_events(requests[i],
                                         event_buffer, EVENT_BUF_SIZE);
                        if (ret < 0)
                                die_perror("error reading line events");