From 7faa5fe2336105bebd07f4579a40317a66767815 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 21 Jul 2017 21:13:59 -0400 Subject: [PATCH] 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 --- klippy/gcode.py | 17 ++++++++++------- 1 file 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) + 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) - if not data and self.is_fileinput: - self.motor_heater_off() - self.printer.request_exit('exit_eof') # Response handling def ack(self, msg=None): if not self.need_ack or self.is_fileinput: