mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-15 18:58:03 -06:00
msgproto: Avoid peeking into the msgproto class members
Update callers to only use exported methods of the msgproto objects. This makes it easier to make internal changes to the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
319c36df52
commit
efa497dfd8
4 changed files with 78 additions and 60 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python2
|
||||
# Script to implement a test console with firmware over serial port
|
||||
#
|
||||
# Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
|
||||
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import sys, optparse, os, re, logging
|
||||
|
@ -54,11 +54,12 @@ class KeyboardReader:
|
|||
self.output("="*20 + " attempting to connect " + "="*20)
|
||||
self.ser.connect()
|
||||
msgparser = self.ser.get_msgparser()
|
||||
self.output("Loaded %d commands (%s / %s)" % (
|
||||
len(msgparser.messages_by_id),
|
||||
msgparser.version, msgparser.build_versions))
|
||||
message_count = len(msgparser.get_messages())
|
||||
version, build_versions = msgparser.get_version_info()
|
||||
self.output("Loaded %d commands (%s / %s)"
|
||||
% (message_count, version, build_versions))
|
||||
self.output("MCU config: %s" % (" ".join(
|
||||
["%s=%s" % (k, v) for k, v in msgparser.config.items()])))
|
||||
["%s=%s" % (k, v) for k, v in msgparser.get_constants().items()])))
|
||||
self.clocksync.connect(self.ser)
|
||||
self.ser.handle_default = self.handle_default
|
||||
self.ser.register_response(self.handle_output, '#output')
|
||||
|
@ -137,9 +138,10 @@ class KeyboardReader:
|
|||
def command_LIST(self, parts):
|
||||
self.update_evals(self.reactor.monotonic())
|
||||
mp = self.ser.get_msgparser()
|
||||
cmds = [msgformat for msgid, msgtype, msgformat in mp.get_messages()
|
||||
if msgtype == 'command']
|
||||
out = "Available mcu commands:"
|
||||
out += "\n ".join([""] + sorted([
|
||||
mp.messages_by_id[i].msgformat for i in mp.command_ids]))
|
||||
out += "\n ".join([""] + sorted(cmds))
|
||||
out += "\nAvailable artificial commands:"
|
||||
out += "\n ".join([""] + [n for n in sorted(self.local_commands)])
|
||||
out += "\nAvailable local variables:"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue