aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-10-18 11:51:35 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-10-28 18:39:45 -0400
commita5e55c2acc2650c70acd6bf852810e30fb959f96 (patch)
treecdf0c9cbb9f5b3000ee92ad3c3f46d09f652308f /klippy/extras
parent37b9a2442ff661e736c15ae6ee5d1f1bcebd7b8d (diff)
downloadkutter-a5e55c2acc2650c70acd6bf852810e30fb959f96.tar.gz
kutter-a5e55c2acc2650c70acd6bf852810e30fb959f96.tar.xz
kutter-a5e55c2acc2650c70acd6bf852810e30fb959f96.zip
gcode: process_batch() should execute commands atomically
Update the process_batch() method so that it will not interleave commands read from the input fd with the batched commands. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/idle_timeout.py18
-rw-r--r--klippy/extras/virtual_sdcard.py2
2 files changed, 10 insertions, 10 deletions
diff --git a/klippy/extras/idle_timeout.py b/klippy/extras/idle_timeout.py
index 7ead83e2..39563b12 100644
--- a/klippy/extras/idle_timeout.py
+++ b/klippy/extras/idle_timeout.py
@@ -15,7 +15,7 @@ class IdleTimeout:
self.toolhead = None
self.last_timeout = 0.
self.idle_timeout = config.getfloat('timeout', 600., above=0.)
- self.idle_script = config.get('gcode', DEFAULT_IDLE_GCODE)
+ self.idle_gcode = config.get('gcode', DEFAULT_IDLE_GCODE).split('\n')
def printer_state(self, state):
if state == 'ready':
self.toolhead = self.printer.lookup_object('toolhead')
@@ -23,14 +23,14 @@ class IdleTimeout:
reactor.register_timer(self.timeout_handler, reactor.NOW)
def run_idle_script(self):
gcode = self.printer.lookup_object('gcode')
- for line in self.idle_script.split('\n'):
- try:
- res = gcode.process_batch(line)
- except:
- break
- if not res:
- # Raced with incoming g-code commands
- return
+ try:
+ res = gcode.process_batch(self.idle_gcode)
+ except:
+ logging.exception("idle timeout gcode execution")
+ return
+ if not res:
+ # Raced with incoming g-code commands
+ return
self.last_timeout = self.toolhead.get_last_move_time()
def timeout_handler(self, eventtime):
info = self.toolhead.get_status(eventtime)
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py
index d7a1fd72..1a0fc2a8 100644
--- a/klippy/extras/virtual_sdcard.py
+++ b/klippy/extras/virtual_sdcard.py
@@ -164,7 +164,7 @@ class VirtualSD:
continue
# Dispatch command
try:
- res = self.gcode.process_batch(lines[-1])
+ res = self.gcode.process_batch([lines[-1]])
if not res:
self.reactor.pause(self.reactor.monotonic() + 0.100)
continue