winIDEA SDK
Loading...
Searching...
No Matches
test_read_write_memory.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
import random
import isystem.connect as ic
winidea_id = ''
def test_readWriteMemory():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
dataCtrl = ic.CDataController(connMgr)
addCtrl = ic.CAddressController(connMgr)
# 4 bytes, 32 bit
DATA = [random.randint(0, 100),
random.randint(0, 100),
random.randint(0, 100),
random.randint(0, 100)]
NUM = len(DATA)
START_ADDRESS = addCtrl.getVariableAddress("mainLoopCounter").getAddress()
print(f"Writing {NUM} bytes to address: {hex(START_ADDRESS)}: {DATA}")
wData = ic.VectorBYTE(DATA)
# write 4 bytes without getting access status info ('NAI')
dataCtrl.writeMemoryNAI(ic.IConnectDebug.fRealTime,
0,
START_ADDRESS,
NUM, 1, # NUM of bytes, 1 byte per MAU
wData)
print(f"Reading {NUM} bytes, starting at address: {hex(START_ADDRESS)}")
rData = dataCtrl.readMemory(ic.IConnectDebug.fRealTime,
0,
START_ADDRESS,
NUM, 1)
for index, data in enumerate(rData[:NUM]):
# bytes, (data + access status)
print(f"\tByte {index}: read value: {data}, access status: {rData[index + NUM]}")
if __name__ == "__main__":
test_readWriteMemory()