summaryrefslogtreecommitdiff
path: root/driver_nmea2000.c
diff options
context:
space:
mode:
authorReinhard Arlt <reinhard.arlt@t-online.de>2015-05-08 11:02:58 +0200
committerReinhard Arlt <reinhard.arlt@t-online.de>2015-05-08 11:02:58 +0200
commit1b5f56735b56a0d26d1e53d9f09d63b7591c2f73 (patch)
tree4b64e7aeaab1ab9fc5c28bfdac9e8f27be9b83a1 /driver_nmea2000.c
parentd6d606e4ddb3dd3f293fef4a98a5b656fffe19e4 (diff)
downloadgpsd-1b5f56735b56a0d26d1e53d9f09d63b7591c2f73.tar.gz
Handle ais type 4 and type 11 in nmea2000.
Diffstat (limited to 'driver_nmea2000.c')
-rw-r--r--driver_nmea2000.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index 028e05e6..df1a0939 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -602,11 +602,46 @@ static gps_mask_t hnd_129793(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) {
+ uint32_t time;
+ uint32_t date;
+ time_t date1;
+ struct tm date2;
+
ais->type4.lon = (int) scale_int(getles32(bu, 5), (int64_t)(SHIFT32 *.06L));
ais->type4.lat = (int) scale_int(getles32(bu, 9), (int64_t)(SHIFT32 *.06L));
ais->type4.accuracy = (bool) ((bu[13] >> 0) & 0x01);
ais->type4.raim = (bool) ((bu[13] >> 1) & 0x01);
+ time = getleu32(bu, 14);
+ if (time != 0xffffffff) {
+ ais->type4.second = time % 60; time = time / 60;
+ ais->type4.minute = time % 60; time = time / 60;
+ ais->type4.hour = time % 24;
+ } else {
+ ais->type4.second = AIS_SECOND_NOT_AVAILABLE;
+ ais->type4.minute = AIS_MINUTE_NOT_AVAILABLE;
+ ais->type4.hour = AIS_HOUR_NOT_AVAILABLE;
+ }
+
+ ais->type4.radio = (unsigned int) (getleu32(bu, 18) & 0x7ffff);
+
+ date = getleu16(bu, 21);
+ if (date != 0xffff) {
+ date1 = (time_t)date * (24L *60L *60L);
+ (void) gmtime_r(&date1, &date2);
+ ais->type4.year = (unsigned int) (date2.tm_year+1900);
+ ais->type4.month = (unsigned int) (date2.tm_mon+1);
+ ais->type4.day = (unsigned int) (date2.tm_mday);
+ } else {
+ ais->type4.day = AIS_DAY_NOT_AVAILABLE;
+ ais->type4.month = AIS_MONTH_NOT_AVAILABLE;
+ ais->type4.year = AIS_YEAR_NOT_AVAILABLE;
+ }
+
+ ais->type4.epfd = (unsigned int) ((bu[23] >> 4) & 0x0f);
+
+ decode_ais_channel_info(bu, len, 163, session);
+
return(ONLINE_SET | AIS_SET);
}
return(0);