From 65fe7842767ce8b4843f9dedc2bba55a6bdf02d3 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 16 Jan 2024 00:06:57 +0000 Subject: [PATCH] windows/serialInterface: Corrected the timeouts configuration as the one copied from from BMDA was all kinds of wrong --- src/windows/serialInterface.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/windows/serialInterface.cxx b/src/windows/serialInterface.cxx index 03c2598..f269a8c 100644 --- a/src/windows/serialInterface.cxx +++ b/src/windows/serialInterface.cxx @@ -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);