1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Fix sp_blocking_read_next() implementation on Windows.

A ReadFile() call needed to check the actual number of bytes read,
instead of assuming all requested bytes were read.
This commit is contained in:
Uwe Hermann 2016-01-22 15:30:44 +01:00
parent 02c8a1424d
commit 888fb45d66

View File

@ -1112,9 +1112,8 @@ SP_API enum sp_return sp_blocking_read_next(struct sp_port *port, void *buf,
/* Loop until we have at least one byte, or timeout is reached. */
while (bytes_read == 0) {
/* Start read. */
if (ReadFile(port->hdl, buf, count, NULL, &port->read_ovl)) {
if (ReadFile(port->hdl, buf, count, &bytes_read, &port->read_ovl)) {
DEBUG("Read completed immediately");
bytes_read = count;
} else if (GetLastError() == ERROR_IO_PENDING) {
DEBUG("Waiting for read to complete");
if (GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE) == 0)