diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-09-22 14:50:03 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-09-22 14:50:03 -0400 |
commit | 282691da60ec526772f713a63fa0b8f43aea7acb (patch) | |
tree | 622f4d55c882f63475b84691d41108dd17326cca /libgps_json.c | |
parent | f63bdafc18991624b872e9efa858c024834a540e (diff) | |
download | gpsd-282691da60ec526772f713a63fa0b8f43aea7acb.tar.gz |
Refactor representation of satellite data into an array of structs...
...from a set of parallel arrays. This change flushed out a
longstanding bug in the computation of DOPs for estimated error bars.
Some test-load rebuilds were required:
geostar-geos1m-binary.log.chk: With this change error
estimates are computed and reported.
trimble-lassen_iq-3dfix.log, trimble-lassen_iq-3dfix.log: the
change revealed a bug in the computation of satellite-seen bits.
Error estimates did not change.
navcom.log: Error estimates changed.
With these rebuilds, all regression tests pass.
Diffstat (limited to 'libgps_json.c')
-rw-r--r-- | libgps_json.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/libgps_json.c b/libgps_json.c index 6e85e42c..ff060f67 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -118,15 +118,14 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata, static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { - bool usedflags[MAXCHANNELS]; /*@ -fullinitblock @*/ - const struct json_attr_t json_attrs_2_1[] = { + const struct json_attr_t json_attrs_satellites[] = { /* *INDENT-OFF* */ - {"PRN", t_integer, .addr.integer = gpsdata->PRN}, - {"el", t_integer, .addr.integer = gpsdata->elevation}, - {"az", t_integer, .addr.integer = gpsdata->azimuth}, - {"ss", t_real, .addr.real = gpsdata->ss}, - {"used", t_boolean, .addr.boolean = usedflags}, + {"PRN", t_integer, STRUCTOBJECT(struct satellite_t, PRN)}, + {"el", t_integer, STRUCTOBJECT(struct satellite_t, elevation)}, + {"az", t_integer, STRUCTOBJECT(struct satellite_t, azimuth)}, + {"ss", t_real, STRUCTOBJECT(struct satellite_t, ss)}, + {"used", t_boolean, STRUCTOBJECT(struct satellite_t, used)}, /* *INDENT-ON* */ {NULL}, }; @@ -153,10 +152,10 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, .dflt.real = NAN}, {"gdop", t_real, .addr.real = &gpsdata->dop.gdop, .dflt.real = NAN}, - {"satellites", t_array, .addr.array.element_type = t_object, - .addr.array.arr.objects.subtype=json_attrs_2_1, - .addr.array.maxlen = MAXCHANNELS, - .addr.array.count = &gpsdata->satellites_visible}, + {"satellites", t_array, + STRUCTARRAY(gpsdata->skyview, + json_attrs_satellites, + &gpsdata->satellites_visible)}, {NULL}, /* *INDENT-ON* */ }; @@ -164,8 +163,8 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, int status, i, j; for (i = 0; i < MAXCHANNELS; i++) { - gpsdata->PRN[i] = 0; - usedflags[i] = false; + gpsdata->skyview[i].PRN = 0; + gpsdata->skyview[i].used = false; } status = json_read_object(buf, json_attrs_2, endptr); @@ -174,12 +173,10 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, gpsdata->satellites_used = 0; gpsdata->satellites_visible = 0; - (void)memset(gpsdata->used, '\0', sizeof(gpsdata->used)); for (i = j = 0; i < MAXCHANNELS; i++) { - if(gpsdata->PRN[i] > 0) + if(gpsdata->skyview[i].PRN > 0) gpsdata->satellites_visible++; - if (usedflags[i]) { - gpsdata->used[j++] = gpsdata->PRN[i]; + if (gpsdata->skyview[i].used) { gpsdata->satellites_used++; } } |