use saturating sub for timeouts, it overflowed at some point
This commit is contained in:
parent
f7070e02e7
commit
835bf50b80
1 changed files with 2 additions and 2 deletions
|
@ -62,7 +62,7 @@ impl<UART: serial::Uart> Iterator for IterableRx<UART> {
|
|||
break None
|
||||
}
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
self.timeout = Some(timeout - now.elapsed());
|
||||
self.timeout = Some(timeout.saturating_sub(now.elapsed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ impl<UART: serial::Uart> Modem<UART> {
|
|||
let match_text: String = contains.unwrap_or("\n".to_string());
|
||||
|
||||
loop {
|
||||
let rdln = self.read_line(start + timeout - Instant::now());
|
||||
let rdln = self.read_line(timeout.saturating_sub(start.elapsed()));
|
||||
if let Ok(line) = rdln {
|
||||
println!("Read {} bytes from serial ({})", line.len(), line);
|
||||
response.push_str(&line);
|
||||
|
|
Loading…
Reference in a new issue