PetteriAimonen opened a new pull request, #2101: URL: https://github.com/apache/nuttx-apps/pull/2101
## Summary This adds beginnings of a PTP (precision time protocol) daemon, which can work as server, client or both. What works: - Basic server & client operation - Transmission and reception of announce, sync and follow-up Still missing: - SO_TIMINGS for getting more precise packet timestamps - Implementation of delay_req and delay_resp packets - Status and stop interfaces for the daemon ## Impact Adds a new application `ptpd`. ## Testing Tested against Linux ptpd2 version 2.3.1 using a custom STM32F4 board. PC to NuttX sync (with debug messages enabled): <pre> linux$ sudo ptpd -i enp8s0 -V nsh> ptpd eth0 Started the PTP daemon as PID=0 ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got sync packet, seq 0 ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got follow-up packet, seq 0 ptp_process_rx_packet: Got packet: 64 bytes ptp_process_rx_packet: Got announce packet, seq 0 ptp_process_announce: Switching to better PTP time source ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got sync packet, seq 1 ptp_process_sync: Waiting for follow-up ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got follow-up packet, seq 1 ptp_update_local_clock: Jumped to timestamp 1695984277.193041402 s ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got sync packet, seq 2 ptp_process_sync: Waiting for follow-up ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got follow-up packet, seq 2 ptp_update_local_clock: Adjusting clock by 0.009991645 s ptp_process_rx_packet: Got packet: 64 bytes ptp_process_rx_packet: Got announce packet, seq 1 ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got sync packet, seq 3 ptp_process_sync: Waiting for follow-up ptp_process_rx_packet: Got packet: 44 bytes ptp_process_rx_packet: Got follow-up packet, seq 3 ptp_update_local_clock: Adjusting clock by 0.000000000 s nsh> date Fri, Sep 29 10:44:56 2023 </pre> NuttX to PC sync: <pre> linux$ sudo ptpd -i enp8s0 -V -s 2023-09-29 13:51:07.797108 ptpd2[88614].startup (info) (___) Configuration OK 2023-09-29 13:51:07.797497 ptpd2[88614].startup (info) (___) Successfully acquired lock on /var/run/ptpd2.lock 2023-09-29 13:51:07.797654 ptpd2[88614].startup (notice) (___) PTPDv2 started successfully on wlp3s0 using "slaveonly" preset (PID 88614) 2023-09-29 13:51:07.797683 ptpd2[88614].startup (info) (___) TimingService.PTP0: PTP service init # Timestamp, State, Clock ID, One Way Delay, Offset From Master, Slave to Master, Master to Slave, Observed Drift, Last packet Received, One Way Delay Mean, One Way Delay Std Dev, Offset From Master Mean, Offset From Master Std Dev, Observed Drift Mean, Observed Drift Std Dev, raw delayMS, raw delaySM 2023-09-29 13:51:07.797717, init, 2023-09-29 13:51:07.798156 ptpd2[88614].wlp3s0 (info) (init) Observed_drift loaded from kernel: -7835 ppb 2023-09-29 13:51:07.898353 ptpd2[88614].wlp3s0 (notice) (lstn_init) Now in state: PTP_LISTENING 2023-09-29 13:51:07.898401, lstn_init, 1 2023-09-29 13:51:17.342671 ptpd2[88614].wlp3s0 (info) (lstn_init) New best master selected: 120f03fffeffffff(unknown)/1 2023-09-29 13:51:26.044174 ptpd2[88614].wlp3s0 (notice) (slv) Now in state: PTP_SLAVE, Best master: 120f03fffeffffff(unknown)/1 2023-09-29 13:51:26.044219, slv, 120f03fffeffffff(unknown)/1, 0.000000000, 0.000000000, 0.000000000, 0.000000000, -7834.701538086, I, 0.000000000, 0, 0.000000000, 0, 0, 0, -4.292860229, 0.000000000 2023-09-29 13:51:26.044372 ptpd2[88614].wlp3s0 (notice) (slv) Received first Sync from Master 2023-09-29 13:51:26.044611, slv, 120f03fffeffffff(unknown)/1, 0.000000000, -4.208697754, 0.000000000, -4.208697754, -7834.701538086, S, 0.000000000, 0, 0.000000000, 0, 0, 0, -4.208697754, 0.000000000 2023-09-29 13:51:27.683261, slv, 120f03fffeffffff(unknown)/1, 0.000000000, -4.090707752, 0.000000000, -4.090707752, -7834.701538086, S, 0.000000000, 0, 0.000000000, 0, 0, 0, -4.090707752, 0.000000000 </pre> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org