From: Dave Hart Date: Fri, 15 May 2009 19:37:17 +0000 (+0000) Subject: [Bug 1190] NMEA refclock fudge flag4 1 obscures position in timecode X-Git-Tag: NTP_4_2_5P177~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11ca7e73e3b606dfe5efcd1e25821bc9330cb540;p=thirdparty%2Fntp.git [Bug 1190] NMEA refclock fudge flag4 1 obscures position in timecode Update NMEA documentation for a number of changes over the last year bk: 4a0dc46dwYqqhwXf5J3bBsDA0EefcQ --- diff --git a/ChangeLog b/ChangeLog index 5f7ac97cb..bed1efe16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 1190] NMEA refclock fudge flag4 1 obscures position in timecode +* Update NMEA refclock documentation in html/drivers/driver20.html (4.2.5p176) 2009/05/13 Released by Harlan Stenn * [Bug 1154] mDNS registration should be done later, repeatedly and only if asked for. (second try for fix) diff --git a/html/drivers/driver20.html b/html/drivers/driver20.html index f297b5bc2..f85dab653 100644 --- a/html/drivers/driver20.html +++ b/html/drivers/driver20.html @@ -4,7 +4,6 @@ - Generic NMEA GPS Receiver @@ -16,21 +15,23 @@

Address: 127.127.20.u
Reference ID: GPS
Driver ID: GPS_NMEA
- Serial Port: /dev/gpsu; 4800/9600 baud, 8-bits, no parity
+ Serial Port: /dev/gpsu; 4800 - 115200 bps, 8-bits, no parity
Serial Port: /dev/gpsppsu; for just the PPS signal (this is tried first for PPS, before /dev/gpsu)
Serial Port: /dev/gpsu; symlink to server:port (for nmead) Features: tty_clk

Description

-

This driver supports GPS receivers with the $GPRMC NMEA output string by default.  Alternately the $GPGGA or $GPGLL may be selected. The driver also supports Accord's custom NMEA sentence $GPZDG, which gives GPS time unlike rest of the sentences which give UTC.

-

The driver expects the receiver to be set up to transmit a $GPRMC message every second.

-

The accuracy depend on the receiver used. Inexpesive GPS models are available with a claimed PPS signal accuracy of 1 ms or better relative to the broadcast signal. However, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.

+

This driver supports GPS receivers with the $GPRMC, $GPGLL, $GPGGA, $GPZDA, and $GPZDG NMEA sentences by default.  Note that Accord's custom NMEA sentence $GPZDG reports using the GPS timescale, while the rest of the sentences report UTC.  The difference between the two is a whole number of seconds which increases with each leap second insertion in UTC.  To avoid problems mixing UTC and GPS timescales, the driver disables processing of UTC sentences once $GPZDG is received.

+

The driver expects the receiver to be set up to transmit at least one supported sentence every second.

+

The accuracy depends on the receiver used. Inexpensive GPS models are available with a claimed PPS signal accuracy of 1 ms or better relative to the broadcast signal. However, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.

If the Operating System supports the PPSAPI, RFC-2783, it will be used.
 

The various GPS sentences that this driver recognises look like this:
(others quietly ignored)

-
$GPRMC,POS_UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CC<cr><lf>
-$GPGLL,LAT,LAT_REF,LONG,LONG_REF,POS_UTC,POS_STAT*CC<cr><lf>
-$GPGGA,POS_UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CC<cr><lf>
+		
$GPRMC,UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CS<cr><lf>
+$GPGLL,LAT,LAT_REF,LONG,LONG_REF,UTC,POS_STAT*CS<cr><lf>
+$GPGGA,UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CS<cr><lf>
+$GPZDA,UTC,DD,MM,YYYY,TH,TM,*CS<cr><lf>
+$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS<cr><lf>
 
-  POS_UTC  - UTC of position. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])
+  UTC      - Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])
   POS_STAT - Position status. (A = Data valid, V = Data invalid)
   LAT      - Latitude (llll.ll)
   LAT_REF  - Latitude direction. (N = North, S = South)
@@ -50,12 +51,7 @@ $GPGGA,POS_UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO
   G_UNIT   - Geoid units (M/F)
   D_AGE    - Age of last DGPS Fix
   D_REF    - Reference ID of DGPS station
-  CC       - Checksum (optional)
-  <cr><lf> - Sentence terminator.
-Accord's $GPZDG has the folowing format: -
$GPZDG,POS_GPS,DD,MM,YYYY,AA.BB,V*CS<cr><lf>
-
-  POS_GPS  - GPS of position. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])
+  GPSTIME  - Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])
   DD       - Day of the month (1-31)
   MM       - Month of the year (1-12)
   YYYY     - Year
@@ -67,10 +63,11 @@ Accord's $GPZDG has the folowing format:
   CS       - Checksum
   <cr><lf> - Sentence terminator.
-

Alternate GPS sentences (other than $GPRMC - the default) and baudrates may be enabled by setting the relevent bits of 'mode' in the server configuration line
 * server 127.127.20.x mode X
    bit 0 - enables RMC    (value = 1)
    bit 1 - enables GGA    (value = 2)
    bit 2 - enables GLL     (value = 4)
    bit 3 - enables ZDG    (value = 8)
-

Multiple sentences may be selected except when ZDG is enabled. The driver falls back to standard NMEA sentences when incorrent selection is configured.The driver uses 4800 baudrate by default. Altenatively, 9600 baudrate can be selected by using the fourth bit of 'mode' field;

-     bit 4 - selects baudrate   ( 0 for 4800 - the default, 1 for 9600 )

-

The driver will send a $PMOTG,RMC,0000*1D<cr><lf> message each time a $GPRMC string is needed. This is not needed on most GPS receivers because they automatically send the $GPRMC string every second and will only work on GPS receivers that understand the $PMOTG string. Others will just ignore it.

+

Specific GPS sentences and bitrates may be selected by setting bits of the 'mode' in the server configuration line:
+   server 127.127.20.x mode X
    bit 0 - process $GPMRC    (value = 1)
    bit 1 - process $GPGGA    (value = 2)
    bit 2 - process $GPGLL     (value = 4)
    bit 4 - process $GPZDA or $GPZDG    (value = 8)
+

The default (mode 0) is to process all supported sentences, which results in the last received each cycle being used.  Multiple sentences may be selected by adding their mode bit values.  The driver uses 4800 bits per second by default.  Faster bitrates can be selected using bits 4, 5, and 6 of the mode field:

+     bits 4/5/6 - select serial bitrate   ( 0 for 4800 - the default, 1 for 9600, 2 for 19200, 3 for 38400, 4 for 57600, 5 for 115200 )

+

The driver will send a $PMOTG,RMC,0000*1D<cr><lf> command each poll interval.  This is not needed on most GPS receivers because they automatically send $GPRMC every second, but helps a Motorola GPS receiver that is otherwise silent.  NMEA devices ignore commands they do not understand.

Setting up the Garmin GPS-25XL

Switch off all output with by sending it the following string.
"$PGRMO,,2<cr><lf>"
@@ -79,7 +76,7 @@ Accord's $GPZDG has the folowing format:

On some systems the PPS signal isn't switched on by default. It can be switched on by sending the following string.

"$PGRMC,,,,,,,,,,,,2<cr><lf>"

Monitor Data

-

The GPS sentence(s) that is used is written to the clockstats file.

+

The GPS sentence that is used is written to the clockstats file and available with ntpq -c clockvar.

Fudge Factors

time1 time @@ -97,7 +94,7 @@ Accord's $GPZDG has the folowing format:
flag3 0 | 1
Controls the kernel PPS discipline: 0 for disable (default), 1 for enable.
flag4 0 | 1 -
Not used by this driver. +
Obscures location in timecode: 0 for disable (default), 1 for enable.

Additional Information

Reference Clock Drivers

diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c index 5de620820..e207d17ef 100644 --- a/ntpd/refclock_nmea.c +++ b/ntpd/refclock_nmea.c @@ -8,7 +8,7 @@ * neo.venu@gmail.com, venugopal_d@pgad.gov.in * * Updated to process 'time1' fudge factor - * Venu Gopal May 05, 2008 + * Venu Gopal May 05, 2008 */ #ifdef HAVE_CONFIG_H #include @@ -31,7 +31,6 @@ #ifdef SYS_WINNT extern int async_write(int, const void *, unsigned int); -#undef write #define write(fd, data, octets) async_write(fd, data, octets) #endif @@ -66,12 +65,12 @@ extern int async_write(int, const void *, unsigned int); * Multiple sentences may be selected except when ZDG/ZDA is selected. * * bit 4/5/6 - selects the baudrate for serial port : - * 0 for 4800 (default) - * 1 for 9600 - * 2 for 19200 - * 3 for 38400 - * 4 for 57600 - * 5 for 115200 + * 0 for 4800 (default) + * 1 for 9600 + * 2 for 19200 + * 3 for 38400 + * 4 for 57600 + * 5 for 115200 */ #define NMEA_MESSAGE_MASK_OLD 0x07 #define NMEA_MESSAGE_MASK_SINGLE 0x08 @@ -612,7 +611,7 @@ nmea_receive( /* Grab field depending on clock string type */ switch (cmdtype) { - case GPRMC: + case GPRMC: /* * Test for synchronization. Check for quality byte. */ @@ -626,7 +625,7 @@ nmea_receive( dp = field_parse(cp, 1); break; - case GPGGA: + case GPGGA: /* * Test for synchronization. Check for quality byte. */ @@ -640,7 +639,7 @@ nmea_receive( dp = field_parse(cp, 1); break; - case GPGLL: + case GPGLL: /* * Test for synchronization. Check for quality byte. */ @@ -654,7 +653,7 @@ nmea_receive( dp = field_parse(cp, 5); break; - case GPZDG_ZDA: + case GPZDG_ZDA: /* * Test for synchronization. For $GPZDG check for validity of GPS time. */ @@ -671,7 +670,7 @@ nmea_receive( dp = field_parse(cp, 1); break; - default: + default: return; } @@ -792,6 +791,83 @@ nmea_receive( } pp->day = day; + /* + * If "fudge 127.127.20.__ flag4 1" is configured in ntp.conf, + * remove the location and checksum from the NMEA sentence + * recorded as the last timecode and visible to remote users + * with: + * + * ntpq -c clockvar + * + * Note that this also removes the location from the clockstats + * log (if it is enabled). Some NTP operators monitor their + * NMEA GPS using the change in location in clockstats over + * time as as a proxy for the quality of GPS reception and + * thereby time reported. + */ + if (CLK_FLAG4 & pp->sloppyclockflag) { + /* + * Start by pointing cp and dp at the fields with + * longitude and latitude in the last timecode. + */ + switch (cmdtype) { + + case GPGLL: + cp = field_parse(pp->a_lastcode, 1); + dp = field_parse(cp, 2); + break; + + case GPGGA: + cp = field_parse(pp->a_lastcode, 2); + dp = field_parse(cp, 2); + break; + + case GPRMC: + cp = field_parse(pp->a_lastcode, 3); + dp = field_parse(cp, 2); + break; + + case GPZDG_ZDA: + default: + cp = dp = NULL; + } + + /* + * Blanking everything after the decimal point '.' is easy and + * gives enough error for at least a few neighbors to be as + * likely as you to be the one with the reflock. We're keeping + * degrees and minutes but tossing the seconds (expressed as + * decimal fractions of a minute). Degrees minutes seconds, + * not hours minutes seconds. :) + */ + while (cp) { + while (',' != *cp) { + if ('.' != *cp) + *cp = '_'; + cp++; + } + + /* + * blank the longitude at cp then the latitude at dp + * then we're done. + */ + if (cp < dp) + cp = dp; + else + cp = NULL; + } + + /* + * blank the checksum, last two characters on the line + */ + if (dp) { + cp = pp->a_lastcode + pp->lencode - 2; + if (0 == cp[2]) + cp[0] = cp[1] = '_'; + } + + } + #ifdef HAVE_PPSAPI /* * If the PPSAPI is working, rather use its timestamps.