![]() |
flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
|
If a suitable Command Line Interface is defined in compile time, the following commands are available:
ptp reset
ptp servo offset [offset_ns]
ptp log {def|corr|ts|info|locked|bmca} {on|off}
ptp master [[un]prefer] [clockid]
ptp info
ptp domain [domain]
ptp addend [addend]
ptp tuning [tuning]
ptp transport [{ipv4|802.3}]
ptp delmech [{e2e|p2p}]
ptp transpec [{def|gPTP}]
ptp profile [preset [<name>]]
default
, defp2p
and gPTP
presets are defined.ptp tlv [preset [name]|unload]
gptp
TLV-preset is defined.ptp pflags [<flags>]
ptp period <delreq|sync|ann> [<lp>|matched]
(P)Delay_Req
, Sync
or Announce
period. Minimum is -3 maximum is +4. matched
makes (P)Delay_Req
transmission triggered by the Sync
reception, that's why this option is only meaningful when setting (P)Delay_Req
period.ptp priority [<p1> <p2>]
ptp coarse [threshold]
time [ns]
ns
is specified, time is returned in UNIX formatThe following command is used for illustration: ptp priority [<p1> <p2>] Print or set clock priority fields
The flexPTP expects a CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
macro with the below parameters. The function should return an int
value. The returned value can be optionally used later to identify the registered commands.
cmd_hintline
: a joint string with the command and the hint separated by at least one tabulator (\t
) character (e.g. ptp priority [<p1> <p2>]\tPrint or set clock priority fields
),n_cmd
: number of words in the command section (2 in this case: ptp
and priority
),n_min_arg
: minimum required number of arguments (0 in this case, since both parameters are optional)cb
: the callback function with the following signature: int cb(const char ** ppArgs, uint8_t argc)
. The return value should be negative if the command execution fails, and 0 at successful processing.ppArgs
: array of command parameters. If char **
typing is not viable with the first parameter, then use any equivalent, like char[N]*
, etc.argc
: number of parameters.The library also expects a CMD_FUNCTION(name)
macro to construct the command callback functions, e.g.
Using the two macro above, the command registration can be easily adapted to any type of CLI management system.
To learn more about flexPTP's CLI command registration, refer to: cli_cmds.c.
Optionally, define the CLI_REMOVE_CMD(id)
macro that removes a CLI command. It will be invoked during the de-initialization of the library. The id
is the numeric value returned by the CLI_REG_CMD()
call.