aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-07-21 21:13:59 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-07-21 21:22:12 -0400
commit7faa5fe2336105bebd07f4579a40317a66767815 (patch)
tree891c94672d477e073074773c6ac6ac0c4ea08b16
parent19090bdd5b2ca8ff2dd0f8524d746a06638bf687 (diff)
downloadkutter-7faa5fe2336105bebd07f4579a40317a66767815.tar.gz
kutter-7faa5fe2336105bebd07f4579a40317a66767815.tar.xz
kutter-7faa5fe2336105bebd07f4579a40317a66767815.zip
gcode: Improve end-of-file handling when input is a debug file
Wait for any pending moves to be fully handled before exiting. Make sure the wait is done inside the "self.is_processing_data" check to avoid infinite recursion. Don't keep reading from the file while waiting to exit. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/gcode.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index fdd76f73..4b4ac382 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -126,22 +126,25 @@ class GCodeParser:
lines[0] = self.partial_input + lines[0]
self.partial_input = lines.pop()
if self.is_processing_data:
- if not lines:
- return
- if not self.is_fileinput and lines[0].strip().upper() == 'M112':
- self.cmd_M112({})
+ if not self.is_fileinput:
+ if not lines:
+ return
+ if lines[0].strip().upper() == 'M112':
+ self.cmd_M112({})
self.reactor.unregister_fd(self.fd_handle)
self.fd_handle = None
while self.is_processing_data:
eventtime = self.reactor.pause(eventtime + 0.100)
self.is_processing_data = True
self.process_commands(lines)
- self.is_processing_data = False
- if self.fd_handle is None:
- self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
if not data and self.is_fileinput:
self.motor_heater_off()
+ if self.toolhead is not None:
+ self.toolhead.wait_moves()
self.printer.request_exit('exit_eof')
+ self.is_processing_data = False
+ if self.fd_handle is None:
+ self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
# Response handling
def ack(self, msg=None):
if not self.need_ack or self.is_fileinput: