summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--binding/afm-gps-binding.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/binding/afm-gps-binding.c b/binding/afm-gps-binding.c
index ffc787b..7fbd907 100644
--- a/binding/afm-gps-binding.c
+++ b/binding/afm-gps-binding.c
@@ -183,7 +183,7 @@ static void *data_poll(void *ptr)
static int init()
{
const char *host, *port;
- int ret;
+ int ret, tries = 5;
location_event = afb_daemon_make_event("location");
@@ -196,6 +196,11 @@ static int init()
gps_stream(&data, WATCH_ENABLE | WATCH_JSON, NULL);
+ // due to the gpsd.socket race condition need to loop till initial event
+ do {
+ gps_read(&data);
+ } while (!gps_waiting(&data, MSECS_TO_USECS(2500)) && tries--);
+
return pthread_create(&thread, NULL, &data_poll, NULL);
}