Skip to content

Commit af5c17b

Browse files
committed
core: significant rework to config subsystem
This change hammers out a bunch of details and changes the form of the config from being a hashmap based on a primary name to just being a list. There is some gymnastics in order to properly parse the toml to a form that has the deafults filled out and such. This should make using the resultant GpioConfig easier for other parts of the system. Signed-off-by: Paul Osborne <[email protected]>
1 parent 7e023eb commit af5c17b

File tree

9 files changed

+257
-61
lines changed

9 files changed

+257
-61
lines changed

Cargo.lock

Lines changed: 61 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ rustc-serialize = "0.3"
99
sysfs_gpio = "0.4"
1010
toml = "0.1"
1111
glob = "0.2"
12+
log = "0.3"
13+
env_logger = "0.3"
1214

1315
[[bin]]
1416
name = "gpio"

src/commands/gpio_exportall.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) 2016, Paul Osborne <[email protected]>
2+
3+
use options::{GpioExportAllOptions};
4+
use config::GpioConfig;
5+
use std::process::exit;
6+
7+
pub fn main(opts: &GpioExportAllOptions) {
8+
let config = match GpioConfig::load(&opts.gpio_opts.configs[..]) {
9+
Ok(config) => config,
10+
Err(e) => {
11+
println!("Error: {:?}", e);
12+
exit(1);
13+
}
14+
};
15+
16+
for pin in config.pins {
17+
println!("{:?}", pin);
18+
}
19+
}

src/commands/gpio_read.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
// Copyright (C) 2016, Paul Osborne <[email protected]>
22

33
use options::{GpioReadOptions};
4+
use config::GpioConfig;
5+
use std::process::exit;
46

57
pub fn main(opts: &GpioReadOptions) {
6-
println!("{:?}", opts);
8+
let config = match GpioConfig::load(&opts.gpio_opts.configs[..]) {
9+
Ok(config) => config,
10+
Err(e) => {
11+
println!("Error: {:?}", e);
12+
exit(1);
13+
}
14+
};
15+
16+
println!("config: {:?}", config);
717
}

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// Copyright (C) 2016, Paul Osborne <[email protected]>
22

33
pub mod gpio_read;
4+
pub mod gpio_exportall;

0 commit comments

Comments
 (0)