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

windows: restart_wait_if_needed(): Inline receive buffer check.

This removes all the debug spam arising from calling sp_input_waiting().
This commit is contained in:
Martin Ling 2015-05-06 20:18:37 +01:00 committed by Uwe Hermann
parent 21ae5ce197
commit 8ebfaf8966

View File

@ -921,19 +921,16 @@ SP_API enum sp_return sp_nonblocking_write(struct sp_port *port,
/* Restart wait operation if buffer was emptied. */ /* Restart wait operation if buffer was emptied. */
static enum sp_return restart_wait_if_needed(struct sp_port *port, unsigned int bytes_read) static enum sp_return restart_wait_if_needed(struct sp_port *port, unsigned int bytes_read)
{ {
int ret, bytes_remaining; DWORD errors;
COMSTAT comstat;
if (bytes_read == 0) if (bytes_read == 0)
RETURN_OK(); RETURN_OK();
ret = sp_input_waiting(port); if (ClearCommError(port->hdl, &errors, &comstat) == 0)
RETURN_FAIL("ClearCommError() failed");
if (ret < 0) if (comstat.cbInQue == 0)
RETURN_CODEVAL(ret);
bytes_remaining = ret;
if (bytes_remaining == 0)
TRY(restart_wait(port)); TRY(restart_wait(port));
RETURN_OK(); RETURN_OK();