我目前正在尝试将来自GPS接收器(如UBlox ZED-F9P)的PPS信号连接到运行Ubuntu Mate 18.04和GPSD的Raspberry Pi。我已经验证了PPS内核模块是否存在,并且RPi确实通过以下命令检测到PPS信号:
$ ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1559136628.231481270, sequence: 631 - clear 0.000000000, sequence: 0 │
...
现在的问题是,当我运行GPSD时,出现以下错误:
$ gpsd -nND8 /dev/ttyACM0 /dev/pps0
...
gpsd:PROG: KPPS:/dev/pps0 Assert cycle: 999997, duration: 0 @ 1559136675.231397794
gpsd:RAW: PPS:/dev/pps0 Assert pps-detect invisible pulse
gpsd:PROG: PPS:/dev/pps0 Assert cycle: 999997, duration: 0 @ 1559136675.231397794
gpsd:PROG: PPS:/dev/pps0 Assert rejected missing last_fixtime
gpsd:PROG: KPPS:/dev/pps0 assert 1559136676.231395175, sequence: 679, clear 0.000000000, sequence: 0 -
using: assert
...
再深入一点源代码,可以发现GPSD在将PPS脉冲与某个时间相关联时遇到了问题。如(gpsd/ppsthread.c
中所述,同时在脉冲时刻计算系统时间与GPS时间之间的偏移量(差)。
/*
* If there has not yet been any valid in-band time stashed
* from the GPS when the PPS event was asserted, we can do
* nothing further. gpsd can not tell what second this pulse is
* in reference to.
*
* Some GPSes like Garmin always send a PPS, valid or not.
* Other GPSes like some uBlox may only send PPS when time is valid.
* It is common to get PPS, and no fixtime, while autobauding.
*/
/* FIXME, some GPS, like Skytraq, may output a the fixtime so
* late in the cycle as to be ambiguous. */
if (last_fixtime.real.tv_sec == 0) {
/* probably should log computed offset just for grins here */
ok = false;
log = "missing last_fixtime\n";
} else if ( ok && last_second_used >= last_fixtime.real.tv_sec ) {
/* uh, oh, this second already handled */
ok = false;
log = "this second already handled\n";
}
if ( !ok ) {
/* can not use this pulse, reject and retry */
thread_context->log_hook(thread_context, THREAD_PROG,
"PPS:%s %.10s ignored %.100s",
thread_context->devicename, edge_str, log);
continue;
}
我的问题是如何解决此问题,以便可以将GPSD与Chrony一起使用来设置NTP服务器。