[Git][NTPsec/ntpsec][master] ntplogtemp: retry read of TEMPer.

Gary E. Miller gitlab at mg.gitlab.com
Wed Mar 29 00:19:57 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
e53fea20 by Gary E. Miller at 2017-03-28T17:18:01-07:00
ntplogtemp: retry read of TEMPer.

Only one device can read the TEMPER at a time.  But if ntpheatusb
and ntplogtemp try to read at the same time both will fail.  This
adds a short retry loop.

- - - - -


1 changed file:

- ntpclients/ntplogtemp


Changes:

=====================================
ntpclients/ntplogtemp
=====================================
--- a/ntpclients/ntplogtemp
+++ b/ntpclients/ntplogtemp
@@ -157,15 +157,23 @@ class Temper:
 
         data = []
         _device = 'TEMPER0'
-        # grab the needed output
-        output = run_binary(["temper-poll", "-c"])
-        try:
-            # make sure it is a temperature
-            temp = float(output[0])
-            now = int(time.time())
-            data.append('%d %s %s' % (now, _device, temp))
-        except:
-            # bad data, ignore it, forever
+        # only one device can read the TEMPer at a time
+        # collisions will happen, so retry a few times
+        for attempt in range(0, 3):
+            # grab the needed output
+            output = run_binary(["temper-poll", "-c"])
+            try:
+                # make sure it is a temperature
+                temp = float(output[0])
+                now = int(time.time())
+                data.append('%d %s %s' % (now, _device, temp))
+                break
+            except:
+                # bad data, ignore it, for a bit
+                if args.verbose:
+                    sys.stderr.write("TEMPer-poll failed\n")
+
+        if 0 == len(data):
             self.has_temper = False
         return data
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/e53fea20c713515894afdbbfc948e3a4d9f26a27
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170329/f1d761a8/attachment.html>


More information about the vc mailing list