Skip to content

Commit

Permalink
more windows and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
noah1510 committed Dec 14, 2023
1 parent 567559e commit e86cdff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion samples/interfaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main (int argc, char **argv) {

// Closing port
std::cout << "\nClosing Serialport ..." << std::endl;
h.Close();
h.DisconnectAll();

return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions src/rs232_native_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ ssize_t sakurajin::RS232_native::readRawData(char* data_location, int length, bo

return callWithOptionalLock(block, [this, data_location, length]() {
int n = 0;
length = std::clamp(length, 0, 4096);
auto local_len = std::clamp(length, 0, 4096);

auto success = ReadFile(getCport(portHandle), data_location, length, (LPDWORD)((void*)&n), NULL);
auto success = ReadFile(getCport(portHandle), data_location, local_len, (LPDWORD)((void*)&n), NULL);
return (ssize_t)(success ? n : -1);
});
}
Expand All @@ -146,9 +146,9 @@ ssize_t sakurajin::RS232_native::writeRawData(char* data_location, int length, b

return callWithOptionalLock(block, [this, data_location, length]() {
int n = 0;
length = std::clamp(length, 0, 4096);
auto local_len = std::clamp(length, 0, 4096);

auto success = WriteFile(getCport(portHandle), data_location, length, (LPDWORD)((void*)&n), NULL);
auto success = WriteFile(getCport(portHandle), data_location, local_len, (LPDWORD)((void*)&n), NULL);
return (ssize_t)(success ? n : -1);
});
}
Expand All @@ -158,7 +158,7 @@ ssize_t sakurajin::RS232_native::retrieveFlags(bool block) noexcept {
return -1;
}

return callWithOptionalLock(block, [this]() {
return callWithOptionalLock(block, [this](){
DWORD flags;
if (!GetCommModemStatus(getCport(portHandle), &flags)) {
return (ssize_t)(-1);
Expand Down

0 comments on commit e86cdff

Please sign in to comment.