winIDEA SDK
test_wait_state.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2# (c) TASKING Germany GmbH, 2023
3#
4# This Python example runs the program and uses the waitUntilStopped and
5# waitWhileRunning functions to wait for the breakpoint to be hit.
6# Once the breakpoint is hit, the script deletes all breakpoints and exits.
7
8import isystem.connect as ic
9
10
11winidea_id = ''
12
13
14def test_waitState():
15 connMgr = ic.ConnectionMgr()
16 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
17
18 execCtrl = ic.CExecutionController(connMgr)
19 addCtrl = ic.CAddressController(connMgr)
20 bpCtrl = ic.CBreakpointController(connMgr)
21 execCtrl.reset()
22 address = addCtrl.getFunctionAddress("target_init").getAddress()
23 print(f"Setting BP at function 'target_init': {hex(address)}")
24 bpCtrl.setBP(0, address)
25
26 print(f"Run and use `waitUntilStopped()` with 1 sec timeout...")
27 execCtrl.resetAndRun()
28 execCtrl.waitUntilStopped(1000, isThrow=True)
29 print(f"\tCPU stopped on BP.")
30
31 print(f"Run and use `waitWhileRunning()` with 1 sec timeout...")
32 execCtrl.resetAndRun()
33 execCtrl.waitWhileRunning(1000, isThrow=True)
34 print(f"\tCPU stopped on BP.")
35
36 bpCtrl.deleteAll()
37
38
39if __name__ == "__main__":
40 test_waitState()