diff --git a/AntennaTracker/GCS_MAVLink_Tracker.cpp b/AntennaTracker/GCS_MAVLink_Tracker.cpp index 6749dc9e0c7441..0613908a3e61c9 100644 --- a/AntennaTracker/GCS_MAVLink_Tracker.cpp +++ b/AntennaTracker/GCS_MAVLink_Tracker.cpp @@ -254,7 +254,7 @@ void GCS_MAVLINK_Tracker::packetReceived(const mavlink_status_t &status, const mavlink_message_t &msg) { // return immediately if sysid doesn't match our target sysid - if ((tracker.g.sysid_target != 0) && (tracker.g.sysid_target != msg.sysid)) { + if ((tracker.g.sysid_target != 0) && (uint32_t(tracker.g.sysid_target.get()) != msg.sysid)) { GCS_MAVLINK::packetReceived(status, msg); return; } diff --git a/AntennaTracker/GCS_Tracker.cpp b/AntennaTracker/GCS_Tracker.cpp index ef5c991856d31c..7305edf0fea8fd 100644 --- a/AntennaTracker/GCS_Tracker.cpp +++ b/AntennaTracker/GCS_Tracker.cpp @@ -1,7 +1,7 @@ #include "GCS_Tracker.h" #include "Tracker.h" -void GCS_Tracker::request_datastream_position(const uint8_t _sysid, const uint8_t compid) +void GCS_Tracker::request_datastream_position(const uint32_t _sysid, const uint8_t compid) { for (uint8_t i=0; i < num_gcs(); i++) { // request position @@ -17,7 +17,7 @@ void GCS_Tracker::request_datastream_position(const uint8_t _sysid, const uint8_ } } -void GCS_Tracker::request_datastream_airpressure(const uint8_t _sysid, const uint8_t compid) +void GCS_Tracker::request_datastream_airpressure(const uint32_t _sysid, const uint8_t compid) { for (uint8_t i=0; i < num_gcs(); i++) { // request air pressure diff --git a/AntennaTracker/GCS_Tracker.h b/AntennaTracker/GCS_Tracker.h index 5695d237826821..055a205f4ea09d 100644 --- a/AntennaTracker/GCS_Tracker.h +++ b/AntennaTracker/GCS_Tracker.h @@ -30,7 +30,7 @@ class GCS_Tracker : public GCS private: - void request_datastream_position(uint8_t sysid, uint8_t compid); - void request_datastream_airpressure(uint8_t sysid, uint8_t compid); + void request_datastream_position(uint32_t sysid, uint8_t compid); + void request_datastream_airpressure(uint32_t sysid, uint8_t compid); }; diff --git a/AntennaTracker/Parameters.cpp b/AntennaTracker/Parameters.cpp index 3a5fd8c0eb2a28..1851ea3faf421e 100644 --- a/AntennaTracker/Parameters.cpp +++ b/AntennaTracker/Parameters.cpp @@ -19,7 +19,7 @@ const AP_Param::Info Tracker::var_info[] = { // @Param: SYSID_TARGET // @DisplayName: Target vehicle's MAVLink system ID // @Description: The identifier of the vehicle being tracked. This should be zero (to auto detect) or be the same as the MAV_SYSID parameter of the vehicle being tracked. - // @Range: 1 255 + // @Range: 1 16777215 // @User: Advanced GSCALAR(sysid_target, "SYSID_TARGET", 0), diff --git a/AntennaTracker/Parameters.h b/AntennaTracker/Parameters.h index 033f18eac353fc..4c345a80d96407 100644 --- a/AntennaTracker/Parameters.h +++ b/AntennaTracker/Parameters.h @@ -140,7 +140,7 @@ class Parameters { // Telemetry control // - AP_Int16 sysid_target; + AP_Int32 sysid_target; AP_Float yaw_slew_time; AP_Float pitch_slew_time; diff --git a/AntennaTracker/system.cpp b/AntennaTracker/system.cpp index dd7cee2fe81431..2113234c8f34ba 100644 --- a/AntennaTracker/system.cpp +++ b/AntennaTracker/system.cpp @@ -5,6 +5,9 @@ static const StorageAccess wp_storage(StorageManager::StorageMission); void Tracker::init_ardupilot() { + // PARAMETER_CONVERSION - Added: Jul-2026 for 32 bit sysids + g.sysid_target.convert_parameter_width(AP_PARAM_INT16); + // initialise notify notify.init(); AP_Notify::flags.pre_arm_check = true; diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 06b5cb487b007f..c55b274519a20d 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -1337,6 +1337,11 @@ void Copter::load_parameters(void) copter.avoid.convert_params(); #endif +#if MODE_FOLLOW_ENABLED + // convert Follow parameters + copter.g2.follow.convert_params(); +#endif + // convert PILOT vertical speed and acceleration parameters // PARAMETER_CONVERSION - Added: Feb 2026 for ardupilot-4.7 { diff --git a/ArduPlane/GCS_MAVLink_Plane.cpp b/ArduPlane/GCS_MAVLink_Plane.cpp index 1edd99a9ac63db..ff70b70de13950 100644 --- a/ArduPlane/GCS_MAVLink_Plane.cpp +++ b/ArduPlane/GCS_MAVLink_Plane.cpp @@ -746,13 +746,15 @@ MAV_RESULT GCS_MAVLINK_Plane::handle_command_int_packet(const mavlink_command_in #endif #if AP_SCRIPTING_ENABLED && AP_FOLLOW_ENABLED - case MAV_CMD_DO_FOLLOW: + case MAV_CMD_DO_FOLLOW: { // param1: sysid of target to follow - if ((packet.param1 > 0) && (packet.param1 <= 255)) { - plane.g2.follow.set_target_sysid((uint8_t)packet.param1); + const int64_t sysid = (int64_t)packet.param1; + if (sysid > 0 && sysid <= (int64_t)0xFFFFFFFF) { + plane.g2.follow.set_target_sysid((uint32_t)sysid); return MAV_RESULT_ACCEPTED; } return MAV_RESULT_DENIED; + } #endif #if AP_ICENGINE_ENABLED diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index ce6671385d148c..c77af68dd30b40 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1478,6 +1478,11 @@ void Plane::load_parameters(void) g.use_reverse_thrust.convert_parameter_width(AP_PARAM_INT16); +#if AP_SCRIPTING_ENABLED && AP_FOLLOW_ENABLED + // convert Follow parameters + g2.follow.convert_params(); +#endif + // PARAMETER_CONVERSION - Added: Jun-2026 for FBWB_CLIMB_RATE width change g.flybywire_climb_rate.convert_parameter_width(AP_PARAM_INT8); diff --git a/Rover/Parameters.cpp b/Rover/Parameters.cpp index 504ed2168f85b0..bb9add7bf7145d 100644 --- a/Rover/Parameters.cpp +++ b/Rover/Parameters.cpp @@ -842,6 +842,11 @@ void Rover::load_parameters(void) }; AP_Param::convert_old_parameters(&ff_and_filt_conversion_info[0], ARRAY_SIZE(ff_and_filt_conversion_info)); +#if AP_FOLLOW_ENABLED + // convert Follow parameters + g2.follow.convert_params(); +#endif + // configure safety switch to allow stopping the motors while armed #if HAL_HAVE_SAFETY_SWITCH AP_Param::set_default_by_name("BRD_SAFETYOPTION", AP_BoardConfig::BOARD_SAFETY_OPTION_BUTTON_ACTIVE_SAFETY_OFF| diff --git a/Rover/mode_auto.cpp b/Rover/mode_auto.cpp index db061454f6b903..e51d0de1a61f18 100644 --- a/Rover/mode_auto.cpp +++ b/Rover/mode_auto.cpp @@ -497,7 +497,7 @@ void ModeAuto::send_guided_position_target() guided_target.last_sent_ms = now_ms; // get system id and component id of offboard navigation system - uint8_t sysid; + uint32_t sysid; uint8_t compid; mavlink_channel_t chan; if (GCS_MAVLINK::find_by_mavtype(MAV_TYPE_ONBOARD_CONTROLLER, sysid, compid, chan)) { diff --git a/Tools/AP_Periph/adsb.cpp b/Tools/AP_Periph/adsb.cpp index b0a2637bae003d..540cc7694455f3 100644 --- a/Tools/AP_Periph/adsb.cpp +++ b/Tools/AP_Periph/adsb.cpp @@ -86,7 +86,11 @@ void AP_Periph_FW::adsb_update(void) &adsb.status, &msg, &heartbeat); - uart->write((uint8_t*)&msg.magic, len); + uint8_t msgbuf[len]; + len = mavlink_msg_to_send_buffer(msgbuf, &msg); + if (len > 0) { + uart->write(msgbuf, len); + } } } diff --git a/Tools/autotest/rover.py b/Tools/autotest/rover.py index 7f7f0b8e505f6f..b22a32f2fb1f0c 100644 --- a/Tools/autotest/rover.py +++ b/Tools/autotest/rover.py @@ -6663,6 +6663,70 @@ def TestWebServer(self, url): self.progress("WebServer tests OK") + def MAV_SYSID_32bit(self): + '''test 32 bit MAV_SYSID''' + if not hasattr(mavutil.mavlink, "MAVLINK_IFLAG_SYSID32"): + raise NotAchievedException("pymavlink is too old for 32 bit system IDs") + + # sysid values must round-trip losslessly through the float32 + # parameter transport, so stay below 2^24 for now + sysid = 100000 + self.set_parameter("MAV_SYSID", sysid) + + # the sysid changes across the reboot so we can't use + # reboot_sitl(); send the reboot at the old sysid and re-point + # the connection at the new one + self.send_reboot_command() + self.mav.target_system = sysid + self.sysid_thismav = lambda: sysid + try: + self.wait_heartbeat(timeout=60) + m = self.wait_heartbeat() + if m.get_srcSystem() != sysid: + raise NotAchievedException("Did not get 32 bit sysid, got %u" % m.get_srcSystem()) + hdr = m.get_header() + if not (hdr.incompat_flags & mavutil.mavlink.MAVLINK_IFLAG_SYSID32): + raise NotAchievedException("expected MAVLINK_IFLAG_SYSID32 to be set") + + # parameter fetch at the new sysid + if int(self.get_parameter("MAV_SYSID")) != sysid: + raise NotAchievedException("MAV_SYSID readback failed") + + # our own GCS with a 32 bit source system, and a targeted + # message each way + mav2 = mavutil.mavlink_connection( + "tcp:localhost:%u" % self.adjust_ardupilot_port(5763), + robust_parsing=True, + source_system=70000, + source_component=7, + ) + mav2.mav.param_request_read_send(sysid, 1, b"MAV_SYSID", -1) + m = mav2.recv_match(type='PARAM_VALUE', blocking=True, timeout=10) + if m is None: + raise NotAchievedException("no PARAM_VALUE for 32 bit source system") + if m.param_id != "MAV_SYSID" or int(m.param_value) != sysid: + raise NotAchievedException("bad PARAM_VALUE %s" % str(m)) + mav2.close() + + # targeted mission-protocol round trip (the mission upload + # helpers hard-code target system 1, so do this by hand) + self.mav.mav.mission_request_list_send(sysid, 1, mavutil.mavlink.MAV_MISSION_TYPE_MISSION) + m = self.assert_receive_message('MISSION_COUNT', timeout=10) + if m.mission_type != mavutil.mavlink.MAV_MISSION_TYPE_MISSION: + raise NotAchievedException("bad MISSION_COUNT") + + self.wait_ready_to_arm() + self.arm_vehicle() + self.disarm_vehicle() + finally: + # restore the old sysid + self.set_parameter("MAV_SYSID", 1) + self.send_reboot_command() + del self.sysid_thismav + self.mav.target_system = 1 + self.wait_heartbeat(timeout=60) + self.wait_heartbeat() + def NetworkingWebServer(self): '''web server''' applet_script = "net_webserver.lua" @@ -7553,6 +7617,7 @@ def tests(self): self.MAV_CMD_BATTERY_RESET, self.GPSForYaw, self.NetworkingWebServer, + self.MAV_SYSID_32bit, self.NetworkingWebServerPPP, self.RTL_SPEED, self.ScriptingLocationBindings, diff --git a/libraries/AP_AccelCal/AP_AccelCal.cpp b/libraries/AP_AccelCal/AP_AccelCal.cpp index 068308ab2125dc..965ec5094f57f0 100644 --- a/libraries/AP_AccelCal/AP_AccelCal.cpp +++ b/libraries/AP_AccelCal/AP_AccelCal.cpp @@ -183,7 +183,7 @@ void AP_AccelCal::update() } } -void AP_AccelCal::start(GCS_MAVLINK *gcs, uint8_t sysid, uint8_t compid) +void AP_AccelCal::start(GCS_MAVLINK *gcs, uint32_t sysid, uint8_t compid) { if (gcs == nullptr || _started) { return; @@ -364,7 +364,7 @@ bool AP_AccelCal::client_active(uint8_t client_num) } #if HAL_GCS_ENABLED -void AP_AccelCal::handle_command_ack(const mavlink_command_ack_t &packet, uint8_t src_sysid, uint8_t src_compid) +void AP_AccelCal::handle_command_ack(const mavlink_command_ack_t &packet, uint32_t src_sysid, uint8_t src_compid) { if(_sysid != src_sysid || _compid != src_compid) { return; diff --git a/libraries/AP_AccelCal/AP_AccelCal.h b/libraries/AP_AccelCal/AP_AccelCal.h index be87f690a06b32..73be7cf3c8747b 100644 --- a/libraries/AP_AccelCal/AP_AccelCal.h +++ b/libraries/AP_AccelCal/AP_AccelCal.h @@ -28,7 +28,7 @@ class AP_AccelCal { { update_status(); } // start all the registered calibrations - void start(GCS_MAVLINK *gcs, uint8_t sysid, uint8_t compid); + void start(GCS_MAVLINK *gcs, uint32_t sysid, uint8_t compid); // called on calibration cancellation void cancel(); @@ -46,7 +46,7 @@ class AP_AccelCal { static void register_client(AP_AccelCal_Client* client); #if HAL_GCS_ENABLED - void handle_command_ack(const mavlink_command_ack_t &packet, uint8_t src_sysid, uint8_t src_compid); + void handle_command_ack(const mavlink_command_ack_t &packet, uint32_t src_sysid, uint8_t src_compid); #endif // true if we are in a calibration process @@ -54,7 +54,7 @@ class AP_AccelCal { private: class GCS_MAVLINK *_gcs; - uint8_t _sysid; + uint32_t _sysid; uint8_t _compid; bool _use_gcs_snoop; bool _waiting_for_mavlink_ack = false; diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.cpp b/libraries/AP_BattMonitor/AP_BattMonitor.cpp index 61554c8d41758b..2dbc0010288720 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor.cpp @@ -1148,7 +1148,7 @@ void AP_BattMonitor::checkPoweringOff(void) cmd_msg.command = MAV_CMD_POWER_OFF_INITIATED; cmd_msg.param1 = i+1; GCS_MAVLINK::send_to_components(MAVLINK_MSG_ID_COMMAND_LONG, (char*)&cmd_msg, sizeof(cmd_msg)); - GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Vehicle %d battery %d is powering off", mavlink_system.sysid, i+1); + GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Vehicle %u battery %d is powering off", (unsigned)mavlink_system.sysid, i+1); #endif // only send this once diff --git a/libraries/AP_CANManager/AP_MAVLinkCAN.cpp b/libraries/AP_CANManager/AP_MAVLinkCAN.cpp index ecf1cdb60fe574..87c4779b091faa 100644 --- a/libraries/AP_CANManager/AP_MAVLinkCAN.cpp +++ b/libraries/AP_CANManager/AP_MAVLinkCAN.cpp @@ -295,7 +295,7 @@ void AP_MAVLinkCAN::_handle_can_filter_modify(const mavlink_message_t &msg) void AP_MAVLinkCAN::can_frame_callback(uint8_t bus, const AP_HAL::CANFrame &frame, AP_HAL::CANIface::CanIOFlags flags) { mavlink_channel_t chan; - uint8_t system_id; + uint32_t system_id; uint8_t component_id; { WITH_SEMAPHORE(can_forward.sem); diff --git a/libraries/AP_CANManager/AP_MAVLinkCAN.h b/libraries/AP_CANManager/AP_MAVLinkCAN.h index d238d9c889f099..6f80470b348795 100644 --- a/libraries/AP_CANManager/AP_MAVLinkCAN.h +++ b/libraries/AP_CANManager/AP_MAVLinkCAN.h @@ -48,7 +48,7 @@ class AP_MAVLinkCAN { */ struct { mavlink_channel_t chan; - uint8_t system_id; + uint32_t system_id; uint8_t component_id; uint8_t frame_counter; uint32_t last_callback_enable_ms; diff --git a/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.cpp b/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.cpp index b89c7be9e3623c..3125686149da05 100644 --- a/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.cpp +++ b/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.cpp @@ -29,13 +29,13 @@ bool AP_Camera_MAVLinkCamV2::trigger_pic() // prepare and send message mavlink_command_long_t pkt {}; - pkt.target_system = _sysid; + pkt.target_system = _sysid>255?0:_sysid; // targets > 255 travel in the extended header pkt.target_component = _compid; pkt.command = MAV_CMD_IMAGE_START_CAPTURE; pkt.param3 = 1; // number of images to take pkt.param4 = image_index+1; // starting sequence number - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); return true; } @@ -51,7 +51,7 @@ bool AP_Camera_MAVLinkCamV2::record_video(bool start_recording) // prepare and send message mavlink_command_long_t pkt {}; - pkt.target_system = _sysid; + pkt.target_system = _sysid>255?0:_sysid; // targets > 255 travel in the extended header pkt.target_component = _compid; if (start_recording) { @@ -63,7 +63,7 @@ bool AP_Camera_MAVLinkCamV2::record_video(bool start_recording) // param1 = 0, video stream id. 0 for all streams } - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); return true; } @@ -78,7 +78,7 @@ bool AP_Camera_MAVLinkCamV2::set_zoom(ZoomType zoom_type, float zoom_value) // prepare and send message mavlink_command_long_t pkt {}; - pkt.target_system = _sysid; + pkt.target_system = _sysid>255?0:_sysid; // targets > 255 travel in the extended header pkt.target_component = _compid; pkt.command = MAV_CMD_SET_CAMERA_ZOOM; switch (zoom_type) { @@ -91,7 +91,7 @@ bool AP_Camera_MAVLinkCamV2::set_zoom(ZoomType zoom_type, float zoom_value) } pkt.param2 = zoom_value; // Zoom Value - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); return true; } @@ -107,7 +107,7 @@ SetFocusResult AP_Camera_MAVLinkCamV2::set_focus(FocusType focus_type, float foc // prepare and send message mavlink_command_long_t pkt {}; - pkt.target_system = _sysid; + pkt.target_system = _sysid>255?0:_sysid; // targets > 255 travel in the extended header pkt.target_component = _compid; pkt.command = MAV_CMD_SET_CAMERA_FOCUS; switch (focus_type) { @@ -126,7 +126,7 @@ SetFocusResult AP_Camera_MAVLinkCamV2::set_focus(FocusType focus_type, float foc } pkt.param2 = focus_value; - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); return SetFocusResult::ACCEPTED; } @@ -242,12 +242,12 @@ void AP_Camera_MAVLinkCamV2::request_camera_information() const 0, // param6 0, // param7 MAV_CMD_REQUEST_MESSAGE, - _sysid, + uint8_t(_sysid>255?0:_sysid), // targets > 255 travel in the extended header _compid, 0 // confirmation }; - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); } #endif // AP_CAMERA_MAVLINKCAMV2_ENABLED diff --git a/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.h b/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.h index 44949bc02f1fde..1425fc5e392bd7 100644 --- a/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.h +++ b/libraries/AP_Camera/AP_Camera_MAVLinkCamV2.h @@ -70,7 +70,7 @@ class AP_Camera_MAVLinkCamV2 : public AP_Camera_Backend mavlink_camera_information_t _cam_info {}; // latest camera information received from camera uint32_t _last_caminfo_req_ms; // system time that CAMERA_INFORMATION was last requested (used to throttle requests) class GCS_MAVLINK *_link; // link we have found the camera on. nullptr if not seen yet - uint8_t _sysid; // sysid of camera + uint32_t _sysid; // sysid of camera uint8_t _compid; // component id of gimbal }; diff --git a/libraries/AP_DDS/AP_DDS_Client.cpp b/libraries/AP_DDS/AP_DDS_Client.cpp index ef89c6a0eb5c76..8a7d90a3048e2c 100644 --- a/libraries/AP_DDS/AP_DDS_Client.cpp +++ b/libraries/AP_DDS/AP_DDS_Client.cpp @@ -1437,10 +1437,10 @@ bool AP_DDS_Client::init_session() return true; } -void AP_DDS_Client::dds_format_name(char* buf, const char* dds_prefix, const uint8_t sysid, const char* name, bool use_sysid_ns) +void AP_DDS_Client::dds_format_name(char* buf, const char* dds_prefix, const uint32_t sysid, const char* name, bool use_sysid_ns) { if (use_sysid_ns) { - snprintf(buf, AP_DDS_MAX_NAME_LEN, "%s/%s/v%u/%s", dds_prefix, participant_name_prefix, sysid, name); + snprintf(buf, AP_DDS_MAX_NAME_LEN, "%s/%s/v%u/%s", dds_prefix, participant_name_prefix, (unsigned)sysid, name); } else { snprintf(buf, AP_DDS_MAX_NAME_LEN, "%s/%s/%s", dds_prefix, participant_name_prefix, name); } @@ -1450,7 +1450,7 @@ bool AP_DDS_Client::create() { WITH_SEMAPHORE(csem); - const uint8_t sysid = gcs().sysid_this_mav(); + const uint32_t sysid = gcs().sysid_this_mav(); const bool use_sysid_ns = use_ns.get() != 0; // Participant @@ -1460,7 +1460,7 @@ bool AP_DDS_Client::create() }; char participant_name[AP_DDS_MAX_NAME_LEN]; if (use_sysid_ns) { - snprintf(participant_name, sizeof(participant_name), "%s_v%u", participant_name_prefix, sysid); + snprintf(participant_name, sizeof(participant_name), "%s_v%u", participant_name_prefix, (unsigned)sysid); } else { snprintf(participant_name, sizeof(participant_name), "%s", participant_name_prefix); } diff --git a/libraries/AP_DDS/AP_DDS_Client.h b/libraries/AP_DDS/AP_DDS_Client.h index c0fad3692b937f..9e4908a326ace2 100644 --- a/libraries/AP_DDS/AP_DDS_Client.h +++ b/libraries/AP_DDS/AP_DDS_Client.h @@ -323,7 +323,7 @@ class AP_DDS_Client static constexpr const char *dds_service_reply_prefix = "rr"; static constexpr const char *participant_name_prefix = "ap"; - static void dds_format_name(char* buf, const char* dds_prefix, uint8_t sysid, const char* name, bool use_sysid_ns); + static void dds_format_name(char* buf, const char* dds_prefix, uint32_t sysid, const char* name, bool use_sysid_ns); public: diff --git a/libraries/AP_Follow/AP_Follow.cpp b/libraries/AP_Follow/AP_Follow.cpp index c541b999cb0de8..ceb2ec9abf5eb6 100644 --- a/libraries/AP_Follow/AP_Follow.cpp +++ b/libraries/AP_Follow/AP_Follow.cpp @@ -83,7 +83,7 @@ const AP_Param::GroupInfo AP_Follow::var_info[] = { // @Param: _SYSID // @DisplayName: Follow target's mavlink system id // @Description: Follow target's mavlink system id - // @Range: 0 255 + // @Range: 0 16777215 // @User: Standard AP_GROUPINFO("_SYSID", 3, AP_Follow, _sysid, 0), @@ -228,6 +228,15 @@ AP_Follow::AP_Follow() : AP_Param::setup_object_defaults(this, var_info); } +// convert parameters. Must be called before anything reads FOLL_SYSID, +// which includes mode entry at startup, so this is done from the vehicle's +// load_parameters() rather than lazily on first use +void AP_Follow::convert_params() +{ + // PARAMETER_CONVERSION - Added: Jul-2026 for 32 bit sysids + _sysid.convert_parameter_width(AP_PARAM_INT16); +} + //============================================================================== // Target Estimation Update Functions @@ -558,7 +567,7 @@ bool AP_Follow::should_handle_message(const mavlink_message_t &msg) const } // skip message if not from our target - if (_sysid != 0 && msg.sysid != _sysid) { + if (_sysid != 0 && msg.sysid != uint32_t(_sysid.get())) { return false; } diff --git a/libraries/AP_Follow/AP_Follow.h b/libraries/AP_Follow/AP_Follow.h index 24ee0be15c36fc..0dab56adde6381 100644 --- a/libraries/AP_Follow/AP_Follow.h +++ b/libraries/AP_Follow/AP_Follow.h @@ -68,7 +68,7 @@ class AP_Follow bool enabled() const { return _enabled; } // set which target to follow - void set_target_sysid(uint8_t sysid) { _sysid.set(sysid); } + void set_target_sysid(uint32_t sysid) { _sysid.set(sysid); } // Resets the follow mode offsets to zero if they were automatically initialized. Should be called when exiting Follow mode. void clear_offsets_if_required(); @@ -83,6 +83,9 @@ class AP_Follow // Projects the target’s position, velocity, and heading forward using the latest updates, smoothing with input shaping if necessary void update_estimates(); + // convert parameters, called from the vehicle's load_parameters() + void convert_params(); + // Retrieves the estimated target position, velocity, and acceleration in the NED frame relative to the origin (units: meters and meters/second). bool get_target_pos_vel_accel_NED_m(Vector3p &pos_ned_m, Vector3f &vel_ned_ms, Vector3f &accel_ned_mss) const; @@ -115,7 +118,6 @@ class AP_Follow // Accessor Methods //========================================================================== - // get target sysid as a 32 bit number to allow for future expansion of MAV_SYSID uint32_t get_target_sysid() const { return (uint32_t)_sysid.get(); } // get position controller. this controller is not used within this library but it is convenient to hold it here @@ -194,7 +196,7 @@ class AP_Follow //========================================================================== AP_Int8 _enabled; // 1 = Follow mode is enabled; 0 = disabled - AP_Int16 _sysid; // MAVLink system ID of the target (0 = auto-select first sender) + AP_Int32 _sysid; // MAVLink system ID of the target (0 = auto-select first sender) AP_Float _dist_max_m; // Maximum allowed distance to target in meters; if exceeded, estimation is rejected AP_Int8 _offset_type; // Offset frame type: 0 = NED, 1 = relative to lead vehicle heading AP_Vector3f _offset_m; // Offset from lead vehicle (meters), in NED or FRD frame depending on _offset_type @@ -237,7 +239,7 @@ class AP_Follow Vector3f _ofs_estimate_accel_ned_mss; // Estimated acceleration with offsets applied (NED frame) bool _automatic_sysid; // True if target sysid was automatically selected - int16_t _sysid_used; // Currently active sysid used for updates + int64_t _sysid_used; // Currently active sysid used for updates, -1 when none float _dist_to_target_m; // Horizontal distance to target, for reporting (meters) float _bearing_to_target_deg; // Bearing to target from vehicle (degrees, 0 = North) bool _offsets_were_zero; // True if initial offset was zero before being initialized diff --git a/libraries/AP_Generator/AP_Generator_Loweheiser.cpp b/libraries/AP_Generator/AP_Generator_Loweheiser.cpp index a26e46ea8854a8..19f3aef424a87d 100644 --- a/libraries/AP_Generator/AP_Generator_Loweheiser.cpp +++ b/libraries/AP_Generator/AP_Generator_Loweheiser.cpp @@ -504,7 +504,7 @@ void AP_Generator_Loweheiser::command_generator() "TimeUS," "SI," "CI," "C," "I," "ES," "GS," "Thr," "Strtr", "s" "-" "-" "-" "#" "-" "-" "-" "-" , "F" "-" "-" "-" "-" "-" "-" "-" "-" , - "Q" "B" "B" "I" "B" "B" "B" "f" "B" , + "Q" "I" "B" "I" "B" "B" "B" "f" "B" , AP_HAL::micros64(), sysid, compid, diff --git a/libraries/AP_Generator/AP_Generator_Loweheiser.h b/libraries/AP_Generator/AP_Generator_Loweheiser.h index 041b8d1d9934ac..643743df03bcad 100644 --- a/libraries/AP_Generator/AP_Generator_Loweheiser.h +++ b/libraries/AP_Generator/AP_Generator_Loweheiser.h @@ -103,7 +103,7 @@ class AP_Generator_Loweheiser : public AP_Generator_Backend // only process from one source: bool seen_good_message; const class GCS_MAVLINK *mavlink_channel; - uint8_t sysid; + uint32_t sysid; uint8_t compid; uint8_t efi_index; diff --git a/libraries/AP_Logger/AP_Logger.h b/libraries/AP_Logger/AP_Logger.h index e2503a10a6a17a..43402d068bd42c 100644 --- a/libraries/AP_Logger/AP_Logger.h +++ b/libraries/AP_Logger/AP_Logger.h @@ -277,8 +277,11 @@ class AP_Logger void Write_Mode(uint8_t mode, const ModeReason reason); void Write_EntireMission(); + // target_system must come from the message header, not the packet; + // the payload byte is zero when the target is in the extended header void Write_Command(const mavlink_command_int_t &packet, - uint8_t source_system, + uint32_t target_system, + uint32_t source_system, uint8_t source_component, MAV_RESULT result, bool was_command_long=false); diff --git a/libraries/AP_Logger/AP_Logger_MAVLink.cpp b/libraries/AP_Logger/AP_Logger_MAVLink.cpp index c3670d32087f21..00ba6c64375713 100644 --- a/libraries/AP_Logger/AP_Logger_MAVLink.cpp +++ b/libraries/AP_Logger/AP_Logger_MAVLink.cpp @@ -254,7 +254,7 @@ void AP_Logger_MAVLink::handle_ack(const GCS_MAVLINK &link, _next_seq_num = 0; start_new_log_reset_variables(); _last_response_time = AP_HAL::millis(); - Debug("Target: (%u/%u)", _target_system_id, _target_component_id); + Debug("Target: (%u/%u)", (unsigned)_target_system_id, _target_component_id); } return; } diff --git a/libraries/AP_Logger/AP_Logger_MAVLink.h b/libraries/AP_Logger/AP_Logger_MAVLink.h index 621da879ba4557..375c1ba40d2b6d 100644 --- a/libraries/AP_Logger/AP_Logger_MAVLink.h +++ b/libraries/AP_Logger/AP_Logger_MAVLink.h @@ -119,7 +119,7 @@ class AP_Logger_MAVLink : public AP_Logger_Backend const GCS_MAVLINK *_link; - uint8_t _target_system_id; + uint32_t _target_system_id; uint8_t _target_component_id; // this controls the maximum number of blocks we will push from diff --git a/libraries/AP_Logger/LogFile.cpp b/libraries/AP_Logger/LogFile.cpp index 33da495d640d8d..803297fa80e90e 100644 --- a/libraries/AP_Logger/LogFile.cpp +++ b/libraries/AP_Logger/LogFile.cpp @@ -277,7 +277,8 @@ void AP_Logger::Write_RSSI() #endif void AP_Logger::Write_Command(const mavlink_command_int_t &packet, - uint8_t source_system, + uint32_t target_system, + uint32_t source_system, uint8_t source_component, const MAV_RESULT result, bool was_command_long) @@ -285,7 +286,7 @@ void AP_Logger::Write_Command(const mavlink_command_int_t &packet, const struct log_MAVLink_Command pkt{ LOG_PACKET_HEADER_INIT(LOG_MAVLINK_COMMAND_MSG), time_us : AP_HAL::micros64(), - target_system : packet.target_system, + target_system : target_system, target_component: packet.target_component, source_system : source_system, source_component: source_component, diff --git a/libraries/AP_Logger/LogStructure.h b/libraries/AP_Logger/LogStructure.h index 5da9588e1d8472..c793daeb560781 100644 --- a/libraries/AP_Logger/LogStructure.h +++ b/libraries/AP_Logger/LogStructure.h @@ -365,9 +365,9 @@ struct PACKED log_MCU { struct PACKED log_MAVLink_Command { LOG_PACKET_HEADER; uint64_t time_us; - uint8_t target_system; + uint32_t target_system; uint8_t target_component; - uint8_t source_system; + uint32_t source_system; uint8_t source_component; uint8_t frame; uint16_t command; @@ -1187,7 +1187,7 @@ LOG_STRUCTURE_FROM_PRECLAND \ "MCU","Qffff","TimeUS,MTemp,MVolt,MVmin,MVmax", "sOvvv", "F0000", true }, \ LOG_STRUCTURE_FROM_MISSION \ { LOG_MAVLINK_COMMAND_MSG, sizeof(log_MAVLink_Command), \ - "MAVC", "QBBBBBHffffiifBB","TimeUS,TS,TC,SS,SC,Fr,Cmd,P1,P2,P3,P4,X,Y,Z,Res,WL", "s---------------", "F---------------" }, \ + "MAVC", "QIBIBBHffffiifBB","TimeUS,TS,TC,SS,SC,Fr,Cmd,P1,P2,P3,P4,X,Y,Z,Res,WL", "s---------------", "F---------------" }, \ { LOG_RADIO_MSG, sizeof(log_Radio), \ "RAD", "QBBBBBHH", "TimeUS,RSSI,RemRSSI,TxBuf,Noise,RemNoise,RxErrors,Fixed", "s-------", "F-------", true }, \ LOG_STRUCTURE_FROM_CAMERA \ diff --git a/libraries/AP_Mount/AP_Mount.cpp b/libraries/AP_Mount/AP_Mount.cpp index df6394b47beda9..5ec3b2a51f630d 100644 --- a/libraries/AP_Mount/AP_Mount.cpp +++ b/libraries/AP_Mount/AP_Mount.cpp @@ -64,6 +64,11 @@ void AP_Mount::init() // perform any required parameter conversion convert_params(); + // PARAMETER_CONVERSION - Added: Jul-2026 for 32 bit sysids + for (uint8_t instance=0; instance255?0:mavlink_control_id.sysid, // primary control system id (8 bit only in this message) mavlink_control_id.compid, // primary control component id 0, // secondary control system id 0); // secondary control component id @@ -606,8 +606,10 @@ MAV_RESULT AP_Mount_Backend::handle_command_do_mount_control(const mavlink_comma // requires original message in order to extract caller's sysid and compid MAV_RESULT AP_Mount_Backend::handle_command_do_gimbal_manager_configure(const mavlink_command_int_t &packet, const mavlink_message_t &msg) { - // sanity check param1 and param2 values - if ((packet.param1 < -3) || (packet.param1 > UINT8_MAX) || (packet.param2 < -3) || (packet.param2 > UINT8_MAX)) { + // sanity check param1 and param2 values. param1 is a system ID, which a + // float parameter can only carry exactly up to 2^24-1; param2 is a compid + if ((packet.param1 < -3) || (packet.param1 > float((1U<<24)-1)) || + (packet.param2 < -3) || (packet.param2 > UINT8_MAX)) { return MAV_RESULT_FAILED; } @@ -615,7 +617,7 @@ MAV_RESULT AP_Mount_Backend::handle_command_do_gimbal_manager_configure(const ma mavlink_control_id_t prev_control_id = mavlink_control_id; // convert negative packet1 and packet2 values - int16_t new_sysid = packet.param1; + int64_t new_sysid = packet.param1; switch (new_sysid) { case -1: // leave unchanged @@ -647,7 +649,7 @@ MAV_RESULT AP_Mount_Backend::handle_command_do_gimbal_manager_configure(const ma } // handle a GLOBAL_POSITION_INT message -bool AP_Mount_Backend::handle_global_position_int(uint8_t msg_sysid, const mavlink_global_position_int_t &packet) +bool AP_Mount_Backend::handle_global_position_int(uint32_t msg_sysid, const mavlink_global_position_int_t &packet) { if (_target_sysid != msg_sysid) { return false; diff --git a/libraries/AP_Mount/AP_Mount_Backend.h b/libraries/AP_Mount/AP_Mount_Backend.h index 2cc192fe4c684a..81926664e9099d 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.h +++ b/libraries/AP_Mount/AP_Mount_Backend.h @@ -119,7 +119,7 @@ class AP_Mount_Backend void clear_roi_target(); // set_sys_target - sets system that mount should attempt to point towards - void set_target_sysid(uint8_t sysid); + void set_target_sysid(uint32_t sysid); #if AP_MOUNT_ROI_WPNEXT_OFFSET_ENABLED // set_roi_target_wpnext_offset - point to next waypoint, with offsets @@ -152,7 +152,7 @@ class AP_Mount_Backend virtual void handle_param_value(const mavlink_message_t &msg) {} // handle a GLOBAL_POSITION_INT message - bool handle_global_position_int(uint8_t msg_sysid, const mavlink_global_position_int_t &packet); + bool handle_global_position_int(uint32_t msg_sysid, const mavlink_global_position_int_t &packet); // handle GIMBAL_DEVICE_INFORMATION message virtual void handle_gimbal_device_information(const mavlink_message_t &msg) {} @@ -483,7 +483,7 @@ class AP_Mount_Backend Vector3f _roi_wpnext_rpy; // angular offsets for pointing-at-waypoint #endif // AP_MOUNT_ROI_WPNEXT_OFFSET_ENABLED - uint8_t _target_sysid; // sysid to track + uint32_t _target_sysid; // sysid to track Location _target_sysid_location;// sysid target location uint32_t _last_warning_ms; // system time of last warning sent to GCS @@ -499,7 +499,7 @@ class AP_Mount_Backend // structure holding mavlink sysid and compid of controller of this gimbal // see MAV_CMD_DO_GIMBAL_MANAGER_CONFIGURE and GIMBAL_MANAGER_STATUS struct mavlink_control_id_t { - uint8_t sysid; + uint32_t sysid; uint8_t compid; // equality operators diff --git a/libraries/AP_Mount/AP_Mount_MAVLink.cpp b/libraries/AP_Mount/AP_Mount_MAVLink.cpp index ea2a73575edd01..0bb95082a1ff16 100644 --- a/libraries/AP_Mount/AP_Mount_MAVLink.cpp +++ b/libraries/AP_Mount/AP_Mount_MAVLink.cpp @@ -183,12 +183,12 @@ void AP_Mount_MAVLink::request_gimbal_device_information() const 0, // param6 0, // param7 MAV_CMD_REQUEST_MESSAGE, - _sysid, + uint8_t(_sysid>255?0:_sysid), // targets > 255 travel in the extended header _compid, 0 // confirmation }; - _link->send_message(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_LONG, (const char*)&pkt, _sysid, _compid); } // start sending ATTITUDE and AUTOPILOT_STATE_FOR_GIMBAL_DEVICE to gimbal @@ -219,11 +219,11 @@ void AP_Mount_MAVLink::send_target_retracted() 0, // angular velocity y 0, // angular velocity z GIMBAL_DEVICE_FLAGS_RETRACT, // flags - _sysid, + uint8_t(_sysid>255?0:_sysid), // targets > 255 travel in the extended header _compid }; - _link->send_message(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt, _sysid, _compid); } // send GIMBAL_DEVICE_SET_ATTITUDE to gimbal to control rate @@ -243,11 +243,11 @@ void AP_Mount_MAVLink::send_target_rates(const MountRateTarget &rate_rads) pitch_rads, // angular velocity y yaw_rads, // angular velocity z flags, - _sysid, + uint8_t(_sysid>255?0:_sysid), // targets > 255 travel in the extended header _compid }; - _link->send_message(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt, _sysid, _compid); } // send GIMBAL_DEVICE_SET_ATTITUDE to gimbal to control attitude @@ -276,11 +276,11 @@ void AP_Mount_MAVLink::send_target_angles(const MountAngleTarget &angle_rad) NAN, // angular velocity y NAN, // angular velocity z flags, - _sysid, + uint8_t(_sysid>255?0:_sysid), // targets > 255 travel in the extended header _compid }; - _link->send_message(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE, (const char*)&pkt, _sysid, _compid); } // Send MAV_CMD_DO_SET_ROI_LOCATION to gimbal @@ -291,7 +291,7 @@ void AP_Mount_MAVLink::send_target_location(const Location &roi_loc) } mavlink_command_int_t pkt {}; - pkt.target_system = _sysid; + pkt.target_system = _sysid>255?0:_sysid; // targets > 255 travel in the extended header pkt.target_component = _compid; if (roi_loc.initialised()) { @@ -304,7 +304,7 @@ void AP_Mount_MAVLink::send_target_location(const Location &roi_loc) pkt.command = MAV_CMD_DO_SET_ROI_NONE; } - _link->send_message(MAVLINK_MSG_ID_COMMAND_INT, (const char*)&pkt); + _link->send_message_target(MAVLINK_MSG_ID_COMMAND_INT, (const char*)&pkt, _sysid, _compid); } #endif // HAL_MOUNT_MAVLINK_ENABLED diff --git a/libraries/AP_Mount/AP_Mount_MAVLink.h b/libraries/AP_Mount/AP_Mount_MAVLink.h index 9914790d7061bb..4bdb21a516d03e 100644 --- a/libraries/AP_Mount/AP_Mount_MAVLink.h +++ b/libraries/AP_Mount/AP_Mount_MAVLink.h @@ -98,7 +98,7 @@ class AP_Mount_MAVLink : public AP_Mount_Backend bool _initialised; // true once the gimbal has provided a GIMBAL_DEVICE_INFORMATION uint32_t _last_devinfo_req_ms; // system time that GIMBAL_DEVICE_INFORMATION was last requested (used to throttle requests) class GCS_MAVLINK *_link; // link we have found gimbal on; nullptr if not seen yet - uint8_t _sysid; // sysid of gimbal + uint32_t _sysid; // sysid of gimbal uint8_t _compid; // component id of gimbal mavlink_gimbal_device_attitude_status_t _gimbal_device_attitude_status; // copy of most recently received gimbal status uint32_t _last_attitude_status_ms; // system time last attitude status was received (used for health reporting) diff --git a/libraries/AP_Mount/AP_Mount_Params.h b/libraries/AP_Mount/AP_Mount_Params.h index ccf42c1fe050c1..7be1694c069dae 100644 --- a/libraries/AP_Mount/AP_Mount_Params.h +++ b/libraries/AP_Mount/AP_Mount_Params.h @@ -29,7 +29,7 @@ class AP_Mount_Params { AP_Float roll_stb_lead; // roll lead control gain (only used by servo backend) AP_Float pitch_stb_lead; // pitch lead control gain (only used by servo backend) - AP_Int8 sysid_default; // target sysid for mount to follow + AP_Int32 sysid_default; // target sysid for mount to follow AP_Int32 dev_id; // Device id taking into account bus AP_Int8 options; // mount options bitmask }; diff --git a/libraries/AP_Mount/AP_Mount_SToRM32.h b/libraries/AP_Mount/AP_Mount_SToRM32.h index 9ea963bc6e09db..be95c496578408 100644 --- a/libraries/AP_Mount/AP_Mount_SToRM32.h +++ b/libraries/AP_Mount/AP_Mount_SToRM32.h @@ -50,7 +50,7 @@ class AP_Mount_SToRM32 : public AP_Mount_Backend // internal variables bool _initialised; // true once the driver has been initialised - uint8_t _sysid; // sysid of gimbal + uint32_t _sysid; // sysid of gimbal uint8_t _compid; // component id of gimbal mavlink_channel_t _chan = MAVLINK_COMM_0; // mavlink channel used to communicate with gimbal }; diff --git a/libraries/AP_OpenDroneID/AP_OpenDroneID.cpp b/libraries/AP_OpenDroneID/AP_OpenDroneID.cpp index 63ef5416490625..1923637a9d8315 100644 --- a/libraries/AP_OpenDroneID/AP_OpenDroneID.cpp +++ b/libraries/AP_OpenDroneID/AP_OpenDroneID.cpp @@ -135,8 +135,10 @@ void AP_OpenDroneID::set_basic_id() { } if (id_len > 0) { // prepare basic id pkt - uint8_t val = gcs().sysid_this_mav(); - pkt_basic_id.target_system = val; + // this packet is sent as a raw struct, so has no extended header + // for a target sysid over 255 + const uint32_t val = gcs().sysid_this_mav(); + pkt_basic_id.target_system = val>255?0:val; pkt_basic_id.target_component = MAV_COMP_ID_ODID_TXRX_1; pkt_basic_id.id_type = atoi(id_type); pkt_basic_id.ua_type = atoi(ua_type); diff --git a/libraries/AP_Scripting/applets/param-lockdown.lua b/libraries/AP_Scripting/applets/param-lockdown.lua index e5a3b74e2e0443..8e5611838d7bca 100644 --- a/libraries/AP_Scripting/applets/param-lockdown.lua +++ b/libraries/AP_Scripting/applets/param-lockdown.lua @@ -211,12 +211,26 @@ local function update() break end - local param_value, _, _, param_id, _ = string.unpack("= 299 + local payload_ofs = sysid32_layout and 16 or 13 + local param_value, _, _, param_id, _ = string.unpack(" 255 then + -- scripting cannot send the extended target header yet, and + -- the payload target byte cannot hold a 32 bit sysid + sysid = 0 + end + compid = string.unpack("= 299) and 16 or 13 + local param_value, _, _, param_id, _ = string.unpack("= 299 +end + ---Return a object containing everything that is not the payload ---@param message any -- encoded message ---@return table +---@return integer -- offset of the payload in the message function mavlink_msgs.decode_header(message) -- build up a map of the result local result = {} @@ -37,13 +48,29 @@ function mavlink_msgs.decode_header(message) -- fetch the incompat/compat flags result.incompat_flags, result.compat_flags = string.unpack(" 0 then - crc_buffer = crc_buffer .. string.sub(message, 13, 12 + result.payload_length) + crc_buffer = crc_buffer .. string.sub(message, payload_ofs, payload_ofs - 1 + result.payload_length) end end @@ -104,7 +148,7 @@ function mavlink_msgs.decode(message, msg_map) end -- map all the fields out - local offset = 13 + local offset = payload_ofs for _,v in ipairs(message_map.fields) do if v[3] then result[v[1]] = {} diff --git a/libraries/GCS_MAVLink/GCS.cpp b/libraries/GCS_MAVLink/GCS.cpp index cdaa7fda23db6c..87e98071a8eb31 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 9d845e40dcef62..c350431622ca8e 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