From 84ddbdbec1bae6306701199cd73a801811f07f96 Mon Sep 17 00:00:00 2001 From: Raphael Hunziker Date: Thu, 10 Sep 2026 20:13:19 +0200 Subject: [PATCH] cli: report UNCALIBRATED sensors in status The status command printed OK for gyro, accelerometer and compass as soon as the sensor was detected and healthy, even when it had never been calibrated. Users troubleshooting a navigation unsafe condition got no hint from the one command they are usually asked to run. Report UNCALIBRATED for those three sensors when they are detected and healthy but not calibrated, using the calibration state the firmware already tracks. All other states are unchanged, and hardwareSensorStatus_e is left alone so MSP_SENSOR_STATUS and the two bit per sensor blackbox packing keep their current values. Fixes #9997 --- src/main/fc/cli.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index 718dadca046..51be817f17c 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -254,6 +254,17 @@ static const char * const hardwareSensorStatusNames[] = { "NONE", "OK", "UNAVAILABLE", "FAILING" }; +// A sensor that is detected and healthy, but has never been calibrated, is reported as +// UNCALIBRATED. Every other state is reported exactly as hardwareSensorStatus_e defines it. +static const char * hardwareSensorStatusName(hardwareSensorStatus_e status, bool isCalibrated) +{ + if ((status == HW_SENSOR_OK) && !isCalibrated) { + return "UNCALIBRATED"; + } + + return hardwareSensorStatusNames[status]; +} + static const char * const *sensorHardwareNames[] = { gyroNames, table_acc_hardware, @@ -4184,10 +4195,16 @@ static void cliStatus(char *cmdline) #endif // for if at32 #endif // for SITL +#ifdef USE_MAG + const bool compassIsCalibrated = compassIsCalibrationComplete(); +#else + const bool compassIsCalibrated = true; +#endif + cliPrintLinef("Sensor status: GYRO=%s, ACC=%s, MAG=%s, BARO=%s, RANGEFINDER=%s, OPFLOW=%s, PITOT=%s, GPS=%s", - hardwareSensorStatusNames[getHwGyroStatus()], - hardwareSensorStatusNames[getHwAccelerometerStatus()], - hardwareSensorStatusNames[getHwCompassStatus()], + hardwareSensorStatusName(getHwGyroStatus(), gyroIsCalibrationComplete()), + hardwareSensorStatusName(getHwAccelerometerStatus(), STATE(ACCELEROMETER_CALIBRATED)), + hardwareSensorStatusName(getHwCompassStatus(), compassIsCalibrated), hardwareSensorStatusNames[getHwBarometerStatus()], hardwareSensorStatusNames[getHwRangefinderStatus()], hardwareSensorStatusNames[getHwOpticalFlowStatus()],