[ntp:questions] How to get shared memory access from gpsd to ntpd to work?

Etaoin Shrdlu etaoin at clickworkorange.com
Wed Aug 16 12:52:44 UTC 2017


Hi all, 

I've been battling for some time with getting ntpd to set the date/time
from gpsd's shared memory locations. My GPS device is on the network
and sends GPS messages every minute over UDP. This is picked up by gpsd
and it appears I get a good fix with all the required data. It also
looks as if the shared memory locations are being set up correctly. But
whatever I do, ntpd time source "reach" stubbornly remains at zero,
even when running ntpd as root. I would be most grateful if someone
could cast their eyes on the configurations and log output below, and
let me know if you can see were it's going wrong! 

P.S. This has been cross-posted from gpsd-users at nongnu.org, where I
failed to get any response to my query. 


# syslog gpsd startup: 

Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: launching (Version 3.11)
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: listening on port gpsd
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: NTPD shmat(0,0,0) succeeded, segment 0
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: NTPD shmat(32769,0,0) succeeded, segment 1
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: NTPD shmat(65538,0,0) succeeded, segment 2
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: NTPD shmat(98307,0,0) succeeded, segment 3
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: successfully connected to the DBUS system bus
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: shmat() succeeded, segment 131076
Aug  6 19:28:16 computer gpsd[374]: gpsd:PROG: shared-segment creation succeeded,
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: stashing device udp://192.168.13.100:10110 at slot 0
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: opening UDP feed at 192.168.13.100, port 10110.
Aug  6 19:28:16 computer gpsd[374]: gpsd:ERROR: UDP device open error can't connect to host/port pair.
Aug  6 19:28:16 computer gpsd[374]: gpsd:ERROR: initial GPS device udp://192.168.13.100:10110 open failed
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: running with effective group ID 20
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: running with effective user ID 110
Aug  6 19:28:16 computer gpsd[374]: gpsd:INFO: startup at 2017-08-06T19:28:16.000Z (1502047696)

# syslog ntpd startup:

Aug  6 19:28:24 computer ntpd[609]: ntpd 4.2.6p5 at 1.2349-o Mon Jul 25 22:35:28 UTC 2016 (1)
Aug  6 19:28:24 computer ntp[582]: Starting NTP server: ntpd.
Aug  6 19:28:24 computer ntpd[652]: proto: precision = 0.781 usec
Aug  6 19:28:24 computer ntpd[652]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Aug  6 19:28:24 computer systemd[1]: Started LSB: Start NTP daemon.
Aug  6 19:28:25 computer ntpd[652]: Listen and drop on 1 v6wildcard :: UDP 123
Aug  6 19:28:25 computer ntpd[652]: Listen normally on 2 lo 127.0.0.1 UDP 123
Aug  6 19:28:25 computer ntpd[652]: Listen normally on 3 eth0 192.168.13.100 UDP 123
Aug  6 19:28:25 computer ntpd[652]: Listen normally on 4 lo ::1 UDP 123
Aug  6 19:28:25 computer ntpd[652]: Listen normally on 5 eth0 fe80::6a89:f1d3:7ec0:510 UDP 123
Aug  6 19:28:25 computer ntpd[652]: peers refreshed
Aug  6 19:28:25 computer ntpd[652]: Listening on routing socket on fd #22 for interface updates

# syslog gpsd sample: 

Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGGA,185748.0,1234.567890,N,00012.345678,E,1,10,0.9,13.6,M,47.0,M,,*6B
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: GPGGA sentence timestamped 185748.00.
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: GPGGA starts a reporting cycle.
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPRMC,185748.0,A,1234.567890,N,00012.345678,E,0.0,,060817,0.0,E,A*2B
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: GPRMC sentence timestamped 185748.00.
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: GPRMC ends a reporting cycle.
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPVTG,,T,0.0,M,0.0,N,0.0,K,A*0D
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGSA,A,2,01,03,06,09,11,17,19,22,23,31,,,1.2,0.9,0.8*31
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: GPGSA sets mode 2
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGSV,4,1,13,01,31,136,41,03,67,068,35,06,32,303,31,09,34,202,41*78
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: Partial satellite data (1 of 4).
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGSV,4,2,13,11,09,153,39,17,40,243,40,19,42,272,30,22,42,082,40*78
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: Partial satellite data (2 of 4).
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGSV,4,3,13,23,61,174,46,31,19,047,36,12,04,329,,14,00,039,*76
Aug  6 19:56:42 computer gpsd[374]: gpsd:PROG: Partial satellite data (3 of 4).
Aug  6 19:56:42 computer gpsd[374]: gpsd:IO: <= GPS: $GPGSV,4,4,13,25,01,001,*4C


# /etc/default/gpsd

START_DAEMON="true"
USBAUTO="false"
DEVICES="udp://192.168.13.100:10110"
GPSD_OPTIONS="-n -D5"


# ntpd.conf: 

GPS Serial data reference (NTP0)
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 time1 0.0 refid GPS

GPS PPS reference (NTP1)
server 127.127.28.1 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.1 refid PPS


# ntpq -p                                                                                                                                         Sun Aug  6 19:48:25 2017

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 SHM(0)          .GPS.            0 l    -   16    0    0.000    0.000   0.000
 SHM(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000


# cat /proc/sysvipc/shm                                                                                                                           Sun Aug  6 19:30:45 2017

       key      shmid perms       size  cpid  lpid nattch   uid   gid  cuid  cgid      atime      dtime      ctime        rss       swap
1314148400          0   600         80   374   652      2     0     0     0     0 1502047705          0 1502047696       4096          0
1314148401      32769   600         80   374   652      2     0     0     0     0 1502047705          0 1502047696       4096          0
1314148402      65538   666         80   374   374      1     0     0     0     0 1502047696          0 1502047696          0          0
1314148403      98307   666         80   374   374      1     0     0     0     0 1502047696          0 1502047696          0          0
1196446532     131076   666      31616   374   374      1     0     0     0     0 1502047696          0 1502047696          0          0


# gpsmon:

tcp://localhost:2947          JSON slave driver>
(83) {"class":"VERSION","release":"3.11","rev":"3.11-3","proto_major":3,"proto_minor":9}
(125) {"class":"DEVICES","devices":[{"class":"DEVICE","path":"udp://192.168.13.100:10110","activated":"2017-08-06T19:31:50.526Z"}]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled":false,"timing":false,"split24":false,"pps":true}

tcp://localhost:2947          NMEA0183>
┌──────────────────────────────────────────────────────────────────────────────┐
│Time: 2017-08-06T18:33:45.000Z Lat:  12 34' 56.789" N Lon:   0 12' 34.567" E  │
└───────────────────────────────── Cooked TPV ─────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│ GPGGA GPRMC GPVTG GPGSA GPGSV                                                │
└───────────────────────────────── Sentences ──────────────────────────────────┘
┌──────────────────┐┌────────────────────────────┐┌────────────────────────────┐
│Ch PRN  Az El S/N ││Time:      183345.0         ││Time:      183345.0         │
│ 0   1 130 42  35 ││Latitude:   1234.567890 N   ││Latitude:  1234.567890      │
│ 1   3  52 78  40 ││Longitude:  00012.34567 E   ││Longitude: 00012.34567      │
│ 2   9 201 22  40 ││Speed:     0.0              ││Altitude:  109.4            │
│ 3  11 151 20  45 ││Course:                     ││Quality:   1   Sats: 10     │
│ 4  17 257 46  25 ││Status:    A       FAA: A   ││HDOP:      0.9              │
│ 5  19 288 41  34 ││MagVar:    0.0  E           ││Geoid:     47.0             │
│ 6  22  77 52  39 │└─────────── RMC ────────────┘└─────────── GGA ────────────┘
│ 7  23 180 50  38 │┌────────────────────────────┐┌────────────────────────────┐
│ 8  31  59 19  26 ││Mode: A2 Sats:              ││UTC:           RMS:         │
│ 9 120   0  0  35 ││DOP: H=0.9   V=0.8   P=1.2  ││MAJ:           MIN:         │
│10  12 338  5   0 ││TOFF:  3535.132782450       ││ORI:           LAT:         │
│11  14  39  9   0 ││PPS:                        ││LON:           ALT:         │
└────── GSV ───────┘└──────── GSA + PPS ─────────┘└─────────── GST ────────────┘
(83) {"class":"VERSION","release":"3.11","rev":"3.11-3","proto_major":3,"proto_minor":9}
(125) {"class":"DEVICES","devices":[{"class":"DEVICE","path":"udp://192.168.13.100:10110","activated":"2017-08-06T19:31:50.526Z"}]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled":false,"timing":false,"split24":false,"pps":true}
(73) $GPGGA,183345.0,1234.567890,N,00012.345678,E,1,10,0.9,9.4,M,47.0,M,,*5D
(71) $GPRMC,183345.0,A,1234.334342,N,00012.345678,E,0.0,,060817,0.0,E,A*24
(34) $GPVTG,,T,0.0,M,0.0,N,0.0,K,A*0D
(59) $GPGSA,A,2,01,03,06,09,11,17,19,22,23,31,,,1.2,0.9,0.8*31
(70) $GPGSV,3,1,12,01,42,130,35,03,78,052,40,09,22,201,40,11,20,151,45*7C
(70) $GPGSV,3,2,12,17,46,257,25,19,41,288,34,22,52,077,39,23,50,180,38*7B
(61) $GPGSV,3,3,12,31,19,059,26,33,,,35,12,05,338,,14,09,039,*46


More information about the questions mailing list