From 0c740348a5056b7eccb63f338f71168c10a8fe62 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 16 Jan 2024 00:06:29 +0000 Subject: [PATCH] windows/serialInterface: Cleaned up handling of data in the receive buffer using PurgeComm() --- src/windows/serialInterface.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/windows/serialInterface.cxx b/src/windows/serialInterface.cxx index 91d357d..03c2598 100644 --- a/src/windows/serialInterface.cxx +++ b/src/windows/serialInterface.cxx @@ -222,9 +222,8 @@ serialInterface_t::serialInterface_t(const usbDevice_t &usbDevice) : device if (!SetCommTimeouts(device, &timeouts)) handleDeviceError("set communications timeouts for device"sv); - // Having adjusted the line state, try to do a read of the serial state notification which will be sat in the buffer - std::array serialState{}; - static_cast(ReadFile(device, serialState.data(), serialState.size(), nullptr, nullptr)); + // Having adjusted the line state, discard anything sat in the receive buffer + PurgeComm(device, PURGE_RXCLEAR); } // NOLINTNEXTLINE(modernize-use-equals-default)