diff options
Diffstat (limited to 'contrib/ntp/scripts/calc_tickadj.in')
-rw-r--r-- | contrib/ntp/scripts/calc_tickadj.in | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/contrib/ntp/scripts/calc_tickadj.in b/contrib/ntp/scripts/calc_tickadj.in new file mode 100644 index 0000000..32eae12 --- /dev/null +++ b/contrib/ntp/scripts/calc_tickadj.in @@ -0,0 +1,38 @@ +#! @PATH_PERL@ +# +# drift of 104.8576 -> +1 tick. Base of 10000 ticks. +# +# 970306 HMS Deal with nanoseconds. Fix sign of adjustments. + +$df="/etc/ntp.drift"; +# Assumes a 100Hz box with "tick" of 10000 +# Someday, we might call "tickadj" for better values... +$base=10000; # tick: 1,000,000 / HZ +$cvt=104.8576; # 2 ** 20 / $base +$v1=0.; +$v2=""; + +if (open(DF, $df)) + { + if ($_=<DF>) + { + ($v1, $v2) = split; + } + + while ($v1 < 0) + { + $v1 += $cvt; + $base--; + } + + while ($v1 > $cvt) + { + $v1 -= $cvt; + $base++; + } + } + +printf("%.3f (drift)\n", $v1); + +printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000); + |