diff options
author | Scott Murray <scott.murray@konsulko.com> | 2019-03-04 07:01:35 +0900 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2019-03-04 00:25:29 +0000 |
commit | 58ac8e3edc029a5e2e2e8d814282f5707369f8fc (patch) | |
tree | ae17f8fb8c2055ad98c1b8388f13234f4e5758bc /binding/afm-gps-binding.c | |
parent | d5a586632c0fe290041f271af12582307061b206 (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>
Diffstat (limited to 'binding/afm-gps-binding.c')
-rw-r--r-- | binding/afm-gps-binding.c | 9 |
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"); |