//! 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() }