DepthAI v2 has been superseded by DepthAI v3. You are viewing legacy documentation.
此页面由 AI 自动翻译。查看英文原版
DepthAI 教程
DepthAI API 参考

本页目录

  • 演示
  • 设置
  • 源代码

引导加载程序版本

此示例演示了基本的引导加载程序交互,检索设备上运行的引导加载程序的版本。点击 引导加载程序 获取更多信息。

演示

示例脚本输出
Command Line
1~/depthai-python/examples$ python3 bootloader_version.py
2    Found device with name: 1.1
3    Version: 0.0.26
4    USB Bootloader - supports only Flash memory
5    Memory 'Memory.FLASH' size: 33554432, info: JEDEC ID: 01 02 19

设置

请运行 安装脚本 以下载所有必需的依赖项。请注意,此脚本必须在 git 上下文中运行,因此您必须先下载 depthai-python 存储库,然后运行脚本
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
有关更多信息,请遵循 安装指南

源代码

Python

Python
GitHub
1#!/usr/bin/env python3
2
3import depthai as dai
4
5(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()
6
7if res == True:
8    print(f'Found device with name: {info.name}')
9    bl = dai.DeviceBootloader(info)
10    print(f'Version: {bl.getVersion()}')
11
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(f"NETWORK Bootloader, is User Bootloader: {bl.isUserBootloader()}")
18
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}")
31else:
32    print('No devices found')

C++

1#include "depthai/depthai.hpp"
2
3int main(int argc, char** argv) {
4    bool res = false;
5    dai::DeviceInfo info;
6    std::tie(res, info) = dai::DeviceBootloader::getFirstAvailableDevice();
7
8    if(res) {
9        std::cout << "Found device with name: " << info.name << std::endl;
10        dai::DeviceBootloader bl(info);
11        std::cout << "Version: " << bl.getVersion().toString() << std::endl;
12
13        std::list<dai::DeviceBootloader::Memory> supportedMemTypes = {dai::DeviceBootloader::Memory::FLASH, dai::DeviceBootloader::Memory::EMMC};
14        if(bl.getType() == dai::DeviceBootloader::Type::USB) {
15            std::cout << "USB Bootloader - supports only Flash memory" << std::endl;
16            supportedMemTypes = {dai::DeviceBootloader::Memory::FLASH};
17        } else {
18            std::cout << "NETWORK Bootloader, is User Bootloader: " << bl.isUserBootloader() << std::endl;
19        }
20
21        try {
22            for(const auto& mem : supportedMemTypes) {
23                std::cout << std::endl;
24                auto memoryInfo = bl.getMemoryInfo(mem);
25                if(memoryInfo.available) {
26                    std::cout << "Memory '" << mem << "' size: " << memoryInfo.size << ", info: " << memoryInfo.info << std::endl;
27
28                    auto appInfo = bl.readApplicationInfo(mem);
29                    std::cout << "Application, flashed: " << appInfo.hasApplication << " firmware version: " << appInfo.firmwareVersion
30                              << " application name: " << appInfo.applicationName << std::endl;
31                } else {
32                    std::cout << "Memory '" << mem << "' not available..." << std::endl;
33                }
34            }
35        } catch(const std::exception& ex) {
36            std::cout << "Couldn't retrieve memory details: " << ex.what() << std::endl;
37        }
38    } else {
39        std::cout << "No devices found" << std::endl;
40    }
41
42    return 0;
43}

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。