From 679e7669a01c5c66fa42c84d4da84851ecdd7507 Mon Sep 17 00:00:00 2001 From: Brandon Nance Date: Tue, 7 Nov 2023 00:58:32 -0500 Subject: [PATCH] revert kevin mcu protocol message change --- klippy/klippy.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/klippy/klippy.py b/klippy/klippy.py index 2405a5381..42865b9bf 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -22,6 +22,8 @@ Printer is halted """ +message_protocol_error = """MCU Protocol error""" + message_protocol_error1 = """ This is frequently caused by running an older version of the firmware on the MCU(s). Fix by recompiling and flashing the @@ -204,36 +206,49 @@ def _read_config(self): def _build_protocol_error_message(self, e): host_version = self.start_args["software_version"] + msg_update = [] msg_updated = [] - for mcu_name, _mcu in self.lookup_objects("mcu"): + + for n, mcu_obj in self.lookup_objects("mcu"): try: - mcu_version = _mcu.get_status()["mcu_version"] + mcu_version = mcu_obj.get_status()["mcu_version"] except: - logging.exception("Unable to retrieve mcu_version from mcu") + logging.exception("Unable to retrieve mcu_version from mcu_obj") continue + if mcu_version != host_version: msg_update.append( "%s: Current version %s" - % (mcu_name.split()[-1], mcu_version) + % (n.split()[-1], mcu_obj.get_status()["mcu_version"]) ) else: msg_updated.append( "%s: Current version %s" - % (mcu_name.split()[-1], mcu_version) + % (n.split()[-1], mcu_obj.get_status()["mcu_version"]) ) - if not msg_update: - msg_update.append("") - if not msg_updated: + + if len(msg_updated) == 0: msg_updated.append("") - msg = [ - "MCU Protocol error", - message_protocol_error1, - "Your Klipper version is: %s" % (host_version,), + + version_msg = [ + "\nYour Klipper version is: %s\n" % host_version, "MCU(s) which should be updated:", + "\n%s\n" % "\n".join(msg_update), + "Up-to-date MCU(s):", + "\n%s\n" % "\n".join(msg_updated), ] - msg += msg_update + ["Up-to-date MCU(s):"] + msg_updated - msg += [message_protocol_error2, str(e)] + + msg = [ + message_protocol_error, + "", + " ".join(message_protocol_error1.splitlines())[1:], + "\n".join(version_msg), + " ".join(message_protocol_error2.splitlines())[1:], + "", + str(e), + ] + return "\n".join(msg) def _connect(self, eventtime):