Discussion:
[ntp:questions] NTP rejecting SHM for NMEA GPS and PPS
n***@datacloud.com
2018-08-10 22:06:15 UTC
Permalink
Hi, I am trying to use a Garmin GPS18x LVC receiver to synchronize my laptop clock using NTP. I have found several documents with similar instructions as to how to make this work and so far I've had no luck. I am able to receive the GPS NMEA string via a usb port:

~$ cat /dev/ttyUSB0
I�����b����r����br�12207.2689,W,2,09,0.8,10.6,M,-32.4,M,,*4E

$GPGSA,A,3,05,13,15,16,20,21,25,26,29,,,,1.2,0.8,0.9*3D

$GPGSV,3,1,11,05,21,045,15,13,22,086,27,15,30,129,29,16,19,317,25*7A

$GPGSV,3,2,11,20,35,220,19,21,53,298,26,25,20,188,17,26,34,292,20*7C

$GPGSV,3,3,11,29,71,104,37,02,01,080,00,10,09,217,00*42

$GPRMC,215057,A,3727.0074,N,12207.2690,W,000.0,020.0,100818,013.8,E,D*09

$GPGGA,215057,3727.0074,N,12207.2690,W,2,09,0.8,10.6,M,-32.4,M,,*40

$GPGSA,A,3,05,13,15,16,20,21,25,26,29,,,,1.2,0.8,0.9*3D

$GPGSV,3,1,11,05,21,045,15,13,22,086,27,15,30,129,29,16,19,317,25*7A

$GPGSV,3,2,11,20,35,220,19,21,53,298,26,25,20,188,17,26,34,292,20*7C

$GPGSV,3,3,11,29,71,104,37,02,01,080,00,10,09,217,00*42


If I monitor the GPS input via gpsmon I can see all the information is there, including the 1PPS pulse:

/dev/ttyUSB0 4800 8N1 NMEA0183>
┌──────────────────────────────────────────────────────────────────────────────┐
│Time: 2018-08-10T21:58:28.000Z Lat: 37 27' 00.215" N Lon: 122 07' 15.888" W │
└───────────────────────────────── Cooked TPV ─────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│ GPRMC GPGGA GPGSA GPGSV PGRMT │
└───────────────────────────────── Sentences ──────────────────────────────────┘
┌──────────────────┐┌────────────────────────────┐┌────────────────────────────┐
│Ch PRN Az El S/N ││Time: 215828 ││Time: 215828 │
│ 0 5 45 18 16 ││Latitude: 3727.0036 N ││Latitude: 3727.0036 │
│ 1 13 82 23 20 ││Longitude: 12207.2648 W ││Longitude: 12207.2648 │
│ 2 15 126 32 34 ││Speed: 000.0 ││Altitude: 45.8 │
│ 3 16 315 21 19 ││Course: 194.5 ││Quality: 2 Sats: 08 │
│ 4 20 222 39 22 ││Status: A FAA: D ││HDOP: 1.0 │
│ 5 21 302 55 23 ││MagVar: 013.8E ││Geoid: -32.4 │
│ 6 26 287 34 24 │└─────────── RMC ────────────┘└─────────── GGA ────────────┘
│ 7 29 112 68 16 │┌────────────────────────────┐┌────────────────────────────┐
│ 8 10 219 12 0 ││Mode: A3 Sats: 5 13 15 16 2 ││UTC: RMS: │
│ 9 25 188 18 0 ││DOP: H=1.0 V=0.9 P=1.3 ││MAJ: MIN: │
│10 ││TOFF: 0.611384951 ││ORI: LAT: │
│11 ││PPS: 0.000169339 ││LON: ALT: │
└────── GSV ───────┘└──────── GSA + PPS ─────────┘└─────────── GST ────────────┘
(70) $GPGSV,3,2,10,20,39,222,22,21,55,302,23,26,34,287,24,29,68,112,16*78


However, ntp does not recognize and reject the SHM peers


ntpq> pe
remote refid st t when poll reach delay offset jitter
==============================================================================
0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 0.000 0.000
SHM(0) .NMEA. 0 l - 16 0 0.000 0.000 0.000
SHM(1) .PPS. 0 l - 16 0 0.000 0.000 0.000
#208.76.53.137 216.218.254.202 2 u 46 64 17 76.696 3.673 0.552
-12.167.151.2 198.148.79.210 3 u 51 64 17 78.516 2.003 0.281
+x.ns.gin.ntt.ne 249.224.99.213 2 u 48 64 17 4.576 0.418 0.464
-mdnworldwide.co 216.218.254.202 2 u 50 64 17 49.261 0.094 1.015
*darwin.kenyonra 127.67.113.92 2 u 45 64 17 5.362 0.354 0.494
-lv1.justaguy.be 127.67.113.92 2 u 47 64 17 23.820 -1.319 0.603
-66-188-102-122. 34.225.6.20 3 u 52 64 17 81.602 -3.496 4.033
+propjet.latt.ne 14.82.97.170 2 u 46 64 17 4.421 -1.750 1.819
-nu.binary.net 204.9.54.119 2 u 49 64 17 53.228 -6.678 0.723
-dns-e.wdc-us.ho 64.113.44.54 2 u 50 64 17 76.942 1.555 1.099
golem.canonical 145.238.203.14 2 u 52 64 17 137.693 0.367 15.467
-195.21.152.161 195.66.241.2 2 u 49 64 17 10.487 -1.236 0.707
#64.52.22.96 (64 199.102.46.72 2 u 47 64 17 13.617 0.187 0.980
pugot.canonical 17.253.34.125 2 u 53 64 17 139.481 0.624 35.522

ntpq> as

ind assid status conf reach auth condition last_event cnt
===========================================================
1 33742 8811 yes none none reject mobilize 1
2 33743 8811 yes none none reject mobilize 1
3 33744 8811 yes none none reject mobilize 1
4 33745 8811 yes none none reject mobilize 1
5 33746 8811 yes none none reject mobilize 1
6 33747 802b yes no none reject clock_alarm 2
7 33748 802b yes no none reject clock_alarm 2
8 33749 1524 no yes none backup reachable 2
9 33750 1324 no yes none outlier reachable 2
10 33751 1424 no yes none candidate reachable 2
11 33752 1324 no yes none outlier reachable 2
12 33753 163a no yes none sys.peer sys_peer 3
13 33754 133a no yes none outlier sys_peer 3
14 33755 1324 no yes none outlier reachable 2
15 33756 1424 no yes none candidate reachable 2
16 33757 1324 no yes none outlier reachable 2
17 33758 1324 no yes none outlier reachable 2
18 33759 1024 no yes none reject reachable 2
19 33760 1324 no yes none outlier reachable 2
20 33761 1524 no yes none backup reachable 2
21 33762 1024 no yes none reject reachable 2

This is what I have added to the ntp.conf file

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
pool 0.ubuntu.pool.ntp.org iburst
pool 1.ubuntu.pool.ntp.org iburst
pool 2.ubuntu.pool.ntp.org iburst
pool 3.ubuntu.pool.ntp.org iburst

# Use Ubuntu's ntp server as a fallback.
pool ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Needed for adding pool entries
restrict source notrap nomodify noquery

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust

restrict 172.56.3.0 mask 255.255.255.0 nomodify


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
disable auth
broadcastclient

#Changes recquired to use pps synchonisation as explained in documentation:
#http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm#AEN3918

#server 127.127.8.1 mode 135 prefer # Meinberg GPS167 with PPS
#fudge 127.127.8.1 time1 0.0042 # relative to PPS for my hardware

#server 127.127.22.1 # ATOM(PPS)
#fudge 127.127.22.1 flag3 1 # enable PPS API

# GPS Serial data reference
server 127.127.28.0 minpoll 4
fudge 127.127.28.0 time1 0.183 refid NMEA

# GPS PPS reference
server 127.127.28.1 minpoll 4 prefer
fudge 127.127.28.1 refid PPS


I am at a loss as to what is happening and how to fix it. Any suggestions are welcome
n***@datacloud.com
2018-08-10 22:16:41 UTC
Permalink
I forgot to mention that I am using Ubuntu 16.04 and the GPS receiver is connected via USB
David Taylor
2018-08-11 15:08:38 UTC
Permalink
Post by n***@datacloud.com
I forgot to mention that I am using Ubuntu 16.04 and the GPS receiver is connected via USB
USB is not the best to get good results. You need to connect the PPS
signal directly to a port on the device - typically the CD (carrier
detect) line on a _true_ serial port is used. Likely the
serial-over-USB is rejected because of excessive jitter.

I don't know whether you may have your "prefer" in the wrong place
without looking in detail. You need the "prefer" against a server which
will provide the coarse seconds (i.e. a clock) otherwise the PPS edge
will not be recognised (as NTP needs both coarse time and the exact
second). You may, or may not, be correct.
--
Cheers,
David
Web: http://www.satsignal.eu
Loading...