From 80fefe1798bcd638ce4d0a59211f0a86d1ab6774 Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Mon, 25 Mar 2019 20:11:15 -0700 Subject: driver_nmea0183: Add decode for $PGRME. Another one with cycle ender issues... --- driver_nmea0183.c | 97 ++++++++++++++++++++++++++++++++++++++----- test/daemon/garmin17n.log.chk | 3 +- 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/driver_nmea0183.c b/driver_nmea0183.c index 74a57b8e..ac47597a 100644 --- a/driver_nmea0183.c +++ b/driver_nmea0183.c @@ -1423,6 +1423,81 @@ static gps_mask_t processPGRME(int c UNUSED, char *field[], return mask; } +/* Garmin GPS Fix Data Sentence + * + * FIXME: seems to happen after cycle ender, so little happens... + */ +static gps_mask_t processPGRMF(int c UNUSED, char *field[], + struct gps_device_t *session) +{ + /* + * $PGRMF,290,293895,160305,093802,13,5213.1439,N,02100.6511,E,A,2,0,226,2,1*11 + * + * 1 = GPS week + * 2 = GPS seconds + * 3 = UTC Date ddmmyy + * 4 = UTC time hhmmss + * 5 = GPS leap seconds + * 6 = Latitude ddmm.mmmm + * 7 = N or S + * 8 = Longitude dddmm.mmmm + * 9 = E or W + * 10 = Mode, M = Manual, A = Automatic + * 11 = Fix type, 0 = No fix, 2 = 2D fix, 2 = 3D fix + * 12 = Ground Speed, 0 to 1151 km/hr + * 13 = Course over ground, 0 to 359 degrees true + * 14 = pdop, 0 to 9 + * 15 = dop, 0 to 9 + */ + gps_mask_t mask = ONLINE_SET; + + if (0 == merge_hhmmss(field[4], session) && + 0 == merge_ddmmyy(field[3], session)) { + /* got a good data/time */ + mask |= TIME_SET; + } + if ('A' != field[10][0]) { + /* Huh? */ + return mask; + } + if ('\0' != field[5][0]) { + session->context->leap_seconds = atoi(field[5]); + session->context->valid = LEAP_SECOND_VALID; + } + if (0 == do_lat_lon(&field[6], &session->newdata)) { + mask |= LATLON_SET; + } + switch (field[11][0]) { + default: + /* Huh? */ + break; + case '0': + session->newdata.mode = MODE_NO_FIX; + mask |= MODE_SET; + break; + case '1': + session->newdata.mode = MODE_2D; + mask |= MODE_SET; + break; + case '2': + session->newdata.mode = MODE_3D; + mask |= MODE_SET; + break; + } + session->newdata.speed = safe_atof(field[12]) / MPS_TO_KPH; + session->newdata.track = safe_atof(field[13]); + mask |= SPEED_SET | TRACK_SET; + session->gpsdata.dop.pdop = safe_atof(field[14]); + session->gpsdata.dop.tdop = safe_atof(field[15]); + mask |= DOP_SET; + + gpsd_log(&session->context->errout, LOG_DATA, + "PGRMF: pdop %.1f tdop %.1f \n", + session->gpsdata.dop.pdop, + session->gpsdata.dop.tdop); + return mask; +} + /* Garmin Map Datum * * FIXME: seems to happen after cycle ender, so nothing happens... @@ -2532,17 +2607,17 @@ gps_mask_t nmea_parse(char *sentence, struct gps_device_t * session) bool cycle_continue; /* cycle continuer? */ nmea_decoder decoder; } nmea_phrase[] = { - {"PGRMB", 0, false, NULL}, /* ignore Garmin DGPS Beacon Info */ - {"PGRMC", 0, false, NULL}, /* ignore Garmin Sensor Config */ - {"PGRME", 7, false, processPGRME}, - {"PGRMF", 0, false, NULL}, /* ignore Garmin GPS Fix Data */ - {"PGRMH", 0, false, NULL}, /* ignore Garmin Aviation Height... */ - {"PGRMI", 0, false, NULL}, /* ignore Garmin Sensor Init */ - {"PGRMM", 2, false, processPGRMM}, /* Garmin Map Datum */ - {"PGRMO", 0, false, NULL}, /* ignore Garmin Sentence Enable */ - {"PGRMT", 0, false, NULL}, /* ignore Garmin Sensor Info */ - {"PGRMV", 0, false, NULL}, /* ignore Garmin 3D Velocity Info */ - {"PGRMZ", 4, false, processPGRMZ}, + {"PGRMB", 0, false, NULL}, /* ignore Garmin DGPS Beacon Info */ + {"PGRMC", 0, false, NULL}, /* ignore Garmin Sensor Config */ + {"PGRME", 7, false, processPGRME}, + {"PGRMF", 15, false, processPGRMF}, /* Garmin GPS Fix Data */ + {"PGRMH", 0, false, NULL}, /* ignore Garmin Aviation Height... */ + {"PGRMI", 0, false, NULL}, /* ignore Garmin Sensor Init */ + {"PGRMM", 2, false, processPGRMM}, /* Garmin Map Datum */ + {"PGRMO", 0, false, NULL}, /* ignore Garmin Sentence Enable */ + {"PGRMT", 0, false, NULL}, /* ignore Garmin Sensor Info */ + {"PGRMV", 0, false, NULL}, /* ignore Garmin 3D Velocity Info */ + {"PGRMZ", 4, false, processPGRMZ}, /* * Basic sentences must come after the PG* ones, otherwise * Garmins can get stuck in a loop that looks like this: diff --git a/test/daemon/garmin17n.log.chk b/test/daemon/garmin17n.log.chk index fda5f45d..c86a123f 100644 --- a/test/daemon/garmin17n.log.chk +++ b/test/daemon/garmin17n.log.chk @@ -11,6 +11,7 @@ $GPGLL,5213.1439,N,02100.6511,E,093802,A,D*48 $GPVTG,226,T,222,M,000.0,N,0000.0,K,D*12 $PGRMV,0.0,0.0,0.0*5C $PGRMF,290,293895,160305,093802,13,5213.1439,N,02100.6511,E,A,2,0,226,2,1*11 +{"class":"TPV","status":2,"mode":3,"time":"2005-03-16T09:38:02.000Z","leapseconds":13,"ept":0.005,"lat":52.219065000,"lon":21.010851667,"alt":137.200,"epx":2.496,"epy":2.496,"epv":4.983,"track":226.0000,"magtrack":222.0000,"speed":0.000,"eph":4.275,"sep":6.229} $PGRMB,0.0,200,,,,K,,W,W*31 $PGRMM,WGS 84*06 $GPRMC,093803,A,5213.1439,N,02100.6511,E,000.0,226.0,160305,004.2,E,D*14 @@ -20,7 +21,7 @@ $GPGSV,3,3,12,26,14,065,48,27,08,336,38,29,14,048,44,44,18,130,41*78 {"class":"SKY","xdop":0.86,"ydop":0.85,"vdop":1.30,"tdop":1.11,"hdop":0.90,"gdop":2.71,"pdop":1.60,"satellites":[{"PRN":18,"el":50,"az":135,"ss":50,"used":true,"gnssid":0,"svid":18},{"PRN":19,"el":15,"az":291,"ss":46,"used":true,"gnssid":0,"svid":19},{"PRN":21,"el":59,"az":69,"ss":51,"used":true,"gnssid":0,"svid":21},{"PRN":22,"el":30,"az":169,"ss":49,"used":true,"gnssid":0,"svid":22},{"PRN":26,"el":14,"az":65,"ss":48,"used":false,"gnssid":0,"svid":26},{"PRN":27,"el":8,"az":336,"ss":38,"used":true,"gnssid":0,"svid":27},{"PRN":29,"el":14,"az":48,"ss":44,"used":true,"gnssid":0,"svid":29},{"PRN":131,"el":18,"az":130,"ss":41,"used":false,"gnssid":1,"svid":131}]} $PGRME,1.7,M,2.4,M,3.0,M*2D $GPGLL,5213.1439,N,02100.6511,E,093803,A,D*49 -{"class":"TPV","status":2,"mode":3,"time":"2005-03-16T09:38:03.000Z","ept":0.005,"lat":52.219065000,"lon":21.010851667,"alt":137.200,"epx":2.496,"epy":2.496,"epv":4.983,"track":226.0000,"speed":0.000,"climb":0.000,"eps":5.71,"epc":12.46,"eph":4.275,"sep":6.229} +{"class":"TPV","status":2,"mode":3,"time":"2005-03-16T09:38:03.000Z","leapseconds":13,"ept":0.005,"lat":52.219065000,"lon":21.010851667,"alt":137.200,"epx":2.496,"epy":2.496,"epv":4.983,"track":226.0000,"speed":0.000,"climb":0.000,"eps":5.71,"epc":12.46,"eph":4.275,"sep":6.229} $GPVTG,226,T,222,M,000.0,N,0000.0,K,D*12 $PGRMV,0.0,0.0,0.0*5C $PGRMF,290,293896,160305,093803,13,5213.1439,N,02100.6511,E,A,2,0,226,2,1*13 -- cgit v1.2.1