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")) {
77static CMD_FUNCTION(CB_time) {
82 if (argc > 0 && !strcmp(ppArgs[0],
"ns")) {
83 MSG(
"%" __PRI64_PREFIX
"u %u\n", t.
sec, t.
nanosec);
86 MSG(
"%s\n", datetime);
92static CMD_FUNCTION(CB_master) {
94 if (!strcmp(ppArgs[0],
"prefer")) {
100 }
else if (!strcmp(ppArgs[0],
"unprefer")) {
105 MSG(
"Master clock ID: ");
111static CMD_FUNCTION(CB_ptpinfo) {
112 MSG(
"Own clock ID: ");
114 MSG(
"\nMaster clock ID: ");
120static CMD_FUNCTION(CB_ptpdomain) {
128#ifdef PTP_ADDEND_INTERFACE
129static CMD_FUNCTION(CB_addend) {
136#elif defined(PTP_HLT_INTERFACE)
137static CMD_FUNCTION(CB_tuning) {
146static CMD_FUNCTION(CB_transportType) {
148 if (!strcmp(ppArgs[0],
"ipv4")) {
150 }
else if (!strcmp(ppArgs[0],
"802.3")) {
159static CMD_FUNCTION(CB_delayMechanism) {
161 if (!strcmp(ppArgs[0],
"e2e")) {
163 }
else if (!strcmp(ppArgs[0],
"p2p")) {
172static CMD_FUNCTION(CB_transpec) {
174 if (!strcmp(ppArgs[0],
"def") || !strcmp(ppArgs[0],
"unknown")) {
176 }
else if (!strcmp(ppArgs[0],
"gPTP")) {
185static CMD_FUNCTION(CB_profile) {
186 bool printProfileSummary =
true;
187 if (argc > 0 && !strcmp(ppArgs[0],
"preset")) {
191 MSG(
"Loading preset '%s'...\n\n", ppArgs[1]);
194 MSG(
"Profile preset '%s' is unknown, settings untouched!\n", ppArgs[1]);
197 MSG(
"PTP profile presets: ");
200 for (i = 0; i < N; i++) {
207 printProfileSummary =
false;
211 if (printProfileSummary) {
217static CMD_FUNCTION(CB_tlv) {
218 bool printLoadedTlvPresetChain =
true;
220 if (!strcmp(ppArgs[0],
"preset")) {
224 MSG(
"Loading TLV-chain '%s'...\n\n", ppArgs[1]);
227 MSG(
"TLV-chain preset '%s' is unknown, settings are not tampered with!\n", ppArgs[1]);
229 printLoadedTlvPresetChain =
false;
232 MSG(
"TLV-chain presets: ");
235 for (i = 0; i < N; i++) {
243 printLoadedTlvPresetChain =
false;
245 }
else if (!strcmp(ppArgs[0],
"unload")) {
246 MSG(
"Unloading any TLV-chain...\n\n");
248 printLoadedTlvPresetChain =
false;
252 if (printLoadedTlvPresetChain) {
253 MSG(
"Loaded TLV-chain: ");
255 if (!strcmp(tlvSet,
"")) {
258 MSG(
"'%s'\n\n", tlvSet);
265static CMD_FUNCTION(CB_profile_flags) {
267 uint8_t pf = atoi(ppArgs[0]);
276static CMD_FUNCTION(CB_logPeriod) {
278 if (!strcmp(ppArgs[0],
"delreq")) {
279 if (!strcmp(ppArgs[1],
"match")) {
282 int8_t lp = atoi(ppArgs[1]);
286 }
else if (!strcmp(ppArgs[0],
"sync")) {
287 int8_t lp = atoi(ppArgs[1]);
290 }
else if (!strcmp(ppArgs[0],
"ann")) {
291 int8_t lp = atoi(ppArgs[1]);
297 MSG(
"(P)Delay_Req log. period: ");
311static CMD_FUNCTION(CB_coarseThreshold) {
320static CMD_FUNCTION(CB_priority) {
347 CMD_COARSE_THRESHOLD,
353static int sCmds[CMD_N + 1];
360 sCmds[CMD_RESET] =
CLI_REG_CMD(
"ptp reset \t\t\tReset PTP subsystem", 2, 0, CB_reset);
361 sCmds[CMD_OFFSET] =
CLI_REG_CMD(
"ptp servo offset [offset_ns] \t\t\tSet or query clock offset", 3, 0, CB_offset);
362 sCmds[CMD_LOG] =
CLI_REG_CMD(
"ptp log {def|corr|ts|info|locked|bmca} {on|off} \t\t\tTurn on or off logging", 2, 2, CB_log);
363 sCmds[CMD_TIME] =
CLI_REG_CMD(
"time [ns] \t\t\tPrint time", 1, 0, CB_time);
364 sCmds[CMD_MASTER] =
CLI_REG_CMD(
"ptp master [[un]prefer] [clockid] \t\t\tMaster clock settings", 2, 0, CB_master);
365 sCmds[CMD_PTPINFO] =
CLI_REG_CMD(
"ptp info \t\t\tPrint PTP info", 2, 0, CB_ptpinfo);
366 sCmds[CMD_PTPDOMAIN] =
CLI_REG_CMD(
"ptp domain [domain]\t\t\tPrint or set PTP domain", 2, 0, CB_ptpdomain);
367#ifdef PTP_ADDEND_INTERFACE
368 sCmds[CMD_ADDEND_TUNING] =
CLI_REG_CMD(
"ptp addend [addend]\t\t\tPrint or set addend", 2, 0, CB_addend);
369#elif defined(PTP_HLT_INTERFACE)
370 sCmds[CMD_ADDEND_TUNING] =
CLI_REG_CMD(
"ptp tuning [tuning]\t\t\tPrint or set tuning", 2, 0, CB_tuning);
372 sCmds[CMD_TRANSPORTTYPE] =
CLI_REG_CMD(
"ptp transport [{ipv4|802.3}]\t\t\tSet or get PTP transport layer", 2, 0, CB_transportType);
373 sCmds[CMD_DELAYMECH] =
CLI_REG_CMD(
"ptp delmech [{e2e|p2p}]\t\t\tSet or get PTP delay mechanism", 2, 0, CB_delayMechanism);
374 sCmds[CMD_TRANSPEC] =
CLI_REG_CMD(
"ptp transpec [{def|gPTP}]\t\t\tSet or get PTP transportSpecific field (majorSdoId)", 2, 0, CB_transpec);
375 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);
376 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);
377 sCmds[CMD_PROFILE_FLAGS] =
CLI_REG_CMD(
"ptp pflags [<flags>]\t\t\tPrint or set profile flags", 2, 0, CB_profile_flags);
378 sCmds[CMD_LOGPERIOD] =
CLI_REG_CMD(
"ptp period <delreq|sync|ann> [<lp>|matched]\t\t\tPrint or set log. periods", 2, 0, CB_logPeriod);
379 sCmds[CMD_COARSE_THRESHOLD] =
CLI_REG_CMD(
"ptp coarse [threshold]\t\t\tPrint or set coarse correction threshold", 2, 0, CB_coarseThreshold);
380 sCmds[CMD_PRIORITY] =
CLI_REG_CMD(
"ptp priority [<p1> <p2>]\t\t\tPrint or set clock priority fields", 2, 0, CB_priority);
387 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_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)