Hi Artur,
Thank you for your reply
As you said, the 1588 protocol has been implemented. I used ptp4l + phc2sys to achieve time synchronization between the two hosts. Using the date command, the time is consistent. But I still have some questions.
1. Synchronize the clock frequency only, how is the time synchronized? Do you have trouble explaining the relationship between clock frequency and time stamp? Thank you
2. Can I get the PHC time directly? The following code:
#define PTP_CLOCK_0_PATH "/dev/ptp0"
int main()
{
int ptp_clk_id = open(PTP_CLOCK_0_PATH, O_RDONLY);
if(ptp_clk_id == -1){
printf("ptp clock open fail\n");
return -1;
}
struct timespec ts;
clock_gettime(ptp_clk_id, &ts);//CLOCK_REALTIME
printf("ptp clock open ok\n");
printf("ts.tv_sec: %ld, ts.tv_nsec: %ld\n", ts.tv_sec, ts.tv_nsec);
close(ptp_clk_id);
return 0;
}
The results are as follows:
root@imx6qsabresd:/mnt/test# ./ptp_clock_time
ptp clock open ok
ts.tv_sec: 0, ts.tv_nsec: 9609002