From 3240e15a7eee0cad6786410bdfc5b345ec46c9af Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Mon, 4 Mar 2019 07:01:35 +0900 Subject: Increase timeout on gpsd response Timeouts in the polling of gpsd were being seen when using the GPS support in the Sierra Wireless MC74xx modem modules, seemingly due to slow startup times. An investigation in the gpsd source tree found that the sample clients either use a much longer poll timeout (60s), or retry the poll for up to 120s. The latter has been implemented to improve behavior, and startup with the MC74xx works as expected now. Change-Id: I732ce12e22bcd85315fed19fcf9182ba9dc5bb65 Signed-off-by: Scott Murray --- binding/afm-gps-binding.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/binding/afm-gps-binding.c b/binding/afm-gps-binding.c index d09765a..873c264 100644 --- a/binding/afm-gps-binding.c +++ b/binding/afm-gps-binding.c @@ -265,13 +265,18 @@ static void add_record(json_object *jresp) static void *data_poll(void *ptr) { + int tries = 0; + /* * keep reading till an error condition happens */ - while (gps_waiting(&data, MSECS_TO_USECS(2000)) && !errno) - { + while (tries < 60) { json_object *jresp = NULL; + if (gps_waiting(&data, MSECS_TO_USECS(2000)) < 0) { + tries++; + continue; + } pthread_mutex_lock(&mutex); if (gps_read(&data) == -1) { AFB_ERROR("Cannot read from GPS daemon.\n"); -- cgit 1.2.3-korg