diff --git a/on-host/src/main.rs b/on-host/src/main.rs index 0e7b66326273d4b37d6341ef19df15f8e3fd8ba0..74caf9839a1317a177d39b694e119eb70340851b 100644 --- a/on-host/src/main.rs +++ b/on-host/src/main.rs @@ -12,7 +12,7 @@ use std::{ }; use clap::Parser; -use log::{debug, error, info, warn}; +use log::{debug, error, info}; use miette::{Context, IntoDiagnostic, Result}; use serialport::SerialPort; use skyward_mavlink::{ @@ -140,6 +140,7 @@ fn get_packets(args: &Cli) -> Result<Vec<MavMessage>> { /// Wait for ACK signal from the device fn wait_for_ack(port: &mut Box<dyn SerialPort>, buffer: &mut [u8]) { // wait ACK + let start = Instant::now(); loop { match port.read(buffer) { Ok(t) => { @@ -148,11 +149,15 @@ fn wait_for_ack(port: &mut Box<dyn SerialPort>, buffer: &mut [u8]) { if buffer[..t].contains(&ACK) { break; } else { - warn!("didn't get the signal"); std::thread::sleep(Duration::from_millis(10)); } } - Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (), + Err(ref e) if e.kind() == io::ErrorKind::TimedOut => { + if start.elapsed() > Duration::from_secs(5) { + error!("FATAL: didn't get the signal"); + std::process::exit(1); + } + } Err(e) => { error!("FATAL: {:?}", e); std::process::exit(1);