diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-23 14:16:16 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-23 14:16:16 -0400 |
commit | 696b86fbe25ea688df61bbc327eb3f58719cf0b1 (patch) | |
tree | 918f90dbb17475425ebc7ce22a5d4699ab31f8b6 /driver_ais.c | |
parent | b647482472848d69610d22d1767a070fd7113afd (diff) | |
download | gpsd-696b86fbe25ea688df61bbc327eb3f58719cf0b1.tar.gz |
libgps version bump to 22: AIS types 6 and 8 get 'structured' member.
Diffstat (limited to 'driver_ais.c')
-rw-r--r-- | driver_ais.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/driver_ais.c b/driver_ais.c index 1610401e..d47c380a 100644 --- a/driver_ais.c +++ b/driver_ais.c @@ -65,9 +65,7 @@ bool ais_binary_decode(const int debug, struct ais_type24_queue_t *type24_queue) /* decode an AIS binary packet */ { - bool structured; - unsigned int u; - int i; + unsigned int u; int i; #ifdef S_SPLINT_S assert(type24_queue != NULL); @@ -188,7 +186,7 @@ bool ais_binary_decode(const int debug, ais->type6.bitcount = bitlen - 88; /* not strictly required - helps stability in testing */ (void)memset(ais->type6.bitdata, '\0', sizeof(ais->type6.bitdata)); - structured = false; + ais->type6.structured = false; /* Inland AIS */ if (ais->type6.dac == 200) { switch (ais->type6.fid) { @@ -207,7 +205,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac200fid21.tugs = UBITS(228, 3); ais->type6.dac200fid21.airdraught = UBITS(231, 12); /* skip 5 bits */ - structured = true; + ais->type6.structured = true; break; case 22: /* RTA at lock/bridge/terminal */ if (bitlen != 232) @@ -223,7 +221,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac200fid22.minute = UBITS(222, 6); ais->type6.dac200fid22.status = UBITS(228, 2); /* skip 2 bits */ - structured = true; + ais->type6.structured = true; break; case 55: /* Number of Persons On Board */ if (bitlen != 168) @@ -232,7 +230,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac200fid55.passengers = UBITS(96, 13); ais->type6.dac200fid55.personnel = UBITS(109, 8); /* skip 51 bits */ - structured = true; + ais->type6.structured = true; break; } break; @@ -252,7 +250,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac235fid10.stat_ext = UBITS(123, 8); ais->type6.dac235fid10.off_pos = UBITS(131, 1); /* skip 4 bits */ - structured = true; + ais->type6.structured = true; break; } break; @@ -277,7 +275,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac1fid12.amount = UBITS(345, 10); ais->type6.dac1fid12.unit = UBITS(355, 2); /* skip 3 bits */ - structured = true; + ais->type6.structured = true; break; case 14: /* IMO236 - Tidal Window */ ais->type6.dac1fid32.month = UBITS(88, 4); @@ -299,18 +297,18 @@ bool ais_binary_decode(const int debug, ais->type6.dac1fid32.ntidals = u; #undef ARRAY_BASE #undef ELEMENT_SIZE - structured = true; + ais->type6.structured = true; break; case 15: /* IMO236 - Extended Ship Static and Voyage Related Data */ ais->type6.dac1fid15.airdraught = UBITS(56, 11); - structured = true; + ais->type6.structured = true; break; case 16: /* IMO236 - Number of persons on board */ if (ais->type6.bitcount == 136) ais->type6.dac1fid16.persons = UBITS(88, 13);/* 289 */ else ais->type6.dac1fid16.persons = UBITS(55, 13);/* 236 */ - structured = true; + ais->type6.structured = true; break; case 18: /* IMO289 - Clearance time to enter port */ ais->type6.dac1fid18.linkage = UBITS(88, 10); @@ -323,7 +321,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac1fid18.lon = SBITS(268, 25); ais->type6.dac1fid18.lat = SBITS(293, 24); /* skip 43 bits */ - structured = true; + ais->type6.structured = true; break; case 20: /* IMO289 - Berthing data - addressed */ ais->type6.dac1fid20.linkage = UBITS(88, 10); @@ -364,7 +362,7 @@ bool ais_binary_decode(const int debug, UCHARS(191, ais->type6.dac1fid20.berth_name); ais->type6.dac1fid20.berth_lon = SBITS(311, 25); ais->type6.dac1fid20.berth_lat = SBITS(336, 24); - structured = true; + ais->type6.structured = true; break; case 23: /* IMO289 - Area notice - addressed */ break; @@ -376,7 +374,7 @@ bool ais_binary_decode(const int debug, ais->type6.dac1fid25.cargos[u].subtype = UBITS(104+u*17,13); } ais->type6.dac1fid25.ncargos = u; - structured = true; + ais->type6.structured = true; break; case 28: /* IMO289 - Route info - addressed */ ais->type6.dac1fid28.linkage = UBITS(88, 10); @@ -397,12 +395,12 @@ bool ais_binary_decode(const int debug, } #undef ARRAY_BASE #undef ELEMENT_SIZE - structured = true; + ais->type6.structured = true; break; case 30: /* IMO289 - Text description - addressed */ ais->type6.dac1fid30.linkage = UBITS(88, 10); ENDCHARS(98, ais->type6.dac1fid30.text); - structured = true; + ais->type6.structured = true; break; case 32: /* IMO289 - Tidal Window */ ais->type6.dac1fid32.month = UBITS(88, 4); @@ -424,10 +422,10 @@ bool ais_binary_decode(const int debug, ais->type6.dac1fid32.ntidals = u; #undef ARRAY_BASE #undef ELEMENT_SIZE - structured = true; + ais->type6.structured = true; break; } - if (!structured) + if (!ais->type6.structured) (void)memcpy(ais->type6.bitdata, (char *)bits + (88 / BITS_PER_BYTE), (ais->type6.bitcount + 7) / 8); @@ -458,7 +456,7 @@ bool ais_binary_decode(const int debug, ais->type8.bitcount = bitlen - 56; /* not strictly required - helps stability in testing */ (void)memset(ais->type8.bitdata, '\0', sizeof(ais->type8.bitdata)); - structured = false; + ais->type8.structured = false; if (ais->type8.dac == 1) switch (ais->type8.fid) { case 11: /* IMO236 - Meteorological/Hydrological data */ @@ -499,7 +497,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac1fid11.preciptype = UBITS(332, 3); ais->type8.dac1fid11.salinity = UBITS(335, 9); ais->type8.dac1fid11.ice = UBITS(344, 2); - structured = true; + ais->type8.structured = true; break; case 13: /* IMO236 - Fairway closed */ UCHARS(56, ais->type8.dac1fid13.reason); @@ -516,19 +514,19 @@ bool ais_binary_decode(const int debug, ais->type8.dac1fid13.thour = UBITS(457, 5); ais->type8.dac1fid13.tminute = UBITS(462, 6); /* skip 4 bits */ - structured = true; + ais->type8.structured = true; break; case 15: /* IMO236 - Extended ship and voyage */ ais->type8.dac1fid15.airdraught = UBITS(56, 11); /* skip 5 bits */ - structured = true; + ais->type8.structured = true; break; case 16: /* Number of Persons On Board */ if (ais->type8.bitcount == 136) ais->type8.dac1fid16.persons = UBITS(88, 13);/* 289 */ else ais->type8.dac1fid16.persons = UBITS(55, 13);/* 236 */ - structured = true; + ais->type8.structured = true; break; case 17: /* IMO289 - VTS-generated/synthetic targets */ #define ARRAY_BASE 56 @@ -561,7 +559,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac1fid17.ntargets = u; #undef ARRAY_BASE #undef ELEMENT_SIZE - structured = true; + ais->type8.structured = true; break; case 19: /* IMO289 - Marine Traffic Signal */ ais->type8.dac1fid19.linkage = UBITS(56, 10); @@ -574,7 +572,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac1fid19.minute = UBITS(247, 6); ais->type8.dac1fid19.nextsignal = UBITS(253, 5); /* skip 102 bits */ - structured = true; + ais->type8.structured = true; break; case 21: /* IMO289 - Weather obs. report from ship */ break; @@ -603,12 +601,12 @@ bool ais_binary_decode(const int debug, } #undef ARRAY_BASE #undef ELEMENT_SIZE - structured = true; + ais->type8.structured = true; break; case 29: /* IMO289 - Text Description - broadcast */ ais->type8.dac1fid29.linkage = UBITS(56, 10); ENDCHARS(66, ais->type8.dac1fid29.text); - structured = true; + ais->type8.structured = true; break; case 31: /* IMO289 - Meteorological/Hydrological data */ ais->type8.dac1fid31.lon = SBITS(56, 25); @@ -649,7 +647,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac1fid31.preciptype = UBITS(336, 3); ais->type8.dac1fid31.salinity = UBITS(339, 9); ais->type8.dac1fid31.ice = UBITS(348, 2); - structured = true; + ais->type8.structured = true; break; } else if (ais->type8.dac == 200) { @@ -668,7 +666,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac200fid10.course_q = (bool)UBITS(158, 1); ais->type8.dac200fid10.heading_q = (bool)UBITS(159, 1); /* skip 8 bits */ - structured = true; + ais->type8.structured = true; break; case 23: /* EMMA warning */ if (bitlen != 256) @@ -693,7 +691,7 @@ bool ais_binary_decode(const int debug, ais->type8.dac200fid23.intensity = UBITS(244, 2); ais->type8.dac200fid23.wind = UBITS(246, 4); /* skip 6 bits */ - structured = true; + ais->type8.structured = true; break; case 24: /* Water level */ if (bitlen != 168) @@ -710,7 +708,7 @@ bool ais_binary_decode(const int debug, #undef ARRAY_BASE #undef ELEMENT_SIZE /* skip 6 bits */ - structured = true; + ais->type8.structured = true; break; case 40: /* Signal status */ if (bitlen != 168) @@ -722,12 +720,12 @@ bool ais_binary_decode(const int debug, ais->type8.dac200fid40.direction = UBITS(124, 3); ais->type8.dac200fid40.status = UBITS(127, 30); /* skip 11 bits */ - structured = true; + ais->type8.structured = true; break; } } /* land here if we failed to match a known DAC/FID */ - if (!structured) + if (!ais->type8.structured) (void)memcpy(ais->type8.bitdata, (char *)bits + (56 / BITS_PER_BYTE), (ais->type8.bitcount + 7) / 8); |