mirror of https://github.com/Desuuuu/klipper.git
serialhdl: Add a get_msgparser() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
647f1ee2e0
commit
461ed4cb80
|
@ -53,7 +53,7 @@ class KeyboardReader:
|
|||
self.output(help_txt)
|
||||
self.output("="*20 + " attempting to connect " + "="*20)
|
||||
self.ser.connect()
|
||||
msgparser = self.ser.msgparser
|
||||
msgparser = self.ser.get_msgparser()
|
||||
self.output("Loaded %d commands (%s / %s)" % (
|
||||
len(msgparser.messages_by_id),
|
||||
msgparser.version, msgparser.build_versions))
|
||||
|
@ -72,8 +72,8 @@ class KeyboardReader:
|
|||
sys.stdout.flush()
|
||||
def handle_default(self, params):
|
||||
tdiff = params['#receive_time'] - self.start_time
|
||||
self.output("%07.3f: %s" % (
|
||||
tdiff, self.ser.msgparser.format_params(params)))
|
||||
msg = self.ser.get_msgparser().format_params(params)
|
||||
self.output("%07.3f: %s" % (tdiff, msg))
|
||||
def handle_output(self, params):
|
||||
tdiff = params['#receive_time'] - self.start_time
|
||||
self.output("%07.3f: %s: %s" % (tdiff, params['#name'], params['#msg']))
|
||||
|
@ -137,7 +137,7 @@ class KeyboardReader:
|
|||
self.clocksync.stats(curtime)]))
|
||||
def command_LIST(self, parts):
|
||||
self.update_evals(self.reactor.monotonic())
|
||||
mp = self.ser.msgparser
|
||||
mp = self.ser.get_msgparser()
|
||||
out = "Available mcu commands:"
|
||||
out += "\n ".join([""] + sorted([
|
||||
mp.messages_by_id[i].msgformat for i in mp.command_ids]))
|
||||
|
|
|
@ -544,7 +544,7 @@ class MCU:
|
|||
self._config_cmds.insert(0, "allocate_oids count=%d" % (
|
||||
self._oid_count,))
|
||||
# Resolve pin names
|
||||
mcu_type = self._serial.msgparser.get_constant('MCU')
|
||||
mcu_type = self._serial.get_msgparser().get_constant('MCU')
|
||||
ppins = self._printer.lookup_object('pins')
|
||||
reserved_pins = ppins.get_reserved_pins(self._name)
|
||||
pin_resolver = pins.PinResolver(mcu_type, reserved_pins)
|
||||
|
@ -616,7 +616,7 @@ class MCU:
|
|||
self._check_restart("enable power")
|
||||
self._serial.connect()
|
||||
self._clocksync.connect(self._serial)
|
||||
msgparser = self._serial.msgparser
|
||||
msgparser = self._serial.get_msgparser()
|
||||
name = self._name
|
||||
log_info = [
|
||||
"Loaded MCU '%s' %d commands (%s / %s)" % (
|
||||
|
@ -689,16 +689,16 @@ class MCU:
|
|||
def try_lookup_command(self, msgformat):
|
||||
try:
|
||||
return self.lookup_command(msgformat)
|
||||
except self._serial.msgparser.error as e:
|
||||
except self._serial.get_msgparser().error as e:
|
||||
return None
|
||||
def lookup_command_id(self, msgformat):
|
||||
return self._serial.msgparser.lookup_command(msgformat).msgid
|
||||
return self._serial.get_msgparser().lookup_command(msgformat).msgid
|
||||
def get_enumerations(self):
|
||||
return self._serial.msgparser.get_enumerations()
|
||||
return self._serial.get_msgparser().get_enumerations()
|
||||
def get_constants(self):
|
||||
return self._serial.msgparser.get_constants()
|
||||
return self._serial.get_msgparser().get_constants()
|
||||
def get_constant_float(self, name):
|
||||
return self._serial.msgparser.get_constant_float(name)
|
||||
return self._serial.get_msgparser().get_constant_float(name)
|
||||
def print_time_to_clock(self, print_time):
|
||||
return self._clocksync.print_time_to_clock(print_time)
|
||||
def clock_to_print_time(self, clock):
|
||||
|
|
|
@ -116,6 +116,8 @@ class SerialReader:
|
|||
self.ffi_lib.serialqueue_get_stats(
|
||||
self.serialqueue, self.stats_buf, len(self.stats_buf))
|
||||
return self.ffi_main.string(self.stats_buf)
|
||||
def get_msgparser(self):
|
||||
return self.msgparser
|
||||
# Serial response callbacks
|
||||
def register_response(self, callback, name, oid=None):
|
||||
with self.lock:
|
||||
|
|
Loading…
Reference in New Issue