winIDEA SDK
test_code_store_diff.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_codeStoreDiff():
14 connMgr = ic.ConnectionMgr()
15 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
16
17 dataCtrl = ic.CDataController(connMgr)
18
19 print(f"Creating 2 new empty code store object...")
20 codeStore = dataCtrl.csCreate()
21 codeStore2 = dataCtrl.csCreate()
22 wksFolderPath = ic.CIDEController(connMgr).getPath(ic.CIDEController.WORKSPACE_DIR)
23 dlFilePath = os.path.join(wksFolderPath, "build", "debug", "STM32", "sdk_example_stm32.elf")
24 codeStore.load(0, dlFilePath, 0)
25 codeStore2.load(0, dlFilePath, 0)
26
27 print(f"Adding example area to 'codeStore2' object...")
28 DIFF_SIZE = 0xF
29 dataContainer = ic.VectorBYTE(DIFF_SIZE)
30 codeStore2.insert(0xFFFFFFFF - DIFF_SIZE, dataContainer)
31
32 print(f"Creating codeStore/codeStore2 diff...")
33 csDiff = dataCtrl.csDif(codeStore, codeStore2)
34 print(f"\tSize difference: {hex(csDiff.getTotal())}")
35
36 # NOTE: Returned diff object is again `ic.CCodeStore` object, explore other available methods.
37
38
39if __name__ == "__main__":
40 test_codeStoreDiff()