From fa88bbd59d76319105b3d93793f4d237c7fa211a Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Fri, 21 Mar 2025 19:46:08 -0700 Subject: [PATCH] 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. --- src/omv/sensors/boson.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/omv/sensors/boson.c b/src/omv/sensors/boson.c index acad93f24..8d13d8982 100644 --- a/src/omv/sensors/boson.c +++ b/src/omv/sensors/boson.c @@ -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; }