Skip to content

Commit

Permalink
Fix write timeout for COM ports
Browse files Browse the repository at this point in the history
  • Loading branch information
nskartoredjo committed Feb 13, 2024
1 parent 819b640 commit 74e6b5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/windows/com.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ impl SerialPort for COMPort {
}

fn set_timeout(&mut self, timeout: Duration) -> Result<()> {
let milliseconds = timeout.as_secs() * 1000 + timeout.subsec_nanos() as u64 / 1_000_000;
let milliseconds = timeout.as_millis();

let mut timeouts = COMMTIMEOUTS {
ReadIntervalTimeout: 0,
ReadTotalTimeoutMultiplier: 0,
ReadTotalTimeoutConstant: milliseconds as DWORD,
WriteTotalTimeoutMultiplier: 0,
WriteTotalTimeoutConstant: 0,
WriteTotalTimeoutConstant: milliseconds as DWORD,
};

if unsafe { SetCommTimeouts(self.handle, &mut timeouts) } == 0 {
Expand Down

0 comments on commit 74e6b5c

Please sign in to comment.