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>
This commit is contained in:
parent
19090bdd5b
commit
7faa5fe233
|
@ -126,22 +126,25 @@ class GCodeParser:
|
||||||
lines[0] = self.partial_input + lines[0]
|
lines[0] = self.partial_input + lines[0]
|
||||||
self.partial_input = lines.pop()
|
self.partial_input = lines.pop()
|
||||||
if self.is_processing_data:
|
if self.is_processing_data:
|
||||||
if not lines:
|
if not self.is_fileinput:
|
||||||
return
|
if not lines:
|
||||||
if not self.is_fileinput and lines[0].strip().upper() == 'M112':
|
return
|
||||||
self.cmd_M112({})
|
if lines[0].strip().upper() == 'M112':
|
||||||
|
self.cmd_M112({})
|
||||||
self.reactor.unregister_fd(self.fd_handle)
|
self.reactor.unregister_fd(self.fd_handle)
|
||||||
self.fd_handle = None
|
self.fd_handle = None
|
||||||
while self.is_processing_data:
|
while self.is_processing_data:
|
||||||
eventtime = self.reactor.pause(eventtime + 0.100)
|
eventtime = self.reactor.pause(eventtime + 0.100)
|
||||||
self.is_processing_data = True
|
self.is_processing_data = True
|
||||||
self.process_commands(lines)
|
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
|
self.is_processing_data = False
|
||||||
if self.fd_handle is None:
|
if self.fd_handle is None:
|
||||||
self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
|
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
|
# Response handling
|
||||||
def ack(self, msg=None):
|
def ack(self, msg=None):
|
||||||
if not self.need_ack or self.is_fileinput:
|
if not self.need_ack or self.is_fileinput:
|
||||||
|
|
Loading…
Reference in New Issue