summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-12-05 20:10:03 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-12-05 20:10:03 +0000
commit939701318fc664415562669073fd4d45b1e03004 (patch)
tree7b9dffd5473f297a9a88d2d2ef2749a0338e3895 /gpsd.c
parentad97c54bb68ef79db86104530155a5a9df253796 (diff)
downloadgpsd-939701318fc664415562669073fd4d45b1e03004.tar.gz
Insurance against flaky drivers.
Don't rely on gpsdata.satellites to be counting only nonzero PRNs.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gpsd.c b/gpsd.c
index 71d5befb..c8217533 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1062,9 +1062,13 @@ static int handle_gpsd_request(struct subscriber_t* sub, char *buf, int buflen)
sub->device->gpsdata.sentence_time);
else
(void)strlcat(phrase, " ? ", BUFSIZ);
+ /* insurance against flaky drivers */
+ for (i = 0; i < sub->device->gpsdata.satellites; i++)
+ if (sub->device->gpsdata.PRN[i])
+ reported++;
(void)snprintf(phrase+strlen(phrase),
sizeof(phrase)-strlen(phrase),
- "%d:", sub->device->gpsdata.satellites);
+ "%d:", reported);
for (i = 0; i < sub->device->gpsdata.satellites; i++) {
used = 0;
for (j = 0; j < sub->device->gpsdata.satellites_used; j++)
@@ -1080,7 +1084,6 @@ static int handle_gpsd_request(struct subscriber_t* sub, char *buf, int buflen)
sub->device->gpsdata.elevation[i],sub->device->gpsdata.azimuth[i],
sub->device->gpsdata.ss[i],
used);
- reported++;
}
}
if (sub->device->gpsdata.satellites != reported)