luxonis / depthai-core

DepthAI C++ Library
MIT License
235 stars 127 forks source link

device->addLogCallback() doesn't work for bootloader warnings #1064

Open diablodale opened 4 months ago

diablodale commented 4 months ago

bootloader warnings are not sent to callbacks. Its because bl init() directly writes to the logger during Device construct. And the logger is processing the message before the Device is constructed to even go to the next line of code to add the log callback.

Setup

Windows, MSVC, and depthai-core v2.27.0

pseudocode

device = std::make_unique<dai::Device>(config.getOpenVINOVersion(), myDeviceInfo);
device->addLogCallback([](const dai::LogMessage& logMessage) {
   if (logMessage.level == dai::LogLevel::CRITICAL)
      do_critical_things();
   else if (logMessage.level >= dai::LogLevel::WARN)
      do_warn_things();

Then run the compiled code against a OAK-D-Pro-POE that has bootloader 0.0.26 flashed.

The debug console will have

[2024-07-11 23:52:12.389] [depthai] [warning] [18443010318EF50800] [192.168.2.23] Flashed bootloader version 0.0.26, less than 0.0.28 is susceptible to bootup/restart failure. Upgrading is advised, flashing main/factory (not user) bootloader. Available: 0.0.28

Result

Yet, do_warn_things() is not called.

Expected

do_warn_things() called