aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-03-04 07:01:35 +0900
committerScott Murray <scott.murray@konsulko.com>2019-03-04 00:25:29 +0000
commit58ac8e3edc029a5e2e2e8d814282f5707369f8fc (patch)
treeae17f8fb8c2055ad98c1b8388f13234f4e5758bc
parentd5a586632c0fe290041f271af12582307061b206 (diff)
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 <scott.murray@konsulko.com>
-rw-r--r--binding/afm-gps-binding.c9
1 files 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");