diff --git a/klippy/gcode.py b/klippy/gcode.py index b1e856d6..2225c92c 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -44,7 +44,7 @@ class GCodeParser: self.fan = self.printer.objects.get('fan') def build_handlers(self): handlers = ['G1', 'G4', 'G20', 'G21', 'G28', 'G90', 'G91', 'G92', - 'M18', 'M82', 'M83', 'M105', 'M110', 'M112', 'M114', + 'M18', 'M82', 'M83', 'M105', 'M110', 'M112', 'M114', 'M115', 'M206', 'M400', 'HELP', 'QUERY_ENDSTOPS', 'RESTART', 'CLEAR_SHUTDOWN', 'STATUS'] @@ -303,6 +303,12 @@ class GCodeParser: self.last_position[0], self.last_position[1], self.last_position[2], self.last_position[3], kinpos[0], kinpos[1], kinpos[2])) + cmd_M115_when_not_ready = True + def cmd_M115(self, params): + # Get Firmware Version and Capabilities + kw = {"FIRMWARE_NAME": "Klipper" + , "FIRMWARE_VERSION": self.printer.software_version} + self.ack(" ".join(["%s:%s" % (k, v) for k, v in kw.items()])) def cmd_M140(self, params): # Set Bed Temperature self.set_temp(self.heater_bed, params) diff --git a/klippy/klippy.py b/klippy/klippy.py index f9f55de1..7af2e9b8 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -82,8 +82,9 @@ class ConfigLogger(): logging.info(data.strip()) class Printer: - def __init__(self, conffile, input_fd, is_fileinput=False): + def __init__(self, conffile, input_fd, is_fileinput=False, version="?"): self.conffile = conffile + self.software_version = version self.reactor = reactor.Reactor() self.gcode = gcode.GCodeParser(self, input_fd, is_fileinput) self.stats_timer = self.reactor.register_timer(self.stats) @@ -260,13 +261,14 @@ def main(): else: logging.basicConfig(level=debuglevel) logging.info("Starting Klippy...") + software_version = util.get_git_version() if debugoutput is None: - util.report_git_version() + logging.info("Git version: %s" % (repr(software_version),)) # Start firmware while 1: is_fileinput = debuginput is not None - printer = Printer(conffile, input_fd, is_fileinput) + printer = Printer(conffile, input_fd, is_fileinput, software_version) if debugoutput: proto_dict = read_dictionary(options.read_dictionary) printer.set_fileoutput(debugoutput, proto_dict) diff --git a/klippy/util.py b/klippy/util.py index 9daf75cd..7a61de08 100644 --- a/klippy/util.py +++ b/klippy/util.py @@ -36,11 +36,11 @@ def create_pty(ptyname): termios.tcsetattr(mfd, termios.TCSADRAIN, old) return mfd -def report_git_version(): +def get_git_version(): # Obtain version info from "git" program if not os.path.exists('.git'): logging.debug("No '.git' file/directory found") - return + return "?" prog = "git describe --tags --long --dirty" try: process = subprocess.Popen(shlex.split(prog), stdout=subprocess.PIPE) @@ -48,6 +48,5 @@ def report_git_version(): retcode = process.poll() except OSError: logging.debug("Exception on run: %s" % (traceback.format_exc(),)) - return - ver = output.strip() - logging.info("Git version: %s" % (repr(ver),)) + return "?" + return output.strip()