From 8f8c578ed394ab1287bb3e22f74bae4861703416 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Jul 2026 07:29:25 +1000 Subject: [PATCH 01/21] modules: mavlink: update for 32 bit system ID support --- modules/mavlink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mavlink b/modules/mavlink index 13f2f7351a9bd..5ad0e91056065 160000 --- a/modules/mavlink +++ b/modules/mavlink @@ -1 +1 @@ -Subproject commit 13f2f7351a9bdf5292a2c243eb9a2c19ff4b6472 +Subproject commit 5ad0e9105606572ae2a3302b07302f8029ff99e1 From 8ec3ae430287cb8cf9170a96e782ed8a4578a907 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Jul 2026 07:29:25 +1000 Subject: [PATCH 02/21] GCS_MAVLink: fix statustext chunking component check the component was compared against last_src_system, so chunked statustexts from different components on the same system were joined together. --- libraries/GCS_MAVLink/GCS_Common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 67a7fe18f189a..316c7eae5db5b 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -3856,7 +3856,7 @@ void GCS_MAVLINK::handle_statustext(const mavlink_message_t &msg) const uint8_t max_prefix_len = 14; const uint8_t text_len = MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN+1+max_prefix_len; if (msg.sysid != statustext_chunking.last_src_system || - msg.compid != statustext_chunking.last_src_system || + msg.compid != statustext_chunking.last_src_component || packet.id != statustext_chunking.last_id) { statustext_chunking.last_src_system = msg.sysid; statustext_chunking.last_src_component = msg.compid; From 41bbd7d69efcef9e35e73b0af5cb79caf5ee7645 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Jul 2026 07:29:40 +1000 Subject: [PATCH 03/21] GCS_MAVLink: support 32 bit system IDs Widen system ID handling throughout for MAVLink2.1 32 bit system IDs (mavlink/rfcs#20): - MAV_SYSID, MAV_GCS_SYSID and MAV_GCS_SYSID_HI become AP_Int32 with parameter width conversion. Values must stay below 2^24 until the parameter transport moves away from float32 - routing table entries, get_targets() and find_by_mavtype use the mavlink_msg_get_target_sysid/compid helpers so targets in the extended header are honoured - packet_overhead_chan() conservatively reserves the extended header - TSYN and MAVC log the full 32 bit source and target system IDs --- libraries/GCS_MAVLink/GCS.cpp | 17 ++++--- libraries/GCS_MAVLink/GCS.h | 48 +++++++++++++------ libraries/GCS_MAVLink/GCS_Common.cpp | 24 ++++++---- libraries/GCS_MAVLink/GCS_FTP.cpp | 5 +- libraries/GCS_MAVLink/GCS_FTP.h | 4 +- libraries/GCS_MAVLink/GCS_MAVLink.cpp | 2 +- libraries/GCS_MAVLink/GCS_Signing.cpp | 16 ++++++- libraries/GCS_MAVLink/MAVLink_routing.cpp | 37 +++++++++----- libraries/GCS_MAVLink/MAVLink_routing.h | 8 ++-- libraries/GCS_MAVLink/MissionItemProtocol.cpp | 10 ++-- libraries/GCS_MAVLink/MissionItemProtocol.h | 2 +- 11 files changed, 114 insertions(+), 59 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.cpp b/libraries/GCS_MAVLink/GCS.cpp index cdaa7fda23db6..87e98071a8eb3 100644 --- a/libraries/GCS_MAVLink/GCS.cpp +++ b/libraries/GCS_MAVLink/GCS.cpp @@ -38,14 +38,14 @@ const AP_Param::GroupInfo GCS::var_info[] { // @Param: _SYSID // @DisplayName: MAVLink system ID of this vehicle // @Description: Allows setting an individual MAVLink system id for this vehicle to distinguish it from others on the same network. - // @Range: 1 255 + // @Range: 1 16777215 // @User: Advanced AP_GROUPINFO("_SYSID", 1, GCS, sysid, MAV_SYSID_DEFAULT), // @Param: _GCS_SYSID // @DisplayName: My ground station number // @Description: This sets what MAVLink source system IDs are accepted for GCS failsafe handling, RC overrides and manual control. When MAV_GCS_SYSID_HI is less than MAV_GCS_SYSID then only this value is considered to be a GCS. When MAV_GCS_SYSID_HI is greater than or equal to MAV_GCS_SYSID then the range of values between MAV_GCS_SYSID and MAV_GCS_SYSID_HI (inclusive) are all treated as valid GCS MAVLink system IDs - // @Range: 1 255 + // @Range: 1 16777215 // @Increment: 1 // @User: Advanced AP_GROUPINFO("_GCS_SYSID", 2, GCS, mav_gcs_sysid, 255), @@ -53,7 +53,7 @@ const AP_Param::GroupInfo GCS::var_info[] { // @Param: _GCS_SYSID_HI // @DisplayName: ground station system ID, maximum // @Description: Upper limit of MAVLink source system IDs considered to be from the GCS. When this is less than MAV_GCS_SYSID then only MAV_GCS_SYSID is used as GCS ID. When this is greater than or equal to MAV_GCS_SYSID then the range of values from MAV_GCS_SYSID to MAV_GCS_SYSID_HI (inclusive) is treated as a GCS ID. - // @Range: 0 255 + // @Range: 0 16777215 // @Increment: 1 // @User: Advanced AP_GROUPINFO("_GCS_SYSID_HI", 5, GCS, mav_gcs_sysid_high, 0), @@ -261,6 +261,11 @@ MissionItemProtocol *GCS::missionitemprotocols[3]; void GCS::init() { + // sysid parameters widened for 32 bit system IDs + sysid.convert_parameter_width(AP_PARAM_INT16); + mav_gcs_sysid.convert_parameter_width(AP_PARAM_INT16); + mav_gcs_sysid_high.convert_parameter_width(AP_PARAM_INT16); + mavlink_system.sysid = sysid_this_mav(); } @@ -724,12 +729,12 @@ MAV_RESULT GCS::lua_command_int_packet(const mavlink_command_int_t &packet) /* return true if a MAVLink system ID is a GCS for this vehicle */ -bool GCS::sysid_is_gcs(uint8_t _sysid) const +bool GCS::sysid_is_gcs(uint32_t _sysid) const { if (mav_gcs_sysid_high <= mav_gcs_sysid) { - return mav_gcs_sysid == _sysid; + return uint32_t(mav_gcs_sysid.get()) == _sysid; } - return _sysid >= mav_gcs_sysid && _sysid <= mav_gcs_sysid_high; + return _sysid >= uint32_t(mav_gcs_sysid.get()) && _sysid <= uint32_t(mav_gcs_sysid_high.get()); } #endif // HAL_GCS_ENABLED diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 9d845e40dcef6..c350431622ca8 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -149,13 +149,13 @@ class GCS_MAVLINK_InProgress Type task; MAV_CMD mav_cmd; - static class GCS_MAVLINK_InProgress *get_task(MAV_CMD cmd, Type t, uint8_t sysid, uint8_t compid, mavlink_channel_t chan); + static class GCS_MAVLINK_InProgress *get_task(MAV_CMD cmd, Type t, uint32_t sysid, uint8_t compid, mavlink_channel_t chan); static void check_tasks(); private: - uint8_t requesting_sysid; + uint32_t requesting_sysid; uint8_t requesting_compid; mavlink_channel_t chan; @@ -260,6 +260,26 @@ class GCS_MAVLINK entry->max_msg_len, entry->crc_extra); } + // variant for raw payload structs with a target sysid over 255; the + // caller must have written the payload target_system byte as + // (target_sysid > 255 ? 0 : target_sysid) + void send_message_target(uint32_t msgid, const char *pkt, uint32_t target_sysid, uint8_t target_compid) { + const mavlink_msg_entry_t *entry = mavlink_get_msg_entry(msgid); + if (entry == nullptr) { + return; + } + if (!check_payload_size(entry->max_msg_len)) { + return; + } + _mav_finalize_message_chan_send_target(chan, + entry->msgid, + pkt, + entry->min_msg_len, + entry->max_msg_len, + entry->crc_extra, + target_sysid, + target_compid); + } // accessor for uart AP_HAL::UARTDriver *get_uart() { return _port; } @@ -391,7 +411,7 @@ class GCS_MAVLINK void send_accelcal_vehicle_position(uint32_t position); void send_scaled_imu(uint8_t instance, void (*send_fn)(mavlink_channel_t chan, uint32_t time_ms, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag, int16_t temperature)); void send_sys_status(); - void send_set_position_target_global_int(uint8_t target_system, uint8_t target_component, const Location& loc); + void send_set_position_target_global_int(uint32_t target_system, uint8_t target_component, const Location& loc); void send_rpm() const; void send_generator_status() const; #if AP_WINCH_ENABLED @@ -469,16 +489,16 @@ class GCS_MAVLINK search for a component in the routing table with given mav_type and retrieve it's sysid, compid and channel returns if a matching component is found */ - static bool find_by_mavtype(uint8_t mav_type, uint8_t &sysid, uint8_t &compid, mavlink_channel_t &channel) { return routing.find_by_mavtype(mav_type, sysid, compid, channel); } + static bool find_by_mavtype(uint8_t mav_type, uint32_t &sysid, uint8_t &compid, mavlink_channel_t &channel) { return routing.find_by_mavtype(mav_type, sysid, compid, channel); } /* search for the first vehicle or component in the routing table with given mav_type and component id and retrieve its sysid and channel returns true if a match is found */ - static bool find_by_mavtype_and_compid(uint8_t mav_type, uint8_t compid, uint8_t &sysid, mavlink_channel_t &channel) { return routing.find_by_mavtype_and_compid(mav_type, compid, sysid, channel); } + static bool find_by_mavtype_and_compid(uint8_t mav_type, uint8_t compid, uint32_t &sysid, mavlink_channel_t &channel) { return routing.find_by_mavtype_and_compid(mav_type, compid, sysid, channel); } // same as above, but returns a pointer to the GCS_MAVLINK object // corresponding to the channel - static GCS_MAVLINK *find_by_mavtype_and_compid(uint8_t mav_type, uint8_t compid, uint8_t &sysid); + static GCS_MAVLINK *find_by_mavtype_and_compid(uint8_t mav_type, uint8_t compid, uint32_t &sysid); #if AP_MAVLINK_SIGNING_ENABLED // update signing timestamp on GPS lock @@ -681,7 +701,7 @@ class GCS_MAVLINK void handle_statustext(const mavlink_message_t &msg); struct { - uint8_t last_src_system; + uint32_t last_src_system; uint8_t last_src_component; uint8_t last_id; // ID from the mavlink packet uint8_t msg_id; // ID used in our logs @@ -983,7 +1003,7 @@ class GCS_MAVLINK mavlink_channel_t chan; int16_t param_index; char param_name[AP_MAX_NAME_SIZE+1]; - uint8_t src_system_id; + uint32_t src_system_id; uint8_t src_component_id; }; @@ -994,7 +1014,7 @@ class GCS_MAVLINK int16_t param_index; uint16_t count; char param_name[AP_MAX_NAME_SIZE+1]; - uint8_t src_system_id; + uint32_t src_system_id; uint8_t src_component_id; MAV_PARAM_ERROR param_error; }; @@ -1176,7 +1196,7 @@ class GCS /* return true if a MAVLink system ID is a GCS */ - bool sysid_is_gcs(uint8_t sysid) const; + bool sysid_is_gcs(uint32_t sysid) const; // last time traffic was seen from my designated GCS. traffic // includes heartbeats and some manual control messages. @@ -1302,7 +1322,7 @@ class GCS bool get_high_latency_status(); #endif // HAL_HIGH_LATENCY2_ENABLED - uint8_t sysid_this_mav() const { return sysid; } + uint32_t sysid_this_mav() const { return sysid; } uint32_t telem_delay() const { return mav_telem_delay; } #if AP_SCRIPTING_ENABLED @@ -1330,9 +1350,9 @@ class GCS GCS_MAVLINK *_chan[MAVLINK_COMM_NUM_BUFFERS]; // parameters - AP_Int16 sysid; - AP_Int16 mav_gcs_sysid; - AP_Int16 mav_gcs_sysid_high; + AP_Int32 sysid; + AP_Int32 mav_gcs_sysid; + AP_Int32 mav_gcs_sysid_high; AP_Enum16