mirror of https://github.com/Desuuuu/klipper.git
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
|
@ -226,11 +226,11 @@ only of interest to developers looking to gain insight into Klipper.
|
|||
pins attached to thermistors controlling heaters - it can be used to
|
||||
check that a heater is within a temperature range.
|
||||
|
||||
* `get_status` : This command causes the micro-controller to generate
|
||||
a "status" response message. The host sends this command once a
|
||||
second to obtain the value of the micro-controller clock and to
|
||||
estimate the drift between host and micro-controller clocks. It
|
||||
enables the host to accurately estimate the micro-controller clock.
|
||||
* `get_clock` : This command causes the micro-controller to generate a
|
||||
"clock" response message. The host sends this command once a second
|
||||
to obtain the value of the micro-controller clock and to estimate
|
||||
the drift between host and micro-controller clocks. It enables the
|
||||
host to accurately estimate the micro-controller clock.
|
||||
|
||||
Stepper commands
|
||||
----------------
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -240,11 +240,11 @@ config_reset(uint32_t *args)
|
|||
****************************************************************/
|
||||
|
||||
void
|
||||
command_get_status(uint32_t *args)
|
||||
command_get_clock(uint32_t *args)
|
||||
{
|
||||
sendf("status clock=%u status=%c", timer_read_time(), sched_is_shutdown());
|
||||
sendf("clock clock=%u", timer_read_time());
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_get_status, HF_IN_SHUTDOWN, "get_status");
|
||||
DECL_COMMAND_FLAGS(command_get_clock, HF_IN_SHUTDOWN, "get_clock");
|
||||
|
||||
static uint32_t stats_send_time, stats_send_time_high;
|
||||
|
||||
|
|
Loading…
Reference in New Issue