]> sigrok.org Git - libserialport.git/commitdiff
Fix ERROR_SEM_TIMEOUT issue on Windows.
authorUwe Hermann <redacted>
Wed, 27 Jan 2016 07:19:38 +0000 (08:19 +0100)
committerUwe Hermann <redacted>
Wed, 27 Jan 2016 11:35:45 +0000 (12:35 +0100)
The sp_blocking_write() call was incorrectly returning an error upon
ERROR_SEM_TIMEOUT. It now returns 0 instead.

serialport.c

index fb603b3edc97c0a5e317b80df7ca870633113792..d271478250f8588e0bfe03651b25f492a3d8523e 100644 (file)
@@ -764,8 +764,14 @@ SP_API enum sp_return sp_blocking_write(struct sp_port *port, const void *buf,
                RETURN_INT(count);
        } else if (GetLastError() == ERROR_IO_PENDING) {
                DEBUG("Waiting for write to complete");
-               if (GetOverlappedResult(port->hdl, &port->write_ovl, &bytes_written, TRUE) == 0)
-                       RETURN_FAIL("GetOverlappedResult() failed");
+               if (GetOverlappedResult(port->hdl, &port->write_ovl, &bytes_written, TRUE) == 0) {
+                       if (GetLastError() == ERROR_SEM_TIMEOUT) {
+                               DEBUG("Write timed out");
+                               RETURN_INT(0);
+                       } else {
+                               RETURN_FAIL("GetOverlappedResult() failed");
+                       }
+               }
                DEBUG_FMT("Write completed, %d/%d bytes written", bytes_written, count);
                RETURN_INT(bytes_written);
        } else {