mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-18 20:28:10 -06:00
msgproto: Rework dump() so it also works with params
Always call the regular .parse() method for each message type during dump() - add a new .format_params() method for dumping a verbose representation of the parsed message. This allows the new format_params() to also be used with data already parsed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a6fe355801
commit
ccb93068fe
2 changed files with 27 additions and 21 deletions
|
@ -25,6 +25,7 @@ class KeyboardReader:
|
|||
self.eval_globals = {}
|
||||
def connect(self, eventtime):
|
||||
self.ser.connect()
|
||||
self.ser.handle_default = self.handle_default
|
||||
self.mcu_freq = self.ser.msgparser.get_constant_float('CLOCK_FREQ')
|
||||
mcu = self.ser.msgparser.get_constant('MCU')
|
||||
self.pins = pins.get_pin_map(mcu)
|
||||
|
@ -33,6 +34,8 @@ class KeyboardReader:
|
|||
def output(self, msg):
|
||||
sys.stdout.write("%s\n" % (msg,))
|
||||
sys.stdout.flush()
|
||||
def handle_default(self, params):
|
||||
self.output(self.ser.msgparser.format_params(params))
|
||||
def update_evals(self, eventtime):
|
||||
self.eval_globals['freq'] = self.mcu_freq
|
||||
self.eval_globals['clock'] = self.ser.get_clock(eventtime)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue