Skip to content
Browse files

Only prevent command processing if streaming AND printing

Otherwise we might run into a rare race condition where the M110 sent
on start of a SD card upload gets prepared for sending after the
source file is already opened. That would then lead to the M110 not
getting processed anymore by OctoPrint and hence the line number
counter not resetting accordingly, leading to one line number
mismatch after the next from the firmware.

Testing if our "isPrinting" flag is ALSO set to true here ensures
that we'll only stop processing commands internally once the state
has actually switched to printing, which only happens after the
firmware responds to the M28 sent after the M110.

Fixes #1882 and probably also the issue encountered by @amd989 in
#1762 (which looks like exactly the same problem)
  • Loading branch information...
foosel committed May 3, 2017
1 parent f125462 commit 844494a9d5e81291344aa1379eeb47dc5fabaa9c
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/octoprint/util/
@@ -2163,7 +2163,7 @@ def _send_loop(self):
self._log("Closing down send loop")

def _process_command_phase(self, phase, command, command_type=None, gcode=None):
if self.isStreaming() or phase not in ("queuing", "queued", "sending", "sent"):
if (self.isStreaming() and self.isPrinting()) or phase not in ("queuing", "queued", "sending", "sent"):
return command, command_type, gcode

if gcode is None:
@@ -2432,17 +2432,17 @@ def _gcode_M116_sent(self, cmd, cmd_type=None):
self._heating = True

def _gcode_M110_sending(self, cmd, cmd_type=None):
newLineNumber = None
newLineNumber = 0
match = regexes_parameters["intN"].search(cmd)
if match:
newLineNumber = int("value"))
newLineNumber = 0

with self._line_mutex:"M110 detected, setting current line number to {}".format(newLineNumber))

# send M110 command with new line number
self._currentLine = newLineNumber

0 comments on commit 844494a

Please sign in to comment.
You can’t perform that action at this time.