diff options
Diffstat (limited to 'contrib/ntp/scripts/calc_tickadj')
-rw-r--r-- | contrib/ntp/scripts/calc_tickadj | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/contrib/ntp/scripts/calc_tickadj b/contrib/ntp/scripts/calc_tickadj new file mode 100644 index 0000000..f7a9f9f --- /dev/null +++ b/contrib/ntp/scripts/calc_tickadj @@ -0,0 +1,38 @@ +#! /usr/local/bin/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); + |