winIDEA SDK
test_data_modify.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2# (c) TASKING Germany GmbH, 2023
3#
4# This Python script is used to modify a variable (g_int) in real-time, and verifying the modifications.
5
6import isystem.connect as ic
7
8
9winidea_id = ''
10
11
12def test_modify():
13 connMgr = ic.ConnectionMgr()
14 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
15
16 dataCtrl = ic.CDataController(connMgr)
17
18 print(f"Modify variable 'g_int' to value '1'...")
19 dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", "1", False)
20 print(f"Modify variable 'g_int' to value '2', with read-back...")
21 value = dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", "2", True)
22 print(f"\tRead-back value: {value}")
23
24 print(f"Optionally, modify variable 'g_int' to value '3' by variable type...")
25 sType = ic.SType()
26 sType.m_byType = ic.SType.tUnsigned
27 sType.m_byBitSize = 32
28 cVal = ic.CValueType(sType, 3)
29 dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", cVal)
30
31 print(f"`modify() is also capable of handling expressions...")
32
33 # Write the result of the equals operation to g_char1 so we can read the
34 # result of the equals operation
35 dataCtrl.modify(ic.IConnectDebug.fRealTime,
36 ic.IConnectDebug.efAllowTernaryOperator,
37 "g_int",
38 "(g_int == g_char) ? 4 : 5")
39 value = dataCtrl.evaluate(ic.IConnectDebug.fRealTime, "g_int").getInt()
40 print(f"\t`(g_int == g_char)` = {value} (4 == True, 5 == False)")
41
42
43if __name__ == "__main__":
44 test_modify()