summaryrefslogtreecommitdiff
path: root/driver_nmea2000.c
diff options
context:
space:
mode:
authorReinhard Arlt <reinhard.arlt@t-online.de>2013-11-08 11:02:19 +0100
committerReinhard Arlt <reinhard.arlt@t-online.de>2013-11-08 11:02:19 +0100
commit414b99fc1237f442d14e4604c0eaadc6d1b9f667 (patch)
tree2e9deae0939d7f1f36a98d8ea03adeac1509c1c4 /driver_nmea2000.c
parente126711d710ad6dbbaf83021b3b49f60a9c52994 (diff)
downloadgpsd-414b99fc1237f442d14e4604c0eaadc6d1b9f667.tar.gz
Honor split24 flag in ais msg24 part b.
Diffstat (limited to 'driver_nmea2000.c')
-rw-r--r--driver_nmea2000.c124
1 files changed, 71 insertions, 53 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index a0a1db38..353d4960 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -839,71 +839,89 @@ static gps_mask_t hnd_129810(unsigned char *bu, int len, PGN *pgn, struct gps_de
"pgn %6d(%3d):\n", pgn->pgn, session->driver.nmea2000.unit);
if (decode_ais_header(session->context, bu, len, ais, 0xffffffffU) != 0) {
- int i, l;
+ int l;
- for (i = 0; i < MAX_TYPE24_INTERLEAVE; i++) {
- if (session->driver.aivdm.context[0].type24_queue.ships[i].mmsi == ais->mmsi) {
- for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) {
- ais->type24.shipname[l] = (char)(session->driver.aivdm.context[0].type24_queue.ships[i].shipname[l]);
- }
- ais->type24.shipname[AIS_SHIPNAME_MAXLEN] = (char) 0;
+ ais->type24.shiptype = (unsigned int) ((bu[ 5] >> 0) & 0xff);
- ais->type24.shiptype = (unsigned int) ((bu[ 5] >> 0) & 0xff);
+ for (l=0;l<7;l++) {
+ ais->type24.vendorid[l] = (char) bu[ 6+l];
+ }
+ ais->type24.vendorid[7] = (char) 0;
- for (l=0;l<7;l++) {
- ais->type24.vendorid[l] = (char) bu[ 6+l];
- }
- ais->type24.vendorid[7] = (char) 0;
+ for (l=0;l<7;l++) {
+ ais->type24.callsign[l] = (char) bu[13+l];
+ }
+ ais->type24.callsign[7] = (char )0;
- for (l=0;l<7;l++) {
- ais->type24.callsign[l] = (char) bu[13+l];
- }
- ais->type24.callsign[7] = (char )0;
+ if (AIS_AUXILIARY_MMSI(ais->mmsi)) {
+ ais->type24.mothership_mmsi = (unsigned int) (getleu32(bu, 28));
+ } else {
+ uint16_t length, beam, to_bow, to_starboard;
+
+ length = getleu16(bu, 20);
+ beam = getleu16(bu, 22);
+ to_starboard = getleu16(bu, 24);
+ to_bow = getleu16(bu, 26);
+ ais->type24.dim.to_bow = (unsigned int) (to_bow/10);
+ ais->type24.dim.to_stern = (unsigned int) ((length-to_bow)/10);
+ ais->type24.dim.to_port = (unsigned int) ((beam-to_starboard)/10);
+ ais->type24.dim.to_starboard = (unsigned int) (to_starboard/10);
+ if ((length == 0xffff) || (to_bow == 0xffff)) {
+ length = 0;
+ to_bow = 0;
+ }
+ if ((beam == 0xffff) || (to_starboard == 0xffff)) {
+ beam = 0;
+ to_starboard = 0;
+ }
+ }
- if (AIS_AUXILIARY_MMSI(ais->mmsi)) {
- ais->type24.mothership_mmsi = (unsigned int) (getleu32(bu, 28));
- } else {
- uint16_t length, beam, to_bow, to_starboard;
-
- length = getleu16(bu, 20);
- beam = getleu16(bu, 22);
- to_starboard = getleu16(bu, 24);
- to_bow = getleu16(bu, 26);
- ais->type24.dim.to_bow = (unsigned int) (to_bow/10);
- ais->type24.dim.to_stern = (unsigned int) ((length-to_bow)/10);
- ais->type24.dim.to_port = (unsigned int) ((beam-to_starboard)/10);
- ais->type24.dim.to_starboard = (unsigned int) (to_starboard/10);
- if ((length == 0xffff) || (to_bow == 0xffff)) {
- length = 0;
- to_bow = 0;
- }
- if ((beam == 0xffff) || (to_starboard == 0xffff)) {
- beam = 0;
- to_starboard = 0;
- }
- }
+ if (session->gpsdata.policy.split24 == true) {
+#if NMEA2000_DEBUG_AIS
+ printf("AIS: MMSI : %09u\n", ais->mmsi);
+ printf("AIS: vendor: %-8.8s c:%-8.8s b:%6u s:%6u p:%6u s:%6u\n",
+ ais->type24.vendorid,
+ ais->type24.callsign,
+ ais->type24.dim.to_bow,
+ ais->type24.dim.to_stern,
+ ais->type24.dim.to_port,
+ ais->type24.dim.to_starboard);
+#endif /* of #if NMEA2000_DEBUG_AIS */
+ decode_ais_channel_info(bu, len, 264, session);
+ ais->type24.part = part_b;
+ return(ONLINE_SET | AIS_SET);
- gpsd_report(session->context->debug, LOG_PROG,
- "NMEA2000: AIS 24B from %09u matches a 24A.\n",
- ais->mmsi);
- /* prevent false match if a 24B is repeated */
- session->driver.aivdm.context[0].type24_queue.ships[i].mmsi = 0;
+ } else {
+ int i;
+
+ for (i = 0; i < MAX_TYPE24_INTERLEAVE; i++) {
+ if (session->driver.aivdm.context[0].type24_queue.ships[i].mmsi == ais->mmsi) {
+ for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) {
+ ais->type24.shipname[l] = (char)(session->driver.aivdm.context[0].type24_queue.ships[i].shipname[l]);
+ }
+ ais->type24.shipname[AIS_SHIPNAME_MAXLEN] = (char) 0;
+
+ gpsd_report(session->context->debug, LOG_PROG,
+ "NMEA2000: AIS 24B from %09u matches a 24A.\n",
+ ais->mmsi);
+ /* prevent false match if a 24B is repeated */
+ session->driver.aivdm.context[0].type24_queue.ships[i].mmsi = 0;
#if NMEA2000_DEBUG_AIS
- printf("AIS: MMSI: %09u\n",
- ais->mmsi);
- printf("AIS: name: %-20.20s v:%-8.8s c:%-8.8s b:%6u s:%6u p:%6u s:%6u\n",
- ais->type24.shipname,
- ais->type24.vendorid,
- ais->type24.callsign,
- ais->type24.dim.to_bow,
- ais->type24.dim.to_stern,
- ais->type24.dim.to_port,
- ais->type24.dim.to_starboard);
+ printf("AIS: MMSI: %09u\n", ais->mmsi);
+ printf("AIS: name: %-20.20s v:%-8.8s c:%-8.8s b:%6u s:%6u p:%6u s:%6u\n",
+ ais->type24.shipname,
+ ais->type24.vendorid,
+ ais->type24.callsign,
+ ais->type24.dim.to_bow,
+ ais->type24.dim.to_stern,
+ ais->type24.dim.to_port,
+ ais->type24.dim.to_starboard);
#endif /* of #if NMEA2000_DEBUG_AIS */
decode_ais_channel_info(bu, len, 264, session);
ais->type24.part = both;
return(ONLINE_SET | AIS_SET);
+ }
}
}
gpsd_report(session->context->debug, LOG_WARN, "NMEA2000: AIS 24B from %09u can't be matched to a 24A.\n", ais->mmsi);