From 1047ab92040746ab9597ffcf57a2ced4aaffc07f Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Fri, 5 Apr 2019 17:30:44 -0700 Subject: gps.h: Add qErr to gps_fix_t. qErr, aka "sawtooth" correction, is the error in the PPS time. --- NEWS | 1 + driver_ubx.c | 6 ++++++ gps.h | 4 +++- gpsutils.c | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 5a013d90..b4588394 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Improve cycle detection, mostly for NMEA. Move epe from gps_data_t to be near its friends in gps_fix_t. Preliminary u-blox 9 support. + Add qErr in gps_data_t to store PPS quantization error. 3.18.1: 2018-10-19 (Gary E. Miller ) Fix some installation issues. diff --git a/driver_ubx.c b/driver_ubx.c index 932d2680..4d396086 100644 --- a/driver_ubx.c +++ b/driver_ubx.c @@ -1135,6 +1135,12 @@ ubx_msg_tim_tp(struct gps_device_t *session, unsigned char *buf, flags = buf[14]; refInfo = buf[15]; + /* are we UTC, and no RAIM? */ + if ((3 == (flags & 0x03)) && + (8 != (flags & 0x0c))) { + /* good, get qErr */ + session->newdata.qErr = qErr; + } /* cast for 32 bit compatibility */ gpsd_log(&session->context->errout, LOG_DATA, "TIM_TP: towMS %lu, towSubMS %lu, qErr %ld week %u\n" diff --git a/gps.h b/gps.h index a844baf3..7ba6e0b9 100644 --- a/gps.h +++ b/gps.h @@ -47,7 +47,7 @@ extern "C" { * Remove epe from gps_data_t, it duplicates gps_fix_t eph * Added sep (estimated spherical error, 3D) * Note: Some GPS call eph as epe, others call sep as epe - * Add gps_fix_t datum string + * Add gps_fix_t datum string, and qErr */ #define GPSD_API_MAJOR_VERSION 8 /* bump on incompatible changes */ #define GPSD_API_MINOR_VERSION 0 /* bump on compatible changes */ @@ -128,6 +128,8 @@ struct gps_fix_t { double vAcc; /* Velocity Accuracy Estimate, probably SEP */ } ecef; char datum[40]; /* map datum */ + /* quantization error adjustment to PPS. aka "sawtooth" correction */ + long qErr; /* offset in picoseconds (ps) */ }; /* diff --git a/gpsutils.c b/gpsutils.c index 49a6959d..feac1253 100644 --- a/gpsutils.c +++ b/gpsutils.c @@ -370,6 +370,9 @@ void gps_merge_fix(struct gps_fix_t *to, if ('\0' != from->datum[0]) { strlcpy(to->datum, from->datum, sizeof(to->datum)); } + if (0 != from->qErr) { + to->qErr = from->qErr; + } } /* NOTE: timestamp_t is a double, so this is only precise to -- cgit v1.2.1