summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libgps_sock.c4
-rw-r--r--timespec.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/libgps_sock.c b/libgps_sock.c
index eea8a04d..808d837a 100644
--- a/libgps_sock.c
+++ b/libgps_sock.c
@@ -144,8 +144,8 @@ bool gps_sock_waiting(const struct gps_data_t *gpsdata, int timeout)
FD_ZERO(&rfds);
FD_SET(gpsdata->gps_fd, &rfds);
- tv.tv_sec = timeout / NS_IN_SEC;
- tv.tv_nsec = timeout % NS_IN_SEC;
+ tv.tv_sec = timeout / US_IN_SEC;
+ tv.tv_nsec = (timeout % US_IN_SEC) * 1000;
/* all error conditions return "not waiting" -- crude but effective */
return (pselect(gpsdata->gps_fd + 1, &rfds, NULL, NULL, &tv, NULL) == 1);
#else
diff --git a/timespec.h b/timespec.h
index a7eb96ec..df178b36 100644
--- a/timespec.h
+++ b/timespec.h
@@ -19,6 +19,7 @@
* NOTE: this normalization is not the same as ntpd uses
*/
#define NS_IN_SEC 1000000000LL
+#define US_IN_SEC 1000000LL /* microseconds in a second */
#define MS_IN_SEC 1000000LL
/* return the difference between timespecs in nanoseconds