import isystem.connect as ic
winidea_id = ''
def test_write():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
devName = "ST STM32F4xxxG_1024KB"
optCtrl = ic.COptionController(connMgr, ic.CStorageDeviceFactory.DEVICES_OPT_URL)
devIndex = optCtrl.index_of("Name", devName)
print("Index of the item whose 'Name' attribute has value " + devName + f": {devIndex}")
storageCtrl = ic.CStorageDeviceFactory.makeDevice(connMgr, ic.EStorageDevice_EmbeddedFlashDevice, devIndex)
print(f"Writing configured data to device with index: {devIndex}")
storageCtrl.write(ic.IConnectUMI.wProgDevice)
print(f"Writing data from a specific file to device with index: {devIndex}")
storageCtrl.write(ic.IConnectUMI.wProgDevice,
ic.IConnectUMI.wFileFormatAuto,
0,
"CORE0/Debug/sdk_test.elf")
print(f"Writing specific data (16 bytes) to a device with index: {devIndex}")
data = ic.VectorBYTE()
for index in range(16):
data.append(index)
storageCtrl.write(ic.IConnectUMI.wProgDevice, 0x08000000, 16, data)
if __name__ == "__main__":
test_write()