Correct MSP-message-sending message truncation issue - #33949
Merged
peterbarker merged 2 commits intoAug 12, 2026
Conversation
The guard here contradicted the comment above it, which allows a send if either the transmit buffer is empty or the frame fits in it. Testing !tx_pending() instead of tx_pending() inverted that: a frame was dropped when the buffer was empty but too small, and sent unconditionally whenever a transmit was already pending. Writes do not block, so sending unconditionally with insufficient space wrote as much of the frame as would fit and discarded the rest, putting a truncated frame on the wire. The write return values were ignored, so the caller was told the whole frame had been sent. The empty-buffer case exists upstream only because a blocking write could push out a frame bigger than the buffer. ArduPilot has no blocking writes, so require the frame to fit and drop it otherwise.
Check that a frame is sent whole when there is room for it, on both an idle and a busy port, and dropped rather than truncated when there is not. Uses a uart which truncates writes to the space available, as the ChibiOS and Linux backends do.
rishabsingh3003
approved these changes
Aug 12, 2026
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
Fix inverted check when sending MSP traffic
Classification & Testing (check all that apply and add your own)
Description
Original betaflight line: https://github.com/betaflight/betaflight/blob/master/src/main/msp/msp_serial.c#L311 - you can see we inverted the pending check when porting ("empty" vs "pending" and both lines have a
!)tx_pending doesn't make a huge amount of sense when our writes are non-blocking anyway. So just make sure the thing fits.