From 72946386810ae65dfe37486854564092790474db Mon Sep 17 00:00:00 2001 From: Blizzard Finnegan Date: Fri, 23 Jun 2023 13:39:50 -0400 Subject: [PATCH] Use single constant for TTY timers --- src/tty.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tty.rs b/src/tty.rs index 6efc46e..c1e8afe 100755 --- a/src/tty.rs +++ b/src/tty.rs @@ -7,7 +7,7 @@ use serialport::SerialPort; use derivative::Derivative; const BAUD_RATE:u32 = 115200; -const SERIAL_READ_TIMEOUT: std::time::Duration = Duration::from_millis(500); +const SERIAL_TIMEOUT: std::time::Duration = Duration::from_millis(500); #[derive(Eq,Derivative,Debug)] @@ -112,7 +112,7 @@ impl std::fmt::Debug for TTY{ impl TTY{ pub fn new(serial_location:&str) -> Option{ - let possible_tty = serialport::new(serial_location,BAUD_RATE).timeout(SERIAL_READ_TIMEOUT).open(); + let possible_tty = serialport::new(serial_location,BAUD_RATE).timeout(SERIAL_TIMEOUT).open(); if let Ok(tty) = possible_tty{ Some(TTY{tty,last:Command::Quit}) } else{ @@ -129,7 +129,7 @@ impl TTY{ let output = self.tty.write_all(COMMAND_MAP.get(&command).unwrap().as_bytes()).is_ok(); self.last = command; _ = self.tty.flush(); - std::thread::sleep(std::time::Duration::from_millis(500)); + std::thread::sleep(SERIAL_TIMEOUT); return output; }