diff options
author | Reinhard Arlt <reinhard.arlt@t-online.de> | 2012-09-23 00:18:56 +0200 |
---|---|---|
committer | Reinhard Arlt <reinhard.arlt@t-online.de> | 2012-09-23 00:18:56 +0200 |
commit | d799f3a3a88ea1832c550e9223b1426966fce1cb (patch) | |
tree | 98c78dda60c143aa439acf948223df1eeb7d414c | |
parent | 80ecc8f59f805fda8d753818a2ca2b80098c4651 (diff) | |
download | gpsd-d799f3a3a88ea1832c550e9223b1426966fce1cb.tar.gz |
More NMEA2000 AIS messages.
-rw-r--r-- | driver_nmea2000.c | 96 |
1 files changed, 79 insertions, 17 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c index cea77907..1715b1b6 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -421,13 +421,13 @@ static gps_mask_t hnd_129039(unsigned char *bu, int len, PGN *pgn, struct gps_de ais->type18.radio = getleu32(bu, 18) & 0x7ffff; ais->type18.heading = ais_direction(getleu16(bu, 21), 1.0); ais->type18.reserved = 0; - ais->type18.regional = 0; - ais->type18.cs = 0; - ais->type18.display = 0; - ais->type18.dsc = 0; - ais->type18.band = 0; - ais->type18.msg22 = 0; - ais->type18.assigned = 0; + ais->type18.regional = (bu[24] >> 0) & 0x03; + ais->type18.cs = (bu[24] >> 2) & 0x01; + ais->type18.display = (bu[24] >> 3) & 0x01; + ais->type18.dsc = (bu[24] >> 4) & 0x01; + ais->type18.band = (bu[24] >> 5) & 0x01; + ais->type18.msg22 = (bu[24] >> 6) & 0x01; + ais->type18.assigned = (bu[24] >> 7) & 0x01; return(ONLINE_SET | AIS_SET); } @@ -444,6 +444,9 @@ static gps_mask_t hnd_129040(unsigned char *bu, int len, PGN *pgn, struct gps_de gpsd_report(LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(bu, len, ais, 0xffffffff) != 0) { + uint16_t length, beam, to_bow, to_starboard; + int l; + ais->type19.lon = getles32(bu, 5) * 0.06; ais->type19.lat = getles32(bu, 9) * 0.06; ais->type19.accuracy = (bu[13] >> 0) & 0x01; @@ -454,15 +457,23 @@ static gps_mask_t hnd_129040(unsigned char *bu, int len, PGN *pgn, struct gps_de ais->type19.reserved = (bu[18] >> 0) & 0xff; ais->type19.regional = (bu[19] >> 0) & 0x0f;; ais->type19.shiptype = (bu[20] >> 0) & 0xff; - ais->type19.heading = ais_direction(getleu16(bu, 21), 1.0); - ais->type19.to_bow = 0; - ais->type19.to_stern = 0; - ais->type19.to_port = 0; - ais->type19.to_starboard = 0; - ais->type19.epfd = 0; - ais->type19.dte = 0; - ais->type19.assigned = 0; - + ais->type19.heading = ais_direction(getleu16(bu, 21), 1.0); + length = getleu16(bu, 24); + beam = getleu16(bu, 26); + to_bow = getleu16(bu, 28); + to_starboard = getleu16(bu, 30); + ais->type19.to_bow = to_bow/10; + ais->type19.to_stern = (length-to_bow)/10; + ais->type19.to_port = (beam-to_starboard)/10; + ais->type19.to_starboard = to_starboard/10; + ais->type19.epfd = (bu[23] >> 4) & 0x0f; + ais->type19.dte = (bu[52] >> 0) & 0x01; + ais->type19.assigned = (bu[52] >> 1) & 0x01; + for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) { + ais->type19.shipname[l] = bu[32+l]; + } + ais->type19.shipname[AIS_SHIPNAME_MAXLEN] = 0; + return(ONLINE_SET | AIS_SET); } return(0); @@ -478,7 +489,58 @@ static gps_mask_t hnd_129794(unsigned char *bu, int len, PGN *pgn, struct gps_de gpsd_report(LOG_DATA, "pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit); if (decode_ais_header(bu, len, ais, 0xffffffff) != 0) { - return(0); + uint16_t length, beam, to_bow, to_starboard, date; + int l; + uint32_t time; + + ais->type5.ais_version = (bu[73] >> 0) & 0x03; + ais->type5.imo = getleu32(bu, 5); + ais->type5.shiptype = (bu[36] >> 0) & 0xff; + length = getleu16(bu, 37); + beam = getleu16(bu, 39); + to_bow = getleu16(bu, 41); + to_starboard = getleu16(bu, 43); + ais->type5.to_bow = to_bow/10; + ais->type5.to_stern = (length-to_bow)/10; + ais->type5.to_port = (beam-to_starboard)/10; + ais->type5.to_starboard = to_starboard/10; + ais->type5.epfd = (bu[73] >> 2) & 0x0f; + date = getleu16(bu, 45); + time = getleu32(bu, 47); +#if 0 + ais->type5.month = UBITS(274, 4); + ais->type5.day = UBITS(278, 5); +#endif + ais->type5.minute = time/(10000*60); + ais->type5.hour = ais->type5.minute/60; + ais->type5.minute = ais->type5.minute-(ais->type5.hour*60); + + ais->type5.draught = getleu16(bu, 51)/10; + ais->type5.dte = (bu[73] >> 6) & 0x01; + + for (l=0;l<7;l++) { + ais->type5.callsign[l] = bu[9+l]; + } + ais->type5.callsign[7] = 0; + + for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) { + ais->type5.shipname[l] = bu[16+l]; + } + ais->type5.shipname[AIS_SHIPNAME_MAXLEN] = 0; + + for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) { + ais->type19.shipname[l] = bu[32+l]; + } + ais->type19.shipname[AIS_SHIPNAME_MAXLEN] = 0; + + for (l=0;l<20;l++) { + ais->type5.destination[l] = bu[53+l]; + } + ais->type5.destination[20] = 0; + + printf("AIS: arival %s at %d %02d:%02d\n", ais->type5.destination, date, ais->type5.hour, ais->type5.minute); + + return(ONLINE_SET | AIS_SET); } return(0); } |