Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down