summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-03-12 12:49:59 -0700
committerGary E. Miller <gem@rellim.com>2015-03-12 12:49:59 -0700
commitcfd75178762a5b8f27c758bb97d8e58c66172c9e (patch)
tree2e7621f765d524707afdf02b35116b431801318d
parent0fc51deea783be9a7dc272972a0141aca3bab227 (diff)
downloadgpsd-cfd75178762a5b8f27c758bb97d8e58c66172c9e.tar.gz
Document SHM and JSON timeout is in uSec. Fix SHM so that is true.
JSON wait was in uSec, but SHM wait was in Sec. Made both uSec and documented three places.
-rw-r--r--libgps_core.c1
-rw-r--r--libgps_shm.c5
-rw-r--r--libgps_sock.c1
3 files changed, 5 insertions, 2 deletions
diff --git a/libgps_core.c b/libgps_core.c
index 4ed336cd..9a26124d 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -217,6 +217,7 @@ const char /*@null observer@*/ *gps_data(const struct gps_data_t *gpsdata CONDIT
bool gps_waiting(const struct gps_data_t *gpsdata CONDITIONALLY_UNUSED, int timeout CONDITIONALLY_UNUSED)
/* is there input waiting from the GPS? */
+/* timeout is in uSec */
{
/* this is bogus, but I can't think of a better solution yet */
bool waiting = true;
diff --git a/libgps_shm.c b/libgps_shm.c
index 90e962c8..bc245bea 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -75,9 +75,10 @@ int gps_shm_open(/*@out@*/struct gps_data_t *gpsdata)
bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout)
/* check to see if new data has been written */
+/* timeout is in uSec */
{
volatile struct shmexport_t *shared = (struct shmexport_t *)PRIVATE(gpsdata)->shmseg;
- timestamp_t basetime = timestamp();
+ timestamp_t endtime = timestamp() + (((double)timeout)/1000000);;
volatile bool newdata = false;
/* busy-waiting sucks, but there's not really an alternative */
@@ -90,7 +91,7 @@ bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout)
memory_barrier();
if (bookend1 == bookend2 && bookend1 > PRIVATE(gpsdata)->tick)
newdata = true;
- if (newdata || (timestamp() - basetime >= (double)timeout))
+ if (newdata || (timestamp() >= endtime))
break;
}
diff --git a/libgps_sock.c b/libgps_sock.c
index e36e4ff1..a87cd444 100644
--- a/libgps_sock.c
+++ b/libgps_sock.c
@@ -100,6 +100,7 @@ int gps_sock_open(/*@null@*/const char *host, /*@null@*/const char *port,
bool gps_sock_waiting(const struct gps_data_t *gpsdata, int timeout)
/* is there input waiting from the GPS? */
+/* timeout is in uSec */
{
#ifndef USE_QT
fd_set rfds;