Skip to content

Report UNCALIBRATED sensors in status - #11910

Open
Raffi1202 wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
Raffi1202:feature/status-uncalibrated
Open

Raffi1202 wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
Raffi1202:feature/status-uncalibrated

Conversation

@Raffi1202

@Raffi1202 Raffi1202 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Issue #9997: the CLI status command prints GYRO=OK, ACC=OK, MAG=OK as soon as a sensor is detected and healthy, even when it has never been calibrated. A user whose navigation modes refuse to arm because of a missing calibration gets no hint from the one command they are usually asked to run. The reporter asked for UNCALIBRATED instead of OK for compass, accelerometer and gyro.

Cause

src/main/fc/cli.c:4187-4190 on maintenance-10.x: the sensor line indexes hardwareSensorStatusNames[] (cli.c:253, values NONE/OK/UNAVAILABLE/FAILING from hardwareSensorStatus_e in src/main/sensors/diagnostics.h:12) with the hardware health status only. Calibration state is never consulted, so a healthy but uncalibrated sensor prints OK.

Change

Adds a static helper hardwareSensorStatusName(status, isCalibrated) in cli.c that returns "UNCALIBRATED" when the status is HW_SENSOR_OK and the sensor is not calibrated, and the existing name otherwise. cliStatus() uses it for GYRO, ACC and MAG with gyroIsCalibrationComplete(), STATE(ACCELEROMETER_CALIBRATED) (the same flag fc_core.c:296 uses for the arming block) and compassIsCalibrationComplete() (treated as calibrated when USE_MAG is not built). hardwareSensorStatus_e is unchanged, so MSP_SENSOR_STATUS (fc_msp.c:512) and the two-bit blackbox packing (blackbox.c:1491) keep their values.

Test

Not run on hardware or SITL. Cause verified by reading cli.c:4187-4190 and the three calibration functions on maintenance-10.x;

Flash / RAM

Not measured yet. The upstream firmware CI has not been released for this PR, so no size report exists.

Docs

No documentation change needed: docs/Cli.md:124 lists status only as "Show status" and no file under docs/ enumerates the sensor status words.

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 iNavFlight#9997
@Raffi1202
Raffi1202 marked this pull request as ready for review September 11, 2026 15:48
@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Report uncalibrated sensors in CLI status

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Reports healthy but uncalibrated gyro, accelerometer, and compass sensors as UNCALIBRATED.
• Preserves hardware status enums, MSP values, blackbox packing, and non-OK sensor output.
Diagram

graph TD
    H["Sensor health"] --> D{"Healthy but uncalibrated?"} -->|Yes| U["UNCALIBRATED text"] --> O["CLI status"]
    G["Calibration flags"] --> D
    D -->|Otherwise| E["Enum status"] --> O
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extend the hardware status enum
  • ➕ Represents calibration state uniformly across all status consumers.
  • ➕ Avoids CLI-specific interpretation of sensor health. calibration.
  • ➖ A fifth value cannot fit the two-bit blackbox sensor fields.
  • ➖ Existing MSP and Configurator consumers would interpret the value as a fault.
  • ➖ Requires coordinated protocol, log-format, and user-interface migrations.

Recommendation: Keep the PR's CLI-only formatter. It resolves the misleading troubleshooting output while preserving the four-value hardware enum, blackbox encoding, MSP payloads, and Configurator behavior; extending the shared enum would create disproportionate compatibility risk.

Files changed (1) +20 / -3

Bug fix (1) +20 / -3
cli.cDisplay calibration-aware sensor status in the CLI +20/-3

Display calibration-aware sensor status in the CLI

• Adds a formatter that returns UNCALIBRATED only when a sensor is healthy but its calibration is incomplete. The status command now supplies existing gyro, persistent accelerometer, and feature-guarded compass calibration states while leaving all other sensor output unchanged.

src/main/fc/cli.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@sensei-hacker sensei-hacker added this to the 10.0 milestone Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants