Mavlink Refactor + Multiple Serial Ports#11472
Draft
xznhj8129 wants to merge 42 commits intoiNavFlight:maintenance-10.xfrom
Draft
Mavlink Refactor + Multiple Serial Ports#11472xznhj8129 wants to merge 42 commits intoiNavFlight:maintenance-10.xfrom
xznhj8129 wants to merge 42 commits intoiNavFlight:maintenance-10.xfrom
Conversation
# Conflicts: # docs/development/msp/inav_enums.json # src/main/telemetry/mavlink.c
Scope MAVLink half-duplex to serial RX
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.
MAVLink multi-port refactor, routing, protocol fixes, and MSP-over-MAVLink tunnel
** Draft WIP, some things need to be adjusted, refactored or changed including user setup workflow, settings; configurator (seperate PR); as well as flight testing **
** Test tooling for routing, performance stress testing and telemetry will be included soon **
Summary
Substantial refactor of INAV's MAVLink implementation. The main goal is to turn the existing single-block MAVLink telemetry code into a modular MAVLink subsystem that can support multiple concurrent MAVLink ports, more correct routing and message handling, and a broader set of MAVLink interactions needed by modern GCS and radio workflows. This enables you to use multiple Mavlink ports for receivers, GCS links, computers, gimbals, cameras and more as you would expect from a Mavlink vehicle. The routing is based on Ardupilot.
The old
src/main/telemetry/mavlink.cfile was split by responsibility instead of continuing to accumulate all MAVLink behavior in one place. Runtime state, port lifecycle, and active-port context moved intosrc/main/mavlink/mavlink_runtime.c; stream scheduling and periodic message emission intosrc/main/mavlink/mavlink_streams.c; route learning and forwarding intosrc/main/mavlink/mavlink_routing.c; mission upload/download and frame handling intosrc/main/mavlink/mavlink_mission.c; mode mapping intosrc/main/mavlink/mavlink_modes.c; and FC-facing command handling plus MSP-over-MAVLink tunnel handling intosrc/main/fc/fc_mavlink.c. Shared types and internal interfaces were moved undersrc/main/mavlink/, leaving the telemetry entry layer much thinner and making further MAVLink work more tractable.On top of that refactor, this branch adds MSP-over-MAVLink Tunnel Service support so the INAV Configurator can talk MSP over an existing MAVLink telemetry link, typically over a radio that does not expose a separate MSP transport. The configurator patch adds a "Mavlink Tunnel" option when Wireless Mode is selected and allows specification of SYSID for multi-vehicle networks.
See docs/Mavlink.md
What this branch changes
src/main/telemetry/mavlink.cimplementation into focused modules for runtime, streams, routing, mission handling, modes, and FC-facing message handling.MAX_MAVLINK_PORTS), with per-port runtime state and per-port configuration.(sysid, compid) -> ingress port(mavlink_sysid, MAV_COMP_ID_AUTOPILOT1)instead of introducing per-port FC component IDs; attached devices remain remote routed components learned from traffic.mavlink_port{1-4}_*_ratemavlink_port{1-4}_min_txbuffermavlink_port{1-4}_radio_typemavlink_port{1-4}_high_latencyserialrx_halfduplexbacks off after RX before transmitting.Protocol and behavior improvements
mav_fix2behavior fixes that were already part of the branch history.MAV_CMD_SET_MESSAGE_INTERVALbehavior with per-message interval overrides layered on top of the existing stream model.GPS_RAW_INT,GLOBAL_POSITION_INT,BATTERY_STATUS,SCALED_PRESSURE, andSYSTEM_TIMEcan be controlled more correctly.SYSTEM_TIMEoutput and corresponding request/interval support.MSP-over-MAVLink tunnel
TUNNELusing private payload type0x8001.msp_serial.User-visible impact
Documentation and tests
docs/Mavlink.mddocument describing the implemented behavior, supported messages/commands, routing, stream configuration, tunnel support, and known MAVLink differences.src/test/unit/mavlink_unittest.cccovering routing, mission flow, guided commands, stream intervals, protocol/capability requests, telemetry details, and MSP tunnel behavior.Important limits / non-goals
Open Questions