winIDEA SDK
test_get_cpustatus.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# This Python example demonstrates the usage of the winIDEA SDK
4# CExecutionController class to get the current CPU status of a
5# connected device. It runs and stops the device, and uses the
6# getCPUStatus() method to get the current CPU status and prints
7# out the status information. It also prints out the current target status.
8
9# (c) TASKING Germany GmbH, 2023
10
11import isystem.connect as ic
12
13
14winidea_id = ''
15
16
17def test_getCPUStatus():
18 connMgr = ic.ConnectionMgr()
19 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
20
21 execCtrl = ic.CExecutionController(connMgr)
22
23 execCtrl.run()
24 execCtrl.stop()
25 cpuStatus = execCtrl.getCPUStatus(True)
26 print("Current CPU status:")
27 print(f"\tIs in 'STOP' state:", cpuStatus.isStopped())
28
29 print(f"\tStop reason:")
30 print(f"\t\tBy explicit action:", cpuStatus.isStopReasonExplicit())
31 print(f"\t\tBy BP:", cpuStatus.isStopReasonBP())
32 print(f"\t\tBy HW BP:", cpuStatus.isStopReasonHW())
33 print(f"\t\tBy `step` action:", cpuStatus.isStopReasonStep())
34
35 print(f"\tIn `ATTACH` state:", cpuStatus.isAttach())
36 print(f"\tIn `HALTED` state:", cpuStatus.isHalted())
37 print(f"\tIn `IDLE` state:", cpuStatus.isIdle())
38 print(f"\tIn `MUST_INIT` state:", cpuStatus.isMustInit())
39 print(f"\tIn `RESET` state:", cpuStatus.isReset())
40 print(f"\tIn `RUNNING` state:", cpuStatus.isRunning())
41 print(f"\tIn `WAITING` state:", cpuStatus.isWaiting())
42 print(f"\tExecution area:", cpuStatus.getExecutionArea())
43 print(f"\tExecution point address:", hex(cpuStatus.getExecutionPoint()))
44
45 smid = ic.SMSID()
46 cpuStatus.getMSID(smid)
47 print("\tCurrent application status:")
48 print("\t\tIs valid info:", smid.m_bValid)
49 print("\t\tIs in secure memory space:", smid.m_bSecure)
50 print("\t\tConsider VMID in identifying the app:", smid.m_bVMID)
51 print("\t\tConsider AppID in identifying the app:", smid.m_bAppID)
52
53 # alternatively, print status with `toString()` method
54
55
56if __name__ == "__main__":
57 test_getCPUStatus()