blob: 120f424ecdbecf9866f5f7a621563a4a9e2fd112 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
//! Change the supply's output state.
use std::env;
use bkp_168xb::{Output, PowerSupply};
static USAGE: &'static str = "Usage: power on [PORT] | power off [PORT]";
fn main() {
let mut args = env::args().skip(1);
let output = args
.next()
.and_then(|arg| match arg.to_lowercase().as_str() {
"off" => Some(Output::Off),
"on" => Some(Output::On),
_ => None,
})
.expect(USAGE);
let port = args.next().expect(USAGE);
let mut ps = PowerSupply::open(port).unwrap();
let (volt, curr) = ps.get_max_voltage_current().unwrap();
println!("{volt} {curr}");
ps.set_output(output).unwrap()
}
|