From f32d7c434d0113f7c8cfb21f6a3eccba73f685c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 3 May 2017 20:18:11 +0200 Subject: [PATCH] Docs: Added note that coordinates in script context might be None Wasn't made clear before. --- docs/features/gcode_scripts.rst | 6 ++++-- src/octoprint/util/comm.py | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst index 7450ff7b..ee3136da 100644 --- a/docs/features/gcode_scripts.rst +++ b/docs/features/gcode_scripts.rst @@ -78,13 +78,15 @@ There are a few additional template variables available for the following specif * ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and current tool - ``t`` taken from commands sent through OctoPrint. + ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no position could be + retrieved from the printer or the values could not be tracked (in case of ``f`` and ``t``)! * ``afterPrintCancelled`` * ``cancel_position``: Position reported by the printer via ``M114`` immediately before the print was cancelled. Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and - current tool ``t`` taken from commands sent through OctoPrint. + current tool ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no + position could be retrieved from the printer or the values could not be tracked (in case of ``f`` and ``t``)! .. warning:: diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index c52c2c61..39f792cf 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -228,11 +228,11 @@ class PositionRecord(object): def as_dict(self): return dict(x=self.x, - y=self.y, - z=self.z, - e=self.e, - t=self.t, - f=self.f) + y=self.y, + z=self.z, + e=self.e, + t=self.t, + f=self.f) class MachineCom(object): STATE_NONE = 0 @@ -1181,6 +1181,7 @@ class MachineCom(object): # there's no way to query it from the firmware and # no way to track it ourselves when not streaming # the file - this all sucks sooo much + self.last_position.valid = True self.last_position.x = float(match.group("x")) self.last_position.y = float(match.group("y")) self.last_position.z = float(match.group("z"))