@@ -191,7 +191,7 @@ def CALL_MDI_WAIT(self, code, time=5, mode_return=False):
191191 self .ensure_mode (premode )
192192 return 0
193193
194- def CALL_INI_MDI (self , key ):
194+ def CALL_INI_MDI (self , key , mode_return = False ):
195195 try :
196196 # prefer named INI MDI commands
197197 mdi = INFO .get_ini_mdi_command (key )
@@ -209,11 +209,21 @@ def CALL_INI_MDI(self, key):
209209
210210
211211 mdi_list = mdi .split (';' )
212+ if mode_return :
213+ self .RECORD_CURRENT_MODE ()
214+ self ._a = STATUS .connect ('command-stopped' , lambda w : self .return_mode_after_finish ())
212215 self .ensure_mode (linuxcnc .MODE_MDI )
213216 for code in (mdi_list ):
214217 LOG .debug ('CALL_INI_MDI command:{}' .format (code ))
215218 self .cmd .mdi ('%s' % code )
216219
220+ # when command stops - we try to continue the generator.
221+ # if generator is done - return to recorded mode.
222+ def return_mode_after_finish (self ):
223+ print ('ini command end' )
224+ self .RESTORE_RECORDED_MODE ()
225+ STATUS .handler_disconnect (self ._a )
226+
217227 def CALL_OWORD (self , code , time = 5 ):
218228 LOG .debug ('OWORD_COMMAND= {}' .format (code ))
219229 self .ensure_mode (linuxcnc .MODE_MDI )
0 commit comments