Re: [PATCH V6 3/8] libgpiod: Add rust wrapper crate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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();

-- 
viresh



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux