Skip to content

Commit 5e82ca7

Browse files
committed
Updated bootloader_version example
1 parent 8ae4882 commit 5e82ca7

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

depthai-core

examples/bootloader/bootloader_version.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@
99
bl = dai.DeviceBootloader(info)
1010
print(f'Version: {bl.getVersion()}')
1111

12-
for mem in (dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC):
13-
memInfo = bl.getMemoryInfo(mem)
14-
if not memInfo.available: continue # Memory is not available, skip
15-
print(f"Memory '{mem}' size: {memInfo.size}, info: {memInfo.info}")
12+
supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC]
13+
if bl.getType() == dai.DeviceBootloader.Type.USB:
14+
print("USB Bootloader - supports only Flash memory")
15+
supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH];
16+
else:
17+
print("NETWORK Bootloader")
1618

17-
appInfo = bl.readApplicationInfo(mem)
18-
if appInfo.hasApplication:
19-
print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}")
19+
try:
20+
for mem in supportedMemTypes:
21+
memInfo = bl.getMemoryInfo(mem)
22+
if memInfo.available:
23+
print(f"Memory '{mem}' size: {memInfo.size}, info: {memInfo.info}")
24+
appInfo = bl.readApplicationInfo(mem)
25+
if appInfo.hasApplication:
26+
print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}")
27+
else:
28+
print(f"Memory '{mem.name}' not available...")
29+
except Exception as ex:
30+
print(f"Couldn't retrieve memory details: {ex}")
2031
else:
2132
print('No devices found')

0 commit comments

Comments
 (0)