Skip to content

Commit

Permalink
virtual_sdcard: Don't wait for M25 in an SD gcode file
Browse files Browse the repository at this point in the history
If an M25 is in a gcode file that is being printed from virtual SD, it
would cause a permanent hang.  Detect that case and don't wait for
those M25 commands.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
  • Loading branch information
KevinOConnor authored and FHeilmann committed Jan 28, 2020
1 parent 17ad26a commit 5ff8508
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions klippy/extras/virtual_sdcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, config):
self.file_position = self.file_size = 0
# Work timer
self.reactor = printer.get_reactor()
self.must_pause_work = False
self.must_pause_work = self.cmd_from_sd = False
self.work_timer = None
# Register commands
self.gcode = printer.lookup_object('gcode')
Expand Down Expand Up @@ -64,7 +64,7 @@ def is_active(self):
def do_pause(self):
if self.work_timer is not None:
self.must_pause_work = True
while self.work_timer is not None:
while self.work_timer is not None and not self.cmd_from_sd:
self.reactor.pause(self.reactor.monotonic() + .001)
# G-Code commands
def cmd_error(self, params):
Expand Down Expand Up @@ -177,16 +177,19 @@ def work_handler(self, eventtime):
self.reactor.pause(self.reactor.monotonic() + 0.100)
continue
# Dispatch command
self.cmd_from_sd = True
try:
self.gcode.run_script(lines[-1])
except self.gcode.error as e:
break
except:
logging.exception("virtual_sdcard dispatch")
break
self.cmd_from_sd = False
self.file_position += len(lines.pop()) + 1
logging.info("Exiting SD card print (position %d)", self.file_position)
self.work_timer = None
self.cmd_from_sd = False
return self.reactor.NEVER

def load_config(config):
Expand Down

0 comments on commit 5ff8508

Please sign in to comment.