-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: ptp_clock: add ptp_clock shell commands #89243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
75bd191
to
498c100
Compare
drivers/ptp_clock/ptp_clock_shell.c
Outdated
return ret; | ||
} | ||
|
||
tm.second = strtoull(argv[2], NULL, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to use the shell_strtoull()
and similar checkers that the shell provides, and then the conversion errors can be easily checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks a lot. I would have noticed them.
drivers/ptp_clock/ptp_clock_shell.c
Outdated
} | ||
|
||
shell_print(sh, "adjust ratio %f, sleep 10s...", ratio); | ||
k_sleep(K_MSEC(10000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps allow user to set the delay instead of always blocking the shell for 10 secs.
So something like ptp_clock selftest <device> [<sleep delay, default 10 sec>]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. I think I should let user configure all args for selftest.
Because ptp hardware varies and something like rate limitation is different.
} | ||
|
||
shell_print(sh, "adjust 3 seconds: %"PRIu64".%09u", tm.second, tm.nanosecond); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to give a better summary of the selftest, or was the plan that user can see the numbers and act accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let me give a new version to review.
Will give a better description in help and print messages to explain what the selftest does.
Actually it's very easy to understand the tests.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In v2, the help info is as below.
uart:~$ ptp_clock
ptp_clock - PTP clock commands
Subcommands:
get : Get time: get <device>
set : Set time: set <device> <seconds>
adj : Adjust time: adj <device> <seconds>
freq : Adjust frequency: freq <device> <ppb>
selftest : selftest <device> <time> <freq> <delay> <adj>
The selftest will do following steps:
1. set 'time' with seconds and read back to
verify clock setting/getting.
2. set 'freq' with ppb value, sleep 'delay' seconds,
and read back time to verify rate adjustment.
3. set 'adj' seconds and read back time to
verify time adjustment.
Example:
ptp_clock selftest ptp_clock 1000 100000000 10 10
The print messages will be as below.
uart:~$ ptp_clock selftest ptp_clock 1000 -10000000 10 10
test1: set time 1000.000000000
result: read back time 1000.002214824
test2: adjust frequency -10000000 ppb (ratio 0.990000), delay 10 seconds...
result: read back time 1009.929990349
test3: adjust time 10 seconds
result: read back time 1009.935486840
Please ignore the adjust time issue. It indeed had issue on my platform:)
Thanks a lot.
498c100
to
f339347
Compare
Updated to v2. Changes include,
Thanks. |
f339347
to
0e05b80
Compare
} | ||
|
||
/* set 'time' seconds and read back to verify clock setting/getting */ | ||
tm.second = seconds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seconds
should be uint64_t
. Please change shell_strtol()
to shell_strtoull()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed in v3.
0e05b80
to
27e36c4
Compare
Updated to v3. Changes include,
Thanks. |
27e36c4
to
2e9134d
Compare
Updated to v4. Changes include,
Thanks. |
2e9134d
to
2c16fb4
Compare
Rebased. Thanks. |
2c16fb4
to
104c55d
Compare
It seems some CI issue on code base. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Added ptp_clock shell commands to check, use, and verify ptp clock. Supported get, set, adjust, rate adjust, and selftest functions. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
104c55d
to
bac4c81
Compare
|
Added ptp_clock shell commands to check, use, and verify ptp clock. Supported get, set, adjust, rate adjust, and selftest functions.