时间同步方案
名词缩写及解释
| 缩写 | 解释 |
|---|---|
| GPS | Global Positioning System |
| RTC | Real_Time Clock |
| PHC | PTP hardware clock |
| PTP | precision time protocol |
| gPTP | precision time protocol, extension of PTP Protocol |
| MCU | Microcontroller Unit |
| UART | Universal Asynchronous Receiver/Transmitter |
| CAN | Controller Area Network |
| PPS | Pulse Per Second |
| NMEA | National Marine Electronics Association |
| NTP | Network Time Protocol |
| NIC | Network Interface Card |
ptp 时间同步
功能
该软件包含两个程序:ptp4l 和 phc2sys。这两个软件结合使用,就可以实现从 master 获取时间,同步 S100的 PHC 时间和 Linux 系统时间。
ptp4l 使用方法
命令行参数
ptp4l 支持 gptp 功能,可以作为 master,也可以作为 slave;如果作为 slave,可以从 master 获取时间,同步 S100的 PHC 时间和 RTC 时间。
可以通过 ptp4l -h 查看帮助信息:
root@ubuntu:/userdata# ptp4l -h
usage: ptp4l [options]
Delay Mechanism
-A Auto, starting with E2E
-E E2E, delay request-response (default)
-P P2P, peer delay mechanism
Network Transport
-2 IEEE 802.3
-4 UDP IPV4 (default)
-6 UDP IPV6
Time Stamping
-H HARDWARE (default)
-S SOFTWARE
-L LEGACY HW
Other Options
-f [file] read configuration from 'file'
-i [dev] interface device to use, for example 'eth0'
(may be specified multiple times)
-p [dev] Clock device to use, default auto
(ignored for SOFTWARE/LEGACY HW time stamping)
-s slave only mode (overrides configuration file)
-l [num] set the logging level to 'num'
-m print messages to stdout
-q do not print messages to the syslog
-v prints the software version and exits
-h prints this message and exits
配置文件的使用
ptp4l 可以通过-f 参数指定配置文件。
配置文件按段划分,空行和#开头的行会被忽略。
有三种段类型:
[global]段,用来配置 program 选项,clock 选项,默认 port 选项。
port 段使用被配置的网口的名字,如[eth0]段,其配置的选项会覆盖[global]段中默认 port 选项。port 段可以为空内容,作用只是指定网口,这样命令行中不必使用-i 选项。
[unicast_master_table]段,配置单播 table。
配置文件的详细信息可以参考:https://linuxptp.nwtime.org/documentation/ptp4l/