Dont hard error

This commit is contained in:
hodasemi 2023-08-25 11:53:08 +02:00
parent 20b31be19e
commit f302bb4c20

View file

@ -63,14 +63,17 @@ fn main() {
if let Some(port) = &mut *port_lock {
// handle incoming message
match port.read().unwrap() {
SerialReadResult::Message(msg) => {
if !msg.is_empty() {
tx.send(msg).unwrap();
match port.read() {
Ok(port_read) => match port_read {
SerialReadResult::Message(msg) => {
if !msg.is_empty() {
tx.send(msg).unwrap();
}
}
}
SerialReadResult::UtfConversion(err) => println!("{:?}", err),
SerialReadResult::Timeout => (),
SerialReadResult::UtfConversion(err) => println!("{:?}", err),
SerialReadResult::Timeout => (),
},
Err(err) => println!("{err}"),
}
}
@ -124,7 +127,9 @@ fn main() {
let mut port_lock = PORT.lock().unwrap();
if let Some(port) = &mut *port_lock {
port.write("reset").unwrap();
if let Err(err) = port.write("reset") {
println!("{err}");
}
}
*port_lock = None;