diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-09-02 11:47:22 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-09-02 12:05:51 -0400 |
commit | 0d13834293d0b5db2fc3407bd603dbfaa691402d (patch) | |
tree | 2057264f58828460c7f9595d1bdbe85035e02bd8 /klippy/gcode.py | |
parent | ac53806e0438dfc2a5841a3d182b521e2896cb76 (diff) | |
download | kutter-0d13834293d0b5db2fc3407bd603dbfaa691402d.tar.gz kutter-0d13834293d0b5db2fc3407bd603dbfaa691402d.tar.xz kutter-0d13834293d0b5db2fc3407bd603dbfaa691402d.zip |
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>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r-- | klippy/gcode.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py index d3af9731..c66b74c5 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -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: - return - if lines[0].strip().upper() == 'M112': - self.cmd_M112({}) + if not self.is_fileinput and not lines: + return 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: |