From 20d0936fa256e0caa41a18a79556c8ade3f8347f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 6 Feb 2017 13:31:34 -0500 Subject: reactor: Use the system monotonic clock instead of the normal system clock The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor --- klippy/serialqueue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'klippy/serialqueue.c') diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c index 6cdd9f77..2286912a 100644 --- a/klippy/serialqueue.c +++ b/klippy/serialqueue.c @@ -23,7 +23,7 @@ #include // tcflush #include // pipe #include "list.h" // list_add_tail -#include "pyhelper.h" // get_time +#include "pyhelper.h" // get_monotonic #include "serialqueue.h" // struct queue_message @@ -149,11 +149,11 @@ static void pollreactor_run(struct pollreactor *pr) { pr->must_exit = 0; - double eventtime = get_time(); + double eventtime = get_monotonic(); while (! pr->must_exit) { int timeout = pollreactor_check_timers(pr, eventtime); int ret = poll(pr->fds, pr->num_fds, timeout); - eventtime = get_time(); + eventtime = get_monotonic(); if (ret > 0) { int i; for (i=0; inum_fds; i++) -- cgit v1.2.3-70-g09d2