24#error "No CMD_FUNCTION macro has been defined, cannot register CLI functions!"
27static CMD_FUNCTION(CB_reset) {
29 MSG(
"> PTP reset!\n");
33static CMD_FUNCTION(CB_offset) {
42static CMD_FUNCTION(CB_log) {
46 if (!strcmp(ppArgs[1],
"on")) {
48 }
else if (!strcmp(ppArgs[1],
"off")) {
54 if (!strcmp(ppArgs[0],
"def")) {
56 }
else if (!strcmp(ppArgs[0],
"corr")) {
58 }
else if (!strcmp(ppArgs[0],
"ts")) {
60 }
else if (!strcmp(ppArgs[0],
"info")) {
62 }
else if (!strcmp(ppArgs[0],
"locked")) {
64 }
else if (!strcmp(ppArgs[0],
"bmca")) {
66 }
else if (!strcmp(ppArgs[0],
"logid")) {
79static CMD_FUNCTION(CB_time) {
84 if (argc > 0 && !strcmp(ppArgs[0],
"ns")) {
85 MSG(
"%" __PRI64_PREFIX
"u %u\n", t.
sec, t.
nanosec);
88 MSG(
"%s\n", datetime);
94static CMD_FUNCTION(CB_master) {
96 if (!strcmp(ppArgs[0],
"prefer")) {
102 }
else if (!strcmp(ppArgs[0],
"unprefer")) {
107 MSG(
"Master clock ID: ");
113static CMD_FUNCTION(CB_ptpinfo) {
114 MSG(
"Own clock ID: ");
116 MSG(
"\nMaster clock ID: ");
122static CMD_FUNCTION(CB_ptpdomain) {
130#ifdef PTP_ADDEND_INTERFACE
131static CMD_FUNCTION(CB_addend) {
138#elif defined(PTP_HLT_INTERFACE)
139static CMD_FUNCTION(CB_tuning) {
148static CMD_FUNCTION(CB_transportType) {
150 if (!strcmp(ppArgs[0],
"ipv4")) {
152 }
else if (!strcmp(ppArgs[0],
"802.3")) {
161static CMD_FUNCTION(CB_delayMechanism) {
163 if (!strcmp(ppArgs[0],
"e2e")) {
165 }
else if (!strcmp(ppArgs[0],
"p2p")) {
174static CMD_FUNCTION(CB_transpec) {
176 if (!strcmp(ppArgs[0],
"def") || !strcmp(ppArgs[0],
"unknown")) {
178 }
else if (!strcmp(ppArgs[0],
"gPTP")) {
187static CMD_FUNCTION(CB_profile) {
188 bool printProfileSummary =
true;
189 if (argc > 0 && !strcmp(ppArgs[0],
"preset")) {
193 MSG(
"Loading preset '%s'...\n\n", ppArgs[1]);
196 MSG(
"Profile preset '%s' is unknown, settings untouched!\n", ppArgs[1]);
199 MSG(
"PTP profile presets: ");
202 for (i = 0; i < N; i++) {
209 printProfileSummary =
false;
213 if (printProfileSummary) {
219static CMD_FUNCTION(CB_tlv) {
220 bool printLoadedTlvPresetChain =
true;
222 if (!strcmp(ppArgs[0],
"preset")) {
226 MSG(
"Loading TLV-chain '%s'...\n\n", ppArgs[1]);
229 MSG(
"TLV-chain preset '%s' is unknown, settings are not tampered with!\n", ppArgs[1]);
231 printLoadedTlvPresetChain =
false;
234 MSG(
"TLV-chain presets: ");
237 for (i = 0; i < N; i++) {
245 printLoadedTlvPresetChain =
false;
247 }
else if (!strcmp(ppArgs[0],
"unload")) {
248 MSG(
"Unloading any TLV-chain...\n\n");
250 printLoadedTlvPresetChain =
false;
254 if (printLoadedTlvPresetChain) {
255 MSG(
"Loaded TLV-chain: ");
257 if (!strcmp(tlvSet,
"")) {
260 MSG(
"'%s'\n\n", tlvSet);
267static CMD_FUNCTION(CB_profile_flags) {
269 uint8_t pf = atoi(ppArgs[0]);
278static CMD_FUNCTION(CB_logPeriod) {
280 if (!strcmp(ppArgs[0],
"delreq")) {
281 if (!strcmp(ppArgs[1],
"match")) {
284 int8_t lp = atoi(ppArgs[1]);
288 }
else if (!strcmp(ppArgs[0],
"sync")) {
289 int8_t lp = atoi(ppArgs[1]);
292 }
else if (!strcmp(ppArgs[0],
"ann")) {
293 int8_t lp = atoi(ppArgs[1]);
299 MSG(
"(P)Delay_Req log. period: ");
313static CMD_FUNCTION(CB_coarseThreshold) {
322static CMD_FUNCTION(CB_priority) {
349 CMD_COARSE_THRESHOLD,
355static int sCmds[CMD_N + 1];
362 sCmds[CMD_RESET] =
CLI_REG_CMD(
"ptp reset \t\t\tReset PTP subsystem", 2, 0, CB_reset);
363 sCmds[CMD_OFFSET] =
CLI_REG_CMD(
"ptp servo offset [offset_ns] \t\t\tSet or query clock offset", 3, 0, CB_offset);
364 sCmds[CMD_LOG] =
CLI_REG_CMD(
"ptp log {def|corr|ts|info|locked|bmca|logid} {on|off} \t\t\tTurn on or off logging", 2, 2, CB_log);
365 sCmds[CMD_TIME] =
CLI_REG_CMD(
"time [ns] \t\t\tPrint time", 1, 0, CB_time);
366 sCmds[CMD_MASTER] =
CLI_REG_CMD(
"ptp master [[un]prefer] [clockid] \t\t\tMaster clock settings", 2, 0, CB_master);
367 sCmds[CMD_PTPINFO] =
CLI_REG_CMD(
"ptp info \t\t\tPrint PTP info", 2, 0, CB_ptpinfo);
368 sCmds[CMD_PTPDOMAIN] =
CLI_REG_CMD(
"ptp domain [domain]\t\t\tPrint or set PTP domain", 2, 0, CB_ptpdomain);
369#ifdef PTP_ADDEND_INTERFACE
370 sCmds[CMD_ADDEND_TUNING] =
CLI_REG_CMD(
"ptp addend [addend]\t\t\tPrint or set addend", 2, 0, CB_addend);
371#elif defined(PTP_HLT_INTERFACE)
372 sCmds[CMD_ADDEND_TUNING] =
CLI_REG_CMD(
"ptp tuning [tuning]\t\t\tPrint or set tuning", 2, 0, CB_tuning);
374 sCmds[CMD_TRANSPORTTYPE] =
CLI_REG_CMD(
"ptp transport [{ipv4|802.3}]\t\t\tSet or get PTP transport layer", 2, 0, CB_transportType);
375 sCmds[CMD_DELAYMECH] =
CLI_REG_CMD(
"ptp delmech [{e2e|p2p}]\t\t\tSet or get PTP delay mechanism", 2, 0, CB_delayMechanism);
376 sCmds[CMD_TRANSPEC] =
CLI_REG_CMD(
"ptp transpec [{def|gPTP}]\t\t\tSet or get PTP transportSpecific field (majorSdoId)", 2, 0, CB_transpec);
377 sCmds[CMD_PROFILE] =
CLI_REG_CMD(
"ptp profile [preset [<name>]]\t\t\tPrint or set PTP profile, or list available presets", 2, 0, CB_profile);
378 sCmds[CMD_TLV] =
CLI_REG_CMD(
"ptp tlv [preset [name]|unload]\t\t\tPrint or set TLV-chain, or list available TLV presets", 2, 0, CB_tlv);
379 sCmds[CMD_PROFILE_FLAGS] =
CLI_REG_CMD(
"ptp pflags [<flags>]\t\t\tPrint or set profile flags", 2, 0, CB_profile_flags);
380 sCmds[CMD_LOGPERIOD] =
CLI_REG_CMD(
"ptp period <delreq|sync|ann> [<lp>|matched]\t\t\tPrint or set log. periods", 2, 0, CB_logPeriod);
381 sCmds[CMD_COARSE_THRESHOLD] =
CLI_REG_CMD(
"ptp coarse [threshold]\t\t\tPrint or set coarse correction threshold", 2, 0, CB_coarseThreshold);
382 sCmds[CMD_PRIORITY] =
CLI_REG_CMD(
"ptp priority [<p1> <p2>]\t\t\tPrint or set clock priority fields", 2, 0, CB_priority);
389 for (uint8_t i = 0; i < CMD_N; i++) {
void ptp_register_cli_commands()
void ptp_remove_cli_commands()
This module handles and registers CLI commands. Commands:
void ptp_print_clock_identity(uint64_t clockID)
uint64_t hextoclkid(const char *str)
This module defines clock identity related operations.
#define CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
void ptp_log_enable(int logId, bool en)
This module handles various logging capabilities.
@ PTP_LOG_BMCA
Notifies the user about BMCA state changes.
@ PTP_LOG_INFO
If enabled, the user will be notified of unexpected events occurred and exceptions.
@ PTP_LOG_CORR_FIELD
The PTP engine will print the correction fields of particular PTP messages.
@ PTP_LOG_LOCKED_STATE
Signals the user if the PTP engine considers the clock have gotten locked.
@ PTP_LOG_LOGID
Prints formatted identifier before each log line.
@ PTP_LOG_TIMESTAMPS
The PTP engine will print the T1-T4/T6 timestamps (in E2E/P2P modes).
@ PTP_LOG_DEF
Default PTP log, prints sync-cycle related data (e.g. time error, tuning, code word etc....
char * PTP_TRANSPORT_TYPE_HINT[]
Hint on transport types.
char * PTP_TRANSPEC_HINT[]
Hint on transport specific field.
char * PTP_DELMECH_HINT[]
Hint on delay mechanism.
This module implements defines a single method that prints a verbose summary of the operating PTP pro...
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
const PtpProfileTlvElement * ptp_tlv_chain_preset_get(const char *pName)
const char * ptp_tlv_chain_preset_get_name(size_t i)
const PtpProfile * ptp_profile_preset_get(const char *pName)
size_t ptp_tlv_chain_preset_cnt()
const char * ptp_profile_preset_get_name(size_t i)
size_t ptp_profile_preset_cnt()
This module manages predefined profile presets. It allows their fetching by name or ID.
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
@ PTP_TP_IPv4
IPv4 Transport Type.
@ PTP_TP_802_3
Ethernet Transport Type.
@ PTP_LOGPER_MAX
Maximal logarithmic messaging period.
@ PTP_LOGPER_MIN
Minimal logarithmic messaging period.
@ PTP_LOGPER_SYNCMATCHED
Messaging occurs whenever a Sync arrives.
@ PTP_DM_E2E
End-to-End Delay Mechanism.
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
@ PTP_TSPEC_GPTP_8021AS
802.1AS Transport Specific Flag
@ PTP_TSPEC_UNKNOWN_DEF
Unkown Transport Specific Flag (default)
void ptp_time(TimestampU *pT)
void ptp_set_delay_mechanism(PtpDelayMechanism dm)
uint64_t ptp_get_coarse_threshold()
void ptp_set_announce_log_period(int8_t alp)
PtpDelayMechanism ptp_get_delay_mechanism()
void ptp_set_delay_req_log_period(int8_t drlp)
int8_t ptp_get_announce_log_period()
void ptp_set_transport_type(PtpTransportType tp)
void ptp_set_clock_offset(int32_t offset)
PtpTransportType ptp_get_transport_type()
uint8_t ptp_get_priority2()
uint8_t ptp_get_profile_flags()
uint64_t ptp_get_current_master_clock_identity()
int8_t ptp_get_sync_log_period()
uint8_t ptp_get_priority1()
int8_t ptp_get_delay_req_log_period()
int32_t ptp_get_clock_offset()
void ptp_set_domain(uint8_t domain)
void ptp_set_priority2(uint8_t p2)
void ptp_set_addend(uint32_t addend)
PtpTransportSpecific ptp_get_transport_specific()
void ptp_set_sync_log_period(int8_t slp)
void ptp_set_transport_specific(PtpTransportSpecific tspec)
void ptp_unprefer_master_clock()
void ptp_prefer_master_clock(uint64_t clockId)
uint64_t ptp_get_own_clock_identity()
void ptp_set_tlv_chain_by_name(const char *tlvSet)
void ptp_set_priority1(uint8_t p1)
void ptp_set_profile_flags(uint8_t flags)
const char * ptp_get_loaded_tlv_chain()
uint32_t ptp_get_addend()
void ptp_load_profile(const PtpProfile *pProfile)
void ptp_set_coarse_threshold(uint64_t ns)
This module features functions to tweak around the PTP engine's almost every property.
void ptp_set_tuning(float tuning_ppb)
PTP profile additional data list element.
uint32_t nanosec
nanoseconds
void tsPrint(char *str, const TimestampI *ts)