diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-06-30 14:10:59 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-06-30 14:13:06 -0400 |
commit | ecf53e6194a7ccdc7015faa79ad3f74f6f7a5d1a (patch) | |
tree | 3b97fe0d848dff77a06f4a8a4c49fc2e9c18349b /klippy/gcode.py | |
parent | 4ad44e3e83c819dacb6f620abfdefdd1ecdf7caf (diff) | |
download | kutter-ecf53e6194a7ccdc7015faa79ad3f74f6f7a5d1a.tar.gz kutter-ecf53e6194a7ccdc7015faa79ad3f74f6f7a5d1a.tar.xz kutter-ecf53e6194a7ccdc7015faa79ad3f74f6f7a5d1a.zip |
gcode: Add run_script() method that is valid from non-command contexts
Add an ability to run a series of g-code commands from a reactor
callback that isn't part of the normal g-code command processing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r-- | klippy/gcode.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py index 38e1124b..0ea50751 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -241,6 +241,17 @@ class GCodeParser: self.process_commands(script.split('\n'), need_ack=False) finally: self.need_ack = prev_need_ack + def run_script(self, script): + curtime = self.reactor.monotonic() + for line in script.split('\n'): + while 1: + try: + res = self.process_batch(line) + except: + break + if res: + break + curtime = self.reactor.pause(curtime + 0.100) # Response handling def ack(self, msg=None): if not self.need_ack or self.is_fileinput: |