From: Uwe Hermann Date: Wed, 27 Jan 2016 07:19:38 +0000 (+0100) Subject: Fix ERROR_SEM_TIMEOUT issue on Windows. X-Git-Tag: libserialport-0.1.1~3 X-Git-Url: https://sigrok.org/gitweb/?p=libserialport.git;a=commitdiff_plain;h=aee7d69195e25fb9e7b250e85df0b50368ddc810 Fix ERROR_SEM_TIMEOUT issue on Windows. The sp_blocking_write() call was incorrectly returning an error upon ERROR_SEM_TIMEOUT. It now returns 0 instead. --- diff --git a/serialport.c b/serialport.c index fb603b3..d271478 100644 --- a/serialport.c +++ b/serialport.c @@ -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 {