diff options
author | Christian Gagneraud <chris@techworks.ie> | 2012-08-22 12:49:23 +0100 |
---|---|---|
committer | Christian Gagneraud <chris@techworks.ie> | 2012-08-23 10:08:00 +0100 |
commit | 55795c1c86ef1e65ab275f669d07a381ff111b19 (patch) | |
tree | 270dad13192b5dcbe4cb51eecfd0b8cf2764da6f /gpsd_json.c | |
parent | 5c40c691805b1622fbd8bc8e1a2b4e98ea53bea4 (diff) | |
download | gpsd-55795c1c86ef1e65ab275f669d07a381ff111b19.tar.gz |
[AIS] Fixed EPFD display in scaled JSON
aivdm-regress passed
Diffstat (limited to 'gpsd_json.c')
-rw-r--r-- | gpsd_json.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gpsd_json.c b/gpsd_json.c index 8ae338b3..7a99c316 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -1391,6 +1391,7 @@ void json_aivdm_dump(const struct ais_t *ais, "Reserved", "Not defined", }; + static char *epfd_legends[] = { "Undefined", "GPS", @@ -1403,6 +1404,8 @@ void json_aivdm_dump(const struct ais_t *ais, "Galileo", }; +#define EPFD_DISPLAY(n) (((n) < (unsigned int)NITEMS(epfd_legends)) ? epfd_legends[n] : "INVALID EPFD") + static char *ship_type_legends[100] = { "Not available", "Reserved for future use", @@ -1741,7 +1744,7 @@ void json_aivdm_dump(const struct ais_t *ais, JSON_BOOL(ais->type4.accuracy), ais->type4.lon / AIS_LATLON_DIV, ais->type4.lat / AIS_LATLON_DIV, - epfd_legends[ais->type4.epfd], + EPFD_DISPLAY(ais->type4.epfd), JSON_BOOL(ais->type4.raim), ais->type4.radio); } else { (void)snprintf(buf + strlen(buf), buflen - strlen(buf), @@ -1782,7 +1785,7 @@ void json_aivdm_dump(const struct ais_t *ais, SHIPTYPE_DISPLAY(ais->type5.shiptype), ais->type5.to_bow, ais->type5.to_stern, ais->type5.to_port, ais->type5.to_starboard, - epfd_legends[ais->type5.epfd], ais->type5.month, + EPFD_DISPLAY(ais->type5.epfd), ais->type5.month, ais->type5.day, ais->type5.hour, ais->type5.minute, ais->type5.draught / 10.0, json_stringify(buf3, sizeof(buf3), @@ -2786,7 +2789,7 @@ void json_aivdm_dump(const struct ais_t *ais, ais->type19.to_stern, ais->type19.to_port, ais->type19.to_starboard, - epfd_legends[ais->type19.epfd], + EPFD_DISPLAY(ais->type19.epfd), JSON_BOOL(ais->type19.raim), ais->type19.dte, JSON_BOOL(ais->type19.assigned)); } else { @@ -2863,7 +2866,7 @@ void json_aivdm_dump(const struct ais_t *ais, JSON_BOOL(ais->type21.accuracy), ais->type21.to_bow, ais->type21.to_stern, ais->type21.to_port, ais->type21.to_starboard, - epfd_legends[ais->type21.epfd], ais->type21.second, + EPFD_DISPLAY(ais->type21.epfd), ais->type21.second, ais->type21.regional, JSON_BOOL(ais->type21.off_position), JSON_BOOL(ais->type21.raim), |