1
2
3
4
5import random
6import isystem.connect as ic
7
8
9winidea_id = ''
10
11
12def test_readWriteMemory():
13 connMgr = ic.ConnectionMgr()
14 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
15
16 dataCtrl = ic.CDataController(connMgr)
17 addCtrl = ic.CAddressController(connMgr)
18
19
20 DATA = [random.randint(0, 100),
21 random.randint(0, 100),
22 random.randint(0, 100),
23 random.randint(0, 100)]
24 NUM = len(DATA)
25 START_ADDRESS = addCtrl.getVariableAddress("mainLoopCounter").getAddress()
26
27 print(f"Writing {NUM} bytes to address: {hex(START_ADDRESS)}: {DATA}")
28 wData = ic.VectorBYTE(DATA)
29
30 dataCtrl.writeMemoryNAI(ic.IConnectDebug.fRealTime,
31 0,
32 START_ADDRESS,
33 NUM, 1,
34 wData)
35
36 print(f"Reading {NUM} bytes, starting at address: {hex(START_ADDRESS)}")
37 rData = dataCtrl.readMemory(ic.IConnectDebug.fRealTime,
38 0,
39 START_ADDRESS,
40 NUM, 1)
41 for index, data in enumerate(rData[:NUM]):
42
43 print(f"\tByte {index}: read value: {data}, access status: {rData[index + NUM]}")
44
45
46if __name__ == "__main__":
47 test_readWriteMemory()