summaryrefslogtreecommitdiff
path: root/driver_nmea2000.c
diff options
context:
space:
mode:
authorReinhard Arlt <reinhard.arlt@t-online.de>2012-08-22 10:07:20 +0200
committerReinhard Arlt <reinhard.arlt@t-online.de>2012-08-22 10:07:20 +0200
commit221b7d774bc6862490ade04a41f23de6e086dbda (patch)
treed39a49ae78e65c070afd1ab196fb0cca3faaa53e /driver_nmea2000.c
parent94ee992380a979e61925f5cb44b3beef7e2d7dbf (diff)
downloadgpsd-221b7d774bc6862490ade04a41f23de6e086dbda.tar.gz
Fix scaling in nmea2000 AIS decoder.
Diffstat (limited to 'driver_nmea2000.c')
-rw-r--r--driver_nmea2000.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index 8b258eea..816eefaa 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -106,6 +106,7 @@ static void decode_ais_header(unsigned char *bu, int len, struct ais_t *ais)
printf("NMEA2000 AIS message type %2d, MMSI %09d:\n", ais->type, ais->mmsi);
}
+
static int ais_turn_rate(int rate)
{
if (rate < 0) {
@@ -115,6 +116,12 @@ static int ais_turn_rate(int rate)
}
+static double ais_direction(unsigned int val, double scale)
+{
+ return(val * RAD_2_DEG * 0.0001 * scale);
+}
+
+
static gps_mask_t hnd_059392(unsigned char *bu, int len, PGN *pgn, struct gps_device_t *session)
{
print_data(bu, len, pgn);
@@ -368,15 +375,14 @@ static gps_mask_t hnd_129038(unsigned char *bu, int len, PGN *pgn, struct gps_de
ais->type1.accuracy = (bu[13] >> 0) & 0x01;
ais->type1.raim = (bu[13] >> 1) & 0x01;
ais->type1.second = (bu[13] >> 2) & 0x3f;
- ais->type1.course = getles16(bu, 14) * RAD_2_DEG * 0.001;
- ais->type1.speed = getleu16(bu, 16) * 0.5144 * 0.1;
+ ais->type1.course = ais_direction(getleu16(bu, 14), 10.0);
+ ais->type1.speed = getleu16(bu, 16) * MPS_TO_KNOTS * 0.01 / 0.1;
ais->type1.radio = getleu32(bu, 18) & 0x7ffff;
- ais->type1.heading = getles16(bu, 21) * RAD_2_DEG * 0.0001;
+ ais->type1.heading = ais_direction(getleu16(bu, 21), 1.0);
ais->type1.turn = ais_turn_rate(getles16(bu, 23));
ais->type1.status = (bu[25] >> 0) & 0xff;
ais->type1.maneuver = 0; /* Not transmitted ???? */
- printf("lon:%10.6f lat:%10.6f\n", ais->type1.lon/600000.0, ais->type1.lat/600000.0);
return(ONLINE_SET | AIS_SET);
}