@@ -295,6 +295,7 @@ def run_state_machine(self, sma):
295
295
# create a list of executed states
296
296
state_change_indexes = []
297
297
298
+ pause_task = False
298
299
# flags used to stop a trial (or all trials)
299
300
interrupt_task = False
300
301
kill_task = False
@@ -306,7 +307,7 @@ def run_state_machine(self, sma):
306
307
if self .stdin is not None :
307
308
inline = self .stdin .readline ()
308
309
if inline is not None :
309
- interrupt_task , kill_task = self .handle_inline (inline , sma )
310
+ pause_task , interrupt_task , kill_task = self .handle_inline (inline , sma )
310
311
#####################################################
311
312
312
313
# read commands from a net socket ###################
@@ -315,8 +316,10 @@ def run_state_machine(self, sma):
315
316
316
317
if inline is not None :
317
318
inline = inline .decode ().strip ()
318
- interrupt_task , kill_task = self .handle_inline (inline , sma )
319
+ pause_task , interrupt_task , kill_task = self .handle_inline (inline , sma )
319
320
#####################################################
321
+ if pause_task :
322
+ continue
320
323
321
324
opcode , data = None , None
322
325
if self ._emulator :
@@ -352,19 +355,31 @@ def run_state_machine(self, sma):
352
355
return not interrupt_task
353
356
354
357
def handle_inline (self , inline , sma ):
358
+ pause_task = False
355
359
interrupt_task = False
356
360
kill_task = False
357
361
if inline .startswith ('pause-trial' ):
358
- self .pause ()
362
+ if self ._emulator is None :
363
+ self .pause ()
364
+ else :
365
+ pause_task = True
359
366
elif inline .startswith ('resume-trial' ):
360
- self .resume ()
367
+ if self ._emulator is None :
368
+ self .resume ()
369
+ else :
370
+ pause_task = False
361
371
elif inline .startswith ('stop-trial' ):
362
- self .stop_trial ()
372
+ if self ._emulator is None :
373
+ self .stop_trial ()
374
+ else :
375
+ interrupt_task = True
363
376
elif inline .startswith ('close' ):
364
- self .stop_trial ()
377
+ if self ._emulator is None :
378
+ self .stop_trial ()
365
379
interrupt_task = True
366
380
elif inline .startswith ('kill' ):
367
- self .stop_trial ()
381
+ if self ._emulator is None :
382
+ self .stop_trial ()
368
383
interrupt_task = kill_task = True
369
384
elif inline .startswith ('SoftCode' ):
370
385
softcode = int (inline [- 1 ]) - 1
@@ -395,7 +410,7 @@ def handle_inline(self, inline, sma):
395
410
final_msg .append (int (x ))
396
411
self .load_message (module_index , final_msg )
397
412
398
- return interrupt_task , kill_task
413
+ return pause_task , interrupt_task , kill_task
399
414
400
415
def load_serial_message (self , serial_channel , message_ID , serial_message ):
401
416
"""
0 commit comments