diff --git a/klippy/console.py b/klippy/console.py index 0259864f..b3932120 100755 --- a/klippy/console.py +++ b/klippy/console.py @@ -52,10 +52,16 @@ class KeyboardReader: self.output(help_txt) self.output("="*20 + " attempting to connect " + "="*20) self.ser.connect() + msgparser = self.ser.msgparser + self.output("Loaded %d commands (%s / %s)" % ( + len(msgparser.messages_by_id), + msgparser.version, msgparser.build_versions)) + self.output("MCU config: %s" % (" ".join( + ["%s=%s" % (k, v) for k, v in msgparser.config.items()]))) self.clocksync.connect(self.ser) self.ser.handle_default = self.handle_default - self.mcu_freq = self.ser.msgparser.get_constant_float('CLOCK_FREQ') - mcu_type = self.ser.msgparser.get_constant('MCU') + self.mcu_freq = msgparser.get_constant_float('CLOCK_FREQ') + mcu_type = msgparser.get_constant('MCU') self.pins = pins.PinResolver(mcu_type, validate_aliases=False) self.reactor.unregister_timer(self.connect_timer) self.output("="*20 + " connected " + "="*20) diff --git a/klippy/klippy.py b/klippy/klippy.py index 9a16d8f0..77ab3cc0 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -131,8 +131,6 @@ class Printer: def __init__(self, input_fd, bglogger, start_args): self.bglogger = bglogger self.start_args = start_args - if bglogger is not None: - bglogger.set_rollover_info("config", None) self.reactor = reactor.Reactor() gc = gcode.GCodeParser(self, input_fd) self.objects = collections.OrderedDict({'gcode': gc}) @@ -170,6 +168,7 @@ class Printer: return [self.objects[module_name]] + objs return objs def set_rollover_info(self, name, info): + logging.info(info) if self.bglogger is not None: self.bglogger.set_rollover_info(name, info) def _stats(self, eventtime, force_output=False): @@ -355,16 +354,18 @@ def main(): logging.info("Starting Klippy...") start_args['software_version'] = util.get_git_version() if bglogger is not None: - lines = ["Args: %s" % (sys.argv,), - "Git version: %s" % (repr(start_args['software_version']),), - "CPU: %s" % (util.get_cpu_info(),), - "Python: %s" % (repr(sys.version),)] - lines = "\n".join(lines) - logging.info(lines) - bglogger.set_rollover_info('versions', lines) + versions = "\n".join([ + "Args: %s" % (sys.argv,), + "Git version: %s" % (repr(start_args['software_version']),), + "CPU: %s" % (util.get_cpu_info(),), + "Python: %s" % (repr(sys.version),)]) + logging.info(versions) # Start Printer() class while 1: + if bglogger is not None: + bglogger.clear_rollover_info() + bglogger.set_rollover_info('versions', versions) printer = Printer(input_fd, bglogger, start_args) res = printer.run() if res == 'exit': diff --git a/klippy/mcu.py b/klippy/mcu.py index c00db3c7..8fcd3918 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -424,7 +424,6 @@ class MCU: self._emergency_stop_cmd = None self._is_shutdown = self._is_timeout = False self._shutdown_msg = "" - printer.set_rollover_info(self._name, None) # Config building pins.get_printer_pins(printer).register_chip(self._name, self) self._oid_count = 0 @@ -559,7 +558,6 @@ class MCU: self._check_restart("CRC mismatch") raise error("MCU '%s' CRC does not match config" % (self._name,)) move_count = config_params['move_count'] - logging.info("Configured MCU '%s' (%d moves)", self._name, move_count) msgparser = self._serial.msgparser info = [ "Configured MCU '%s' (%d moves)" % (self._name, move_count), diff --git a/klippy/queuelogger.py b/klippy/queuelogger.py index 32cb125d..370b46e9 100644 --- a/klippy/queuelogger.py +++ b/klippy/queuelogger.py @@ -40,11 +40,12 @@ class QueueListener(logging.handlers.TimedRotatingFileHandler): self.bg_thread.join() def set_rollover_info(self, name, info): self.rollover_info[name] = info + def clear_rollover_info(self): + self.rollover_info.clear() def doRollover(self): logging.handlers.TimedRotatingFileHandler.doRollover(self) lines = [self.rollover_info[name] - for name in sorted(self.rollover_info) - if self.rollover_info[name]] + for name in sorted(self.rollover_info)] lines.append( "=============== Log rollover at %s ===============" % ( time.asctime(),)) diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py index 75c61346..0f9e87a2 100644 --- a/klippy/serialhdl.py +++ b/klippy/serialhdl.py @@ -84,11 +84,6 @@ class SerialReader: msgparser.process_identify(identify_data) self.msgparser = msgparser self.register_callback(self.handle_unknown, '#unknown') - logging.info("Loaded %d commands (%s / %s)", - len(msgparser.messages_by_id), - msgparser.version, msgparser.build_versions) - logging.info("MCU config: %s", " ".join( - ["%s=%s" % (k, v) for k, v in msgparser.config.items()])) # Setup baud adjust mcu_baud = msgparser.get_constant_float('SERIAL_BAUD', None) if mcu_baud is not None: