Do not hiccup on manually sent M28 commands

In case of trying to switch to state printing with no selected file that
scenario is now caught by setting an internal manualStreaming flag.
That will stop the M105 polling until M29 is sent (through whatever
means).

Note that printing is not disabled... this is merely for testing stuff and
not encouraged to be used for actually streaming files to the printer,
use the built-in functionality for that!
This commit is contained in:
Gina Häußge 2016-02-09 11:32:56 +01:00
parent 4b7552e56e
commit 8069d08d3b
2 changed files with 18 additions and 4 deletions

View file

@ -587,6 +587,7 @@ class VirtualPrinter():
def _finishSdFile(self):
self._writingToSd = False
self._selectedSdFile = None
self.outgoing.put("Done saving file")
def _sdPrintingWorker(self):
self._selectedSdFilePos = 0

View file

@ -271,6 +271,7 @@ class MachineCom(object):
self._sdFiles = []
self._sdFileToSelect = None
self._ignore_select = False
self._manualStreaming = False
# print job
self._currentFile = None
@ -1035,15 +1036,14 @@ class MachineCom(object):
elif 'File selected' in line:
if self._ignore_select:
self._ignore_select = False
elif self._currentFile is not None:
elif self._currentFile is not None and self.isSdFileSelected():
# final answer to M23, at least on Marlin, Repetier and Sprinter: "File selected"
self._callback.on_comm_file_selected(self._currentFile.getFilename(), self._currentFile.getFilesize(), True)
eventManager().fire(Events.FILE_SELECTED, {
"file": self._currentFile.getFilename(),
"origin": self._currentFile.getFileLocation()
})
elif 'Writing to file' in line:
# anwer to M28, at least on Marlin, Repetier and Sprinter: "Writing to file: %s"
elif 'Writing to file' in line and self.isStreaming():
self._changeState(self.STATE_PRINTING)
self._clear_to_send.set()
line = "ok"
@ -1237,7 +1237,7 @@ class MachineCom(object):
will be done.
"""
if self.isOperational() and not self.isStreaming() and not self._long_running_command and not self._heating:
if self.isOperational() and not self.isStreaming() and not self._long_running_command and not self._heating and not self._manualStreaming:
self.sendCommand("M105", cmd_type="temperature_poll")
def _poll_sd_status(self):
@ -1437,6 +1437,9 @@ class MachineCom(object):
return ret
def _getNext(self):
if self._currentFile is None:
return None
line = self._currentFile.getNext()
if line is None:
if self.isStreaming():
@ -1795,6 +1798,16 @@ class MachineCom(object):
if self.isPrinting() and not self.isSdPrinting():
self.setPause(True)
def _gcode_M28_sent(self, cmd, cmd_type=None):
if not self.isStreaming():
self._log("Detected manual streaming. Disabling temperature polling. Finish writing with M29. Do NOT attempt to print while manually streaming!")
self._manualStreaming = True
def _gcode_M29_sent(self, cmd, cmd_type=None):
if self._manualStreaming:
self._log("Manual streaming done. Re-enabling temperature polling. All is well.")
self._manualStreaming = False
def _gcode_M140_queuing(self, cmd, cmd_type=None):
if not self._printerProfileManager.get_current_or_default()["heatedBed"]:
self._log("Warn: Not sending \"{}\", printer profile has no heated bed".format(cmd))