Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug where a HANDLE pointer is used instead of HANDLE. #46

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions examples/win32/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
}
}
Loading