Conversation
mavlinkSendTunnelMspReply() wrote all TUNNEL chunks of a reply back to back, and mavlinkSendMessage() drops any frame that does not fit the port's free TX space. Hardware UART TX rings are 256 bytes and a full chunk is 145 bytes on the wire, so the second chunk of every reply above about 221 framed bytes was dropped deterministically. MSP_BOXNAMES never completed over a UART; USB VCP (4 KB buffer) and SITL hid it. Keep the encoded reply and a resume offset as a single pending state (the reply payload buffer is already shared, so one reply at a time), send each chunk only after checking the ingress port's free TX space, and continue in the following telemetry cycles before RX and the periodic stream. Nothing blocks. A request that arrives while a reply is pending is dropped; a reply with no progress for one second is abandoned so a stalled port cannot lock the tunnel. The pending state is cleared on port re-init, the flush respects the half-duplex backoff, and the MSP_REBOOT reply is flushed before the reboot. Unit tests get a settable TX budget to reproduce the 256-byte ring; seven tunnel tests cover the resume, the held-back chunk, busy drops on the same and on a second port, the stall, the re-init and the reboot. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoResume MSP tunnel replies across constrained MAVLink TX cycles
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
The busy check flushed the pending reply from inside RX processing, right after lastRxFrameUs was updated, so on a half-duplex port a pipelined request could put a chunk on the line inside the backoff window. The per-cycle flush already runs before RX and respects the backoff, so the check now only reports whether a reply is pending. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12036 251 targets built. Find your board's
|
|
@xznhj8129 If you have some time, I would appreciate if you have a look and tell me if you have concerns before we merge. Fix is verified on my end and 560B message goes through no problem. very nice feature. |
Bug
Found while writing a GCS client for the MSP-over-MAVLink tunnel (#11718) and reproduced on a Matek F765-WING with 10.0.0-RC1 over a physical UART at 115200:
MSP_BOXNAMESnever completes, only two of the expected chunks arrive, every retry fails the same way. Small replies work, and so does a 640-byte all-zero reply (MAVLink2 trims trailing zeros).mavlinkSendTunnelMspReply()writes allTUNNELchunks of a reply back to back, andmavlinkSendMessage()drops any frame that does not fit the port's free TX space. Hardware UART TX rings are 256 bytes and a full chunk is 145 bytes on the wire, so the second chunk of every reply above roughly 221 framed bytes is dropped deterministically. USB VCP (4 KB CDC buffer) and SITL (65535 free) never show it, and the unit-test stub reported 1024 free bytes, so the existing fragmentation tests passed.Fix
Resumable, non-blocking send:
serialTxBytesFree()against the encoded length before writing, and neither drops nor consumes a sequence number when the frame does not fit.mavlinkSendMessage()itself is unchanged in behaviour (the encode step is shared).MSP_REBOOT: a reply left pending by a full ring is flushed before the reboot (it was lost before as well).No settings, no PG change.
docs/Mavlink.mdgains one sentence describing the observable behaviour.Verification
3d2c8fdcd: MATEKF765 flash +512 B, RAM +48 B; MATEKH743 flash +508 B; MATEKF405SE flash +576 B, RAM +48 B. 512 KB targets have no MAVLink and are unaffected.Known limits, unchanged from before: the periodic stream can still use TX space a chunk did not fit into, which delays but never corrupts a reply; radio flow control (
txbuffFree) is not considered by the tunnel.🤖 Generated with Claude Code