mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-08 07:27:43 -06:00
basecmd: Rename get_status to get_clock
Change the get_status command to get_clock. Don't report the shutdown status in the new get_clock command. The primary purpose of this change is to force the host code to report a firmware version mismatch with older firmwares as recent changes (namely the ordering of message block acks) have subtle incompatibilities if different host/mcu code is used. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
879c45db19
commit
b93fd5b1b5
3 changed files with 21 additions and 21 deletions
|
@ -14,8 +14,8 @@ class ClockSync:
|
|||
def __init__(self, reactor):
|
||||
self.reactor = reactor
|
||||
self.serial = None
|
||||
self.status_timer = self.reactor.register_timer(self._status_event)
|
||||
self.status_cmd = None
|
||||
self.get_clock_timer = self.reactor.register_timer(self._get_clock_event)
|
||||
self.get_clock_cmd = None
|
||||
self.mcu_freq = 1.
|
||||
self.last_clock = 0
|
||||
self.clock_est = (0., 0., 0.)
|
||||
|
@ -38,14 +38,14 @@ class ClockSync:
|
|||
self.time_avg = params['#sent_time']
|
||||
self.clock_est = (self.time_avg, self.clock_avg, self.mcu_freq)
|
||||
self.prediction_variance = (.001 * self.mcu_freq)**2
|
||||
# Enable periodic get_status timer
|
||||
self.status_cmd = serial.lookup_command('get_status')
|
||||
# Enable periodic get_clock timer
|
||||
self.get_clock_cmd = serial.lookup_command('get_clock')
|
||||
for i in range(8):
|
||||
params = self.status_cmd.send_with_response(response='status')
|
||||
self._handle_status(params)
|
||||
params = self.get_clock_cmd.send_with_response(response='clock')
|
||||
self._handle_clock(params)
|
||||
self.reactor.pause(0.100)
|
||||
serial.register_callback(self._handle_status, 'status')
|
||||
self.reactor.update_timer(self.status_timer, self.reactor.NOW)
|
||||
serial.register_callback(self._handle_clock, 'clock')
|
||||
self.reactor.update_timer(self.get_clock_timer, self.reactor.NOW)
|
||||
def connect_file(self, serial, pace=False):
|
||||
self.serial = serial
|
||||
self.mcu_freq = serial.msgparser.get_constant_float('CLOCK_FREQ')
|
||||
|
@ -54,13 +54,13 @@ class ClockSync:
|
|||
if pace:
|
||||
freq = self.mcu_freq
|
||||
serial.set_clock_est(freq, self.reactor.monotonic(), 0)
|
||||
# MCU clock querying (_handle_status is invoked from background thread)
|
||||
def _status_event(self, eventtime):
|
||||
self.status_cmd.send()
|
||||
# Use an unusual time for the next event so status messages
|
||||
# MCU clock querying (_handle_clock is invoked from background thread)
|
||||
def _get_clock_event(self, eventtime):
|
||||
self.get_clock_cmd.send()
|
||||
# Use an unusual time for the next event so clock messages
|
||||
# don't resonate with other periodic events.
|
||||
return eventtime + .9839
|
||||
def _handle_status(self, params):
|
||||
def _handle_clock(self, params):
|
||||
# Extend clock to 64bit
|
||||
last_clock = self.last_clock
|
||||
clock = (last_clock & ~0xffffffff) | params['clock']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue