diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-12-05 20:10:03 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-12-05 20:10:03 +0000 |
commit | 939701318fc664415562669073fd4d45b1e03004 (patch) | |
tree | 7b9dffd5473f297a9a88d2d2ef2749a0338e3895 /gpsd.c | |
parent | ad97c54bb68ef79db86104530155a5a9df253796 (diff) | |
download | gpsd-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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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) |