From 38c4738909ed7d4dcb3fed1ef12094d0173af9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 18 Aug 2013 18:40:08 +0200 Subject: [PATCH 1/6] Properly enable serial logging on startup if configured (cherry picked from commit 2261ddf) --- octoprint/server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/octoprint/server.py b/octoprint/server.py index 8d2287d7..f4b3113c 100644 --- a/octoprint/server.py +++ b/octoprint/server.py @@ -1039,6 +1039,11 @@ class Server(): logging.config.dictConfig(config) + if settings().getBoolean(["serial", "log"]): + # enable debug logging to serial.log + logging.getLogger("SERIAL").setLevel(logging.DEBUG) + logging.getLogger("SERIAL").debug("Enabling serial logging") + if __name__ == "__main__": octoprint = Server() octoprint.run() From 456eb8cb470a79a92d8ca96e396cfef747933705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 18 Aug 2013 18:40:52 +0200 Subject: [PATCH 2/6] Only match "rs"/"resend" on the start of a line, otherwise the wrong lines might be interpreted as resend requests (cherry picked from commit ae09a50) --- octoprint/util/comm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index 32f66c76..87a001b4 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -692,7 +692,7 @@ class MachineCom(object): self._sendCommand("M105") tempRequestTimeout = getNewTimeout("communication") # resend -> start resend procedure from requested line - elif "resend" in line.lower() or "rs" in line: + elif line.lower().startswith("resend") or line.lower().startswith("rs"): self._handleResendRequest(line) ### Printing @@ -726,7 +726,7 @@ class MachineCom(object): self._sendCommand(self._commandQueue.get()) else: self._sendNext() - elif "resend" in line.lower() or "rs" in line: + elif line.lower().startswith("resend") or line.lower().startswith("rs"): self._handleResendRequest(line) except: self._logger.exception("Something crashed inside the serial connection loop, please report this in OctoPrint's bug tracker:") From 481a750cf67ee445f89d68bee4201d48943b7a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 18 Aug 2013 18:41:20 +0200 Subject: [PATCH 3/6] Check if self._comm is None before trying to select a file... (cherry picked from commit 5631a45) --- octoprint/printer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint/printer.py b/octoprint/printer.py index d5b56fa2..d5fc445f 100644 --- a/octoprint/printer.py +++ b/octoprint/printer.py @@ -175,7 +175,7 @@ class Printer(): self._comm.sendCommand(command) def selectFile(self, filename, sd, printAfterSelect=False): - if self._comm is not None and (self._comm.isBusy() or self._comm.isStreaming()): + if self._comm is None or (self._comm.isBusy() or self._comm.isStreaming()): return self._printAfterSelect = printAfterSelect From 30c837fa1303110161ce2c7bbd83fe3ad03ae846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 25 Aug 2013 14:05:52 +0200 Subject: [PATCH 4/6] Added .gco to supported extensions (cherry picked from commit d51aa65) --- octoprint/gcodefiles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/octoprint/gcodefiles.py b/octoprint/gcodefiles.py index 704a7b36..7cc024d5 100644 --- a/octoprint/gcodefiles.py +++ b/octoprint/gcodefiles.py @@ -15,6 +15,8 @@ from octoprint.settings import settings from werkzeug.utils import secure_filename +SUPPORTED_EXTENSIONS=["gcode", "gco"] + class GcodeManager: def __init__(self): self._logger = logging.getLogger(__name__) @@ -171,7 +173,7 @@ class GcodeManager: """ filename = self._getBasicFilename(filename) - if not util.isAllowedFile(filename, set(["gcode"])): + if not util.isAllowedFile(filename.lower(), set(SUPPORTED_EXTENSIONS)): return None secure = os.path.join(self._uploadFolder, secure_filename(self._getBasicFilename(filename))) From d16b96056bab74c63f16a22c4919500834741396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 25 Aug 2013 15:03:27 +0200 Subject: [PATCH 5/6] Properly handle failed uploads: display message, reset upload status (cherry picked from commit ce7ccc1) --- octoprint/static/js/ui.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index 12cc4ed5..df5359b4 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -2136,6 +2136,18 @@ $(function() { $("#gcode_upload_progress .bar").text(""); } + function gcode_upload_fail(e, data) { + $.pnotify({ + title: "Upload failed", + text: "

Could not upload the file. Make sure it is a GCODE file and has one of the following extensions: .gcode, .gco

Server reported:

" + data.jqXHR.responseText + "

", + type: "error", + hide: false + }); + $("#gcode_upload_progress .bar").css("width", "0%"); + $("#gcode_upload_progress").removeClass("progress-striped").removeClass("active"); + $("#gcode_upload_progress .bar").text(""); + } + function gcode_upload_progress(e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $("#gcode_upload_progress .bar").css("width", progress + "%"); @@ -2158,6 +2170,7 @@ $(function() { dropZone: localTarget, formData: {target: "local"}, done: gcode_upload_done, + fail: gcode_upload_fail, progressall: gcode_upload_progress }); @@ -2167,6 +2180,7 @@ $(function() { dropZone: $("#drop_sd"), formData: {target: "sd"}, done: gcode_upload_done, + fail: gcode_upload_fail, progressall: gcode_upload_progress }); } From 63555d2c4bd204deae90262c59b73f6c663f3c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 10 Sep 2013 23:17:34 +0200 Subject: [PATCH 6/6] Fixed SD upload (managed to break this by introducing temperature offsets). Closes #249 --- octoprint/util/comm.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index bb3f9aab..db555393 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -1134,26 +1134,28 @@ class PrintingGcodeFileInformation(PrintingFileInformation): line = line[0:line.find(";")] line = line.strip() if len(line) > 0: - (tempOffset, bedTempOffset) = self._offsetCallback() - if tempOffset != 0 or bedTempOffset != 0: - tempMatch = self._tempCommandPattern.match(line) - if tempMatch is not None: - if tempMatch.group(1) == "104" or tempMatch.group(1) == "109": - offset = tempOffset - elif tempMatch.group(1) == "140" or tempMatch.group(1) == "190": - offset = bedTempOffset - else: - offset = 0 + if self._offsetCallback is not None: + (tempOffset, bedTempOffset) = self._offsetCallback() + if tempOffset != 0 or bedTempOffset != 0: + tempMatch = self._tempCommandPattern.match(line) + if tempMatch is not None: + if tempMatch.group(1) == "104" or tempMatch.group(1) == "109": + offset = tempOffset + elif tempMatch.group(1) == "140" or tempMatch.group(1) == "190": + offset = bedTempOffset + else: + offset = 0 - try: - temp = float(tempMatch.group(2)) - newTemp = temp + offset - line = line.replace("S" + tempMatch.group(2), "S%f" % newTemp) - except ValueError: - pass + try: + temp = float(tempMatch.group(2)) + newTemp = temp + offset + line = line.replace("S" + tempMatch.group(2), "S%f" % newTemp) + except ValueError: + pass return line else: return None class StreamingGcodeFileInformation(PrintingGcodeFileInformation): - pass + def __init__(self, filename): + PrintingGcodeFileInformation.__init__(self, filename, None) \ No newline at end of file