### Generic NMEA GPS Receiver

#### Synopsis

Address: 127.127.20.u
Reference ID: `GPS`
Driver ID: `GPS_NMEA`
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, $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 PPSAPI (RFC 2783), fudge flag1 1 enables its use.

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

    $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>

      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)
      LON      - Longitude (yyyyy.yy)
      LON_REF  - Longitude direction (E = East, W = West)
      SPD      - Speed over ground. (knots) (x.x)
      HDG      - Heading/track made good (degrees True) (x.x)
      DATE     - Date (ddmmyy)
      MAG_VAR  - Magnetic variation (degrees) (x.x)
      MAG_REF  - Magnetic variation (E = East, W = West)
      FIX_MODE - Position Fix Mode (0 = Invalid, >0 = Valid)
      SAT_USED - Number Satellites used in solution
      HDOP     - Horizontal Dilution of Precision
      ALT      - Antenna Altitude
      ALT_UNIT - Altitude Units (Metres/Feet)
      GEO      - Geoid/Elipsoid separation
      G_UNIT   - Geoid units (M/F)
      D_AGE    - Age of last DGPS Fix
      D_REF    - Reference ID of DGPS station
      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
      AA.BB    - Denotes the signal strength (should be < 05.00)
      V        - GPS sync status
                '0' => INVALID time,
                '1' => accuracy of +/- 20ms,
                '2' => accuracy of +/- 100ns
      CS       - Checksum
      <cr><lf> - Sentence terminator.

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, 16 for 9600, 32 for 19200, 48 for 38400, 64 for 57600, 80 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>"

Now switch only $GPRMC on by sending it the following string.

    "$PGRMO,GPRMC,1<cr><lf>"

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 that is used is written to the clockstats file and available with ntpq -c clockvar.

#### Fudge Factors

`time1 time`
  Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0.
`time2 time`
  Specifies the serial end of line time offset calibration factor, in seconds and fraction, with default 0.0.
`stratum number`
  Specifies the driver stratum, in decimal from 0 to 15, with default 0.
`refid string`
  Specifies the driver reference identifier, an ASCII string from one to four characters, with default `GPS`.
`flag1 0 | 1`
  Disable PPS signal processing if 0 (default); enable PPS signal processing if 1.
`flag2 0 | 1`
  If PPS signal processing is enabled, capture the pulse on the rising edge if 0 (default); capture on the falling edge if 1.
`flag3 0 | 1`
  If PPS signal processing is enabled, use the `ntpd` clock discipline if 0 (default); use the kernel discipline if 1.
`flag4 0 | 1`
  Obscures location in timecode: 0 for disable (default), 1 for enable.

Additional Information

Reference Clock Drivers