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 07:06:47 +0900
commit3240e15a7eee0cad6786410bdfc5b345ec46c9af (patch)
treecaf3bfd6f4cab95a9fb0fce7495b83251477328a
parent3d01a83c2e405e9435a4f150e5a6e8210ce9ad52 (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");