From 236067f214a510897f958b78306275460c81530b Mon Sep 17 00:00:00 2001 From: Rafael Bachmann Date: Fri, 18 Nov 2022 19:28:17 +0100 Subject: [PATCH] Update to ebyte-32 0.9.0 --- Cargo.toml | 2 +- src/lib.rs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 453f62a..c6757b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ clap = { version = "3.1.14", features = ["derive"] } #ebyte-e32 = { git = "https://github.com/barafael/ebyte-e32-rs", rev = "fee291a427df8e7c55e8dc154e181257ebb52a41", features = [ #"arg_enum", #] } -ebyte-e32 = { version = "0.8.0", features = ["value_enum"] } +ebyte-e32 = { version = "0.9.0", features = ["value_enum"] } embedded-hal = "0.2.7" klask = "1" linux-embedded-hal = "0.3.2" diff --git a/src/lib.rs b/src/lib.rs index b07c26d..b12cec1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ pub fn create(args: &Args) -> anyhow::Result( @@ -102,17 +102,19 @@ where Mode::Listen => loop { let b = block!(ebyte.read()).expect("Failed to read"); print!("{}", b as char); - std::io::Write::flush(&mut std::io::stdout()).expect("Failed to flush"); + std::io::Write::flush(&mut std::io::stdout()).context("Failed to flush")?; }, Mode::ReadModelData => { println!("Reading model data"); - let model_data = ebyte.model_data().expect("Failed to read model data"); + let model_data = ebyte.model_data().context("Failed to read model data")?; println!("{model_data:#?}"); Ok(()) } Mode::ReadParameters => { println!("Reading parameter data"); - let parameters = ebyte.parameters().expect("Failed to read parameter data"); + let parameters = ebyte + .parameters() + .context("Failed to read parameter data")?; println!("{parameters:#?}"); Ok(()) } @@ -132,7 +134,7 @@ where M1: OutputPin, D: delay::DelayMs, { - let mut prompt = Editor::<()>::new().expect("Failed to set up prompt"); + let mut prompt = Editor::<()>::new().context("Failed to set up prompt")?; loop { match prompt.readline("Enter message >> ") { Ok(line) => { @@ -144,7 +146,7 @@ where for b in line.as_bytes() { block!(ebyte.write(*b)).expect("Failed to write"); print!("{}", *b as char); - std::io::Write::flush(&mut std::io::stdout()).expect("Failed to flush"); + std::io::Write::flush(&mut std::io::stdout()).context("Failed to flush")?; } block!(ebyte.write(b'\n')).expect("Failed to write"); println!(); @@ -187,7 +189,7 @@ where println!("Loading existing parameters"); let old_params = ebyte .parameters() - .expect("Failed to read existing parameters"); + .context("Failed to read existing parameters")?; println!("Loaded parameters: {old_params:#?}"); // Create Ebyte parameters from argument parameters. @@ -202,12 +204,12 @@ where ); ebyte .set_parameters(&new_params, parameters.persistence) - .expect("Failed to set new parameters"); + .context("Failed to set new parameters")?; // Check if it worked. let current_params = ebyte .parameters() - .expect("Failed to read current parameters"); + .context("Failed to read current parameters")?; if current_params != new_params { eprintln!("Error: parameters unchanged: {current_params:#?}"); }