Function gpiocdev::find_named_line

source ·
pub fn find_named_line(name: &str) -> Option<FoundLine>
Expand description

Find the chip hosting a named line, and the line offset on that chip.

Stops at the first matching line, if one can be found.

Returns the path of the chip containing the line, and the offset of the line on that chip.

If checking that the line name is unique is required then use find_named_lines with the strict option.

If multiple lines are required then find_named_lines is more performant.

§Examples

The found line can be used to request the line:

let led0 = gpiocdev::find_named_line("LED0").unwrap();
let req = gpiocdev::Request::builder()
    .with_found_line(&led0)
    .as_output(Value::Active)
    .request()?;

Using the chip and offset from the found line to request the line:

let led0 = gpiocdev::find_named_line("LED0").unwrap();
let req = gpiocdev::Request::builder()
    .on_chip(&led0.chip)
    .with_line(led0.info.offset)
    .as_output(Value::Active)
    .request()?;