winIDEA SDK
test_read_write_register.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_readWriteRegister():
12 connMgr = ic.ConnectionMgr()
13 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
14
15 dataCtrl = ic.CDataController(connMgr)
16
17 REG_NAME = "R0"
18
19 print(f"Writing value '42' to register {REG_NAME}...")
20 sType = ic.SType()
21 sType.m_byType = ic.SType.tUnsigned
22 sType.m_byBitSize = 32
23 cVal = ic.CValueType(sType, 42)
24 dataCtrl.writeRegister(ic.IConnectDebug.fRealTime, REG_NAME, cVal)
25
26 print(f"Reading register {REG_NAME} value:")
27 val = dataCtrl.readRegister(ic.IConnectDebug.fRealTime, REG_NAME)
28 print(f"\tValue (int): {val.getInt()}")
29
30 # NOTE: Object 'val' is `ic.CValueType` object, explore other available methods.
31
32
33if __name__ == "__main__":
34 test_readWriteRegister()