mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-11-05 04:46:00 +01:00
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 <kevin@koconnor.net>
This commit is contained in:
@@ -195,6 +195,10 @@ class Printer:
|
||||
self.reactor.unregister_timer(self.connect_timer)
|
||||
return self.reactor.NEVER
|
||||
def run(self):
|
||||
systime = time.time()
|
||||
monotime = self.reactor.monotonic()
|
||||
logging.info("Start printer at %s (%.1f %.1f)" % (
|
||||
time.asctime(time.localtime(systime)), systime, monotime))
|
||||
try:
|
||||
self.reactor.run()
|
||||
except:
|
||||
@@ -216,7 +220,7 @@ class Printer:
|
||||
def disconnect(self):
|
||||
try:
|
||||
if self.mcu is not None:
|
||||
self.stats(time.time())
|
||||
self.stats(self.reactor.monotonic())
|
||||
self.mcu.disconnect()
|
||||
except:
|
||||
logging.exception("Unhandled exception during disconnect")
|
||||
|
||||
Reference in New Issue
Block a user