Skip to content

Fix CRSF 0x09 baro/vario unpack and duplicate airspeed function#11572

Merged
sensei-hacker merged 2 commits into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/crsf-0x09-baro-vario-unpack
May 19, 2026
Merged

Fix CRSF 0x09 baro/vario unpack and duplicate airspeed function#11572
sensei-hacker merged 2 commits into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix/crsf-0x09-baro-vario-unpack

Conversation

@sensei-hacker
Copy link
Copy Markdown
Member

Summary

Fixes two related compile errors introduced by the combined baro+vario/airspeed CRSF telemetry work.

Changes

src/main/io/crsf_sensor.c

  • Rename CRSF_FRAMETYPE_BAROMETER_ALTITUDECRSF_FRAMETYPE_BAROMETER_ALTITUDE_VARIO_SENSOR and CRSF_FRAME_BAROMETER_ALTITUDE_PAYLOAD_SIZECRSF_FRAME_BAROMETER_ALTITUDE_VARIO_PAYLOAD_SIZE to match current crsf.h after the combined frame type was introduced
  • Fix altitude MSB=1 decode: remove incorrect -5 dm offset; per TBS spec get_altitude_dm() is (packed & 0x7fff) * 10 with no offset
  • Add vertical speed decode from payload[2] using the TBS log formula: (exp(|packed| * 0.026) - 1) * 100 * sign
  • Mark crsfSensorVario and crsfSensorVarioLastUpdateMs volatile, consistent with other cross-task shared variables in this file

src/main/telemetry/crsf.c

  • Remove duplicate unconditional crsfFrameAirSpeedSensor definition that conflicted with the #ifdef USE_PITOT version added later; the original also had an integer division bug (36 / 100 == 0 in C)
  • Guard the getCrsfFrame() dispatch case for CRSF_FRAMETYPE_AIRSPEED_SENSOR with #ifdef USE_PITOT to match the function's availability

Testing

  • Both modified files compile without errors (verified on ZEEZF7 target; flash overflow on that target is pre-existing and unrelated)
  • Altitude unpack verified against TBS CRSF spec reference get_altitude_dm() function
  • Vario unpack formula verified against TBS CRSF spec get_vertical_speed_cm_s() function

Code 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).

- 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.
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions
Copy link
Copy Markdown

Test firmware build ready — commit 29a763a

Download firmware for PR #11572

234 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

@sensei-hacker sensei-hacker merged commit 47e603d into iNavFlight:maintenance-10.x May 19, 2026
23 checks passed
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.

1 participant