From: Richard Cochran <richardcochran@gmail.com>
To: Dong Zhu <bluezhudong@gmail.com>
Cc: Rob Landley <rob@landley.net>,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptp: measure the time offset between PHC and system clock
Date: Sat, 14 Sep 2013 16:31:46 +0200 [thread overview]
Message-ID: <20130914143144.GA4206@netboy> (raw)
In-Reply-To: <20130914080306.GC23682@zhudong.nay.redhat.com>
On Sat, Sep 14, 2013 at 04:03:06PM +0800, Dong Zhu wrote:
> This patch add a method into testptp.c to measure the time offset
> between phc and system clock through the ioctl PTP_SYS_OFFSET.
>
This is a nice addition to the testptp program. I do have a few
comments, below.
First off, the subject line should mention testptp. How about this?
[PATCH] ptp: add the PTP_SYS_OFFSET ioctl to the testptp program
> Signed-off-by: Dong Zhu <bluezhudong@gmail.com>
> ---
> Documentation/ptp/testptp.c | 40 ++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/ptp/testptp.c b/Documentation/ptp/testptp.c
> index f59ded0..72bb030 100644
> --- a/Documentation/ptp/testptp.c
> +++ b/Documentation/ptp/testptp.c
> @@ -112,6 +112,7 @@ static void usage(char *progname)
> " -f val adjust the ptp clock frequency by 'val' ppb\n"
> " -g get the ptp clock time\n"
> " -h prints this message\n"
> + " -k val measure the time offset between PHC and system clock\n"
The help message should tell the user what 'val' is.
> " -p val enable output with a period of 'val' nanoseconds\n"
> " -P val enable or disable (val=1|0) the system clock PPS\n"
> " -s set the ptp clock time from the system time\n"
> @@ -133,8 +134,12 @@ int main(int argc, char *argv[])
> struct itimerspec timeout;
> struct sigevent sigevent;
>
> + struct ptp_clock_time *pct;
> + struct ptp_sys_offset *sysoff;
> +
> +
> char *progname;
> - int c, cnt, fd;
> + int i, c, cnt, fd;
>
> char *device = DEVICE;
> clockid_t clkid;
> @@ -144,6 +149,8 @@ int main(int argc, char *argv[])
> int extts = 0;
> int gettime = 0;
> int oneshot = 0;
> + int offset = 0;
> + int n_samples = 0;
> int periodic = 0;
> int perout = -1;
> int pps = -1;
> @@ -151,7 +158,7 @@ int main(int argc, char *argv[])
>
> progname = strrchr(argv[0], '/');
> progname = progname ? 1+progname : argv[0];
> - while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghp:P:sSt:v"))) {
> + while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghk:p:P:sSt:v"))) {
> switch (c) {
> case 'a':
> oneshot = atoi(optarg);
> @@ -174,6 +181,10 @@ int main(int argc, char *argv[])
> case 'g':
> gettime = 1;
> break;
> + case 'k':
> + offset = 1;
> + n_samples = atoi(optarg);
> + break;
> case 'p':
> perout = atoi(optarg);
> break;
> @@ -376,6 +387,31 @@ int main(int argc, char *argv[])
> }
> }
>
> + if (offset) {
> + sysoff = calloc(1, sizeof(*sysoff));
> + if (!sysoff) {
> + perror("calloc");
> + return -1;
> + }
> + sysoff->n_samples = n_samples;
> +
> + if (ioctl(fd, PTP_SYS_OFFSET, sysoff))
> + perror("PTP_SYS_OFFSET");
> + else
> + puts("time offset between PHC and
> + system clock request okay");
> +
> + pct = &sysoff->ts[0];
> + for (i = 0; i < sysoff->n_samples; i++, pct++) {
> + printf("system time: %ld.%ld\n", pct->sec, pct->nsec);
> + pct++;
> + printf("phc time: %ld.%ld\n\n", pct->sec, pct->nsec);
^^^^
I think the output would look nicer with only one newline. After all,
each measurement is a {sys,phc,sys} triplet and not a {sys,phc} pair.
> + }
> + printf("system time: %ld.%ld\n", pct->sec, pct->nsec);
> +
> + free(sysoff);
> + }
> +
Thanks,
Richard
next prev parent reply other threads:[~2013-09-14 14:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-14 8:03 [PATCH] ptp: measure the time offset between PHC and system clock Dong Zhu
2013-09-14 14:31 ` Richard Cochran [this message]
2013-09-14 15:39 ` [PATCH] ptp: add the PTP_SYS_OFFSET ioctl to the testptp program clock Dong Zhu
2013-09-15 8:48 ` Richard Cochran
2013-09-15 9:25 ` [PATCH net-next v3] ptp: add the PTP_SYS_OFFSET ioctl to the testptp program Dong Zhu
2013-09-17 7:32 ` [PATCH net-next v4] " Dong Zhu
2013-09-23 20:46 ` David Miller
2013-09-14 19:21 ` [PATCH] ptp: measure the time offset between PHC and system clock Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130914143144.GA4206@netboy \
--to=richardcochran@gmail.com \
--cc=bluezhudong@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rob@landley.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.