From 590bff696b5c6742dc8981992706cd8d8a265429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 18 Mar 2015 11:32:55 +0100 Subject: [PATCH 1/3] Also allow plugins to extend gcode scripts which are empty --- src/octoprint/util/comm.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 7814561e5..4a2ee588d 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -432,15 +432,15 @@ class MachineCom(object): template = settings().loadScript("gcode", scriptName, context=context) if template is None: - return None - - scriptLines = filter( - lambda x: x is not None and x.strip() != "", - map( - lambda x: process_gcode_line(x, offsets=self._tempOffsets, current_tool=self._currentTool), - template.split("\n") + scriptLines = [] + else: + scriptLines = filter( + lambda x: x is not None and x.strip() != "", + map( + lambda x: process_gcode_line(x, offsets=self._tempOffsets, current_tool=self._currentTool), + template.split("\n") + ) ) - ) for hook in self._gcodescript_hooks: try: From 7b9e3efea14e1b63fb14b4dd942e0e36f363c653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 18 Mar 2015 12:08:21 +0100 Subject: [PATCH 2/3] Removed /dev/ttyAMA* from serial ports added by default to connection list Added additional ports configuration to settings to make it easier for people who actually need that port in the selection to add it back. --- CHANGELOG.md | 4 ++++ src/octoprint/server/api/settings.py | 4 +++- src/octoprint/static/js/app/viewmodels/settings.js | 11 ++++++++++- .../dialogs/settings/serialconnection.jinja2 | 7 +++++++ src/octoprint/util/comm.py | 1 - 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a491e78c..44cc05551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,10 @@ * OctoPrint server should no longer hang when big changes in the system time happen, e.g. after first contact to an NTP server on a Raspberry Pi image. Achieved through monkey patching Tornado with [this PR](https://github.com/tornadoweb/tornado/pull/1290). +* Serial ports matching ``/dev/ttyAMA*`` are not anymore listed by default (this was the reason for a lot of people + attempting to connect to their printer on their Raspberry Pis, on which ``/dev/ttyAMA0`` is the OS's serial console + by default). Added configuration of additional ports to the Serial Connection section in the Settings to make it easier + for those people who do indeed have their printer connected to ``/dev/ttyAMA0``. ### Bug Fixes diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 6da2cc9a6..42e72bbdd 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -76,7 +76,8 @@ def getSettings(): "timeoutCommunication": s.getFloat(["serial", "timeout", "communication"]), "timeoutTemperature": s.getFloat(["serial", "timeout", "temperature"]), "timeoutSdStatus": s.getFloat(["serial", "timeout", "sdStatus"]), - "log": s.getBoolean(["serial", "log"]) + "log": s.getBoolean(["serial", "log"]), + "additionalPorts": s.get(["serial", "additionalPorts"]) }, "folder": { "uploads": s.getBaseFolder("uploads"), @@ -183,6 +184,7 @@ def setSettings(): if "timeoutCommunication" in data["serial"].keys(): s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"]) if "timeoutTemperature" in data["serial"].keys(): s.setFloat(["serial", "timeout", "temperature"], data["serial"]["timeoutTemperature"]) if "timeoutSdStatus" in data["serial"].keys(): s.setFloat(["serial", "timeout", "sdStatus"], data["serial"]["timeoutSdStatus"]) + if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"]) oldLog = s.getBoolean(["serial", "log"]) if "log" in data["serial"].keys(): s.setBoolean(["serial", "log"], data["serial"]["log"]) diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 30da456e6..85afe67e4 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -85,6 +85,7 @@ $(function() { self.serial_timeoutTemperature = ko.observable(undefined); self.serial_timeoutSdStatus = ko.observable(undefined); self.serial_log = ko.observable(undefined); + self.serial_additionalPorts = ko.observable(undefined); self.folder_uploads = ko.observable(undefined); self.folder_timelapse = ko.observable(undefined); @@ -220,6 +221,7 @@ $(function() { self.serial_timeoutTemperature(response.serial.timeoutTemperature); self.serial_timeoutSdStatus(response.serial.timeoutSdStatus); self.serial_log(response.serial.log); + self.serial_additionalPorts(response.serial.additionalPorts.join("\n")); self.folder_uploads(response.folder.uploads); self.folder_timelapse(response.folder.timelapse); @@ -290,7 +292,14 @@ $(function() { "timeoutCommunication": self.serial_timeoutCommunication(), "timeoutTemperature": self.serial_timeoutTemperature(), "timeoutSdStatus": self.serial_timeoutSdStatus(), - "log": self.serial_log() + "log": self.serial_log(), + "additionalPorts": _.filter( + _.map( + self.serial_additionalPorts().split("\n"), + function(item) { return (item) ? item.trim() : ""; } + ), + function(item) { return item && !_.startsWith(item, "#"); } + ) }, "folder": { "uploads": self.folder_uploads(), diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 234aad021..13b7177d3 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -70,4 +70,11 @@ +
+ +
+ + {{ _('Use this to define additional glob patterns matching serial ports to list for connecting against, e.g. /dev/ttyAMA*. One entry per line.')|format(glob_url="http://docs.python.org/2/library/glob.html") }} +
+
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 4a2ee588d..7a970f30c 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -46,7 +46,6 @@ def serialList(): baselist = baselist \ + glob.glob("/dev/ttyUSB*") \ + glob.glob("/dev/ttyACM*") \ - + glob.glob("/dev/ttyAMA*") \ + glob.glob("/dev/tty.usb*") \ + glob.glob("/dev/cu.*") \ + glob.glob("/dev/cuaU*") \ From aa0e7a6dd310c69f10547d71c16f1823905da440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 18 Mar 2015 15:54:06 +0100 Subject: [PATCH 3/3] Fixed ``/api/printer`` which wasn't adapter yet to new internal offset data model --- CHANGELOG.md | 1 + src/octoprint/printer/standard.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44cc05551..b8645fb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -171,6 +171,7 @@ * Don't display a "Disconnected" screen when trying to download a timelapse in Firefox * Fixed handling of SD card files in folders * Fixed refreshing of timelapse file list upon finished rendering of a new one + * Fixed ``/api/printer`` which wasn't adapter yet to new internal offset data model ([Commits](https://github.com/foosel/OctoPrint/compare/master...devel)) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 3127e0278..289741b50 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -436,24 +436,23 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): def get_current_temperatures(self): if self._comm is not None: - tempOffset, bedTempOffset = self._comm.getOffsets() + offsets = self._comm.getOffsets() else: - tempOffset = {} - bedTempOffset = None + offsets = dict() result = {} if self._temp is not None: for tool in self._temp.keys(): result["tool%d" % tool] = { - "actual": self._temp[tool][0], - "target": self._temp[tool][1], - "offset": tempOffset[tool] if tool in tempOffset.keys() and tempOffset[tool] is not None else 0 + "actual": self._temp[tool][0], + "target": self._temp[tool][1], + "offset": offsets[tool] if tool in offsets and offsets[tool] is not None else 0 } if self._bedTemp is not None: result["bed"] = { - "actual": self._bedTemp[0], - "target": self._bedTemp[1], - "offset": bedTempOffset + "actual": self._bedTemp[0], + "target": self._bedTemp[1], + "offset": offsets["bed"] if "bed" in offsets and offsets["bed"] is not None else 0 } return result