gcode: Fix error that could cause commands to be processed out of order

Commit d0932009 changed the way command handling was performed, and
commit 95950949 fixed a defect in that commit.  Unfortunately, the fix
was incomplete.

If multiple commands were sent to Klippy without waiting for an "ok"
response from Klippy, then it was possible for those additional
commands to be queued and processed after subsequent commands.  This
would result in commands being processed out of order.

Fix this by only reregistering the input fd in the greenlet that
performs the unregistration of the fd.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-09-02 11:47:22 -04:00
parent ac53806e04
commit 0d13834293
1 changed files with 5 additions and 7 deletions

View File

@ -126,15 +126,15 @@ class GCodeParser:
lines[0] = self.partial_input + lines[0]
self.partial_input = lines.pop()
if self.is_processing_data:
if not self.is_fileinput:
if not lines:
if not self.is_fileinput and not lines:
return
if lines[0].strip().upper() == 'M112':
self.cmd_M112({})
self.reactor.unregister_fd(self.fd_handle)
self.fd_handle = None
if not self.is_fileinput and lines[0].strip().upper() == 'M112':
self.cmd_M112({})
while self.is_processing_data:
eventtime = self.reactor.pause(eventtime + 0.100)
self.fd_handle = self.reactor.register_fd(self.fd, self.process_data)
self.is_processing_data = True
self.process_commands(lines)
if not data and self.is_fileinput:
@ -143,8 +143,6 @@ class GCodeParser:
self.toolhead.wait_moves()
self.printer.request_exit()
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: