From ca26f090fa9a4fc0dba71ad8dc71108efe29853d Mon Sep 17 00:00:00 2001 From: Empire Phoenix Date: Mon, 12 Aug 2024 19:46:56 +0200 Subject: [PATCH] fix for read line --- rust/src/webserver/webserver.rs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/rust/src/webserver/webserver.rs b/rust/src/webserver/webserver.rs index f6ad0bb..d0f1a6d 100644 --- a/rust/src/webserver/webserver.rs +++ b/rust/src/webserver/webserver.rs @@ -330,26 +330,16 @@ pub fn shared() -> Box> { println!("Updated btn"); loop { - let mut line = std::string::String::new(); println!("Check for line"); - let has_line = line_buffer.read_line(&mut line); - let mut line_size = 0; - match has_line { - Ok(size) => { - line_size = size; - if size == 0 { - println!("Was no line no string read"); - break; - } - }, - Err(err) => { - println!("Was no line and error {}", err); - break; - }, + let has_line = line_buffer.contains(&b'\n'); + if has_line { + println!("Was no line no string read"); + break; } + let mut line = std::string::String::new(); + let line_size = line_buffer.read_line(&mut line)?; println!("Processing line with size {} {}", line_size, line); - //let validate = board.flash_bq34_z100(&line, is_dry_run); - let validate = anyhow::Ok(()); + let validate = board.flash_bq34_z100(&line, is_dry_run); delay.delay_us(2); if validate.is_err() { let mut response = request.into_status_response(400_u16).unwrap();