diff --git a/src/lib.rs b/src/lib.rs index 1d7f213..bdee736 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -803,17 +803,18 @@ mod sys { #[cfg(windows)] mod sys { + use winapi::um::winnt::MAXDWORD; + use super::os_prelude::*; use super::StdIoResult; /// Overrides timeout value set by serialport-rs so that the read end will /// never wake up with 0-byte payload. pub(crate) fn override_comm_timeouts(handle: RawHandle) -> StdIoResult<()> { let mut timeouts = COMMTIMEOUTS { - // wait at most 1ms between two bytes (0 means no timeout) - ReadIntervalTimeout: 1, - // disable "total" timeout to wait at least 1 byte forever - ReadTotalTimeoutMultiplier: 0, - ReadTotalTimeoutConstant: 0, + // Enable POSIX-like behaviour to wait for ANY about of bytes or timeout + ReadIntervalTimeout: MAXDWORD, + ReadTotalTimeoutMultiplier: MAXDWORD, + ReadTotalTimeoutConstant: 1, // write timeouts are just copied from serialport-rs WriteTotalTimeoutMultiplier: 0, WriteTotalTimeoutConstant: 0,