winIDEA SDK
test_code_store.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6
7import isystem.connect as ic
8
9
10winidea_id = ''
11
12
13def test_codeStore():
14 connMgr = ic.ConnectionMgr()
15 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
16
17 dataCtrl = ic.CDataController(connMgr)
18
19 print(f"Creating new empty code store object...")
20 codeStore = dataCtrl.csCreate()
21 print(f"\tIs empty: {codeStore.empty()}, num of items: {codeStore.numItems()}")
22
23 print(f"Loading current download file...")
24 wksFolderPath = ic.CIDEController(connMgr).getPath(ic.CIDEController.WORKSPACE_DIR)
25 dlFilePath = os.path.join(wksFolderPath, "build", "debug", "STM32", "sdk_example_stm32.elf")
26 codeStore.load(0, dlFilePath, 0)
27 print(f"\tIs empty: {codeStore.empty()}, num of items: {codeStore.numItems()}")
28 print(f"\tStart address: {hex(codeStore.getRangeLo())}")
29 print(f"\tEnd address: {hex(codeStore.getRangeHi())}")
30
31 print(f"Adding new area to code store object...")
32 dataContainer = ic.VectorBYTE(0xF)
33 codeStore.insert(0xFFFFFF00, dataContainer)
34 print(f"\tNew number of items: {codeStore.numItems()}")
35
36 csDownloaded = dataCtrl.csGetDownloaded(0, dlFilePath, False)
37 print(f"\tNumber of actual downloaded locations: {csDownloaded.getTotal()}")
38
39 codeStore.save(ic.ICodeCache.lFormatMotorolaS, 'MemoryDump.s37', 0) # save to MotorolaS format
40
41 # NOTE: Other functions exists for building areas and reports, check documentation.
42
43
44if __name__ == "__main__":
45 test_codeStore()