Here is what happens at each call for easier understanding:
On 27-09-22, 17:25, Bartosz Golaszewski wrote:
So what happens if I do this:
let buf = edge::event::Buffer::new(10)?;
buf1 = gpiod_edge_event_buffer_new()
let request = chip.request_lines(&rconfig, &lconfig)?;
gpiod_chip_request_lines()
let count = request.read_edge_events(&buffer)?;
gpiod_line_request_read_edge_event(buf1)
let event = buffer.event(0);
event1 = gpiod_edge_event_buffer_get_event(buf1, 0)
let count = request.read_edge_events(&buffer)?;
gpiod_line_request_read_edge_event(buf1)
println!("line: {}", event.line_offset());
gpiod_edge_event_get_line_offset(event1)
We will allocate a single buffer (buf1) and the event (event1) will be a reference onto its first event entry in the buffer. It will print offset value from the second read_edge_events() here instead of first, as it was just a reference to the first event. And for such a use case, the user should do
event = buffer.event(0).event_clone();