From 1731fbbca4ef799546fba47ccafd29c923c3d735 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 4 Mar 2019 13:04:18 -0500 Subject: [PATCH] gcode: Change respond_info() to log by default It makes sense to log most respond_info() content, so do that by default. Signed-off-by: Kevin O'Connor --- klippy/extras/bltouch.py | 5 +---- klippy/extras/display/menu.py | 5 ++--- klippy/extras/tmc2130.py | 8 ++------ klippy/extras/tmc2208.py | 8 ++------ klippy/extras/z_tilt.py | 1 - klippy/gcode.py | 13 +++++++------ klippy/kinematics/extruder.py | 2 +- klippy/mathutil.py | 2 +- klippy/toolhead.py | 2 +- 9 files changed, 17 insertions(+), 29 deletions(-) diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py index 237fe690..889e23d2 100644 --- a/klippy/extras/bltouch.py +++ b/klippy/extras/bltouch.py @@ -118,7 +118,6 @@ class BLTouchEndstopWrapper: if retry >= 2: raise msg = "Failed to verify BLTouch probe is raised; retrying." - logging.warning(msg) self.gcode.respond_info(msg) self.next_cmd_time += RETRY_RESET_TIME continue @@ -172,9 +171,7 @@ class BLTouchEndstopWrapper: self.gcode.respond_info("BLTouch commands: %s" % ( ", ".join(sorted([c for c in Commands if c is not None])))) return - msg = "Sending BLTOUCH_DEBUG COMMAND=%s" % (cmd,) - self.gcode.respond_info(msg) - logging.info(msg) + self.gcode.respond_info("Sending BLTOUCH_DEBUG COMMAND=%s" % (cmd,)) self.sync_print_time() self.send_cmd(cmd, duration=self.pin_move_time) self.send_cmd(None) diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index e6304e39..b3c0ea16 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -1457,7 +1457,8 @@ class MenuManager: elif action == 'exit': self.exit() elif action == 'respond': - self.gcode.respond_info("{}".format(' '.join(map(str, args)))) + self.gcode.respond_info("{}".format(' '.join(map(str, args))), + log=False) elif action == 'event' and len(args) > 0: if len(str(args[0])) > 0: self.printer.send_event( @@ -1530,11 +1531,9 @@ class MenuManager: key1, key2, self.parameters[key1].get(key2) ) - logging.info(msg) self.gcode.respond_info(msg) else: msg = "{0} = {1}".format(key1, self.parameters.get(key1)) - logging.info(msg) self.gcode.respond_info(msg) # buttons & encoder callbacks diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index 0bbfcf32..67672659 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -280,15 +280,11 @@ class TMC2130: gcode.respond_info("========== Write-only registers ==========") for reg_name, val in self.regs.items(): if reg_name not in ReadRegisters: - msg = self.fields.pretty_format(reg_name, val) - logging.info(msg) - gcode.respond_info(msg) + gcode.respond_info(self.fields.pretty_format(reg_name, val)) gcode.respond_info("========== Queried registers ==========") for reg_name in ReadRegisters: val = self.get_register(reg_name) - msg = self.fields.pretty_format(reg_name, val) - logging.info(msg) - gcode.respond_info(msg) + gcode.respond_info(self.fields.pretty_format(reg_name, val)) cmd_INIT_TMC_help = "Initialize TMC stepper driver registers" def cmd_INIT_TMC(self, params): logging.info("INIT_TMC 2130 %s", self.name) diff --git a/klippy/extras/tmc2208.py b/klippy/extras/tmc2208.py index f312c205..51971b0a 100644 --- a/klippy/extras/tmc2208.py +++ b/klippy/extras/tmc2208.py @@ -359,9 +359,7 @@ class TMC2208: gcode.respond_info("========== Write-only registers ==========") for reg_name, val in self.regs.items(): if reg_name not in ReadRegisters: - msg = self.fields.pretty_format(reg_name, val) - logging.info(msg) - gcode.respond_info(msg) + gcode.respond_info(self.fields.pretty_format(reg_name, val)) gcode.respond_info("========== Queried registers ==========") for reg_name in ReadRegisters: try: @@ -373,9 +371,7 @@ class TMC2208: if reg_name == "IOIN": drv_type = self.fields.get_field("SEL_A", val) reg_name = "IOIN@TMC220x" if drv_type else "IOIN@TMC222x" - msg = self.fields.pretty_format(reg_name, val) - logging.info(msg) - gcode.respond_info(msg) + gcode.respond_info(self.fields.pretty_format(reg_name, val)) cmd_INIT_TMC_help = "Initialize TMC stepper driver registers" def cmd_INIT_TMC(self, params): logging.info("INIT_TMC 2208 %s", self.name) diff --git a/klippy/extras/z_tilt.py b/klippy/extras/z_tilt.py index 04b7d4c1..bcbfddd9 100644 --- a/klippy/extras/z_tilt.py +++ b/klippy/extras/z_tilt.py @@ -84,7 +84,6 @@ class ZTilt: stepstrs = ["%s = %.6f" % (s.get_name(), so) for so, s in positions] msg = "Making the following Z adjustments:\n%s\nz_adjust = %.6f" % ( "\n".join(stepstrs), z_adjust) - logging.info(msg) self.gcode.respond_info(msg) # Move each z stepper (sorted from lowest to highest) until they match positions.sort() diff --git a/klippy/gcode.py b/klippy/gcode.py index 7be039cb..8cddde9f 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -307,20 +307,21 @@ class GCodeParser: os.write(self.fd, msg+"\n") except os.error: logging.exception("Write g-code response") - def respond_info(self, msg): - logging.debug(msg) + def respond_info(self, msg, log=True): + if log: + logging.info(msg) lines = [l.strip() for l in msg.strip().split('\n')] self.respond("// " + "\n// ".join(lines)) def respond_error(self, msg): logging.warning(msg) lines = msg.strip().split('\n') if len(lines) > 1: - self.respond_info("\n".join(lines)) + self.respond_info("\n".join(lines), log=False) self.respond('!! %s' % (lines[0].strip(),)) if self.is_fileinput: self.printer.request_exit('error_exit') def _respond_state(self, state): - self.respond_info("Klipper state: %s" % (state,)) + self.respond_info("Klipper state: %s" % (state,), log=False) # Parameter parsing helpers class sentinel: pass def get_str(self, name, params, default=sentinel, parser=str, @@ -695,7 +696,7 @@ class GCodeParser: self.request_restart('firmware_restart') cmd_ECHO_when_not_ready = True def cmd_ECHO(self, params): - self.respond_info(params['#original']) + self.respond_info(params['#original'], log=False) cmd_STATUS_when_not_ready = True cmd_STATUS_help = "Report the printer status" def cmd_STATUS(self, params): @@ -714,4 +715,4 @@ class GCodeParser: for cmd in sorted(self.gcode_handlers): if cmd in self.gcode_help: cmdhelp.append("%-10s: %s" % (cmd, self.gcode_help[cmd])) - self.respond_info("\n".join(cmdhelp)) + self.respond_info("\n".join(cmdhelp), log=False) diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index b32b66d9..de6668d4 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -216,7 +216,7 @@ class PrinterExtruder: "pressure_advance_lookahead_time: %.6f" % ( pressure_advance, pressure_advance_lookahead_time)) self.printer.set_rollover_info(self.name, "%s: %s" % (self.name, msg)) - gcode.respond_info(msg) + gcode.respond_info(msg, log=False) # Dummy extruder class used when a printer has no extruder at all class DummyExtruder: diff --git a/klippy/mathutil.py b/klippy/mathutil.py index 737999b2..ed330c61 100644 --- a/klippy/mathutil.py +++ b/klippy/mathutil.py @@ -65,7 +65,7 @@ def background_coordinate_descent(printer, adj_params, params, error_func): while calc_proc.is_alive(): if eventtime > last_report_time + 5.: last_report_time = eventtime - gcode.respond_info("Working on calibration...") + gcode.respond_info("Working on calibration...", log=False) eventtime = reactor.pause(eventtime + .1) # Return results res = parent_conn.recv() diff --git a/klippy/toolhead.py b/klippy/toolhead.py index edf6d326..b7413fb1 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -462,7 +462,7 @@ class ToolHead: max_velocity, max_accel, self.requested_accel_to_decel, square_corner_velocity)) self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,)) - gcode.respond_info(msg) + gcode.respond_info(msg, log=False) def cmd_M204(self, params): gcode = self.printer.lookup_object('gcode') if 'P' in params and 'T' in params and 'S' not in params: