[Git][NTPsec/ntpsec][wip-ntpq-peers-display] 8 commits: Cleanup on ntpheatusb comments and program name

Ian Bruene gitlab at mg.gitlab.com
Wed Mar 22 23:55:56 UTC 2017


Ian Bruene pushed to branch wip-ntpq-peers-display at NTPsec / ntpsec


Commits:
772c36d7 by Kenneth Finnegan at 2017-03-21T22:32:45-07:00
Cleanup on ntpheatusb comments and program name

- - - - -
fc1ea1b4 by Eric S. Raymond at 2017-03-22T06:30:52-04:00
Save a pointer to info on how to play with wildcard addresses.

- - - - -
13e2b4d6 by Eric S. Raymond at 2017-03-22T06:30:52-04:00
Documentation polishing.

- - - - -
fda25abf by Eric S. Raymond at 2017-03-22T15:45:48-04:00
Update our 1.0 objectives.

- - - - -
61fb4653 by Gary E. Miller at 2017-03-22T16:04:45-07:00
ntpheatusb: Make step mode work.  Ten 1°C steps up, ten back down.

- - - - -
853ce155 by Gary E. Miller at 2017-03-22T16:08:12-07:00
ntpq: tweak error message.

- - - - -
b3a13fc1 by Gary E. Miller at 2017-03-22T16:10:46-07:00
ntpheatusb: more cruft from botched merge.

- - - - -
29fdc8d7 by Ian Bruene at 2017-03-22T18:41:34-05:00
Merge branch 'master' into wip-ntpq-peers-display

Including previous fix to ntpq by Gary Miller

- - - - -


5 changed files:

- contrib/ntpheatusb
- devel/TODO
- docs/ntpspeak.txt
- include/ntp_fp.h
- ntpclients/ntpq


Changes:

=====================================
contrib/ntpheatusb
=====================================
--- a/contrib/ntpheatusb
+++ b/contrib/ntpheatusb
@@ -6,16 +6,22 @@
 # an incadescent light bulb in the box.  Heat to 45C.  profit.
 #
 # This code depends on the program 'usbrelay' to manage your usbrelay
-# conencted device. Get it here:  git at github.com:darrylb123/usbrelay.git
+# connected device.
+#   Get it here:  git at github.com:darrylb123/usbrelay.git
+#   Update the usbrelay_on/off variables below with your device ID
 #
-# makeheatusb will use a lot less CPU than ntpheat, and more directly
+# This code depends on the program 'temper-poll' to read the box temp
+# from an attached TEMPer device.
+#   Get it here: git at github.com:padelt/temper-python.git
+#
+# ntpheatusb will use a lot less CPU than ntpheat, and more directly
 # heats the XTAL rather than the CPU.
 #
-# Avoid the desire to increase the wait time.  The realy clocks twice
+# Avoid the desire to decrease the wait time.  The relay clocks twice
 # per cycle, and those cycles add up.  Minimize wear on your relay.
 #
-# Try the simple P controller (the defaul) before tyring the PID controller.
-# the PID controller may take some fiddling with the constants to get
+# Try the simple P controller (the default) before trying the PID controller.
+# The PID controller may take some fiddling with the constants to get
 # it working better than the simple P controller.
 
 import argparse
@@ -26,7 +32,7 @@ import time
 try:
     import ntp.util
 except ImportError as e:
-    sys.stderr.write("makeheatusb: can't find Python NTP modules "
+    sys.stderr.write("ntpheatusb: can't find Python NTP modules "
                      "-- check PYTHONPATH.\n%s\n" % e)
     sys.exit(1)
 
@@ -85,6 +91,13 @@ Discrete PID control
     def __repr__(self):
         return ("D_value=%s, I_value=%s" % (self.D_value, self.I_value))
 
+
+    def setPoint(self,set_point):
+            """
+            Initilize the setpoint of PID
+            """
+            self.set_point = set_point
+
     def update(self, current_value):
         """
         Calculate PID output value for given reference input and feedback
@@ -118,7 +131,7 @@ parser.add_argument('-p', '--pid',
 parser.add_argument('-s', '--step',
                     action="store_true",
                     dest='step',
-                    help="Step up 1C every hour for 10 hours, then back down.")
+                    help="Step up 1C every 2 hours for 20 hours, then back down.")
 parser.add_argument('-t', '--temp',
                     default=[45.0],
                     dest='target_temp',
@@ -137,7 +150,7 @@ parser.add_argument('-v', '--verbose',
                     help="be verbose")
 parser.add_argument('-V', '--version',
                     action="version",
-                    version="makeheatusb %s" % ntp.util.stdversion())
+                    version="ntpheatusb %s" % ntp.util.stdversion())
 args = parser.parse_args()
 
 zone0 = '/sys/class/thermal/thermal_zone0/temp'
@@ -151,7 +164,7 @@ period = float(args.wait[0])
 usbrelay_on = ['usbrelay', '959BI_1=1']
 usbrelay_off = ['usbrelay', '959BI_1=0']
 
-# to adjsut the PID variables
+# to adjust the PID variables
 # set I and D to zero
 #
 # increase P until you get a small overshoot, and mostly damped response,
@@ -161,17 +174,21 @@ usbrelay_off = ['usbrelay', '959BI_1=0']
 #
 # if the temp oscillates then increase D
 #
-pid = PID(setpoint=temp_gate, P=35.0, I=10.0, D=5.0)
+pid = PID(setpoint=temp_gate, P=35.0, I=10.0, D=10.0)
+
+start_time = time.time()
+step_time = start_time
+step = 0
 
-start_time = gmtime()
+start_time = time.time()
 step_time = start_time
 step = 0
 
 try:
     while True:
         if args.step:
-            now = gmtime()
-            if 3600 < (now - step_time):
+            now = time.time()
+            if 7200 < (now - step_time):
                 # time to step
                 step_time = now
                 step += 1
@@ -182,7 +199,8 @@ try:
                     # step down
                     temp_gate -= 1.0
                 if 9 < step:
-                    step = 10-
+                    step = -11
+            pid.setPoint(temp_gate)
 
         # grab the needed output
         output = run_binary(["temper-poll", "-c"])
@@ -195,7 +213,7 @@ try:
             print("temper read failed: %s" % output)
             sys.exit(1)
 
-        # the +2- is to create and 80/20 band around the setpoint
+        # the +20 is to create an 80/20 band around the setpoint
         p_val = pid.update(temp) + 20
         p_val1 = p_val
         if p_val > 100:


=====================================
devel/TODO
=====================================
--- a/devel/TODO
+++ b/devel/TODO
@@ -2,10 +2,11 @@
 
 == Checklist for a quality 1.0 release ==
 
-=== Code ===
+* Units as an option in ntpq/ntpmon.
 
-* All the code relating to iteration over interfaces can and should be removed
-  in favor of binding to wildcard addresses.
+* Easier assembly of config file snippets - ntpconf.d.
+
+* Package metadata for Debian, Ubuntu, Raspbian, Red Hat, Gentoo, and SuSe.
 
 === Testing ===
 
@@ -15,10 +16,6 @@
   on at least one platform and test the NMEA, Atom, and SHM drivers
   on most platforms.
 
-=== Packaging ===
-
-* Package metadata for Debian, Ubuntu, Raspbian, Red Hat, Gentoo, and SuSe.
-
 == After 1.0 release ==
 
 === Slow convergence ===
@@ -83,9 +80,17 @@ Neither is ideal, easy pickings for someone to code on.
   (and multiple inbound NTP connections, and a hole in your firewall) even when
   it has a known-good local timesource like a GPS.  This should be fixed.
 
+* Full support for NTS, once IETF has the spec ready
+
+* All the code relating to iteration over interfaces can and should be removed
+  in favor of binding to wildcard addresses.  Information on how to do this
+  us here: https://blog.powerdns.com/2012/10/08/on-binding-datagram-udp-sockets-to-the-any-addresses/
+
 * We could open only V6 sockets and allow them to handle mapped PV4 addresses,
   as described at http://man7.org/linux/man-pages/man7/ipv6.7.html
 
+* A clock driver or auxiliary daemon for PTP.
+
 * The code used for asynchronous DNS lookup is more general, more complex,
   and more bug-prone than it should be.  Either our version should be
   rewritten and simplified or (better idea!) it should be replaced by
@@ -108,7 +113,9 @@ Neither is ideal, easy pickings for someone to code on.
   codes and use it systematically to make reports more readable.
 
 * Timer events need, as much as possible, to be eliminated - they eat
-  power on laptops and mobile devices, usually unnecessarily.
+  power on laptops and mobile devices, usually unnecessarily. To fix this,
+  go to an event-queue architecture that wakes the daemon up just in time
+  for the next scheduled event (rather than a once-per-second timer tick).
 
 * Richer signal semantics: HUP for close/reopen of any files (logrotate…),
   USR1 for re-read of config and maybe USR2 for re-read of an alternate
@@ -143,9 +150,9 @@ __________
 970318: in hourly_stats(?), squawk if the magnitude of the drift is,
 	say, >400.
 
-== Simple tasks for an intern ==
+== Simple tasks for an intern/trainee ==
 
-[quote, ESR 2015-09-30]
+* A conformant SNMP subagent in Python - see RFC 5907.
 
 * In the docs subdirectory, include/command.txt is an HTML passthrough
   in a not entirely successful attempt to emulate the look of the


=====================================
docs/ntpspeak.txt
=====================================
--- a/docs/ntpspeak.txt
+++ b/docs/ntpspeak.txt
@@ -34,6 +34,10 @@
   Old name for the PPS driver.  Origin lost in the mists of history,
   but probably related in some way to cesium atomic clocks.
 
+[[cycle]] cycle::
+  An <<era>>; code comments sometimes use tjis term to emphasize that
+  modular arithmetic is going on.
+
 [[drift]] drift::
   In an NTP context, drift refers to the frequency offset of a clock crystal
   in an NTP host that causes the system time to slowly drift.  It is
@@ -53,6 +57,19 @@
   and asymmetric network delays between server and client, but firmware
   bugs in GPS receivers have produced falsetickers.
 
+[[epoch]] epoch::
+  1. The zero date of an NTP era.  The "prime epoch" (of era 0) was
+  1900-00-00T00:00:00 in proleptic UTC (leap second correction was not
+  introduced until 1972). 2. Other calendar systems have other
+  definitions; notably, the Unix epoch is 1970-00-00T00:00:00.
+
+[[era]] era::
+  One complete revolution of a 64-bit NTP 64-bit timestamp; approximately
+  136 years. Eras are numbered from 0, but this era number is not
+  represented internally in NTP code because modular-arithmetic
+  trickery is used to deduce the nearest time that could fit a given
+  timestamp.
+
 [[fudge]] fudge::
   Can have one of two senses.  Either (1) an offset configured for a
   <<refclock>> or server to correct its time, reversing a fixed or
@@ -97,7 +114,7 @@
    interface.
 
 [[holdover]] holdover::
-   In connection with a <<GPSD0>> or <<time radio>> that may lose
+   In connection with a <<GPSDO>> or <<time radio>> that may lose
    signal from its time source, holdover is its ability to continue
    delivering accurate time from an internal oscillator. Due to
    <<drift>> in the oscillator, accuracy drops as holdover time (time


=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -13,7 +13,7 @@
  * NTP uses two fixed point formats.
  *
  * The first (l_fp) is the "long" format and is 64 bits wide in units
- * of 1/2e32 seconds (which is between 232 and 233 decimal
+ * of 1/2^32 seconds (which is between 232 and 233 decimal
  * picoseconds).  The zero value signifies the zero date of the
  * current NTP era; era zero began on the date 1900-00-00T00:00:00 in
  * proleptic UTC (leap second correction was not introduced until
@@ -23,7 +23,7 @@
  * network byte order).  It is defined in RFC 5905 in Section 6 (Data
  * Types). In the on-the-wire context, it is always unsigned.
  *
- * When it is convenient to compute in float seconds, this type can
+ * When it is convenient to compute in seconds, this type can
  * be interpreted as a fixed-point float with the radix point between
  * bits 31 and 32. This is why there are macros to extract the low and
  * high halves.
@@ -32,7 +32,7 @@
  * context it is interpreted as signed and can only express offsets
  * up to a half cycle. Offsets are normally much, much smaller than that;
  * for an offset to have a value even as large as 1 second would be 
- * highly unusual.
+ * highly unusual after ntpd initialization.
  *
  * Anyway, an l_fp looks like:
  *


=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -1633,7 +1633,8 @@ if __name__ == '__main__':
             try:
                 interpreter.termwidth = int(val)
             except ValueError as e:
-                sys.stderr.write("'%s' is not a recognizable number\n" % val)
+                sys.stderr.write("Error: -W parameter '%s' not a number\n"
+                                 % val)
                 sys.stderr.write(usage)
                 raise SystemExit(1)
         elif switch in ("-u", "--units"):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/d3f9f8f02ded2d88e6a585aadcaf9bbc28152400...29fdc8d744d6abbeedfab4acfd149aae7d7409e3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170322/9df645ed/attachment.html>


More information about the vc mailing list