Skip to content

Commit 1f86b03

Browse files
committed
Fixed bootloader version example
1 parent 7b59e20 commit 1f86b03

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

examples/bootloader/bootloader_version.py

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

12-
(ok, err, info) = bl.readApplicationInfo()
13-
if ok:
14-
print(f'Application, flashed: {info.hasApplication}, firmware version: {info.firmwareVersion}, application name: {info.applicationName}')
15-
else:
16-
print(f'Error reading application info: {err}')
17-
1812
for mem in (dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC):
19-
(ok, err, info) = bl.getMemoryInfo(mem)
20-
if ok:
21-
print(f'Memory size: {info.size}, info: {info.info}')
22-
else:
23-
print(f'Error retrieving memory information: {err}')
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}")
16+
17+
appInfo = bl.readApplicationInfo(mem)
18+
if appInfo.hasApplication:
19+
print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}")
2420
else:
2521
print('No devices found')

src/DeviceBootloaderBindings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){
121121

122122
deviceBootloderMemoryInfo
123123
.def(py::init<>())
124+
.def_readwrite("available", &DeviceBootloader::MemoryInfo::available)
124125
.def_readwrite("size", &DeviceBootloader::MemoryInfo::size)
125126
.def_readwrite("info", &DeviceBootloader::MemoryInfo::info)
126127
;

0 commit comments

Comments
 (0)