Skip to content

Commit

Permalink
Fix target temperature propagation from comm layer
Browse files Browse the repository at this point in the history
When setting the tracked target temperature from a sent temperature
command, the changes in tracked temperature were not propagated
from the comm layer to registered callbacks.

But since the standard printer also didn't make a copy of the mutable
dict of tool temperatures, those were in fact updated even without
propagation in the printer implementation when the values in the
comm layer got updated, whereas the bed temperature - an immutable
tupel - was not.

Two wrongs sometimes do in fact make a right. In this case that led
to target temperature changes on the tools immediately reflecting
in printer.get_current_temperatures after the command was sent,
but changes to the bed target taking until the next M105 response
to propagate.

Decoupling the data structures and adding propagation commands
to the comm layer solves this issue.

Fixes #1543
  • Loading branch information
foosel committed Oct 14, 2016
1 parent c863562 commit bc5044b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/octoprint/printer/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def change_tool(self, tool):

def set_temperature(self, heater, value):
if not PrinterInterface.valid_heater_regex.match(heater):
raise ValueError("heater must match \"tool[0-9]+\" or \"bed\": {heater}".format(type=heater))
raise ValueError("heater must match \"tool[0-9]+\" or \"bed\": {heater}".format(heater=heater))

if not isinstance(value, (int, long, float)) or value < 0:
raise ValueError("value must be a valid number >= 0: {value}".format(value=value))
Expand Down Expand Up @@ -915,7 +915,7 @@ def on_comm_log(self, message):
self._addLog(to_unicode(message, "utf-8", errors="replace"))

def on_comm_temperature_update(self, temp, bedTemp):
self._addTemperatureData(temp, bedTemp)
self._addTemperatureData(copy.deepcopy(temp), copy.deepcopy(bedTemp))

def on_comm_state_change(self, state):
"""
Expand Down
2 changes: 2 additions & 0 deletions src/octoprint/util/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,7 @@ def _gcode_M104_sent(self, cmd, cmd_type=None, wait=False):
self._temp[toolNum] = (actual, target)
else:
self._temp[toolNum] = (None, target)
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
except ValueError:
pass

Expand All @@ -2154,6 +2155,7 @@ def _gcode_M140_sent(self, cmd, cmd_type=None, wait=False):
self._bedTemp = (actual, target)
else:
self._bedTemp = (None, target)
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
except ValueError:
pass

Expand Down

0 comments on commit bc5044b

Please sign in to comment.