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");
::gpiod::edge_event_buffer buffer;
for (;;) {
- request.read_edge_event(buffer);
+ request.read_edge_events(buffer);
for (const auto& event: buffer)
print_event(event);
* @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
* @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.
* 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:
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");
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();
)
.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]")
::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();
::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();
}
::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();
}
::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);
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);
{
::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) {
{
::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);
}
}
::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")
{
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")
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;
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)
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;
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)
.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,
},
{ }
self._req.reconfigure_lines(line_cfg)
- def wait_edge_event(
+ def wait_edge_events(
self, timeout: Optional[Union[timedelta, float]] = None
) -> bool:
"""
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.
"""
self._check_released()
- return self._req.read_edge_event(max_events)
+ return self._req.read_edge_events(max_events)
def __str__(self):
"""
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()
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):
)
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)
)
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(
)
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(
)
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.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)
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:
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>",
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);
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);
// 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(),
}
/// 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
};
// 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(
// 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();
// 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();
// 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);
// 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();
// No events available
assert!(!config
.request()
- .wait_edge_event(Some(Duration::from_millis(100)))
+ .wait_edge_events(Some(Duration::from_millis(100)))
.unwrap());
}
// 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();
// No events available
assert!(!config
.request()
- .wait_edge_event(Some(Duration::from_millis(100)))
+ .wait_edge_events(Some(Duration::from_millis(100)))
.unwrap());
}
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();
// 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();
// No events available
assert!(!config
.request()
- .wait_edge_event(Some(Duration::from_millis(100)))
+ .wait_edge_events(Some(Duration::from_millis(100)))
.unwrap());
}
// 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();
// 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();
// No events available
assert!(!config
.request()
- .wait_edge_event(Some(Duration::from_millis(100)))
+ .wait_edge_events(Some(Duration::from_millis(100)))
.unwrap());
}
}
* 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.
* @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);
/**
* @}
}
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);
}
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);
}
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
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);
/* 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);
/* 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);
/* 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);
/* 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);
/* 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);
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();
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();
}
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");