diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | ais_json.c | 4 | ||||
-rw-r--r-- | gpsd_json.c | 25 | ||||
-rw-r--r-- | gpsdecode.c | 23 |
4 files changed, 56 insertions, 1 deletions
@@ -1,4 +1,7 @@ -* Tue Mar 2 2010 Eric S. Raymond <esr@snark.thyrsus.com> - 2.92 +* Tue Mar 6 2010 Eric S. Raymond <esr@snark.thyrsus.com> - 2.92 + Support for JSON dumping and parsing of AIS message types 25 and 26, + not yet observed in the wild on AISHub. + Fix a packaging error. The new Python library module was inadvertently omitted from the 2.91 tarball. Also, improve the json import test slightly. @@ -136,6 +136,10 @@ int json_ais_read(const char *buf, status = json_read_object(buf, json_ais22, endptr); } else if (strstr(buf, "\"type\":24,") != NULL) { status = json_read_object(buf, json_ais24, endptr); + } else if (strstr(buf, "\"type\":25,") != NULL) { + status = json_read_object(buf, json_ais25, endptr); + } else if (strstr(buf, "\"type\":26,") != NULL) { + status = json_read_object(buf, json_ais26, endptr); } else { if (endptr != NULL) *endptr = NULL; diff --git a/gpsd_json.c b/gpsd_json.c index becfe3e2..8edd3848 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -1281,6 +1281,31 @@ void aivdm_json_dump(const struct ais_t *ais, bool scaled, /*@out@*/char *buf, s ais->type24.dim.to_starboard); } break; + case 25: /* Binary Message, Single Slot */ + (void)snprintf(buf+strlen(buf), buflen-strlen(buf), + "\"addressed\":%s,\"structured\":%s,\"dest_mmsi\":%u," + "\"app_id\":%u,\"data\":\"%zd:%s\"}\r\n", + JSON_BOOL(ais->type25.addressed), + JSON_BOOL(ais->type25.structured), + ais->type25.dest_mmsi, + ais->type25.app_id, + ais->type25.bitcount, + gpsd_hexdump(ais->type25.bitdata, + (ais->type25.bitcount+7)/8)); + break; + case 26: /* Binary Message, Multiple Slot */ + (void)snprintf(buf+strlen(buf), buflen-strlen(buf), + "\"addressed\":%s,\"structured\":%s,\"dest_mmsi\":%u," + "\"app_id\":%u,\"data\":\"%zd:%s\"\"radio\":%u}\r\n", + JSON_BOOL(ais->type26.addressed), + JSON_BOOL(ais->type26.structured), + ais->type26.dest_mmsi, + ais->type26.app_id, + ais->type26.bitcount, + gpsd_hexdump(ais->type26.bitdata, + (ais->type26.bitcount+7)/8), + ais->type26.radio); + break; default: if (buf[strlen(buf)-1] == ',') buf[strlen(buf)-1] = '\0'; diff --git a/gpsdecode.c b/gpsdecode.c index 37cf6db2..7ac3bca5 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -341,6 +341,29 @@ static void aivdm_csv_dump(struct ais_t *ais, char *buf, size_t buflen) ais->type24.dim.to_starboard); } break; + case 25: /* Binary Message, Single Slot */ + (void)snprintf(buf+strlen(buf), buflen-strlen(buf), + "%u,%u,%u,%u,%zd:%s\r\n", + (uint)ais->type25.addressed, + (uint)ais->type25.structured, + ais->type25.dest_mmsi, + ais->type25.app_id, + ais->type25.bitcount, + gpsd_hexdump(ais->type25.bitdata, + (ais->type25.bitcount+7)/8)); + break; + case 26: /* Binary Message, Multiple Slot */ + (void)snprintf(buf+strlen(buf), buflen-strlen(buf), + "%u,%u,%u,%u,%zd:%s:%u\r\n", + (uint)ais->type26.addressed, + (uint)ais->type26.structured, + ais->type26.dest_mmsi, + ais->type26.app_id, + ais->type26.bitcount, + gpsd_hexdump(ais->type26.bitdata, + (ais->type26.bitcount+7)/8), + ais->type26.radio); + break; default: (void)snprintf(buf+strlen(buf), buflen-strlen(buf), "unknown AIVDM message content."); |