From 7230a6dd8e58d50ab4651900ab5d43873ee13f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 8 Jun 2023 15:26:28 +0200 Subject: [PATCH] commander: add option to exclude mag to param SYS_FAC_CAL_MODE --- src/lib/systemlib/system_params.c | 4 +++- .../commander/factory_calibration_storage.cpp | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/systemlib/system_params.c b/src/lib/systemlib/system_params.c index f019b6f2d0..f62a8ec853 100644 --- a/src/lib/systemlib/system_params.c +++ b/src/lib/systemlib/system_params.c @@ -239,7 +239,9 @@ PARAM_DEFINE_INT32(SYS_HAS_NUM_DIST, 0); * Note: this is only supported on boards with a separate calibration storage * /fs/mtd_caldata. * - * @boolean + * @value 0 Disabled + * @value 1 All sensors + * @value 2 All sensors except mag * @group System */ PARAM_DEFINE_INT32(SYS_FAC_CAL_MODE, 0); diff --git a/src/modules/commander/factory_calibration_storage.cpp b/src/modules/commander/factory_calibration_storage.cpp index cd1e78e2b4..450f48c49d 100644 --- a/src/modules/commander/factory_calibration_storage.cpp +++ b/src/modules/commander/factory_calibration_storage.cpp @@ -43,6 +43,12 @@ static const char *CALIBRATION_STORAGE = "/fs/mtd_caldata"; +enum class FactoryCalibrationMode : uint32_t { + Disabled = 0, + AllSensors, + AllSensorsExceptMag, +}; + static bool ends_with(const char *str, const char *suffix) { if (!str || !suffix) { @@ -59,9 +65,18 @@ static bool ends_with(const char *str, const char *suffix) return strncmp(str + len_str - len_suffix, suffix, len_suffix) == 0; } +static FactoryCalibrationMode factory_calibration_mode{FactoryCalibrationMode::Disabled}; + static bool filter_calibration_params(param_t handle) { const char *name = param_name(handle); + + if (factory_calibration_mode == FactoryCalibrationMode::AllSensorsExceptMag) { + if (strncmp(name, "CAL_MAG", 7) == 0) { + return false; + } + } + // filter all non-calibration params return (strncmp(name, "CAL_", 4) == 0 && strcmp(name, "CAL_MAG_SIDES") != 0 @@ -73,7 +88,8 @@ FactoryCalibrationStorage::FactoryCalibrationStorage() { int32_t param = 0; param_get(param_find("SYS_FAC_CAL_MODE"), ¶m); - _enabled = param == 1; + _enabled = param >= 1; + factory_calibration_mode = (FactoryCalibrationMode)param; } int FactoryCalibrationStorage::open()