diff --git a/src/serial.rs b/src/serial.rs index a850c29519bf7b13ab0d487969793052ddfcdf66..731be06a7bab7ae620bec11d3498e4d7757d0001 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -6,6 +6,7 @@ use std::{ Arc, }, thread::{self, JoinHandle}, + time::Duration, }; use hashbrown::HashMap; @@ -83,7 +84,11 @@ impl SerialQueue { /// Open the serial port and start a thread to write data as soon as it is /// available (by using a channel) fn open(port: &str, baudrate: u32) -> SResult<Self> { - let serial = Arc::new(Mutex::new(serialport::new(port, baudrate).open()?)); + let serial = Arc::new(Mutex::new( + serialport::new(port, baudrate) + .timeout(Duration::from_millis(200)) + .open()?, + )); let (tx, rx) = channel::<Vec<u8>>(); let ser = Arc::clone(&serial); let _handle = thread::spawn(move || {