1

Inspired by this answer: https://askubuntu.com/a/1374637 I'm attempting to get chrony to get its time from gpsd without a pulse per second.

I am aware that https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html implies that you need a pulse per second:

GPSD, NTP and a GPS receiver supplying 1PPS (one pulse-per-second) output can be used to set up a high-quality NTP time server.

I understand that without a pulse per second, the time will be subject to delay caused by the 9600 baud serial connection and jitter introduced by the (Linux) OS.

Time accurate to +/- 1 second is acceptable.

I've added the lines from the original answer (with the serial port changed):

refclock SHM 0 refid GPS precision 1e-1 offset 0 delay 0 stratum 2
refclock SOCK /var/run/chrony.ttymxc0.sock refid PPS

to /etc/chrony.conf.

I then started chrony in the foreground. All it ever reports is:

root@imx6ul-var-dart:~# chronyd -d
2022-09-08T09:27:25Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SIGND +ASYNCDNS -SECHASH +IPV6 -DEBUG)
2022-09-08T09:27:25Z Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift

It does create the socket:

root@imx6ul-var-dart:~# ls -lA /run/chrony.ttymxc2.sock 
srwxr-xr-x 1 root root 0 Sep  8 09:27 /run/chrony.ttymxc2.sock

I then run gpsd in the foreground:

root@imx6ul-var-dart:~# gpsd -N -D3 -F /run/gpsd.sock /dev/ttymxc2
gpsd:WARN: This system has a 32-bit time_t.  This gpsd will fail at 2038-01-19T03:14:07Z.
gpsd:INFO: launching (Version 3.23)
gpsd:INFO: listening on port gpsd
gpsd:INFO: stashing device /dev/ttymxc2 at slot 0
gpsd:INFO: running with effective group ID 20
gpsd:INFO: running with effective user ID 65534
gpsd:INFO: startup at 2022-09-08T09:37:52.000Z (1662629872)
gpsd:CLIENT: => client(0): {"class":"VERSION","release":"3.23","rev":"3.23","proto_major":3,"proto_minor":14}\x0d\x0a
gpsd:CLIENT: <= client(0): ?WATCH={"enable":true,"json":true};\x0a
gpsd:INFO: SER: opening GPS data source type 2 at '/dev/ttymxc2'
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8O1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: SER: speed 9600, 8N1
gpsd:INFO: gpsd_activate(2): activated GPS (fd 8)
gpsd:CLIENT: => client(0): {"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttymxc2","activated":"2022-09-08T09:38:02.070Z","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}]}\x0d\x0a{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false,"split24":false,"pps":false}\x0d\x0a
gpsd:INFO: /dev/ttymxc2 identified as type NMEA0183, 0 sec @ 9600bps
gpsd:CLIENT: => client(0): {"class":"DEVICE","path":"/dev/ttymxc2","driver":"NMEA0183","activated":"2022-09-08T09:38:02.073Z","native":0,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}\x0d\x0a
gpsd:WARN: NMEA0183: xxGSV field 3 value of 11 != actual count 7
gpsd:INFO: Sats used (0):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","nSat":7,"uSat":0,"satellites":[{"PRN":14,"el":27.0,"az":272.0,"ss":11.0,"used":false,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":false,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":13.0,"used":false,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":false,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":false,"gnssid":0,"svid":32}]}\x0d\x0a
gpsd:WARN: NMEA0183: malformed GPGSV - fieldcount 18 % 4 != 0
gpsd:WARN: NMEA0183: xxGSV field 3 value of 9 != actual count 5
gpsd:INFO: Sats used (0):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","nSat":5,"uSat":0,"satellites":[{"PRN":76,"el":16.0,"az":340.0,"ss":33.0,"used":false,"gnssid":6,"svid":12},{"PRN":77,"el":0.0,"az":23.0,"ss":0.0,"used":false,"gnssid":6,"svid":13},{"PRN":83,"el":20.0,"az":115.0,"ss":9.0,"used":false,"gnssid":6,"svid":19},{"PRN":84,"el":77.0,"az":58.0,"ss":22.0,"used":false,"gnssid":6,"svid":20},{"PRN":85,"el":30.0,"az":309.0,"ss":29.0,"used":false,"gnssid":6,"svid":21}]}\x0d\x0a
gpsd:WARN: NMEA0183: can't use GLL time until after ZDA or RMC has supplied a year.
gpsd:CLIENT: => client(0): {"class":"TPV","device":"/dev/ttymxc2","mode":2,"lat":53.232661333,"lon":-2.098090167,"magvar":-1.0}\x0d\x0a
gpsd:INFO: PRN  1 az 309.0 el 80.0 (-0.134950,  0.109280,  0.984808)
gpsd:INFO: PRN  3 az 220.0 el 49.0 (-0.421707, -0.502570,  0.754710)
gpsd:INFO: PRN  8 az 161.0 el 31.0 ( 0.279066, -0.810468,  0.515038)
gpsd:INFO: PRN 14 az 272.0 el 27.0 (-0.890464,  0.031096,  0.453990)
gpsd:INFO: PRN 17 az 309.0 el 31.0 (-0.666144,  0.539433,  0.515038)
gpsd:INFO: PRN 21 az  96.0 el 70.0 ( 0.340147, -0.035751,  0.939693)
gpsd:INFO: PRN 22 az  89.0 el 38.0 ( 0.787891,  0.013753,  0.615661)
gpsd:INFO: PRN 32 az  57.0 el 31.0 ( 0.718881,  0.466847,  0.515038)
gpsd:INFO: Sats used (8):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","xdop":0.61,"ydop":0.84,"vdop":1.36,"tdop":1.27,"hdop":0.88,"gdop":2.47,"pdop":1.62,"nSat":11,"uSat":8,"satellites":[{"PRN":1,"el":80.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":1},{"PRN":3,"el":49.0,"az":220.0,"ss":12.0,"used":true,"gnssid":0,"svid":3},{"PRN":8,"el":31.0,"az":161.0,"ss":20.0,"used":true,"gnssid":0,"svid":8},{"PRN":10,"el":2.0,"az":53.0,"ss":14.0,"used":false,"gnssid":0,"svid":10},{"PRN":14,"el":27.0,"az":272.0,"ss":8.0,"used":true,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":14.0,"used":true,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":true,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":true,"gnssid":0,"svid":32}]}\x0d\x0a
gpsd:INFO: PRN  1 az 309.0 el 80.0 (-0.134950,  0.109280,  0.984808)
gpsd:INFO: PRN  3 az 220.0 el 49.0 (-0.421707, -0.502570,  0.754710)
gpsd:INFO: PRN  8 az 161.0 el 31.0 ( 0.279066, -0.810468,  0.515038)
gpsd:INFO: PRN 14 az 272.0 el 27.0 (-0.890464,  0.031096,  0.453990)
gpsd:INFO: PRN 17 az 309.0 el 31.0 (-0.666144,  0.539433,  0.515038)
gpsd:INFO: PRN 21 az  96.0 el 70.0 ( 0.340147, -0.035751,  0.939693)
gpsd:INFO: PRN 22 az  89.0 el 38.0 ( 0.787891,  0.013753,  0.615661)
gpsd:INFO: PRN 32 az  57.0 el 31.0 ( 0.718881,  0.466847,  0.515038)
gpsd:INFO: PRN 68 az  44.0 el 44.0 ( 0.499695,  0.517450,  0.694658)
gpsd:INFO: PRN 75 az 285.0 el 14.0 (-0.937234,  0.251131,  0.241922)
gpsd:INFO: PRN 76 az 340.0 el 16.0 (-0.328771,  0.903291,  0.275637)
gpsd:INFO: PRN 83 az 115.0 el 20.0 ( 0.851651, -0.397131,  0.342020)
gpsd:INFO: PRN 84 az  58.0 el 77.0 ( 0.190769,  0.119206,  0.974370)
gpsd:INFO: PRN 85 az 309.0 el 30.0 (-0.673028,  0.545007,  0.500000)
gpsd:INFO: Sats used (14):
gpsd:CLIENT: => client(0): {"class":"SKY","device":"/dev/ttymxc2","xdop":0.46,"ydop":0.62,"vdop":1.36,"tdop":0.77,"hdop":0.88,"gdop":1.60,"pdop":1.62,"nSat":20,"uSat":14,"satellites":[{"PRN":1,"el":80.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":1},{"PRN":3,"el":49.0,"az":220.0,"ss":12.0,"used":true,"gnssid":0,"svid":3},{"PRN":8,"el":31.0,"az":161.0,"ss":20.0,"used":true,"gnssid":0,"svid":8},{"PRN":10,"el":2.0,"az":53.0,"ss":14.0,"used":false,"gnssid":0,"svid":10},{"PRN":14,"el":27.0,"az":272.0,"ss":8.0,"used":true,"gnssid":0,"svid":14},{"PRN":17,"el":31.0,"az":309.0,"ss":32.0,"used":true,"gnssid":0,"svid":17},{"PRN":19,"el":3.0,"az":316.0,"ss":0.0,"used":false,"gnssid":0,"svid":19},{"PRN":21,"el":70.0,"az":96.0,"ss":14.0,"used":true,"gnssid":0,"svid":21},{"PRN":22,"el":38.0,"az":89.0,"ss":28.0,"used":true,"gnssid":0,"svid":22},{"PRN":24,"el":0.0,"az":357.0,"ss":0.0,"used":false,"gnssid":0,"svid":24},{"PRN":32,"el":31.0,"az":57.0,"ss":41.0,"used":true,"gnssid":0,"svid":32},{"PRN":68,"el":44.0,"az":44.0,"ss":30.0,"used":true,"gnssid":6,"svid":4},{"PRN":69,"el":64.0,"az":144.0,"ss":0.0,"used":false,"gnssid":6,"svid":5},{"PRN":70,"el":12.0,"az":193.0,"ss":0.0,"used":false,"gnssid":6,"svid":6},{"PRN":75,"el":14.0,"az":285.0,"ss":28.0,"used":true,"gnssid":6,"svid":11},{"PRN":76,"el":16.0,"az":340.0,"ss":34.0,"used":true,"gnssid":6,"svid":12},{"PRN":77,"el":0.0,"az":23.0,"ss":0.0,"used":false,"gnssid":6,"svid":13},{"PRN":83,"el":20.0,"az":115.0,"ss":9.0,"used":true,"gnssid":6,"svid":19},{"PRN":84,"el":77.0,"az":58.0,"ss":22.0,"used":true,"gnssid":6,"svid":20},{"PRN":85,"el":30.0,"az":309.0,"ss":29.0,"used":true,"gnssid":6,"svid":21}]}\x0d\x0a
gpsd:CLIENT: => client(0): {"class":"TPV","device":"/dev/ttymxc2","mode":3,"time":"2022-09-08T09:20:35.000Z","ept":0.005,"lat":53.232662500,"lon":-2.098090333,"altHAE":84.6000,"altMSL":36.4000,"alt":36.4000,"epx":6.970,"epy":9.328,"epv":31.280,"magvar":-1.0,"speed":0.026,"geoidSep":48.200,"eph":16.720,"sep":30.780}\x0d\x0a

There is no mention of /run/chrony.ttymxc2.sock, even if I use -D6.

It looks like gpsd isn't even checking for the existence of /run/chrony.ttymxc2.sock.

With chronyc, I see:

root@imx6ul-var-dart:~# chronyc -n sources
210 Number of sources = 2
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
#? GPS                           0   4     0     -     +0ns[   +0ns] +/-    0ns
#? PPS                           0   4     0     -     +0ns[   +0ns] +/-    0ns

Aside: I didn't understand how gpsd knew the name of the chrony socket, but it appears that gpsd explictly supports chrony. (It's an odd design for a source of data to enumerate the consumers, but gpsd is a first class project so I'm sure there is a good reason.)

root@imx6ul-var-dart:~# strings /usr/sbin/gpsd | grep chrony
accepted chrony sock
PPS chrony_send %s @ %s Offset: %0.9f
/run/chrony.%s.sock
/tmp/chrony.%s.sock
PPS:%s chrony socket %s doesn't exist
PPS:%s connect chrony socket failed: %s, error: %d, errno: %d/%s
PPS:%s using chrony socket: %s

I have also tried these chrony configurations without success:

refclock SOCK /var/run/chrony.ttymxc2.sock refid GPS precision 1e-1 offset 0 delay 0 stratum 2
refclock SOCK /var/run/chrony.ttymxc2.sock refid PPS      

refclock SHM 0 offset 0.5 delay 0.2 refid NMEA

refclock SOCK /var/run/chrony.ttymxc2.sock refid GPS precision 1e-1 offset 0 delay 0

refclock SHM 0 offset 0.0 delay 0.2                                  
refclock SHM 1 offset 0.0 delay 0.0  

Is it possible to use gpsd to provide time to chrony without a pulse per second?

If so, what is the configuration?

2 Answers 2

3

It should work with the refclock SHM 0 directive alone. SHM 1 and SOCK work only with PPS.

In the gpsd log there is a hint about missing GPRMC message. The receiver needs to be configured to send a message that contains full time and date in order for gpsd to be able to write samples to SHM 0.

In the manual for your receiver there should be a command which can enable the GPRMC and other messages. There could also be a configuration utility provided by the vendor. For instance, there is u-center for u-blox receivers.

1

James Browning, on the gpsd mailing list, provided the solution:

Nobody reads the fine documentation properly (even me)

refclock SHM 0 poll 3 refid gps1
pool pool.ntp.org maxsources=3

driftfile /var/db/chrony/chrony.drift
bindcmdaddress /var/run/chrony/chrony.sock
rtcsync

Is a good place to start for chrony.

I had to remove the "pool" line as it didn't parse in chronyd.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .