]> sigrok.org Git - libserialport.git/commitdiff
Fix conversion of timeout to struct timeval.
authorMartin Ling <redacted>
Wed, 27 Nov 2013 11:11:55 +0000 (11:11 +0000)
committerMartin Ling <redacted>
Wed, 27 Nov 2013 11:11:55 +0000 (11:11 +0000)
serialport.c

index af8f1b1e2239a2bec4b2e0fc7a40ba2ea3c40058..0a467dea1a74732cde11d144ae564d2b13fe516f 100644 (file)
@@ -870,7 +870,7 @@ enum sp_return sp_blocking_write(struct sp_port *port, const void *buf, size_t c
                gettimeofday(&start, NULL);
                /* Define duration of timeout. */
                delta.tv_sec = timeout / 1000;
-               delta.tv_usec = timeout % 1000;
+               delta.tv_usec = (timeout % 1000) * 1000;
                /* Calculate time at which we should give up. */
                timeradd(&start, &delta, &end);
        }
@@ -1041,7 +1041,7 @@ enum sp_return sp_blocking_read(struct sp_port *port, void *buf, size_t count, u
                gettimeofday(&start, NULL);
                /* Define duration of timeout. */
                delta.tv_sec = timeout / 1000;
-               delta.tv_usec = timeout % 1000;
+               delta.tv_usec = (timeout % 1000) * 1000;
                /* Calculate time at which we should give up. */
                timeradd(&start, &delta, &end);
        }