Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send now fix #924

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 19 additions & 15 deletions printrun/printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,16 @@ def _stop_sender(self):
self.send_thread = None

def _sender(self):
if not self.paused:
self.lineno = 0
self._send("M110", -1, True)
while not self.stop_send_thread:
try:
command = self.priqueue.get(True, 0.1)
except QueueEmpty:
continue
while self.printer and self.printing and not self.clear:
time.sleep(0.001)
self._send(command)
if not(self.priqueue.empty()):
self._sendnext(now=True)
else:
time.sleep(0.1)
while self.printer and self.printing and not self.clear:
time.sleep(0.001)

Expand Down Expand Up @@ -565,16 +567,16 @@ def process_host_command(self, command):
if command.startswith(";@pause"):
self.pause()

def _sendnext(self):
def _sendnext(self, now=False):
if not self.printer:
return
while self.printer and self.printing and not self.clear:
while self.printer and (self.printing or now) and not self.clear:
time.sleep(0.001)
# Only wait for oks when using serial connections or when not using tcp
# in streaming mode
if not self.printer_tcp or not self.tcp_streaming_mode:
self.clear = False
if not (self.printing and self.printer and self.online):
if not ((self.printing or now) and self.printer and self.online):
self.clear = True
return
if self.resendfrom < self.lineno and self.resendfrom > -1:
Expand All @@ -583,7 +585,8 @@ def _sendnext(self):
return
self.resendfrom = -1
if not self.priqueue.empty():
self._send(self.priqueue.get_nowait())
self._send(self.priqueue.get_nowait(),self.lineno, True)
self.lineno += 1
self.priqueue.task_done()
return
if self.printing and self.queueindex < len(self.mainqueue):
Expand Down Expand Up @@ -636,12 +639,13 @@ def _sendnext(self):
self.clear = True
self.queueindex += 1
else:
self.printing = False
self.clear = True
if not self.paused:
self.queueindex = 0
self.lineno = 0
self._send("M110", -1, True)
if not now:
self.printing = False
self.clear = True
if not self.paused:
self.queueindex = 0
self.lineno = 0
self._send("M110", -1, True)

def _send(self, command, lineno = 0, calcchecksum = False):
# Only add checksums if over serial (tcp does the flow control itself)
Expand Down