]> sigrok.org Git - libserialport.git/commitdiff
Flush only the requested buffers
authorJanne Huttunen <redacted>
Sat, 11 Oct 2014 09:13:41 +0000 (12:13 +0300)
committerUwe Hermann <redacted>
Sun, 12 Oct 2014 19:38:03 +0000 (21:38 +0200)
Fix the sp_flush() so that it flushes only the requested buffers
also in unix.

serialport.c

index d4371400d5fa46a388ab66061a920fed6448d9d2..4f42740a2388fe398034f13722e3aaaa9f4f2121 100644 (file)
@@ -618,11 +618,11 @@ SP_API enum sp_return sp_flush(struct sp_port *port, enum sp_buffer buffers)
                RETURN_FAIL("PurgeComm() failed");
 #else
        int flags = 0;
-       if (buffers & SP_BUF_BOTH)
+       if (buffers == SP_BUF_BOTH)
                flags = TCIOFLUSH;
-       else if (buffers & SP_BUF_INPUT)
+       else if (buffers == SP_BUF_INPUT)
                flags = TCIFLUSH;
-       else if (buffers & SP_BUF_OUTPUT)
+       else if (buffers == SP_BUF_OUTPUT)
                flags = TCOFLUSH;
 
        /* Returns 0 upon success, -1 upon failure. */