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 }
18
do_main(args: Cli) -> std::result::Result<(), gpio_cdev::Error>19 fn do_main(args: Cli) -> std::result::Result<(), gpio_cdev::Error> {
20 let mut chip = Chip::new(args.chip)?;
21 let ini_vals = vec![0; chip.num_lines() as usize];
22 let handle = chip
23 .get_all_lines()?
24 .request(LineRequestFlags::INPUT, &ini_vals, "readall")?;
25 println!("Values: {:?}", handle.get_values()?);
26
27 Ok(())
28 }
29
main() -> CliResult30 fn main() -> CliResult {
31 let args = Cli::from_args();
32 do_main(args).or_else(|e| {
33 error!("{:?}", e);
34 Ok(())
35 })
36 }
37