winIDEA SDK
Loading...
Searching...
No Matches
test_reset_and_run.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
# (c) TASKING Germany GmbH, 2023
#
# This Python example creates a winIDEA instance, prints a message to the console,
# and calls the resetAndRun() method on the ExecutionController class. It then gets the address of the
# main function and sets a breakpoint at that address. It then calls the resetAndRun() method again,
# this time with a 1-second timeout, and prints a message to the console depending on the result.
# At the end, it deletes all breakpoints.
import isystem.connect as ic
import time
winidea_id = ''
def test_resetAndRun():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
execCtrl = ic.CExecutionController(connMgr)
sessionCtrl = ic.CSessionCtrl(connMgr)
addCtrl = ic.CAddressController(connMgr)
bpCtrl = ic.CBreakpointController(connMgr)
sessionCtrl.begin_prepare()
execCtrl.runUntilFunction('main')
print("`resetAndRun` the CPU without timeout (not expecting `STOP` state)...")
execCtrl.resetAndRun()
address = addCtrl.getFunctionAddress("main").getAddress()
print(f"Setting BP at function 'main': {hex(address)}")
bpCtrl.setBP(0, address)
sessionCtrl.begin_reset()
print("`resetAndRun` the CPU with 1 sec timeout (expecting stop at function 'main')...")
if execCtrl.resetAndRun(ic.CExecutionController.TOUT_1s) == 0:
print("\tSuccess.")
else:
print("\tTIMEOUT!")
bpCtrl.deleteAll()
if __name__ == "__main__":
test_resetAndRun()