1 // Copyright (c) 2018 The rust-gpio-cdev Project Developers.
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8
9 use gpio_cdev::{Chip, LineRequestFlags};
10 use quicli::prelude::*;
11 use structopt::StructOpt;
12
13 #[derive(Debug, StructOpt)]
14 struct Cli {
15 /// The gpiochip device (e.g. /dev/gpiochip0)
16 chip: String,
17 /// The offset of the GPIO lines for the provided chip
18 lines: Vec<u32>,
19 }
20
do_main(args: Cli) -> std::result::Result<(), gpio_cdev::Error>21 fn do_main(args: Cli) -> std::result::Result<(), gpio_cdev::Error> {
22 let mut chip = Chip::new(args.chip)?;
23 let ini_vals = vec![0; args.lines.len()];
24 let handle =
25 chip.get_lines(&args.lines)?
26 .request(LineRequestFlags::INPUT, &ini_vals, "multiread")?;
27 println!("Values: {:?}", handle.get_values()?);
28
29 Ok(())
30 }
31
main() -> CliResult32 fn main() -> CliResult {
33 let args = Cli::from_args();
34 do_main(args).or_else(|e| {
35 error!("{:?}", e);
36 Ok(())
37 })
38 }
39