pub fn find_named_lines<'a>(
    names: &'a [&'a str],
    strict: bool
) -> Result<HashMap<&'a str, FoundLine>>
Expand description

Find a collection of named lines.

  • strict: if true then the names are checked to be unique within the available lines

For each name, returns the first matching line, if one can be found. If it cannot be found then there will be no matching entry in the returned map.

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

Examples

Adding the found lines to the request directly:

let sensors = gpiocdev::find_named_lines(&["SENSOR0", "SENSOR1"], true)?;
let req = Request::builder()
    .with_found_lines(&sensors)
    .as_input()
    .request()?;
let sensor1 = sensors.get("SENSOR1").unwrap();
let value = req.value(sensor1.offset)?;

Using the individual found lines to request the lines with different configuration for each line:

let lines = gpiocdev::find_named_lines(&["SENSOR0", "LED0"], true)?;
let sensor0 = lines.get("SENSOR0").unwrap();
let led0 = lines.get("LED0").unwrap();
let req = Request::builder()
    .with_found_line(&sensor0)
    .as_input()
    .with_found_line(&led0)
    .as_output(Value::Active)
    .request()?;
let value = req.value(sensor0.offset)?;