[Git][NTPsec/ntpsec][master] Fix parse and DCF77 refclock

Gary E. Miller gitlab at mg.gitlab.com
Mon Feb 20 20:33:48 UTC 2017


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


Commits:
0145bff8 by Achim Gratz at 2017-02-20T12:32:29-08:00
Fix parse and DCF77 refclock

include/timespecops: Remove misleading definitions of the result
coding of the ternary comparison macros (the comments in that file are
still wrong).

libparse/parse.c (parse_timedout): Use the correct condition code
(follow the examples elsewhere in the code by using comparison against
zero).

libparse/clk_rawdcf.c (calc_usecdiff): Apply the offset backwards as
the original code before the lfp fixup did.  The delta timestamp must
not be treated as an absolute time, so use the appropriate conversion
function.

Signed-off-by: Gary E. Miller <gem at rellim.com>

- - - - -


3 changed files:

- include/timespecops.h
- libparse/clk_rawdcf.c
- libparse/parse.c


Changes:

=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -215,9 +215,6 @@ abs_tspec(
  * compare previously-normalised a and b
  * return 1 / 0 / -1 if a < / == / > b
  */
-#define TIMESPEC_LESS_THAN	1
-#define TIMESPEC_EQUAL		0
-#define TIMESPEC_GREATER_THAN	-1
 
 static inline int
 cmp_tspec(


=====================================
libparse/clk_rawdcf.c
=====================================
--- a/libparse/clk_rawdcf.c
+++ b/libparse/clk_rawdcf.c
@@ -509,11 +509,11 @@ calc_usecdiff(
 	l_fp delt;
 
 	delt = *ref;
-	bumplfpsint(delt, offset);
+       bumplfpsint(delt, -offset);
 	delt -= *base;
-	delta = lfp_stamp_to_tspec(delt, NULL);
+       delta = lfp_uintv_to_tspec(delt);
 
-	delta_usec = 1000000 * (int32_t)delta.tv_sec + delta.tv_nsec/1000;
+       delta_usec = (NANOSECONDS/1000)*(int32_t)delta.tv_sec + delta.tv_nsec/1000;
 	return delta_usec;
 }
 
@@ -553,7 +553,7 @@ snt_rawdcf(
 			       parseio->parse_index - 1, delta_usec));
 
 	if (((parseio->parse_dtime.parse_status & CVT_MASK) == CVT_OK) &&
-	    (delta_usec < 500000 && delta_usec >= 0)) /* only if minute marker is available */
+           (delta_usec < (NANOSECONDS/2000) && delta_usec >= 0)) /* only if minute marker is available */
 	{
 		parseio->parse_dtime.parse_stime = *ptime;
 
@@ -578,7 +578,7 @@ inp_rawdcf(
 	  timestamp_t  *tstamp
 	  )
 {
-	static struct timespec timeout = { 1, 500000000 }; /* 1.5 secongs denote second #60 */
+       static struct timespec timeout = { 1, (NANOSECONDS/2) }; /* 1.5 seconds denote second #60 */
 
 	parseprintf(DD_PARSE, ("inp_rawdcf(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
 
@@ -618,7 +618,7 @@ inp_rawdcf(
 				delta_usec = -1;
 			}
 
-			if (delta_usec < 500000 && delta_usec >= 0)
+                       if (delta_usec < (NANOSECONDS/2000) && delta_usec >= 0)
 			{
 				parseprintf(DD_RAWDCF, ("inp_rawdcf: timeout time difference %ld usec - minute marker set\n", delta_usec));
 				/* collect minute markers only if spaced by 60 seconds */


=====================================
libparse/parse.c
=====================================
--- a/libparse/parse.c
+++ b/libparse/parse.c
@@ -43,7 +43,7 @@ parse_timedout(
 	delt = *tstamp;
 	delt -= parseio->parse_lastchar;
 	delta = lfp_uintv_to_tspec(delt);
-	if (cmp_tspec(delta, *del) == TIMESPEC_GREATER_THAN)
+       if (cmp_tspec(delta, *del) > 0)
 	{
 		parseprintf(DD_PARSE, ("parse: timedout: TRUE\n"));
 		return true;



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


More information about the vc mailing list