MSP2_INAV_SET_AUX_RC (0x2230) — Bandwidth-efficient auxiliary RC channel updates#11482
MSP2_INAV_SET_AUX_RC (0x2230) — Bandwidth-efficient auxiliary RC channel updates#11482b14ckyy wants to merge 6 commits intoiNavFlight:maintenance-9.xfrom
Conversation
Review Summary by QodoAdd MSP2_INAV_SET_AUX_RC for auxiliary RC channel updates WalkthroughsDescription• Adds MSP2_INAV_SET_AUX_RC (0x2230) for bandwidth-efficient auxiliary RC updates • Supports configurable resolution (2/4/8/16-bit) for CH9-CH32 channels • Implements persistent MSP aux overlay applied post-RX, pre-failsafe • Protects CH1-CH8 from MSP updates for flight safety Diagramflowchart LR
MSP["MSP2_INAV_SET_AUX_RC<br/>0x2230"] -->|"Definition byte<br/>Start channel + resolution"| Parser["Parse channel data<br/>2/4/8/16-bit modes"]
Parser -->|"Validate<br/>CH9-CH32 only"| Decode["Decode sub-byte<br/>or byte-aligned values"]
Decode -->|"Skip if 0"| Overlay["Apply to mspAuxOverlay[]<br/>CH9-CH32"]
Overlay -->|"Post-RX integration"| RxCalc["calculateRxChannelsAndUpdateFailsafe<br/>Override rcChannels after MSP RC Override"]
RxCalc -->|"Before failsafe"| Failsafe["Failsafe evaluation<br/>unaffected"]
File Changes1. src/main/msp/msp_protocol_v2_inav.h
|
Code Review by Qodo
1. 16-bit PWM signed overflow
|
|
Test firmware build ready — commit Download firmware for PR #11482 228 targets built. Find your board's
|
|
This is AWESOME, I'll use it for sure on Bullet GCSS. The current RAW_RC implementation always let me unease, with this I think I'll have a more reliable way to set flight modes from outside. I'll test this and post back the results ASAP. |
Testing is so VERY much appreciated! |
- Clamp 16-bit PWM values to 750-2250 (prevent int16_t overflow) - Reject oversized payloads (dataSize > 49) - Skip channels actively provided by primary RX (SBUS/CRSF/etc.) - When MSP is the RX provider, use actual MSP_SET_RAW_RC channel count - Skip channels controlled by MSP_RC_OVERRIDE bitmask when active
This ensures that AUX_RC is really just acting as a low priority auxiliary control for definitely unused channels. tests pending |
- Raise minimum channel from CH9 to CH13 (index 12) All common protocols deliver at least 12 channels on the wire. - Remove rxChannelCount-based guard (protocol drivers report max capacity, not actual sender channel count — unusable as guard) - Remove rxMspGetLastChannelCount (no longer needed) - Keep MSP_RC_OVERRIDE bitmask guard
When MSP is the primary RX provider (e.g. mLRS), skip channels already covered by MSP_SET_RAW_RC to avoid wasting bandwidth on overlapping updates.
|
Slight spec change. I cannot safely determine what channel range the receiver actually sends to add a reliable safeguard and reject all channels that come through sbus or crsf. Alternative solution implemented:
|
- Rx.md: Add 'MSP Auxiliary RC Channel Overlay' section with key properties, use case, priority order, and safeguard descriptions - Rx.md: Fix MSP RX channel count (18 -> 34) - msp_messages.json: Update channel range to CH13-CH32, add clamp range, payload size limits, and guard descriptions
|
Docs updated. Bench tested. All functions as expected. Ready to merge. Wiki Update is prepared as well, when merged. |
Closes #11476
Summary
Adds a new MSPv2 command
MSP2_INAV_SET_AUX_RC(0x2230) that allows lightweight updates to auxiliary RC channels (CH13–CH32) with configurable resolution. Designed for extending channel count beyond native RC link capacity via MSP passthrough (SmartPort, CRSF, FPort) without the overhead ofMSP_SET_RAW_RC.Motivation
Most common RC links are limited to 12–16 channels but offer native MSP passthrough.
MSP_SET_RAW_RCis impractical over these links because it always starts at CH1, sends 2 bytes per channel, and scaling up to higher channels causes payload fragmentation across multiple transport chunks — killing passthrough performance.MSP2_INAV_SET_AUX_RCsolves this with:0= no update, previous value persistsExample savings: 8 channels above CH16 in 8-bit mode = 18 bytes vs 52 bytes with
MSP_SET_RAW_RC(65% reduction).Changes
New feature:
MSP2_INAV_SET_AUX_RCsrc/main/msp/msp_protocol_v2_inav.hMSP2_INAV_SET_AUX_RC 0x2230src/main/rx/rx.h/src/main/rx/rx.cstatic uint16_t mspAuxOverlay[]— persistent overlay array for CH13–CH32rxMspAuxOverlaySet(channelIndex, value)— setter with bounds validation (index 12–31)calculateRxChannelsAndUpdateFailsafe()— after MSP RC Override, before failsafe evaluationsrc/main/rx/msp.c/src/main/rx/msp.hMSP_SET_RAW_RCchannel count viarxMspGetLastChannelCount()src/main/fc/fc_msp.ccase MSP2_INAV_SET_AUX_RC:handler with:docs/development/msp/msp_messages.jsonIncluded bugfixes (from separate PRs, merged into base branch):
initSharedMsp()response buffer initialization fixMSP_FLAG_DONT_REPLYhandling fix for telemetry passthroughSafety Design
CH1–CH12 are rejected by design (
MSP_RESULT_ERROR). These channels carry:This means
MSP2_SET_AUX_RCshould not arm/disarm, change flight modes, or take over aircraft control. NoUSE_RX_MSP, no MSP-RC-OVERRIDE flight mode, no additional safety gates required — any MSP source can safely update aux channels at any time.Overlay priority & safeguards
The overlay applies as the last writer in
calculateRxChannelsAndUpdateFailsafe():Three safeguards prevent unintended channel conflicts:
MSP_RESULT_ERROR— message rejected ifstartChannel < 12RX_TYPE_MSPonly (e.g. mLRS)max(12, mspLastChannelCount)— channels covered byMSP_SET_RAW_RCare skipped silentlyBOXMSPRCOVERRIDEmode is activemspOverrideChannelsbitmask are skipped silentlyNote: For serial RX protocols (SBUS, CRSF, FPort, etc.), the protocol drivers report their maximum capacity (up to 34 channels) rather than actual sender channel count. The firmware cannot reliably detect which channels the sender actively uses. If AUX_RC targets a channel that the RX link also sends, AUX_RC wins (last writer). It is the user's responsibility to configure AUX_RC start channel above their RX link's active channel range.
No failsafe interaction
The overlay does not affect RX signal loss detection or failsafe triggering. If the primary RX link is lost, failsafe triggers normally regardless of overlay state.
Message Format (Quick Reference)
Recommended:
MSP_FLAG_DONT_REPLY(flags=0x01) on passthrough links for faster update rate for periodic updatesTesting
Build verification
MATEKF765target builds clean (STM32F7, arm-none-eabi-gcc 13.2.1)Hardware test setup
Functional tests performed
MSP_RESULT_ERROR, channels unaffectedstartChannel + channelCount > 32returnsMSP_RESULT_ERRORMSP_RESULT_ERRORMSP_RESULT_ERRORdataSize < 2returnsMSP_RESULT_ERRORdataSize > 49returnsMSP_RESULT_ERRORflags=0x01, no response frame sent on SmartPort (saves bandwidth)Related PRs
initSharedMsp()fix (merged into base branch)MSP_FLAG_DONT_REPLYhandling fix (merged into base branch)