Skip to content

Commit

Permalink
windows/serialInterface: Corrected the timeouts configuration as the …
Browse files Browse the repository at this point in the history
…one copied from from BMDA was all kinds of wrong
  • Loading branch information
dragonmux committed Jan 16, 2024
1 parent 0c74034 commit 65fe784
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/windows/serialInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,15 @@ serialInterface_t::serialInterface_t(const usbDevice_t &usbDevice) : device
}

COMMTIMEOUTS timeouts{};
timeouts.ReadIntervalTimeout = 10;
timeouts.ReadTotalTimeoutConstant = 10;
timeouts.ReadTotalTimeoutMultiplier = 10;
timeouts.WriteTotalTimeoutConstant = 10;
timeouts.WriteTotalTimeoutMultiplier = 10;
// Turn off read timeouts so that ReadFill() instantly returns even if there's no data waiting
// (we implement our own mechanism below for that case as we only want to wait if we get no data)
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
// Configure an exactly 100ms write timeout - we want this triggering to be fatal as something
// has gone very wrong if we ever hit this.
timeouts.WriteTotalTimeoutConstant = 100;
timeouts.WriteTotalTimeoutMultiplier = 0;
if (!SetCommTimeouts(device, &timeouts))
handleDeviceError("set communications timeouts for device"sv);

Expand Down

0 comments on commit 65fe784

Please sign in to comment.