]> sigrok.org Git - libserialport.git/commitdiff
windows: restart_wait_if_needed(): Inline receive buffer check.
authorMartin Ling <redacted>
Wed, 6 May 2015 19:18:37 +0000 (20:18 +0100)
committerUwe Hermann <redacted>
Wed, 27 May 2015 09:09:25 +0000 (11:09 +0200)
This removes all the debug spam arising from calling sp_input_waiting().

serialport.c

index ab263a95650a51c60ed881d919733378436909bb..bae37ed73a2801359f50b35cfbc4381ddbbf4495 100644 (file)
@@ -921,19 +921,16 @@ SP_API enum sp_return sp_nonblocking_write(struct sp_port *port,
 /* Restart wait operation if buffer was emptied. */
 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)
                RETURN_OK();
 
-       ret = sp_input_waiting(port);
-
-       if (ret < 0)
-               RETURN_CODEVAL(ret);
-
-       bytes_remaining = ret;
+       if (ClearCommError(port->hdl, &errors, &comstat) == 0)
+               RETURN_FAIL("ClearCommError() failed");
 
-       if (bytes_remaining == 0)
+       if (comstat.cbInQue == 0)
                TRY(restart_wait(port));
 
        RETURN_OK();