mirror of
				https://github.com/Klipper3d/klipper.git
				synced 2025-10-31 02:15:52 +01:00 
			
		
		
		
	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:
		| @@ -241,6 +241,17 @@ class GCodeParser: | |||||||
|             self.process_commands(script.split('\n'), need_ack=False) |             self.process_commands(script.split('\n'), need_ack=False) | ||||||
|         finally: |         finally: | ||||||
|             self.need_ack = prev_need_ack |             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 |     # Response handling | ||||||
|     def ack(self, msg=None): |     def ack(self, msg=None): | ||||||
|         if not self.need_ack or self.is_fileinput: |         if not self.need_ack or self.is_fileinput: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user