[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] Print offset in ntpshmmon?
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] Print offset in ntpshmmon? |
Date: |
Tue, 21 Apr 2015 10:55:02 -0700 |
Yo Miroslav!
How about you remove the float and do full timespec math? Otherwise
the offset will be bad for large offsets.
On Tue, 21 Apr 2015 13:23:22 +0200
Miroslav Lichvar <address@hidden> wrote:
> When debugging problems with NTP SHM segments, I use a very simple
> program to print the SHM segment. Now that gpsd includes ntpshmmon,
> which has a nice feature that it finds all used segments
> automatically, I thought I could start using that instead.
>
> For me, it's quite useful to see the offset (the difference between
> the clock and receive timestamps). Would there be any interest in
> adding that to ntpshmmon?
>
> It seems there is no more room for additional entries to fit in 80
> columns. Would it be ok to replace the clock timestamp?
>
> --- a/ntpshmmon.c
> +++ b/ntpshmmon.c
> @@ -20,6 +20,7 @@
> /* int is too small, avoid floats */
> /* WARNING! this will overflow if x and y differ by more than a few
> seconds */ #define timespec_diff_ns(x, y)
> (long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec)
> +#define timespec_diff(x, y)
> (((x).tv_sec-(y).tv_sec)+1e-9*((x).tv_nsec-(y).tv_nsec))
>
> static struct shmTime *segments[NTPSEGMENTS + 1];
> static struct timespec tick[NTPSEGMENTS + 1];
> @@ -80,7 +81,7 @@ int main(int argc, char **argv)
> }
>
> (void)printf("ntpshmmon version 1\n");
> - (void)printf(" Name Seen@
> Clock Real L Prec\n");
> + (void)printf(" Name Seen@
> Clock Offset L Prec\n");
>
> do {
> struct shm_stat_t shm_stat;
> @@ -93,11 +94,11 @@ int main(int argc, char **argv)
> {
> case OK:
> if (timespec_diff_ns(shm_stat.tvc, tick[i]) >= cycle
> * 1000000000) {
> - printf("sample %s %ld.%09ld %ld.%09ld %ld.%09ld
> %d %3d\n",
> + printf("sample %s %ld.%09ld %ld.%09ld %+020.9f %d
> %3d\n", ntp_name(i),
> (long)shm_stat.tvc.tv_sec,
> shm_stat.tvc.tv_nsec, (long)shm_stat.tvr.tv_sec, shm_stat.tvr.tv_nsec,
> - (long)shm_stat.tvt.tv_sec,
> shm_stat.tvt.tv_nsec,
> + timespec_diff(shm_stat.tvt, shm_stat.tvr),
> shm_stat.leap, shm_stat.precision);
> tick[i] = shm_stat.tvc;
> --nsamples;
>
>
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
address@hidden Tel:+1(541)382-8588
- Re: [gpsd-dev] Print offset in ntpshmmon?, (continued)
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/21
- Re: [gpsd-dev] Print offset in ntpshmmon?, Miroslav Lichvar, 2015/04/22
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/22
- Re: [gpsd-dev] Print offset in ntpshmmon?, Eric S. Raymond, 2015/04/28
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/28
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/28
- Re: [gpsd-dev] Print offset in ntpshmmon?, Miroslav Lichvar, 2015/04/30
- Re: [gpsd-dev] Print offset in ntpshmmon?, Hal Murray, 2015/04/30
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/30
- Re: [gpsd-dev] Print offset in ntpshmmon?, Gary E. Miller, 2015/04/30
Re: [gpsd-dev] Print offset in ntpshmmon?,
Gary E. Miller <=