使用 GPSD 作为 Chronyd 源的问题

使用 GPSD 作为 Chronyd 源的问题

我正在尝试使用不带 PPS 加密狗的 USB GPS 作为 Ubuntu 18.04 上的唯一时间源。 GPSD 似乎工作正常,因为 cgps 报告了 3D 修复。但是,我无法及时查看 GPS 信息。

# gpsd -ND 8 /dev/ttyUSB0
gpsd:INFO: launching (Version 3.17)
gpsd:IO: opening IPv4 socket
gpsd:SPIN: passivesock_af() -> 3
gpsd:IO: opening IPv6 socket
gpsd:SPIN: passivesock_af() -> 4
gpsd:INFO: listening on port gpsd
gpsd:PROG: NTP: shmat(4718600,0,0) succeeded, segment 0
gpsd:PROG: NTP: shmat(4751369,0,0) succeeded, segment 1
gpsd:PROG: NTP: shmat(4784139,0,0) succeeded, segment 2
gpsd:PROG: NTP: shmat(4816908,0,0) succeeded, segment 3
gpsd:PROG: NTP: shmat(4849677,0,0) succeeded, segment 4
gpsd:PROG: NTP: shmat(4882446,0,0) succeeded, segment 5
gpsd:PROG: NTP: shmat(4915215,0,0) succeeded, segment 6
gpsd:PROG: NTP: shmat(4947984,0,0) succeeded, segment 7
gpsd:PROG: successfully connected to the DBUS system bus
gpsd:PROG: shmget(0x47505344, 8936, 0666) for SHM export succeeded
gpsd:PROG: shmat() for SHM export succeeded, segment 4980753
gpsd:INFO: stashing device /dev/ttyUSB0 at slot 0
gpsd:INFO: running with effective group ID 20
gpsd:INFO: running with effective user ID 128
gpsd:INFO: startup at 2022-12-06T16:50:17.000Z (1670345417)

chrony.conf:

refclock SHM 0 poll 3 refid gps1
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
logdir /var/log/chrony
maxupdateskew 10
rtcsync
makestep 1 3
# chronyd -df /etc/chrony/chrony.conf
2022-12-06T16:52:15Z chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH +SIGND +ASYNCDNS +IPV6 -DEBUG)
2022-12-06T16:52:15Z Frequency -22.003 +/- 4.168 ppm read from /var/lib/chrony/chrony.drift
# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
#? GPS0                          0   4     0     -     +0ns[   +0ns] +/-    0ns

我认为这个问题与共享内存有关,因为我认为 chrony/gpsd 应该利用 SHM ID 0,但它似乎不存在。

# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 262144     localuser    600        67108864   2          dest         
0x00000000 229377     localuser    600        16777216   2          dest         
0x00000000 360450     localuser    600        524288     2          dest         
0x00000000 393219     localuser    600        524288     2          dest         
0x00000000 491524     localuser    600        524288     2          dest         
0x00000000 5177349    localuser    600        524288     2          dest         
0x00000000 5210118    localuser    600        524288     2          dest         
0x00000000 655367     localuser    600        524288     2          dest         
0x4e545030 4718600    root       600        96         2                       
0x4e545031 4751369    root       600        96         1                       
0x00000000 2293770    localuser    600        16777216   2          dest         
0x4e545032 4784139    root       666        96         1                       
0x4e545033 4816908    root       666        96         1                       
0x4e545034 4849677    root       666        96         1                       
0x4e545035 4882446    root       666        96         1                       
0x4e545036 4915215    root       666        96         1                       
0x4e545037 4947984    root       666        96         1                       
0x47505344 4980753    root       666        8936       1                       
0x00000000 5472274    localuser    600        16384      2          dest         
0x4e9c5038 5570579    root       600        96         0                       
0x00000000 5308436    localuser    600        532480     2          dest         
0x00000000 5341205    localuser    600        532480     2          dest         
0x00000000 5439510    localuser    600        16384      2          dest         
0x4ea05041 5603351    root       600        96         0           

我尝试在 gpsd 之前启动 chronyd 但没有帮助。有任何想法吗?我错过了一些明显的事情吗?提前致谢。

类似问题: 使用 gpsd 和 chrony 没有每秒脉冲

我读过的另一个来源: GPSD 时间服务指南

答案1

事实证明 gpsd 需要 -n 标志。我在 /etc/default/gpsd 中添加了它

       -n
           Don't wait for a client to connect before polling whatever GPS is associated with it.
           Some RS232 GPSes wait in a standby mode (drawing less power) when the host machine is
           not asserting DTR, and some cellphone and handheld embedded GPSes have similar
           behaviors. Accordingly, waiting for a watch request to open the device may save battery
           power. (This capability is rare in consumer-grade devices).

https://chrony.tuxfamily.org/examples.html#_server_using_reference_clock_on_serial_port

相关内容