首页 > 技术知识 > 正文

1. 前言

承接上篇https://www.ebaina.com/articles/140000012570

2. 获取时间戳

在/dev/pps0上可以获得时间戳 我很惊讶ntpd不能获得pps时间戳作为时间的输入 nvidia xavier nx平台上精确时间协议(PTP)调试记录5

ll /dev/gpspps0 lrwxrwxrwx 1 root root 4 Jun 29 16:06 /dev/gpspps0 -> pps0 ll /dev/gps0 lrwxrwxrwx 1 root root 7 Jun 29 16:12 /dev/gps0 -> ttyACM0

在我尝试改变udev规则从ttyACM0 -> ttyTHS0,但是发现它已经改变了

cat /etc/udev/rules.d/99-gps.rules KERNEL==“ttyTHS0”, SYMLINK+=“gps0” KERNEL==“pps0”, MODE=“0660”, SYMLINK+=“gpspps0” sudo udevadm control –reload-rules nx2@nx2-desktop:~$ ll /dev/gps0 lrwxrwxrwx 1 root root 7 Jun 29 16:12 /dev/gps0 -> ttyACM0 3. 调试u-blox server 127.127.20.0 mode 81 minpoll 3 burst iburst

模式域控制波特率和所使用的信息。 我把它设置为81,这意味着115200波特,并使用RMC消息。 为了让它与u-blox一起工作,它需要是41,这意味着38400,并使用RMC消息。

u-blox默认会发出许多消息,所以最好让它停止发送除RMC和ZDA之外的所有消息。 因此38400、RMS和ZDA的模式为49

NTP文档确实说明了对于NMEA refclock,必须有可读的NMEA消息,以便PPS输入被识别。 对于只有PPS输入和网络时间源的人来说,还有另一个refclock(22)可用于仅捕获PPS部分。

http://doc.ntp.org/current-stable/drivers/driver22.html 2

ublox输出如下 nvidia xavier nx平台上精确时间协议(PTP)调试记录51 工作在/dev/ttyTHS0 nvidia xavier nx平台上精确时间协议(PTP)调试记录52

调试记录

设置波特率后,ntp得到GPS0的东西

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 *GPS_NMEA(0) .GPS0. 1 l 3 8 1 0.000 0.177 0.000

试图将NTP的输出添加到linuxptp中

timedatectl set-ntp true phc_ctl /dev/ptp0 set phc_ctl /dev/ptp0 get ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m

log如下

ptp4l[1466.840]: selected /dev/ptp0 as PTP clock ptp4l[1466.876]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[1466.876]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[1466.876]: port 1: link down ptp4l[1466.876]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) ptp4l[1466.908]: selected local clock 48b02d.fffe.05a771 as best master ptp4l[1466.908]: port 1: assuming the grand master role ptp4l[1466.908]: port 1: master state recommended in slave only mode ptp4l[1466.908]: port 1: defaultDS.priority1 probably misconfigured

不需要指定-p /dev/ptp0。 ptp4l可以通过指定-i eth0得到它需要的东西。 gPTP.cfg默认为二层传输 然后需要运行phc2sys -m -s CLOCK_REALTIME -c eth0 -w 以保持PHC与系统时钟同步(由ntpd设置)

在两个终端,我然后得到类似下面的东西

phc2sys[3991.116]: Waiting for ptp4l… phc2sys[3992.117]: Waiting for ptp4l… phc2sys[3993.118]: Waiting for ptp4l… phc2sys[3994.120]: Waiting for ptp4l… ————————————– ptp4l[3980.248]: selected local clock 48b02d.fffe.05a771 as best master ptp4l[3987.980]: selected local clock 48b02d.fffe.05a771 as best master ptp4l[3994.676]: selected local clock 48b02d.fffe.05a771 as best master ptp4l[4002.237]: selected local clock 48b02d.fffe.05a771 as best master ptp4l[4008.889]: selected local clock 48b02d.fffe.05a771 as best master cat /sys/class/ptp/ptp0/pps_available 0

Pps_available是由eqos驱动程序控制的,可以忽略它。 执行如下命令查看当前PHC状态。

$ phc_ctl eth0 get cmp phc_ctl[28596.190]: clock time is 1593636215.461996018 or Wed Jul 1 14:43:35 2020 phc_ctl[28596.190]: offset from CLOCK_REALTIME is -37000000008ns

运行观察一段时间

watch -n5 (ntpq -p ; echo “” ; ntptime ; echo “” ; phc_ctl eth0 get cmp) Every 5.0s: (ntpq -p ; echo “” ; ntptime ; echo “” ; phc_ctl eth0 get cmp) remote refid st t when poll reach delay offset jitter ============================================================================== oGPS_NMEA(0) .GPP0. 1 l 2 8 377 0.000 +0.001 0.002 *time-d-b.nist.g .NIST. 1 u 38 64 377 10.751 +2.109 0.446 ntp_gettime() returns code 0 (OK) time e2a77473.5d017db0 Wed, Jul 1 2020 14:45:39.363, (.363304958), maximum error 2000 us, estimated error 7 us, TAI offset 0 ntp_adjtime() returns code 0 (OK) modes 0x0 (), offset 0.491 us, frequency 5.540 ppm, interval 1 s, maximum error 2000 us, estimated error 7 us, status 0x2001 (PLL,NANO), time constant 3, precision 0.001 us, tolerance 500 ppm, phc_ctl[28757.094]: clock time is 1593636376.365505506 or Wed Jul 1 14:46:16 2020 phc_ctl[28757.094]: offset from CLOCK_REALTIME is -37000000006ns

猜你喜欢