Skip to content

Conversation

@xznhj8129
Copy link
Contributor

@xznhj8129 xznhj8129 commented Oct 12, 2025

User description

This PR is just running the lib/main/MAVLink/generate.sh script (after a small fix) to update the mavlink libraries as they were quite out of date and missing many files.

Tested on an SB F405 wing mini, everything seemed to work fine including receiver and telemetry


PR Type

Enhancement, Documentation


Description

This description is generated by an AI tool. It may have inaccuracies

  • Regenerated MAVLink headers using the lib/main/MAVLink/generate.sh script to update outdated libraries

  • Added comprehensive new message definitions including BATTERY_INFO (message ID 372) with voltage, current, capacity, and health metrics

  • Enhanced multiple existing messages with new fields:

    • Added gimbal_device_id and camera_device_id fields to camera and gimbal messages for device identification
    • Extended MANUAL_CONTROL message with 10 new fields including buttons2, auxiliary inputs (aux1-aux6), and extension flags
    • Added angular_velocity_z to autopilot gimbal state message
    • Added delta_yaw, delta_yaw_velocity fields to gimbal attitude status
    • Extended Open Drone ID system message with operator altitude and timestamp
  • Enhanced MAVLink signing infrastructure with status tracking (mavlink_signing_status_t enum and last_status field)

  • Added new parse state MAVLINK_PARSE_STATE_SIGNATURE_WAIT_BAD_CRC for improved error handling

  • Added pack_status functions across multiple message types for status-aware encoding

  • Updated message lengths and CRC values to reflect structural changes

  • Improved documentation comments to clarify NaN/unknown value handling and field usage

  • Changed primary XML identifier from index-based to hash-based system

  • Fixed typo in CRC initialization documentation

  • Added standard MAVLink dialect header file

  • Tested on SB F405 wing mini with receiver and telemetry working correctly


Diagram Walkthrough

flowchart LR
  A["MAVLink Library"] --> B["Regenerate Headers"]
  B --> C["New Messages"]
  B --> D["Enhanced Messages"]
  B --> E["Infrastructure Updates"]
  C --> F["BATTERY_INFO"]
  D --> G["Camera/Gimbal IDs"]
  D --> H["Manual Control Extensions"]
  D --> I["Open Drone ID Updates"]
  E --> J["Signing Status Tracking"]
  E --> K["Hash-based XML ID"]
Loading

File Walkthrough

Relevant files
New feature
2 files
mavlink_msg_battery_info.h
Add BATTERY_INFO MAVLink message definition with comprehensive battery
telemetry

lib/main/MAVLink/common/mavlink_msg_battery_info.h

  • Added new MAVLink message definition for BATTERY_INFO (message ID 372)
  • Includes comprehensive battery information fields: voltage limits,
    current limits, capacity, health metrics, and metadata
  • Provides packing, unpacking, encoding, and sending functions for the
    message
  • Supports both byte-swapped and aligned field configurations
+784/-0 
mavlink.h
Add standard MAVLink dialect header file                                 

lib/main/MAVLink/standard/mavlink.h

  • Added new header file for standard MAVLink dialect
  • Defines MAVLink protocol constants and configuration macros
  • Includes version and standard dialect headers
+34/-0   
Enhancement
9 files
mavlink_msg_camera_information.h
Enhance CAMERA_INFORMATION message with device ID fields and improved
documentation

lib/main/MAVLink/common/mavlink_msg_camera_information.h

  • Updated field documentation to clarify when values should be 0 or NaN
    for unknown data
  • Added two new fields: gimbal_device_id and camera_device_id for device
    association
  • Increased message length from 235 to 237 bytes
  • Added mavlink_msg_camera_information_pack_status function for
    status-aware packing
+204/-67
mavlink_msg_camera_tracking_image_status.h
Add camera device ID field to CAMERA_TRACKING_IMAGE_STATUS message

lib/main/MAVLink/common/mavlink_msg_camera_tracking_image_status.h

  • Added new field camera_device_id to identify non-MAVLink cameras
  • Increased message length from 31 to 32 bytes
  • Added mavlink_msg_camera_tracking_image_status_pack_status function
  • Updated all packing, encoding, and sending functions to include the
    new field
+114/-12
mavlink_msg_open_drone_id_system.h
Extended Open Drone ID System Message with Altitude and Timestamp

lib/main/MAVLink/common/mavlink_msg_open_drone_id_system.h

  • Added two new fields to the message structure: operator_altitude_geo
    (float) and timestamp (uint32_t)
  • Updated message length from 46 to 54 bytes
  • Updated CRC value from 203 to 77
  • Modified field offsets to accommodate new fields
  • Updated field descriptions to clarify usage for swarms/multiple UA
  • Added mavlink_msg_open_drone_id_system_pack_status function
  • Updated all pack, encode, send functions to include new parameters
+240/-103
mavlink_msg_manual_control.h
Enhanced Manual Control Message with Extended Button and Auxiliary
Inputs

lib/main/MAVLink/common/mavlink_msg_manual_control.h

  • Extended message structure with 10 new fields: buttons2,
    enabled_extensions, s, t, aux1-aux6
  • Increased message length from 11 to 30 bytes
  • Added MAVPACKED macro to structure definition
  • Updated field descriptions for buttons to clarify it covers buttons
    0-15
  • Added mavlink_msg_manual_control_pack_status function
  • Updated all pack, encode, send, and decode functions to handle new
    fields
+362/-20
mavlink_msg_camera_settings.h
Added Camera Device ID to Camera Settings Message               

lib/main/MAVLink/common/mavlink_msg_camera_settings.h

  • Added new field camera_device_id (uint8_t) to identify non-MAVLink
    cameras
  • Increased message length from 13 to 14 bytes
  • Updated field descriptions for zoomLevel and focusLevel to clarify
    percentage range
  • Added mavlink_msg_camera_settings_pack_status function
  • Updated all pack, encode, send, and decode functions to include new
    parameter
+106/-22
mavlink_types.h
Enhanced MAVLink Signing with Status Tracking                       

lib/main/MAVLink/mavlink_types.h

  • Added new parse state MAVLINK_PARSE_STATE_SIGNATURE_WAIT_BAD_CRC to
    enum
  • Added new enum mavlink_signing_status_t with signing status codes
  • Added last_status field to mavlink_signing_t structure to track
    signing status
+13/-1   
mavlink_msg_autopilot_state_for_gimbal_device.h
Add angular velocity Z field to autopilot gimbal state message

lib/main/MAVLink/common/mavlink_msg_autopilot_state_for_gimbal_device.h

  • Updated MAVLink message structure to add angular_velocity_z field
  • Increased message length from 53 to 57 bytes
  • Added MAVPACKED macro to struct definition
  • Updated field count from 12 to 13 in message info
  • Enhanced documentation comments to clarify NaN/unknown value handling
  • Added new pack_status function for encoding with status structure
  • Changed mav_array_memcpy to mav_array_assign_float for quaternion
    array handling
+154/-48
mavlink_msg_gimbal_device_information.h
Add gimbal device ID field to gimbal information message 

lib/main/MAVLink/common/mavlink_msg_gimbal_device_information.h

  • Added gimbal_device_id field to support shared component IDs
  • Increased message length from 144 to 145 bytes
  • Updated field count from 15 to 16 in message info
  • Enhanced documentation to clarify NaN handling for angle limits
  • Added pack_status function for status-aware encoding
  • Changed mav_array_memcpy to mav_array_assign_char for string arrays
  • Updated firmware/hardware version encoding documentation with escaped
    pipe characters
+177/-62
mavlink_msg_gimbal_device_attitude_status.h
Extend gimbal attitude status with delta yaw and device ID

lib/main/MAVLink/common/mavlink_msg_gimbal_device_attitude_status.h

  • Added three new fields: delta_yaw, delta_yaw_velocity, and
    gimbal_device_id
  • Increased message length from 40 to 49 bytes
  • Updated field count from 9 to 12 in message info
  • Enhanced documentation to clarify frame descriptions and NaN handling
  • Added pack_status and encode_status functions
  • Changed mav_array_memcpy to mav_array_assign_float for quaternion
    handling
  • Fixed typo in comment: 'varient' to 'variant'
+189/-36
Documentation
1 files
checksum.h
Fix typo in CRC initialization documentation                         

lib/main/MAVLink/checksum.h

  • Fixed typo in function documentation comment: 'Initiliaze' to
    'Initialize'
+1/-1     
Configuration changes
1 files
mavlink.h
Update MAVLink primary XML identifier to hash-based system

lib/main/MAVLink/common/mavlink.h

  • Changed MAVLINK_PRIMARY_XML_IDX to MAVLINK_PRIMARY_XML_HASH with new
    hash value
+1/-1     
Additional files
101 files
common.h +954/-333
mavlink_msg_actuator_control_target.h +56/-5   
mavlink_msg_actuator_output_status.h +56/-5   
mavlink_msg_adsb_vehicle.h +91/-10 
mavlink_msg_ais_vessel.h +106/-13
mavlink_msg_altitude.h +66/-1   
mavlink_msg_att_pos_mocap.h +68/-8   
mavlink_msg_attitude.h +66/-1   
mavlink_msg_attitude_quaternion.h +74/-5   
mavlink_msg_attitude_quaternion_cov.h +68/-8   
mavlink_msg_attitude_target.h +68/-5   
mavlink_msg_auth_key.h +52/-5   
mavlink_msg_available_modes.h +390/-0 
mavlink_msg_available_modes_monitor.h +260/-0 
mavlink_msg_battery_status.h +92/-8   
mavlink_msg_button_change.h +54/-1   
mavlink_msg_camera_capture_status.h +110/-17
mavlink_msg_camera_fov_status.h +116/-16
mavlink_msg_camera_image_captured.h +93/-18 
mavlink_msg_camera_thermal_range.h +484/-0 
mavlink_msg_camera_tracking_geo_status.h +123/-12
mavlink_msg_camera_trigger.h +51/-1   
mavlink_msg_can_filter_modify.h +390/-0 
mavlink_msg_can_frame.h +390/-0 
mavlink_msg_canfd_frame.h +390/-0 
mavlink_msg_cellular_config.h +80/-14 
mavlink_msg_cellular_status.h +71/-6   
mavlink_msg_change_operator_control.h +59/-5   
mavlink_msg_change_operator_control_ack.h +54/-1   
mavlink_msg_collision.h +66/-1   
mavlink_msg_command_ack.h +83/-21 
mavlink_msg_command_cancel.h +54/-1   
mavlink_msg_command_int.h +84/-1   
mavlink_msg_command_long.h +78/-1   
mavlink_msg_component_information.h +150/-118
mavlink_msg_component_information_basic.h +450/-0 
mavlink_msg_component_metadata.h +306/-0 
mavlink_msg_control_system_state.h +104/-11
mavlink_msg_current_event_sequence.h +288/-0 
mavlink_msg_current_mode.h +316/-0 
mavlink_msg_data_stream.h +54/-1   
mavlink_msg_data_transmission_handshake.h +66/-1   
mavlink_msg_debug.h +54/-1   
mavlink_msg_debug_float_array.h +62/-8   
mavlink_msg_debug_vect.h +62/-5   
mavlink_msg_distance_sensor.h +88/-10 
mavlink_msg_efi_status.h +165/-14
mavlink_msg_encapsulated_data.h +53/-5   
mavlink_msg_esc_info.h +133/-64
mavlink_msg_esc_status.h +68/-11 
mavlink_msg_estimator_status.h +75/-1   
mavlink_msg_event.h +418/-0 
mavlink_msg_extended_sys_state.h +51/-1   
mavlink_msg_fence_status.h +60/-1   
mavlink_msg_file_transfer_protocol.h +64/-10 
mavlink_msg_flight_information.h +111/-27
mavlink_msg_follow_target.h +97/-22 
mavlink_msg_fuel_status.h +456/-0 
mavlink_msg_generator_status.h +78/-1   
mavlink_msg_gimbal_device_set_attitude.h +88/-25 
mavlink_msg_gimbal_manager_information.h +77/-6   
mavlink_msg_gimbal_manager_set_attitude.h +71/-5   
mavlink_msg_gimbal_manager_set_manual_control.h +69/-1   
mavlink_msg_gimbal_manager_set_pitchyaw.h +69/-1   
mavlink_msg_gimbal_manager_status.h +71/-6   
mavlink_msg_global_position_int.h +77/-6   
mavlink_msg_global_position_int_cov.h +77/-5   
mavlink_msg_global_vision_position_estimate.h +74/-5   
mavlink_msg_gps2_raw.h +255/-32
mavlink_msg_gps2_rtk.h +84/-1   
mavlink_msg_gps_global_origin.h +57/-1   
mavlink_msg_gps_inject_data.h +59/-5   
mavlink_msg_gps_input.h +102/-1 
mavlink_msg_gps_raw_int.h +118/-26
mavlink_msg_gps_rtcm_data.h +56/-5   
mavlink_msg_gps_rtk.h +84/-1   
mavlink_msg_gps_status.h +77/-17 
mavlink_msg_high_latency.h +122/-6 
mavlink_msg_high_latency2.h +131/-6 
mavlink_msg_highres_imu.h +98/-6   
mavlink_msg_hil_actuator_controls.h +64/-10 
mavlink_msg_hil_controls.h +78/-1   
mavlink_msg_hil_gps.h +115/-26
mavlink_msg_hil_optical_flow.h +81/-1   
mavlink_msg_hil_rc_inputs_raw.h +92/-6   
mavlink_msg_hil_sensor.h +98/-6   
mavlink_msg_hil_state.h +93/-1   
mavlink_msg_hil_state_quaternion.h +95/-5   
mavlink_msg_home_position.h +124/-25
mavlink_msg_hygrometer_sensor.h +316/-0 
mavlink_msg_illuminator_status.h +540/-0 
mavlink_msg_isbd_link_status.h +69/-1   
mavlink_msg_landing_target.h +94/-10 
mavlink_msg_link_node_status.h +78/-1   
mavlink_msg_local_position_ned.h +66/-1   
mavlink_msg_local_position_ned_cov.h +83/-5   
mavlink_msg_local_position_ned_system_global_offset.h +66/-1   
mavlink_msg_log_data.h +59/-5   
mavlink_msg_log_entry.h +60/-1   
mavlink_msg_log_erase.h +51/-1   
Additional files not shown

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Oct 12, 2025

PR Compliance Guide 🔍

(Compliance updated until commit 30c5bbf)

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

🔴
Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
Sensitive data handling: The code packs and sends the key field (likely sensitive authentication material) without
any safeguards or redaction guidance, risking exposure if logged elsewhere.

Referred Code
#else
    mavlink_auth_key_t packet;

    mav_array_assign_char(packet.key, key, 32);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
}

/**
 * @brief Pack a auth_key message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param status MAVLink status structure
 * @param msg The MAVLink message to compress the data into
 *
 * @param key  key
 * @return length of the message in bytes (excluding serial stream start sign)
 */


 ... (clipped 151 lines)
Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Missing validation: Functions accept and transmit a 32-byte authentication key without validation, masking, or
safeguards, which can lead to insecure handling of secrets in transit or memory.

Referred Code
#else
    mavlink_auth_key_t packet;

    mav_array_assign_char(packet.key, key, 32);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
}

/**
 * @brief Pack a auth_key message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param status MAVLink status structure
 * @param msg The MAVLink message to compress the data into
 *
 * @param key  key
 * @return length of the message in bytes (excluding serial stream start sign)
 */


 ... (clipped 151 lines)
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logs: The new/updated code packs and sends authentication key and device information messages
without any visible logging of critical actions, but as this is auto-generated protocol
code, auditing may exist at higher layers not shown here.

Referred Code
#else
    mavlink_auth_key_t packet;

    mav_array_assign_char(packet.key, key, 32);
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
}

/**
 * @brief Pack a auth_key message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param status MAVLink status structure
 * @param msg The MAVLink message to compress the data into
 *
 * @param key  key
 * @return length of the message in bytes (excluding serial stream start sign)
 */


 ... (clipped 151 lines)
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
No error handling: New pack/send helpers add fields (e.g., angular_velocity_z) but do not perform validation
or handle edge cases, which may be acceptable for autogenerated serialization code yet
lacks explicit error handling in this layer.

Referred Code
 * @param target_component  Component ID
 * @param time_boot_us [us] Timestamp (time since system boot).
 * @param q  Quaternion components of autopilot attitude: w, x, y, z (1 0 0 0 is the null-rotation, Hamilton convention).
 * @param q_estimated_delay_us [us] Estimated delay of the attitude data. 0 if unknown.
 * @param vx [m/s] X Speed in NED (North, East, Down). NAN if unknown.
 * @param vy [m/s] Y Speed in NED (North, East, Down). NAN if unknown.
 * @param vz [m/s] Z Speed in NED (North, East, Down). NAN if unknown.
 * @param v_estimated_delay_us [us] Estimated delay of the speed data. 0 if unknown.
 * @param feed_forward_angular_velocity_z [rad/s] Feed forward Z component of angular velocity (positive: yawing to the right). NaN to be ignored. This is to indicate if the autopilot is actively yawing.
 * @param estimator_status  Bitmap indicating which estimator outputs are valid.
 * @param landed_state  The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown.
 * @param angular_velocity_z [rad/s] Z component of angular velocity in NED (North, East, Down). NaN if unknown.
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_autopilot_state_for_gimbal_device_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               uint8_t target_system, uint8_t target_component, uint64_t time_boot_us, const float *q, uint32_t q_estimated_delay_us, float vx, float vy, float vz, uint32_t v_estimated_delay_us, float feed_forward_angular_velocity_z, uint16_t estimator_status, uint8_t landed_state, float angular_velocity_z)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN];
    _mav_put_uint64_t(buf, 0, time_boot_us);
    _mav_put_uint32_t(buf, 24, q_estimated_delay_us);


 ... (clipped 480 lines)
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Previous compliance checks

Compliance check up to commit 30c5bbf
Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

@qodo-code-review
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Include the fix for the generation script

The PR should include the fix for the generate.sh script mentioned in the
description. This is necessary to ensure the header regeneration process is
reproducible.

Solution Walkthrough:

Before:

// PR description: "running the lib/main/MAVLink/generate.sh script (after a small fix)"

// PR changes only include the output of the script:
// File: 'lib/main/MAVLink/common/testsuite.h'
// ... changes to generated file

// File: 'lib/main/MAVLink/common/mavlink_msg_battery_info.h'
// ... changes to generated file

// The change to 'generate.sh' is missing from the PR.

After:

// PR description: "running the lib/main/MAVLink/generate.sh script (after a small fix)"

// Proposed PR changes should include the script fix:
// File: 'lib/main/MAVLink/generate.sh'
...
- some_command_with_a_bug
+ some_command_with_a_fix
...

// Along with the generated files:
// File: 'lib/main/MAVLink/common/testsuite.h'
// ... changes to generated file

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly points out the missing fix to the generate.sh script, which is critical for the reproducibility and future maintenance of the auto-generated code.

High
Possible issue
Correct field type for negative values

Change the type of the state_of_health field from uint8_t to int8_t to correctly
support the documented sentinel value of -1.

lib/main/MAVLink/common/mavlink_msg_battery_info.h [23]

-uint8_t state_of_health; /*< [%] State of Health (SOH) estimate. Typically 100% at the time of manufacture and will decrease over time and use. -1: field not provided.*/
+int8_t state_of_health; /*< [%] State of Health (SOH) estimate. Typically 100% at the time of manufacture and will decrease over time and use. -1: field not provided.*/
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a data type mismatch where state_of_health is uint8_t but its documentation specifies -1 as a special value, which an unsigned type cannot represent, thus fixing a potential bug.

Medium
Use safer functions for array copying

In the mavlink_msg_camera_information_pack_status function, replace
mav_array_memcpy with the safer mav_array_assign_uint8_t and
mav_array_assign_char functions for consistency and to prevent potential null
pointer issues.

lib/main/MAVLink/common/mavlink_msg_camera_information.h [209-211]

-mav_array_memcpy(packet.vendor_name, vendor_name, sizeof(uint8_t)*32);
-mav_array_memcpy(packet.model_name, model_name, sizeof(uint8_t)*32);
-mav_array_memcpy(packet.cam_definition_uri, cam_definition_uri, sizeof(char)*140);
+mav_array_assign_uint8_t(packet.vendor_name, vendor_name, 32);
+mav_array_assign_uint8_t(packet.model_name, model_name, 32);
+mav_array_assign_char(packet.cam_definition_uri, cam_definition_uri, 140);
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out an inconsistency where the new mavlink_msg_camera_information_pack_status function uses mav_array_memcpy while other functions were updated to use safer mav_array_assign_* variants, improving robustness against potential null pointers.

Low
Security
Use safe string copy function

In mavlink_msg_battery_info_pack_status, replace mav_array_memcpy with the safer
mav_array_assign_char for string copying to ensure null-termination and prevent
potential buffer over-reads.

lib/main/MAVLink/common/mavlink_msg_battery_info.h [254-256]

-mav_array_memcpy(packet.manufacture_date, manufacture_date, sizeof(char)*9);
-mav_array_memcpy(packet.serial_number, serial_number, sizeof(char)*32);
-mav_array_memcpy(packet.name, name, sizeof(char)*50);
+mav_array_assign_char(packet.manufacture_date, manufacture_date, 9);
+mav_array_assign_char(packet.serial_number, serial_number, 32);
+mav_array_assign_char(packet.name, name, 50);
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies the use of an unsafe memory copy function for strings and proposes using a safer, null-terminating alternative (mav_array_assign_char) which also improves consistency with other functions in the file.

Medium
General
Refactor duplicated test code into a helper function

Consolidate duplicated test assertions for mavlink_get_message_info_by_name and
mavlink_get_message_info_by_id into a single helper function to reduce code
repetition and improve maintainability.

lib/main/MAVLink/common/testsuite.h [96-99]

+static void mavlink_test_get_message_info(const char *message_name, uint32_t message_id)
+{
 #ifdef MAVLINK_HAVE_GET_MESSAGE_INFO
-    MAVLINK_ASSERT(mavlink_get_message_info_by_name("SYS_STATUS") != NULL);
-    MAVLINK_ASSERT(mavlink_get_message_info_by_id(MAVLINK_MSG_ID_SYS_STATUS) != NULL);
+    MAVLINK_ASSERT(mavlink_get_message_info_by_name(message_name) != NULL);
+    MAVLINK_ASSERT(mavlink_get_message_info_by_id(message_id) != NULL);
 #endif
+}
 
+...
+
+static void mavlink_test_sys_status(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
+{
+    ...
+    mavlink_msg_sys_status_decode(last_msg, &packet2);
+    MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
+
+    mavlink_test_get_message_info("SYS_STATUS", MAVLINK_MSG_ID_SYS_STATUS);
+}
+

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies significant code duplication introduced in the PR and proposes a sensible refactoring into a helper function, which improves code quality and maintainability.

Low
  • More

@sensei-hacker sensei-hacker merged commit f78cbb3 into iNavFlight:master Nov 8, 2025
21 checks passed
@xznhj8129 xznhj8129 deleted the mavlink_lib_update branch November 13, 2025 18:47
@sensei-hacker sensei-hacker added this to the 9.0 milestone Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants