Hey everyone! I’m struggling with a Python script that uses the lauterbach.trace32.rcl library to control a Trace32 instance. I’m trying to run multiple CMM files, but I keep getting random ‘Practice stack depth error’ messages. Here’s what I’m doing:
instance.cmm('run_test.cmm')
instance.cmd('SYStem.Mode Go')
The problem is that the second command starts before the first one finishes. I tried adding a time.sleep(1)
between them, but it’s not reliable:
instance.cmm('run_test.cmm')
time.sleep(1)
instance.cmd('SYStem.Mode Go')
I also tried using timeout=None
like this:
instance.cmm('run_test.cmm', timeout=None)
But it didn’t work either. Does anyone know a better way to make sure the first command finishes before running the second one? I’d really appreciate any help or suggestions!
I’ve dealt with similar synchronization hiccups when working with Trace32 and Python. One trick that’s worked well for me is using the PRACTICE.StateRun() command to check if a script is still running. Here’s how you could implement it:
instance.cmd(‘PRACTICE run_test’)
while instance.eval(‘PRACTICE.StateRun()’) == ‘1’:
time.sleep(0.1)
instance.cmd(‘SYStem.Mode Go’)
This approach polls the script state every 100ms until it’s finished. It’s more reliable than fixed sleep times and doesn’t require modifying your CMM files.
Another option is to use the PRACTICE.Script.WAIT command within your CMM script. This ensures all operations complete before the script exits. You’d add something like this at the end of run_test.cmm:
PRACTICE.Script.WAIT
Hope this helps solve your synchronization issues!
I’ve encountered similar synchronization issues when working with the Lauterbach Trace32 library in Python. One effective approach I’ve found is to use the WAIT command in your CMM script. You can modify run_test.cmm to include a WAIT at the end, ensuring all operations complete before the script returns control.
Alternatively, you could try using the PRACTICE command in Python to execute your CMM script. This method tends to be more reliable for synchronization:
instance.cmd('PRACTICE run_test')
instance.cmd('SYStem.Mode Go')
If issues persist, consider implementing a polling mechanism to check for script completion before moving on. This approach is more robust than relying on fixed sleep times.
hey, have u tried using the PRACTICE.WaitForScriptTermination() command? it might help with ur syncing issues. smth like this:
instance.cmd(‘PRACTICE run_test’)
instance.cmd(‘PRACTICE.WaitForScriptTermination()’)
instance.cmd(‘SYStem.Mode Go’)
this should make sure the first script finishes b4 moving on. hope it helps!