From: Martin Ling Date: Wed, 27 Nov 2013 11:11:55 +0000 (+0000) Subject: Fix conversion of timeout to struct timeval. X-Git-Tag: libserialport-0.1.0~36 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1b34204261800897b46957bccd353470ef793a76;p=libserialport.git Fix conversion of timeout to struct timeval. --- diff --git a/serialport.c b/serialport.c index af8f1b1..0a467de 100644 --- a/serialport.c +++ b/serialport.c @@ -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); }