Skip to content

Commit

Permalink
Virtual printer: allow empty/None prepared oks
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Nov 22, 2017
1 parent 8a977e8 commit b252da4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/octoprint/plugins/virtual_printer/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def _gcode_M30(self, data):
def _gcode_M114(self, data):
output = "X:{} Y:{} Z:{} E:{} Count: A:{} B:{} C:{}".format(self._lastX, self._lastY, self._lastZ, self._lastE, int(self._lastX*100), int(self._lastY*100), int(self._lastZ*100))
if not self._okBeforeCommandOutput:
output = "{} {}".format(self._ok(), output)
ok = self._ok()
if ok:
output = "{} {}".format(self._ok(), output)
self._send(output)
return True

Expand Down Expand Up @@ -555,7 +557,7 @@ def _triggerResend(self, expected=None, actual=None, checksum=None):

def request_resend():
self._send("Resend:%d" % expected)
self._send(self._ok())
self._sendOk()

if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleResends"]):
request_resend()
Expand Down Expand Up @@ -772,7 +774,9 @@ def _processTemperatureQuery(self):
output = self._generateTemperatureOutput()

if includeOk:
output = "{} {}".format(self._ok(), output)
ok = self._ok()
if ok:
output = "{} {}".format(ok, output)
self._send(output)

def _parseHotendCommand(self, line, wait=False, support_r=False):
Expand Down Expand Up @@ -1156,7 +1160,9 @@ def close(self):
def _sendOk(self):
if self.outgoing is None:
return
self._send(self._ok())
ok = self._ok()
if ok:
self._send(ok)

def _sendWaitAfterTimeout(self, timeout=5):
time.sleep(timeout)
Expand All @@ -1171,6 +1177,8 @@ def _ok(self):
ok = self._okFormatString
if self._prepared_oks:
ok = self._prepared_oks.pop(0)
if ok is None:
return ok

return ok.format(ok, lastN=self.lastN, buffer=self.buffered.maxsize - self.buffered.qsize())

Expand Down

0 comments on commit b252da4

Please sign in to comment.