From 1223dda6e36ac123e9b68148ed7a0e12d9c5a439 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 18 Apr 2011 21:15:25 -0400 Subject: In AIS, support for message class 8 dac=1 fid=29. --- ais_json.c | 6 +++++- driver_aivdm.c | 5 ++++- gps.h | 8 +++++++- gpsd_json.c | 15 ++++++++------- jsongen.py.in | 15 ++++++++++++++- www/AIVDM.txt | 6 +++--- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/ais_json.c b/ais_json.c index ad0f5ee0..67126a3d 100644 --- a/ais_json.c +++ b/ais_json.c @@ -117,7 +117,11 @@ int json_ais_read(const char *buf, status = json_read_object(buf, json_ais7, endptr); } else if (strstr(buf, "\"type\":8,") != NULL) { bool imo = false; - if (strstr(buf, "\"fid\":31,") != NULL || strstr(buf, "\"fid\":11,") != NULL) { + if (strstr(buf, "\"fid\":29,") != NULL) { + status = json_read_object(buf, json_ais8_fid29, endptr); + imo = true; + } + else if (strstr(buf, "\"fid\":31,") != NULL || strstr(buf, "\"fid\":11,") != NULL) { status = json_read_object(buf, json_ais8_fid31, endptr); imo = true; } diff --git a/driver_aivdm.c b/driver_aivdm.c index 3aca0869..8e6aec46 100644 --- a/driver_aivdm.c +++ b/driver_aivdm.c @@ -504,8 +504,11 @@ bool aivdm_decode(const char *buf, size_t buflen, case 27: /* IMO289 - Route information - broadcast */ break; case 29: /* IMO289 - Text Description - broadcast */ + ais->type8.dac1fid29.linkage = UBITS(56, 10); + from_sixbit((char *)ais_context->bits, + 56, ais_context->bitlen-56, + ais->type8.dac1fid29.text); break; - case 30: /* IMO289 - Text Description - addressed */ break; case 31: /* IMO289 - Meteorological/Hydrological data */ ais->type8.dac1fid31.lat = SBITS(56, 24); diff --git a/gps.h b/gps.h index 5fdc4f1e..81d7ef39 100644 --- a/gps.h +++ b/gps.h @@ -963,7 +963,6 @@ struct ais_t } type7; /* Type 8 - Broadcast Binary Message */ struct { - /* IMO236 & IMO289 - Meteorological-Hydrological data */ //unsigned int spare; spare bit(s) */ unsigned int dac; /* Designated Area Code */ unsigned int fid; /* Functional ID */ @@ -971,6 +970,13 @@ struct ais_t size_t bitcount; /* bit count of the data */ union { char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8]; + /* IMO289 - Text message (broadcast) */ + struct { + unsigned int linkage; +#define AIS_DAC1FID29_TEXT_MAX 162 /* 920 bits of six-bit, plus NUL */ + char text[AIS_DAC1FID29_TEXT_MAX]; + } dac1fid29; + /* IMO236 & IMO289 - Meteorological-Hydrological data */ struct { bool accuracy; /* position accuracy, <10m if true */ #define DAC1FID31_LATLON_SCALE 1000 diff --git a/gpsd_json.c b/gpsd_json.c index 5d8605bf..8469dc84 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -1765,6 +1765,8 @@ void json_aivdm_dump(const struct ais_t *ais, break; case 18: /* IMO289 - Clearance time to enter port */ break; + case 23: /* IMO289 - Area notice - addressed */ + break; case 25: /* IMO289 = Dangerous cargo indication */ break; case 28: /* IMO289 - Route info - addressed */ @@ -1910,7 +1912,7 @@ void json_aivdm_dump(const struct ais_t *ais, preciptypes[ais->type8.dac1fid31.preciptype], ais->type8.dac1fid31.salinity * 0.1, JSON_BOOL(ais->type8.dac1fid31.ice)); - }else + } else (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"leveltrend\":%u," "\"cspeed\":%u,\"cdir\":%u" @@ -1956,8 +1958,6 @@ void json_aivdm_dump(const struct ais_t *ais, break; case 22: /* IMO289 - Area notice - broadcast */ break; - case 23: /* IMO289 - Area notice - addressed */ - break; case 24: /* IMO289 - Extended ship static & voyage-related data */ break; case 25: /* IMO289 - Dangerous Cargo Indication */ @@ -1965,10 +1965,11 @@ void json_aivdm_dump(const struct ais_t *ais, case 27: /* IMO289 - Route information - broadcast */ break; case 29: /* IMO289 - Text Description - broadcast */ - break; - case 30: /* IMO289 - Text Description - addressed */ - break; - case 32: /* Tidal Window */ + (void)snprintf(buf + strlen(buf), buflen - strlen(buf), + "\"linkage\":%u,\"text\":\"%s\"}\r\n", + ais->type8.dac1fid29.linkage, + json_stringify(buf1, sizeof(buf1), + ais->type8.dac1fid29.text)); break; } } diff --git a/jsongen.py.in b/jsongen.py.in index d420293f..979f2d34 100644 --- a/jsongen.py.in +++ b/jsongen.py.in @@ -122,7 +122,7 @@ ais_specs = ( ('dac1fid30.linkage', 'uinteger', '0'), ('dac1fid30.text', 'string', '0'), ), - "stringbuffered":("dacfid31.text",), + "stringbuffered":("dacfid30.text",), }, { "initname" : "json_ais6_fid32", @@ -172,6 +172,19 @@ ais_specs = ( "stringbuffered":("data",), }, { + "initname" : "json_ais8_fid29", + "header": "\tAIS_HEADER,", + "structname": "ais->type8", + "fieldmap":( + # fieldname type default + ('dac', 'uinteger', '0'), + ('fid', 'uinteger', '0'), + ('dac1fid29.linkage', 'uinteger', '0'), + ('dac1fid29.text', 'string', '0'), + ), + "stringbuffered":("dacfid29.text",), + }, + { "initname" : "json_ais8_fid31", "header": "\tAIS_HEADER,", "structname": "ais->type8", diff --git a/www/AIVDM.txt b/www/AIVDM.txt index 8660c826..0f0f5403 100644 --- a/www/AIVDM.txt +++ b/www/AIVDM.txt @@ -441,7 +441,7 @@ location transmission in military exercises. It is also used for unencrypted structured extension messages by local authorities such as the St. Lawrence Seaway and PAWSS. This document describes all of the Class 8 special message formats approved for use in <> and -<> except Area Report (FID = 22) and Environmental (FID=26). +<> except Area Notices (FID = 22,23) and Environmental (FID=26). Classes 12 and 14 are used for safety-related text messaging. @@ -2031,7 +2031,7 @@ Information (addressed)" message (DAC=1, FID=28). ==== Text description (broadcast) ==== -A message 8 subtype. DAC = 001 FID = 29. Variable length: 72-1034 bits. +A message 8 subtype. DAC = 001 FID = 29. Variable length: 72-1032 bits. Intended to be used to associate a text annotation with another message via the Message Linkage ID field. @@ -2045,7 +2045,7 @@ via the Message Linkage ID field. |38-39 | 2 |Spare | |Not used |40-55 | 16 |DAC/FID | |DAC = 001 FID = 29 |56-65 | 10 |Message Linkage ID |linkage |Unsigned integer -|66-? | 6-930 |Description |description |String +|66-? | 6-966 |Description |description |String |============================================================================== There is an equivalent subtype of message 6 that is an addressed description. -- cgit v1.2.1