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>
This commit is contained in:
parent
4ad44e3e83
commit
ecf53e6194
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue