winIDEA SDK
Loading...
Searching...
No Matches
test_get_cpustatus.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 demonstrates how to get the current CPU status of a
# connected device. It runs and stops the device, and uses the
# getCPUStatus() method to get the current CPU status and prints
# out the status information. It also prints out the current target status.
import isystem.connect as ic
winidea_id = ''
def test_getCPUStatus():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
execCtrl = ic.CExecutionController(connMgr)
execCtrl.run()
execCtrl.stop()
cpuStatus = execCtrl.getCPUStatus(True)
print("Current CPU status:")
print(f"\tIs in 'STOP' state:", cpuStatus.isStopped())
print(f"\tStop reason:")
print(f"\t\tBy explicit action:", cpuStatus.isStopReasonExplicit())
print(f"\t\tBy BP:", cpuStatus.isStopReasonBP())
print(f"\t\tBy HW BP:", cpuStatus.isStopReasonHW())
print(f"\t\tBy `step` action:", cpuStatus.isStopReasonStep())
print(f"\tIn `ATTACH` state:", cpuStatus.isAttach())
print(f"\tIn `HALTED` state:", cpuStatus.isHalted())
print(f"\tIn `IDLE` state:", cpuStatus.isIdle())
print(f"\tIn `MUST_INIT` state:", cpuStatus.isMustInit())
print(f"\tIn `RESET` state:", cpuStatus.isReset())
print(f"\tIn `RUNNING` state:", cpuStatus.isRunning())
print(f"\tIn `WAITING` state:", cpuStatus.isWaiting())
print(f"\tExecution area:", cpuStatus.getExecutionArea())
print(f"\tExecution point address:", hex(cpuStatus.getExecutionPoint()))
smid = ic.SMSID()
cpuStatus.getMSID(smid)
print("\tCurrent application status:")
print("\t\tIs valid info:", smid.m_bValid)
print("\t\tIs in secure memory space:", smid.m_bSecure)
print("\t\tConsider VMID in identifying the app:", smid.m_bVMID)
print("\t\tConsider AppID in identifying the app:", smid.m_bAppID)
# alternatively, print status with `toString()` method
if __name__ == "__main__":
test_getCPUStatus()