Skip to content

MAVLink: make MISSION_CURRENT settable via SET_MESSAGE_INTERVAL and silent on high-latency ports - #12035

Open
xznhj8129 wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
xznhj8129:fix/mavlink-mission-current-interval
Open

xznhj8129 wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
xznhj8129:fix/mavlink-mission-current-interval

Conversation

@xznhj8129

@xznhj8129 xznhj8129 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

MISSION_CURRENT (42) was sent by mavlinkMissionUpdate() on a hardcoded 1000 ms timer to every active MAVLink port:

  • SET_MESSAGE_INTERVAL / GET_MESSAGE_INTERVAL returned MAV_RESULT_UNSUPPORTED for it, so a GCS could neither slow it down nor turn it off.
  • The send mask came from mavlinkActivePortMask(), which ignores highLatencyEnabled, so high-latency ports received it alongside HIGH_LATENCY2.

Fix

  • MISSION_CURRENT is now a regular periodic message (MAVLINK_PERIODIC_MESSAGE_MISSION_CURRENT), sent from processMAVLinkTelemetry() per port.
  • It has a fixed 1000 ms default on every port (MAVLINK_MISSION_CURRENT_INTERVAL_MS), independent of any REQUEST_DATA_STREAM rate. Existing behaviour doesn't change unless a GCS asks for a different interval.
  • SET_MESSAGE_INTERVAL / GET_MESSAGE_INTERVAL work for it per port (-1 disables, 0 resets to default).
  • MAV_CMD_REQUEST_MESSAGE for 42 now sends it once.
  • High-latency ports no longer get it: the existing high-latency early return in processMAVLinkTelemetry() now covers it.
  • Mission state tracking (completion, WP-mode rising edge, transfer timeouts) stays in mavlinkMissionUpdate(). Only the send moved, into mavlinkSendMissionCurrent(). lastMissionCurrentMs is removed.

Testing

  • New unit tests SetMessageIntervalControlsMissionCurrent and HighLatencyPortDoesNotSendMissionCurrent. Both fail on the current maintenance-10.x and pass with this change.
  • New unit test MissionCurrentDefaultIgnoresDataStreamRates: changing the heartbeat stream or MAV_DATA_STREAM_ALL rate leaves MISSION_CURRENT at 1000 ms.
  • The first periodic send is now staggered like the other periodic messages (about 1.036 s after init instead of exactly 1.0 s). The two existing MISSION_CURRENT tests had their time ticks moved 100 ms later to account for this.
  • All mavlink_unittest tests pass.
  • Not yet tested against a live GCS.

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Make MISSION_CURRENT configurable per MAVLink port

🐞 Bug fix ✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Schedule MISSION_CURRENT per port at heartbeat rate, preserving the 1 Hz default.
• Support interval configuration and one-shot requests for MISSION_CURRENT.
• Suppress MISSION_CURRENT on high-latency links and cover behavior with unit tests.
Diagram

graph TD
  GCS["GCS Commands"] --> MAP["Message Mapping"] --> SCH["Per-Port Scheduler"] --> LAT{"High Latency?"}
  LAT -- "Yes" --> HL["HIGH_LATENCY2"]
  LAT -- "No" --> CUR["MISSION_CURRENT"]
  STATE["Mission State"] --> CUR
Loading
High-Level Assessment

The selected approach is optimal because it reuses the established per-port periodic-message scheduler, automatically gaining interval overrides, request handling, staggering, and high-latency suppression. Retaining a mission-specific timer with custom per-port filtering would duplicate scheduler behavior and preserve unnecessary state.

Files changed (6) +99 / -20

Enhancement (2) +2 / -0
mavlink_mission.hExpose the MISSION_CURRENT sender +1/-0

Expose the MISSION_CURRENT sender

• Declares mavlinkSendMissionCurrent() so telemetry scheduling and request handling can invoke it.

src/main/mavlink/mavlink_mission.h

mavlink_types.hAdd the MISSION_CURRENT periodic message identifier +1/-0

Add the MISSION_CURRENT periodic message identifier

• Extends the periodic-message enumeration so each MAVLink port can maintain an independent MISSION_CURRENT schedule and override interval.

src/main/mavlink/mavlink_types.h

Bug fix (2) +17 / -13
mavlink_mission.cSeparate mission tracking from MISSION_CURRENT transmission +4/-13

Separate mission tracking from MISSION_CURRENT transmission

• Keeps completion transitions and mission transfer timeout handling in mavlinkMissionUpdate(). Extracts message construction and transmission into mavlinkSendMissionCurrent() for scheduler and request-driven use.

src/main/mavlink/mavlink_mission.c

mavlink_streams.cIntegrate MISSION_CURRENT with periodic telemetry scheduling +13/-0

Integrate MISSION_CURRENT with periodic telemetry scheduling

• Maps MISSION_CURRENT into the periodic-message registry with the heartbeat stream's 1 Hz default. Adds periodic and one-shot sending, enabling SET/GET_MESSAGE_INTERVAL behavior and applying the existing high-latency early return.

src/main/mavlink/mavlink_streams.c

Refactor (1) +0 / -2
mavlink_internal.hRemove mission-specific transmission timer state +0/-2

Remove mission-specific transmission timer state

• Removes the hardcoded MISSION_CURRENT interval and global last-send timestamp now superseded by per-port scheduler state.

src/main/mavlink/mavlink_internal.h

Tests (1) +80 / -5
mavlink_unittest.ccTest MISSION_CURRENT interval and high-latency behavior +80/-5

Test MISSION_CURRENT interval and high-latency behavior

• Adjusts existing mission-current timing assertions for scheduler staggering. Adds helpers and tests covering default interval reporting, custom rates, disabling transmission, and suppression on high-latency ports.

src/test/unit/mavlink_unittest.cc

@xznhj8129
xznhj8129 force-pushed the fix/mavlink-mission-current-interval branch from 9413a56 to 38406a2 Compare September 25, 2026 18:02
MISSION_CURRENT was sent by the mission module on a hardcoded 1000 ms
timer to every active port. SET_MESSAGE_INTERVAL could not change it,
and high-latency ports received it despite only expecting HIGH_LATENCY2.

Send it from the per-port periodic scheduler instead, with a fixed
1000 ms default on every port that no data stream rate affects. This
makes it configurable via SET/GET_MESSAGE_INTERVAL and REQUEST_MESSAGE,
and the high-latency early return now covers it.
@xznhj8129
xznhj8129 force-pushed the fix/mavlink-mission-current-interval branch from 38406a2 to 0fb1751 Compare September 25, 2026 18:05
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

RAM / Flash usage vs. base commit 3d2c8fd — commit 0fb1751

Target Flash Δ RAM Δ
MATEKF405 +272 B (+0.04%) CCM: ±0 B (±0.00%)
RAM: +64 B (+0.06%)
MATEKF722 ±0 B (±0.00%) ITCM_RAM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)
TCM: ±0 B (±0.00%)
MATEKF765 +16 B (+0.00%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: +64 B (+0.05%)
MATEKH743 +16 B (+0.00%) D2_RAM: ±0 B (±0.00%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)

See RAM/flash optimization guide for techniques to reduce usage.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Test firmware build ready — commit 0fb1751

Download firmware for PR #12035

251 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.

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