sensors/boson: Try to initialize the FLIR BOSON in a loop.

Older FLIR Boson Sensors (< IDD 4.x) take almost 10 seconds to boot compared to newer FLIR Boson Sensors.

This change tests if the FLIR BOSON sensors has booted once a second for up to 10 times before giving up.
This commit is contained in:
Kwabena W. Agyeman 2025-03-21 19:46:08 -07:00
parent c8a7f3fc5f
commit fa88bbd59d

View File

@ -44,21 +44,38 @@
#include "Client_API.h"
#include "UART_Connector.h"
#define FLIR_BOSON_BOOT_TIME_MS (2500)
#define FLIR_BOSON_BOOT_TRY_COUNT (10)
#define FLIR_BOSON_BOOT_TIME_MS (1000)
static int boson_framesize = 0;
static int reset(omv_csi_t *csi) {
csi->color_palette = NULL;
// Give the camera time to boot.
mp_hal_delay_ms(FLIR_BOSON_BOOT_TIME_MS);
// Turn the com port on.
Initialize();
int i = 0;
FLR_BOSON_PARTNUMBER_T part;
if (bosonGetCameraPN(&part) != FLR_OK) {
// Older FLIR Boson (< IDD 4.x) cameras take forever to boot up.
for (; i < FLIR_BOSON_BOOT_TRY_COUNT; i++) {
if (i > 1) {
// Print something to prevent the user from thinking the camera is stuck.
mp_printf(MP_PYTHON_PRINTER,
"CSI: FLIR Boson not ready, retrying (%d/%d)...\n",
i, FLIR_BOSON_BOOT_TRY_COUNT - 1);
}
// Give the camera time to boot.
mp_hal_delay_ms(FLIR_BOSON_BOOT_TIME_MS);
// Turn the com port on.
Initialize();
if (bosonGetCameraPN(&part) == FLR_OK) {
break;
}
}
if (i == FLIR_BOSON_BOOT_TRY_COUNT) {
return -1;
}