From e5d720c55de6ffabe703ce23433c342c8b39a430 Mon Sep 17 00:00:00 2001 From: "M. Rashvand" <68546431+m-rashvand@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:31:29 +0330 Subject: [PATCH] Fix a bug where a HANDLE pointer is used instead of HANDLE. --- examples/win32/comm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/win32/comm.c b/examples/win32/comm.c index 0b2f6fc..19fe970 100644 --- a/examples/win32/comm.c +++ b/examples/win32/comm.c @@ -93,8 +93,8 @@ bool InitCommPort(HANDLE* hComm, int PortNumber) { } bool CloseCommPort(HANDLE* hComm) { - if (hComm != INVALID_HANDLE_VALUE) - CloseHandle(hComm); + if (*hComm != INVALID_HANDLE_VALUE) + CloseHandle(*hComm); else return false; @@ -104,7 +104,6 @@ bool CloseCommPort(HANDLE* hComm) { int32_t ReadCommPort(HANDLE hComm, uint8_t* buf, uint16_t count, int32_t byte_timeout_ms) { int TotalBytesRead = 0; bool Status = false; - bool TimedOut = false; ULONGLONG StartTime = 0; uint8_t b; int tmpByteCount; @@ -126,11 +125,10 @@ int32_t ReadCommPort(HANDLE hComm, uint8_t* buf, uint16_t count, int32_t byte_ti // did we time out yet?? if (GetTickCount64() - StartTime > byte_timeout_ms) { - TimedOut = true; break; } } while (TotalBytesRead < count); return TotalBytesRead; -} \ No newline at end of file +}