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