Skip to content

Correct MSP-message-sending message truncation issue - #33949

Merged
peterbarker merged 2 commits into
ArduPilot:masterfrom
peterbarker:pr-claude/msp-send-fix
Aug 12, 2026
Merged

Correct MSP-message-sending message truncation issue#33949
peterbarker merged 2 commits into
ArduPilot:masterfrom
peterbarker:pr-claude/msp-send-fix

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Fix inverted check when sending MSP traffic

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

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.

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.
@peterbarker
peterbarker merged commit 8b7028f into ArduPilot:master Aug 12, 2026
99 checks passed
@github-project-automation github-project-automation Bot moved this from ReadyForDevCall to Done in Peter's ArduPilot 4.8 Queue Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants