From 6d2e4b5fa75fe50ceff2dcda844c039299e2cfb2 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 24 Nov 2015 12:42:09 -0600 Subject: [PATCH] Return after encountering errors in windows write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unix version breaks the while loop by returning on certain errors. On Windows, the errors were being contained because the while loop was never breaking. For example, pulling the USB cable out would raise “Access Denied” errors but the while loop would run forever and contain that error. --- src/serialport_win.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index b992441..c2d8ff9 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -378,6 +378,7 @@ void EIO_Write(uv_work_t* req) { if(lastError != ERROR_IO_PENDING) { // Write operation error ErrorCodeToString("Writing to COM port (WriteFile)", lastError, data->errorString); + return; } else { // Write operation is asynchronous and is pending @@ -390,6 +391,7 @@ void EIO_Write(uv_work_t* req) { // Write operation error DWORD lastError = GetLastError(); ErrorCodeToString("Writing to COM port (GetOverlappedResult)", lastError, data->errorString); + return; } else { // Write operation completed asynchronously