fix bug in timeout handling

use timeout.saturating_sub instead of plain '-'
This commit is contained in:
Vladan Popovic 2022-06-22 14:35:18 +02:00
parent f0d474d062
commit 327c86a504

View file

@ -150,7 +150,7 @@ impl<UART: serial::Uart> Modem<UART> {
let match_text: String = contains.unwrap_or("\n".to_string()); let match_text: String = contains.unwrap_or("\n".to_string());
loop { loop {
let timeout = timeout - start.elapsed(); let timeout = timeout.saturating_sub(start.elapsed());
let line = self.rx.read_line(timeout)?; let line = self.rx.read_line(timeout)?;
print!("Read {} bytes from serial: {}", line.len(), line); print!("Read {} bytes from serial: {}", line.len(), line);
response.push_str(&line); response.push_str(&line);