winIDEA SDK
test_reset_and_run.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2# (c) TASKING Germany GmbH, 2023
3#
4# This Python example creates a winIDEA instance, prints a message to the console,
5# and calls the resetAndRun() method on the ExecutionController class. It then gets the address of the
6# main function and sets a breakpoint at that address. It then calls the resetAndRun() method again,
7# this time with a 1-second timeout, and prints a message to the console depending on the result.
8# At the end, it deletes all breakpoints.
9
10import isystem.connect as ic
11
12
13winidea_id = ''
14
15
16def test_resetAndRun():
17 connMgr = ic.ConnectionMgr()
18 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20 execCtrl = ic.CExecutionController(connMgr)
21 addCtrl = ic.CAddressController(connMgr)
22 bpCtrl = ic.CBreakpointController(connMgr)
23
24 print("`resetAndRun` the CPU without timeout (not expecting `STOP` state)...")
25 execCtrl.resetAndRun()
26
27 address = addCtrl.getFunctionAddress("main").getAddress()
28 print(f"Setting BP at function 'main': {hex(address)}")
29 bpCtrl.setBP(0, address)
30
31 print("`resetAndRun` the CPU with 1 sec timeout (expecting stop at function 'main')...")
32 if execCtrl.resetAndRun(ic.CExecutionController.TOUT_1s) == 0:
33 print("\tSuccess.")
34 else:
35 print("\tTIMEOUT!")
36
37 bpCtrl.deleteAll()
38
39
40if __name__ == "__main__":
41 test_resetAndRun()