![]() |
flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
|
In the following flexPTP's detailed logging and monitoring features are described.
The flexPTP library implements several kinds of automatic logging, that can be turned on and off using ptp_log_enable(). Predefined logging features are introduced below.
All of these logging features are available through the CLI command ptp log {def|corr|ts|info|locked|bmca} {on|off}
as well.
ID: PTP_LOG_DEF
, CLI: def
Definition: slave.c, ptp_perform_correction()
Each synchronization cycle (after the reception of a Sync
message) the below several current clock and network state variables are getting printed.
Field | Description | Format |
---|---|---|
T1 | reception time of the Sync message corresponding to the current cycle | (s, ns): %d %09d |
T4 | reception time (by the master) of the last Delay_Req message | (s, ns): %d %09d |
Δt | time error between us and the master (positive value means we're ahead of the master) | (s, ns), clock ticks: %d %09d d |
addend | hardware clock addend | (no unit) %u |
corr_ppb | relative clock tuning (correction) value in PPB | PPB: %f |
MPD | network Mean Path Delay between us and the master | ns: %ld |
MSP | measured Sync period | ns: %%09lu |
A logging header gets also issued when this logging capability is turned on.
T1 [s] | T1 [ns] | T4 [s] | T4 [ns] | Dt [s] | Dt [ns] | Dt [tick] | addend | corr_ppb | mpd_ns | sync_period_ns
Definition: master.c, PTP_MASTER_P2P_SLAVE_STATE_LOG(), ptp_master_commence_mpd_computation()
Print slave recognition states and Mean Path Delay values in any P2P mode.
Possible slave recognition state values:
State | Description |
---|---|
NONE | No suitable slave has been recognized |
CANDIDATE | A slave has been responding consequently and qualification is in progress |
ESTABLISHED | The slave clock has been accepted, a synchronization path has been established |
ID: PTP_LOG_BMCA
, CLI: bmca
Definition: bmca.c, SBMC_PRINT_LOG()
BMCA state transitions get printed. Possible states: INITIALIZING
, LISTENING
, PRE_MASTER
, MASTER
, SLAVE
, PASSIVE
, UNCALIBRATED
, FAULTY
, DISABLED
. To learn more about the specific state definitions refer to the IEEE 1588 Standard.
ID: PTP_LOG_TIMESTAMPS
, CLI: ts
Definition: slave.c, ptp_perform_correction()
Print timestamps of received and transmitted messages tagged with the sequence number of the current synchronization cycle.
In E2E mode four timestamps get printed in each synchronization cycle, e.g.:
In P2P mode six timestamps get printed in each synchronization cycle, e.g.:
Definition: master.c, ptp_master_commence_mpd_computation()
In master mode the four Peer-Delay Mechanism-related timestamps are printed along the relevant correction fields, e.g.:
ID: PTP_LOG_CORR_FIELD
, CLI: corr
Definition: slave.c, ptp_slave_process_message()
The correction fields of Follow_Up
, Delay_Resp
, PDelay_Resp
and PDel_Resp_Follow_Up
are printed.
ID: PTP_LOG_INFO
, CLI: info
Definition: slave.c, ptp_perform_correction()
The user gets notified of unexpected events occurred and exceptions.
ID: PTP_LOG_LOCKED_STATE
, CLI: locked
Definition: stats.c, ptp_collect_stats()
The user gets notified of changes in the clock's accuracy. The clock is considered LOCKED
if the filtered time error is less than PTP_ACCURACY_LIMIT_NS.
The flexPTP enables the user to register a callback function that gets invoked whenever one of the following events occur in the core:
Name | Description |
---|---|
PTP_UEV_INIT_DONE | The flexPTP core has been initialized. |
PTP_UEV_RESET_DONE | The flexPTP module has been reset. |
PTP_UEV_SYNC_RECVED | A Sync message has been received (slave) |
PTP_UEV_SYNC_SENT | A Sync message has eebn sent (master) |
PTP_UEV_FOLLOW_UP_RECVED | A Follow_Up message has been received (slave) |
PTP_UEV_DELAY_REQ_RECVED | A Delay_Req had been received (master) |
PTP_UEV_DELAY_REQ_SENT | A Delay_Req had been sent (slave) |
PTP_UEV_DELAY_RESP_RECVED | A Delay_Resp had been received (slave) |
PTP_UEV_DELAY_RESP_SENT | A Delay_Resp had been sent (master) |
PTP_UEV_PDELAY_REQ_RECVED | A PDelay_Req had been received (master/slave) |
PTP_UEV_PDELAY_REQ_SENT | A PDelay_Req had been sent (master/slave) |
PTP_UEV_PDELAY_RESP_RECVED | A PDelay_Resp had been received (master/slave) |
PTP_UEV_PDELAY_RESP_SENT | A PDelay_Resp had been sent (master/slave) |
PTP_UEV_PDELAY_RESP_FOLLOW_UP_RECVED | A PDelay_Resp_Follow_Up had been received (master/slave) |
PTP_UEV_ANNOUNCE_SENT | An Announce message has been sent (master) |
PTP_UEV_ANNOUNCE_RECVED | An Announce message has been received (master/slave) |
PTP_UEV_LOCKED | The average clock accuracy is sufficient. |
PTP_UEV_UNLOCKED | Our clock has deviated from the master in average. |
PTP_UEV_BMCA_STATE_CHANGED | The BMCA state has changed. |
PTP_UEV_NETWORK_ERROR | Indication of lost messages or the absence of expected responses. |
PTP_UEV_QUEUE_ERROR | This event signals that the flexPTP's internal transmission output queue is full and blocked. |
The callback function can be hooked into flexPTP either by calling ptp_set_user_event_callback() in runtime or by defining the PTP_USER_EVENT_CALLBACK macro in compile time. PTP_UEV_INIT_DONE can only be caught if the latter method is used.
The flexPTP library collects runtime statistics. Currently two fields are implemented in the PtpStats structure:
Field | Description |
---|---|
filtTimeErr | 0.1 Hz IIR low-pass filtered time error |
locked | _indicates if the filtered time error is less than PTP_ACCURACY_LIMIT_NS |
Statistics can be queried using ptp_get_stats(). Learn more in stats.h.