Fix CRSF 0x09 baro/vario unpack and duplicate airspeed function#11572
Merged
sensei-hacker merged 2 commits intoMay 19, 2026
Merged
Conversation
- Rename CRSF_FRAMETYPE_BAROMETER_ALTITUDE to CRSF_FRAMETYPE_BAROMETER_ALTITUDE_VARIO_SENSOR and CRSF_FRAME_BAROMETER_ALTITUDE_PAYLOAD_SIZE to CRSF_FRAME_BAROMETER_ALTITUDE_VARIO_PAYLOAD_SIZE, matching current crsf.h definitions after the combined frame was introduced - Fix altitude MSB=1 decode: remove spurious -5dm offset; per TBS spec get_altitude_dm() is (packed & 0x7fff) * 10 with no offset - Add vertical speed decode from payload[2] using the log formula specified by TBS: (exp(|packed| * 0.026) - 1) * 100 * sign - Mark crsfSensorVario and crsfSensorVarioLastUpdateMs volatile, consistent with other cross-task shared variables in this file
The commit adding combined baro+vario/airspeed support introduced a USE_PITOT-guarded definition of crsfFrameAirSpeedSensor but did not remove the original unconditional definition, causing a redefinition error. The original also had an integer division bug (36/100 == 0). Remove the unconditional definition and guard the getCrsfFrame() dispatch case with USE_PITOT to match the function's availability.
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Test firmware build ready — commit Download firmware for PR #11572 234 targets built. Find your board's
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two related compile errors introduced by the combined baro+vario/airspeed CRSF telemetry work.
Changes
src/main/io/crsf_sensor.cCRSF_FRAMETYPE_BAROMETER_ALTITUDE→CRSF_FRAMETYPE_BAROMETER_ALTITUDE_VARIO_SENSORandCRSF_FRAME_BAROMETER_ALTITUDE_PAYLOAD_SIZE→CRSF_FRAME_BAROMETER_ALTITUDE_VARIO_PAYLOAD_SIZEto match currentcrsf.hafter the combined frame type was introduced-5 dmoffset; per TBS specget_altitude_dm()is(packed & 0x7fff) * 10with no offsetpayload[2]using the TBS log formula:(exp(|packed| * 0.026) - 1) * 100 * signcrsfSensorVarioandcrsfSensorVarioLastUpdateMsvolatile, consistent with other cross-task shared variables in this filesrc/main/telemetry/crsf.ccrsfFrameAirSpeedSensordefinition that conflicted with the#ifdef USE_PITOTversion added later; the original also had an integer division bug (36 / 100 == 0in C)getCrsfFrame()dispatch case forCRSF_FRAMETYPE_AIRSPEED_SENSORwith#ifdef USE_PITOTto match the function's availabilityTesting
get_altitude_dm()functionget_vertical_speed_cm_s()functionCode Review
Reviewed with inav-code-review agent — volatile fix and range safety of vario cast confirmed, no critical issues.
Notes
Documentation not needed (bug fixes only, no behavior changes for correctly-functioning hardware).