From c46a23bed662a803eda4399e4b64f0d07611ebce Mon Sep 17 00:00:00 2001 From: PX4BuildBot Date: Wed, 6 Mar 2024 03:13:26 +0000 Subject: [PATCH] autogenerated headers for rev https://github.com/mavlink/mavlink/tree/2909b48183888bd884c6d81764c42aa7ba7daf11 --- ASLUAV/ASLUAV.h | 2 +- ASLUAV/mavlink.h | 2 +- ASLUAV/mavlink_msg_asl_obctrl.h | 68 ++++++ ASLUAV/mavlink_msg_aslctrl_data.h | 119 +++++++++++ ASLUAV/mavlink_msg_aslctrl_debug.h | 77 +++++++ ASLUAV/mavlink_msg_asluav_status.h | 54 +++++ ASLUAV/mavlink_msg_command_int_stamped.h | 89 ++++++++ ASLUAV/mavlink_msg_command_long_stamped.h | 83 ++++++++ ASLUAV/mavlink_msg_ekf_ext.h | 65 ++++++ ASLUAV/mavlink_msg_fw_soaring_data.h | 119 +++++++++++ ASLUAV/mavlink_msg_gsm_link_status.h | 65 ++++++ ASLUAV/mavlink_msg_satcom_link_status.h | 68 ++++++ ASLUAV/mavlink_msg_sens_atmos.h | 53 +++++ ASLUAV/mavlink_msg_sens_batmon.h | 89 ++++++++ ASLUAV/mavlink_msg_sens_mppt.h | 83 ++++++++ ASLUAV/mavlink_msg_sens_power.h | 56 +++++ ASLUAV/mavlink_msg_sens_power_board.h | 80 ++++++++ ASLUAV/mavlink_msg_sensor_airflow_angles.h | 59 ++++++ ASLUAV/mavlink_msg_sensorpod_status.h | 68 ++++++ ASLUAV/version.h | 2 +- AVSSUAS/AVSSUAS.h | 2 +- AVSSUAS/mavlink.h | 2 +- AVSSUAS/mavlink_msg_avss_drone_imu.h | 77 +++++++ .../mavlink_msg_avss_drone_operation_mode.h | 53 +++++ AVSSUAS/mavlink_msg_avss_drone_position.h | 62 ++++++ AVSSUAS/mavlink_msg_avss_prs_sys_status.h | 59 ++++++ AVSSUAS/version.h | 2 +- all/all.h | 2 +- all/mavlink.h | 2 +- all/version.h | 2 +- ardupilotmega/ardupilotmega.h | 2 +- ardupilotmega/mavlink.h | 2 +- ardupilotmega/mavlink_msg_adap_tuning.h | 83 ++++++++ ardupilotmega/mavlink_msg_ahrs.h | 65 ++++++ ardupilotmega/mavlink_msg_ahrs2.h | 62 ++++++ ardupilotmega/mavlink_msg_ahrs3.h | 74 +++++++ ardupilotmega/mavlink_msg_airspeed_autocal.h | 80 ++++++++ ardupilotmega/mavlink_msg_aoa_ssa.h | 53 +++++ ardupilotmega/mavlink_msg_ap_adc.h | 62 ++++++ .../mavlink_msg_autopilot_version_request.h | 50 +++++ ardupilotmega/mavlink_msg_battery2.h | 50 +++++ ardupilotmega/mavlink_msg_camera_feedback.h | 86 ++++++++ ardupilotmega/mavlink_msg_camera_status.h | 71 +++++++ ardupilotmega/mavlink_msg_compassmot_status.h | 62 ++++++ ardupilotmega/mavlink_msg_data16.h | 51 +++++ ardupilotmega/mavlink_msg_data32.h | 51 +++++ ardupilotmega/mavlink_msg_data64.h | 51 +++++ ardupilotmega/mavlink_msg_data96.h | 51 +++++ ardupilotmega/mavlink_msg_deepstall.h | 74 +++++++ ardupilotmega/mavlink_msg_device_op_read.h | 72 +++++++ .../mavlink_msg_device_op_read_reply.h | 60 ++++++ ardupilotmega/mavlink_msg_device_op_write.h | 75 +++++++ .../mavlink_msg_device_op_write_reply.h | 50 +++++ ardupilotmega/mavlink_msg_digicam_configure.h | 77 +++++++ ardupilotmega/mavlink_msg_digicam_control.h | 74 +++++++ ardupilotmega/mavlink_msg_ekf_status_report.h | 65 ++++++ .../mavlink_msg_esc_telemetry_1_to_4.h | 62 ++++++ .../mavlink_msg_esc_telemetry_5_to_8.h | 62 ++++++ .../mavlink_msg_esc_telemetry_9_to_12.h | 62 ++++++ ardupilotmega/mavlink_msg_fence_fetch_point.h | 53 +++++ ardupilotmega/mavlink_msg_fence_point.h | 62 ++++++ ardupilotmega/mavlink_msg_gimbal_control.h | 59 ++++++ ardupilotmega/mavlink_msg_gimbal_report.h | 80 ++++++++ .../mavlink_msg_gimbal_torque_cmd_report.h | 59 ++++++ ardupilotmega/mavlink_msg_gopro_get_request.h | 53 +++++ .../mavlink_msg_gopro_get_response.h | 51 +++++ ardupilotmega/mavlink_msg_gopro_heartbeat.h | 53 +++++ ardupilotmega/mavlink_msg_gopro_set_request.h | 54 +++++ .../mavlink_msg_gopro_set_response.h | 50 +++++ ardupilotmega/mavlink_msg_hwstatus.h | 50 +++++ ardupilotmega/mavlink_msg_led_control.h | 60 ++++++ ardupilotmega/mavlink_msg_limits_status.h | 71 +++++++ ardupilotmega/mavlink_msg_mag_cal_progress.h | 69 +++++++ ardupilotmega/mavlink_msg_mcu_status.h | 59 ++++++ ardupilotmega/mavlink_msg_meminfo.h | 53 +++++ ardupilotmega/mavlink_msg_mount_configure.h | 62 ++++++ ardupilotmega/mavlink_msg_mount_control.h | 62 ++++++ ardupilotmega/mavlink_msg_mount_status.h | 62 ++++++ .../mavlink_msg_obstacle_distance_3d.h | 71 +++++++ ardupilotmega/mavlink_msg_osd_param_config.h | 72 +++++++ .../mavlink_msg_osd_param_config_reply.h | 50 +++++ .../mavlink_msg_osd_param_show_config.h | 59 ++++++ .../mavlink_msg_osd_param_show_config_reply.h | 63 ++++++ ardupilotmega/mavlink_msg_pid_tuning.h | 71 +++++++ ardupilotmega/mavlink_msg_radio.h | 65 ++++++ ardupilotmega/mavlink_msg_rally_fetch_point.h | 53 +++++ ardupilotmega/mavlink_msg_rally_point.h | 74 +++++++ ardupilotmega/mavlink_msg_rangefinder.h | 50 +++++ .../mavlink_msg_remote_log_block_status.h | 56 +++++ .../mavlink_msg_remote_log_data_block.h | 54 +++++ ardupilotmega/mavlink_msg_rpm.h | 50 +++++ ardupilotmega/mavlink_msg_sensor_offsets.h | 80 ++++++++ ardupilotmega/mavlink_msg_set_mag_offsets.h | 59 ++++++ ardupilotmega/mavlink_msg_simstate.h | 77 +++++++ .../mavlink_msg_vision_position_delta.h | 57 +++++ ardupilotmega/mavlink_msg_water_depth.h | 77 +++++++ ardupilotmega/mavlink_msg_wind.h | 53 +++++ ardupilotmega/version.h | 2 +- common/common.h | 2 +- common/mavlink.h | 2 +- common/mavlink_msg_actuator_control_target.h | 51 +++++ common/mavlink_msg_actuator_output_status.h | 51 +++++ common/mavlink_msg_adsb_vehicle.h | 81 ++++++++ common/mavlink_msg_ais_vessel.h | 93 +++++++++ common/mavlink_msg_altitude.h | 65 ++++++ common/mavlink_msg_att_pos_mocap.h | 60 ++++++ common/mavlink_msg_attitude.h | 65 ++++++ common/mavlink_msg_attitude_quaternion.h | 69 +++++++ common/mavlink_msg_attitude_quaternion_cov.h | 60 ++++++ common/mavlink_msg_attitude_target.h | 63 ++++++ common/mavlink_msg_auth_key.h | 47 +++++ ...nk_msg_autopilot_state_for_gimbal_device.h | 81 ++++++++ common/mavlink_msg_autopilot_version.h | 78 +++++++ common/mavlink_msg_battery_info.h | 102 +++++++++ common/mavlink_msg_battery_status.h | 84 ++++++++ common/mavlink_msg_button_change.h | 53 +++++ common/mavlink_msg_camera_capture_status.h | 65 ++++++ common/mavlink_msg_camera_fov_status.h | 72 +++++++ common/mavlink_msg_camera_image_captured.h | 75 +++++++ common/mavlink_msg_camera_information.h | 84 ++++++++ common/mavlink_msg_camera_settings.h | 56 +++++ .../mavlink_msg_camera_tracking_geo_status.h | 83 ++++++++ ...mavlink_msg_camera_tracking_image_status.h | 74 +++++++ common/mavlink_msg_camera_trigger.h | 50 +++++ common/mavlink_msg_can_filter_modify.h | 60 ++++++ common/mavlink_msg_can_frame.h | 60 ++++++ common/mavlink_msg_canfd_frame.h | 60 ++++++ common/mavlink_msg_cellular_config.h | 66 ++++++ common/mavlink_msg_cellular_status.h | 65 ++++++ common/mavlink_msg_change_operator_control.h | 54 +++++ .../mavlink_msg_change_operator_control_ack.h | 53 +++++ common/mavlink_msg_collision.h | 65 ++++++ common/mavlink_msg_command_ack.h | 62 ++++++ common/mavlink_msg_command_cancel.h | 53 +++++ common/mavlink_msg_command_int.h | 83 ++++++++ common/mavlink_msg_command_long.h | 77 +++++++ common/mavlink_msg_component_information.h | 57 +++++ common/mavlink_msg_component_metadata.h | 51 +++++ common/mavlink_msg_control_system_state.h | 93 +++++++++ common/mavlink_msg_current_event_sequence.h | 50 +++++ common/mavlink_msg_data_stream.h | 53 +++++ .../mavlink_msg_data_transmission_handshake.h | 65 ++++++ common/mavlink_msg_debug.h | 53 +++++ common/mavlink_msg_debug_float_array.h | 54 +++++ common/mavlink_msg_debug_vect.h | 57 +++++ common/mavlink_msg_distance_sensor.h | 78 +++++++ common/mavlink_msg_efi_status.h | 101 +++++++++ common/mavlink_msg_encapsulated_data.h | 48 +++++ common/mavlink_msg_esc_info.h | 69 +++++++ common/mavlink_msg_esc_status.h | 57 +++++ common/mavlink_msg_estimator_status.h | 74 +++++++ common/mavlink_msg_event.h | 63 ++++++ common/mavlink_msg_extended_sys_state.h | 50 +++++ common/mavlink_msg_fence_status.h | 59 ++++++ common/mavlink_msg_file_transfer_protocol.h | 54 +++++ common/mavlink_msg_flight_information.h | 59 ++++++ common/mavlink_msg_follow_target.h | 75 +++++++ common/mavlink_msg_generator_status.h | 77 +++++++ ...avlink_msg_gimbal_device_attitude_status.h | 78 +++++++ .../mavlink_msg_gimbal_device_information.h | 90 ++++++++ .../mavlink_msg_gimbal_device_set_attitude.h | 63 ++++++ .../mavlink_msg_gimbal_manager_information.h | 71 +++++++ .../mavlink_msg_gimbal_manager_set_attitude.h | 66 ++++++ ...nk_msg_gimbal_manager_set_manual_control.h | 68 ++++++ .../mavlink_msg_gimbal_manager_set_pitchyaw.h | 68 ++++++ common/mavlink_msg_gimbal_manager_status.h | 65 ++++++ common/mavlink_msg_global_position_int.h | 71 +++++++ common/mavlink_msg_global_position_int_cov.h | 72 +++++++ ...link_msg_global_vision_position_estimate.h | 69 +++++++ common/mavlink_msg_gps2_raw.h | 98 +++++++++ common/mavlink_msg_gps2_rtk.h | 83 ++++++++ common/mavlink_msg_gps_global_origin.h | 56 +++++ common/mavlink_msg_gps_inject_data.h | 54 +++++ common/mavlink_msg_gps_input.h | 101 +++++++++ common/mavlink_msg_gps_raw_int.h | 92 +++++++++ common/mavlink_msg_gps_rtcm_data.h | 51 +++++ common/mavlink_msg_gps_rtk.h | 83 ++++++++ common/mavlink_msg_gps_status.h | 60 ++++++ common/mavlink_msg_high_latency.h | 116 +++++++++++ common/mavlink_msg_high_latency2.h | 125 +++++++++++ common/mavlink_msg_highres_imu.h | 92 +++++++++ common/mavlink_msg_hil_actuator_controls.h | 54 +++++ common/mavlink_msg_hil_controls.h | 77 +++++++ common/mavlink_msg_hil_gps.h | 89 ++++++++ common/mavlink_msg_hil_optical_flow.h | 80 ++++++++ common/mavlink_msg_hil_rc_inputs_raw.h | 86 ++++++++ common/mavlink_msg_hil_sensor.h | 92 +++++++++ common/mavlink_msg_hil_state.h | 92 +++++++++ common/mavlink_msg_hil_state_quaternion.h | 90 ++++++++ common/mavlink_msg_home_position.h | 79 +++++++ common/mavlink_msg_hygrometer_sensor.h | 53 +++++ common/mavlink_msg_isbd_link_status.h | 68 ++++++ common/mavlink_msg_landing_target.h | 84 ++++++++ common/mavlink_msg_link_node_status.h | 77 +++++++ common/mavlink_msg_local_position_ned.h | 65 ++++++ common/mavlink_msg_local_position_ned_cov.h | 78 +++++++ ..._local_position_ned_system_global_offset.h | 65 ++++++ common/mavlink_msg_log_data.h | 54 +++++ common/mavlink_msg_log_entry.h | 59 ++++++ common/mavlink_msg_log_erase.h | 50 +++++ common/mavlink_msg_log_request_data.h | 59 ++++++ common/mavlink_msg_log_request_end.h | 50 +++++ common/mavlink_msg_log_request_list.h | 56 +++++ common/mavlink_msg_logging_ack.h | 53 +++++ common/mavlink_msg_logging_data.h | 60 ++++++ common/mavlink_msg_logging_data_acked.h | 60 ++++++ common/mavlink_msg_mag_cal_report.h | 98 +++++++++ common/mavlink_msg_manual_control.h | 92 +++++++++ common/mavlink_msg_manual_setpoint.h | 65 ++++++ common/mavlink_msg_memory_vect.h | 54 +++++ common/mavlink_msg_message_interval.h | 50 +++++ common/mavlink_msg_mission_ack.h | 65 ++++++ common/mavlink_msg_mission_clear_all.h | 53 +++++ common/mavlink_msg_mission_count.h | 65 ++++++ common/mavlink_msg_mission_current.h | 65 ++++++ common/mavlink_msg_mission_item.h | 89 ++++++++ common/mavlink_msg_mission_item_int.h | 89 ++++++++ common/mavlink_msg_mission_item_reached.h | 47 +++++ common/mavlink_msg_mission_request.h | 56 +++++ common/mavlink_msg_mission_request_int.h | 56 +++++ common/mavlink_msg_mission_request_list.h | 53 +++++ ...mavlink_msg_mission_request_partial_list.h | 59 ++++++ common/mavlink_msg_mission_set_current.h | 53 +++++ .../mavlink_msg_mission_write_partial_list.h | 59 ++++++ common/mavlink_msg_mount_orientation.h | 59 ++++++ common/mavlink_msg_named_value_float.h | 51 +++++ common/mavlink_msg_named_value_int.h | 51 +++++ common/mavlink_msg_nav_controller_output.h | 68 ++++++ common/mavlink_msg_obstacle_distance.h | 69 +++++++ common/mavlink_msg_odometry.h | 96 +++++++++ common/mavlink_msg_onboard_computer_status.h | 102 +++++++++ common/mavlink_msg_open_drone_id_arm_status.h | 48 +++++ ...mavlink_msg_open_drone_id_authentication.h | 69 +++++++ common/mavlink_msg_open_drone_id_basic_id.h | 60 ++++++ common/mavlink_msg_open_drone_id_location.h | 99 +++++++++ .../mavlink_msg_open_drone_id_message_pack.h | 60 ++++++ .../mavlink_msg_open_drone_id_operator_id.h | 57 +++++ common/mavlink_msg_open_drone_id_self_id.h | 57 +++++ common/mavlink_msg_open_drone_id_system.h | 87 ++++++++ .../mavlink_msg_open_drone_id_system_update.h | 62 ++++++ common/mavlink_msg_optical_flow.h | 74 +++++++ common/mavlink_msg_optical_flow_rad.h | 80 ++++++++ common/mavlink_msg_orbit_execution_status.h | 62 ++++++ common/mavlink_msg_param_ext_ack.h | 54 +++++ common/mavlink_msg_param_ext_request_list.h | 50 +++++ common/mavlink_msg_param_ext_request_read.h | 54 +++++ common/mavlink_msg_param_ext_set.h | 57 +++++ common/mavlink_msg_param_ext_value.h | 57 +++++ common/mavlink_msg_param_map_rc.h | 69 +++++++ common/mavlink_msg_param_request_list.h | 50 +++++ common/mavlink_msg_param_request_read.h | 54 +++++ common/mavlink_msg_param_set.h | 57 +++++ common/mavlink_msg_param_value.h | 57 +++++ common/mavlink_msg_ping.h | 56 +++++ common/mavlink_msg_play_tune.h | 54 +++++ common/mavlink_msg_play_tune_v2.h | 54 +++++ .../mavlink_msg_position_target_global_int.h | 86 ++++++++ .../mavlink_msg_position_target_local_ned.h | 86 ++++++++ common/mavlink_msg_power_status.h | 53 +++++ common/mavlink_msg_radio_status.h | 65 ++++++ common/mavlink_msg_raw_imu.h | 80 ++++++++ common/mavlink_msg_raw_pressure.h | 59 ++++++ common/mavlink_msg_raw_rpm.h | 50 +++++ common/mavlink_msg_rc_channels.h | 107 ++++++++++ common/mavlink_msg_rc_channels_override.h | 104 ++++++++++ common/mavlink_msg_rc_channels_raw.h | 77 +++++++ common/mavlink_msg_rc_channels_scaled.h | 77 +++++++ common/mavlink_msg_request_data_stream.h | 59 ++++++ common/mavlink_msg_request_event.h | 56 +++++ common/mavlink_msg_resource_request.h | 57 +++++ common/mavlink_msg_response_event_error.h | 59 ++++++ common/mavlink_msg_safety_allowed_area.h | 65 ++++++ common/mavlink_msg_safety_set_allowed_area.h | 71 +++++++ common/mavlink_msg_scaled_imu.h | 77 +++++++ common/mavlink_msg_scaled_imu2.h | 77 +++++++ common/mavlink_msg_scaled_imu3.h | 77 +++++++ common/mavlink_msg_scaled_pressure.h | 59 ++++++ common/mavlink_msg_scaled_pressure2.h | 59 ++++++ common/mavlink_msg_scaled_pressure3.h | 59 ++++++ common/mavlink_msg_serial_control.h | 66 ++++++ common/mavlink_msg_servo_output_raw.h | 98 +++++++++ .../mavlink_msg_set_actuator_control_target.h | 57 +++++ common/mavlink_msg_set_attitude_target.h | 72 +++++++ common/mavlink_msg_set_gps_global_origin.h | 59 ++++++ common/mavlink_msg_set_home_position.h | 78 +++++++ common/mavlink_msg_set_mode.h | 53 +++++ ...vlink_msg_set_position_target_global_int.h | 92 +++++++++ ...avlink_msg_set_position_target_local_ned.h | 92 +++++++++ common/mavlink_msg_setup_signing.h | 54 +++++ common/mavlink_msg_sim_state.h | 113 ++++++++++ common/mavlink_msg_statustext.h | 54 +++++ common/mavlink_msg_storage_information.h | 81 ++++++++ common/mavlink_msg_supported_tunes.h | 53 +++++ common/mavlink_msg_sys_status.h | 92 +++++++++ common/mavlink_msg_system_time.h | 50 +++++ common/mavlink_msg_terrain_check.h | 50 +++++ common/mavlink_msg_terrain_data.h | 57 +++++ common/mavlink_msg_terrain_report.h | 65 ++++++ common/mavlink_msg_terrain_request.h | 56 +++++ common/mavlink_msg_time_estimate_to_target.h | 59 ++++++ common/mavlink_msg_timesync.h | 56 +++++ ...ink_msg_trajectory_representation_bezier.h | 63 ++++++ ..._msg_trajectory_representation_waypoints.h | 84 ++++++++ common/mavlink_msg_tunnel.h | 57 +++++ common/mavlink_msg_uavcan_node_info.h | 69 +++++++ common/mavlink_msg_uavcan_node_status.h | 62 ++++++ common/mavlink_msg_utm_global_position.h | 96 +++++++++ common/mavlink_msg_v2_extension.h | 57 +++++ common/mavlink_msg_vfr_hud.h | 62 ++++++ common/mavlink_msg_vibration.h | 65 ++++++ common/mavlink_msg_vicon_position_estimate.h | 66 ++++++ common/mavlink_msg_video_stream_information.h | 78 +++++++ common/mavlink_msg_video_stream_status.h | 68 ++++++ common/mavlink_msg_vision_position_estimate.h | 69 +++++++ common/mavlink_msg_vision_speed_estimate.h | 60 ++++++ common/mavlink_msg_wheel_distance.h | 51 +++++ common/mavlink_msg_wifi_config_ap.h | 54 +++++ common/mavlink_msg_winch_status.h | 68 ++++++ common/mavlink_msg_wind_cov.h | 71 +++++++ common/version.h | 2 +- csAirLink/csAirLink.h | 2 +- csAirLink/mavlink.h | 2 +- csAirLink/mavlink_msg_airlink_auth.h | 50 +++++ csAirLink/mavlink_msg_airlink_auth_response.h | 47 +++++ ...ink_msg_airlink_eye_gs_hole_push_request.h | 47 +++++ ...nk_msg_airlink_eye_gs_hole_push_response.h | 57 +++++ csAirLink/mavlink_msg_airlink_eye_hp.h | 47 +++++ csAirLink/mavlink_msg_airlink_eye_turn_init.h | 47 +++++ csAirLink/version.h | 2 +- cubepilot/cubepilot.h | 2 +- cubepilot/mavlink.h | 2 +- ...vlink_msg_cubepilot_firmware_update_resp.h | 53 +++++ ...link_msg_cubepilot_firmware_update_start.h | 56 +++++ cubepilot/mavlink_msg_cubepilot_raw_rc.h | 47 +++++ cubepilot/mavlink_msg_herelink_telem.h | 65 ++++++ ...nk_msg_herelink_video_stream_information.h | 66 ++++++ cubepilot/version.h | 2 +- development/development.h | 2 +- development/mavlink.h | 2 +- development/mavlink_msg_airspeed.h | 59 ++++++ development/mavlink_msg_available_modes.h | 60 ++++++ .../mavlink_msg_available_modes_monitor.h | 47 +++++ development/mavlink_msg_battery_status_v2.h | 68 ++++++ .../mavlink_msg_component_information_basic.h | 66 ++++++ development/mavlink_msg_current_mode.h | 53 +++++ ...avlink_msg_figure_eight_execution_status.h | 68 ++++++ development/mavlink_msg_group_end.h | 54 +++++ development/mavlink_msg_group_start.h | 54 +++++ .../mavlink_msg_param_ack_transaction.h | 60 ++++++ development/mavlink_msg_set_velocity_limits.h | 59 ++++++ development/mavlink_msg_target_absolute.h | 81 ++++++++ development/mavlink_msg_target_relative.h | 75 +++++++ development/mavlink_msg_velocity_limits.h | 53 +++++ development/mavlink_msg_wifi_network_info.h | 57 +++++ development/version.h | 2 +- icarous/icarous.h | 2 +- icarous/mavlink.h | 2 +- icarous/mavlink_msg_icarous_heartbeat.h | 47 +++++ icarous/mavlink_msg_icarous_kinematic_bands.h | 92 +++++++++ icarous/version.h | 2 +- matrixpilot/matrixpilot.h | 2 +- matrixpilot/mavlink.h | 2 +- matrixpilot/mavlink_msg_airspeeds.h | 65 ++++++ matrixpilot/mavlink_msg_altitudes.h | 65 ++++++ ...avlink_msg_flexifunction_buffer_function.h | 63 ++++++ ...nk_msg_flexifunction_buffer_function_ack.h | 56 +++++ .../mavlink_msg_flexifunction_command.h | 53 +++++ .../mavlink_msg_flexifunction_command_ack.h | 50 +++++ .../mavlink_msg_flexifunction_directory.h | 60 ++++++ .../mavlink_msg_flexifunction_directory_ack.h | 62 ++++++ .../mavlink_msg_flexifunction_read_req.h | 56 +++++ matrixpilot/mavlink_msg_flexifunction_set.h | 50 +++++ .../mavlink_msg_serial_udb_extra_f13.h | 56 +++++ .../mavlink_msg_serial_udb_extra_f14.h | 77 +++++++ .../mavlink_msg_serial_udb_extra_f15.h | 50 +++++ .../mavlink_msg_serial_udb_extra_f16.h | 50 +++++ .../mavlink_msg_serial_udb_extra_f17.h | 53 +++++ .../mavlink_msg_serial_udb_extra_f18.h | 59 ++++++ .../mavlink_msg_serial_udb_extra_f19.h | 68 ++++++ .../mavlink_msg_serial_udb_extra_f20.h | 83 ++++++++ .../mavlink_msg_serial_udb_extra_f21.h | 62 ++++++ .../mavlink_msg_serial_udb_extra_f22.h | 62 ++++++ .../mavlink_msg_serial_udb_extra_f2_a.h | 125 +++++++++++ .../mavlink_msg_serial_udb_extra_f2_b.h | 194 ++++++++++++++++++ matrixpilot/mavlink_msg_serial_udb_extra_f4.h | 74 +++++++ matrixpilot/mavlink_msg_serial_udb_extra_f5.h | 56 +++++ matrixpilot/mavlink_msg_serial_udb_extra_f6.h | 59 ++++++ matrixpilot/mavlink_msg_serial_udb_extra_f7.h | 62 ++++++ matrixpilot/mavlink_msg_serial_udb_extra_f8.h | 65 ++++++ matrixpilot/version.h | 2 +- mavlink_helpers.h | 2 +- minimal/mavlink.h | 2 +- minimal/mavlink_msg_heartbeat.h | 61 ++++++ minimal/mavlink_msg_protocol_version.h | 57 +++++ minimal/minimal.h | 2 +- minimal/version.h | 2 +- paparazzi/mavlink.h | 2 +- paparazzi/mavlink_msg_script_count.h | 53 +++++ paparazzi/mavlink_msg_script_current.h | 47 +++++ paparazzi/mavlink_msg_script_item.h | 54 +++++ paparazzi/mavlink_msg_script_request.h | 53 +++++ paparazzi/mavlink_msg_script_request_list.h | 50 +++++ paparazzi/paparazzi.h | 2 +- paparazzi/version.h | 2 +- protocol.h | 2 + python_array_test/mavlink.h | 2 +- python_array_test/mavlink_msg_array_test_0.h | 57 +++++ python_array_test/mavlink_msg_array_test_1.h | 47 +++++ python_array_test/mavlink_msg_array_test_3.h | 48 +++++ python_array_test/mavlink_msg_array_test_4.h | 48 +++++ python_array_test/mavlink_msg_array_test_5.h | 50 +++++ python_array_test/mavlink_msg_array_test_6.h | 78 +++++++ python_array_test/mavlink_msg_array_test_7.h | 71 +++++++ python_array_test/mavlink_msg_array_test_8.h | 51 +++++ python_array_test/python_array_test.h | 2 +- python_array_test/version.h | 2 +- standard/mavlink.h | 2 +- standard/standard.h | 2 +- standard/version.h | 2 +- storm32/mavlink.h | 2 +- storm32/mavlink_msg_frsky_passthrough_array.h | 51 +++++ storm32/mavlink_msg_param_value_array.h | 57 +++++ storm32/mavlink_msg_qshot_status.h | 50 +++++ storm32/mavlink_msg_radio_link_stats.h | 89 ++++++++ storm32/mavlink_msg_radio_rc_channels.h | 51 +++++ ...vlink_msg_storm32_gimbal_manager_control.h | 72 +++++++ ..._storm32_gimbal_manager_control_pitchyaw.h | 74 +++++++ ..._msg_storm32_gimbal_manager_correct_roll.h | 59 ++++++ ...k_msg_storm32_gimbal_manager_information.h | 71 +++++++ ...avlink_msg_storm32_gimbal_manager_status.h | 59 ++++++ storm32/storm32.h | 2 +- storm32/version.h | 2 +- test/mavlink.h | 2 +- test/mavlink_msg_test_types.h | 108 ++++++++++ test/test.h | 2 +- test/version.h | 2 +- uAvionix/mavlink.h | 2 +- uAvionix/mavlink_msg_uavionix_adsb_out_cfg.h | 66 ++++++ .../mavlink_msg_uavionix_adsb_out_dynamic.h | 92 +++++++++ ..._uavionix_adsb_transceiver_health_report.h | 47 +++++ uAvionix/uAvionix.h | 2 +- uAvionix/version.h | 2 +- ualberta/mavlink.h | 2 +- ualberta/mavlink_msg_nav_filter_bias.h | 65 ++++++ ualberta/mavlink_msg_radio_calibration.h | 62 ++++++ ualberta/mavlink_msg_ualberta_sys_status.h | 53 +++++ ualberta/ualberta.h | 2 +- ualberta/version.h | 2 +- 448 files changed, 25939 insertions(+), 55 deletions(-) diff --git a/ASLUAV/ASLUAV.h b/ASLUAV/ASLUAV.h index be0bc69a..99d98232 100644 --- a/ASLUAV/ASLUAV.h +++ b/ASLUAV/ASLUAV.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_ASLUAV.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_ASLUAV_XML_HASH 316866643315165655 +#define MAVLINK_ASLUAV_XML_HASH 5280776994826192524 #ifdef __cplusplus extern "C" { diff --git a/ASLUAV/mavlink.h b/ASLUAV/mavlink.h index 6fa42776..9187ceb7 100644 --- a/ASLUAV/mavlink.h +++ b/ASLUAV/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 316866643315165655 +#define MAVLINK_PRIMARY_XML_HASH 5280776994826192524 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/ASLUAV/mavlink_msg_asl_obctrl.h b/ASLUAV/mavlink_msg_asl_obctrl.h index 34d1b57f..53da3430 100644 --- a/ASLUAV/mavlink_msg_asl_obctrl.h +++ b/ASLUAV/mavlink_msg_asl_obctrl.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_asl_obctrl_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ASL_OBCTRL_MIN_LEN, MAVLINK_MSG_ID_ASL_OBCTRL_LEN, MAVLINK_MSG_ID_ASL_OBCTRL_CRC); } +/** + * @brief Pack a asl_obctrl 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 timestamp [us] Time since system start + * @param uElev Elevator command [~] + * @param uThrot Throttle command [~] + * @param uThrot2 Throttle 2 command [~] + * @param uAilL Left aileron command [~] + * @param uAilR Right aileron command [~] + * @param uRud Rudder command [~] + * @param obctrl_status Off-board computer status + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_asl_obctrl_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, float uElev, float uThrot, float uThrot2, float uAilL, float uAilR, float uRud, uint8_t obctrl_status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ASL_OBCTRL_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, uElev); + _mav_put_float(buf, 12, uThrot); + _mav_put_float(buf, 16, uThrot2); + _mav_put_float(buf, 20, uAilL); + _mav_put_float(buf, 24, uAilR); + _mav_put_float(buf, 28, uRud); + _mav_put_uint8_t(buf, 32, obctrl_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ASL_OBCTRL_LEN); +#else + mavlink_asl_obctrl_t packet; + packet.timestamp = timestamp; + packet.uElev = uElev; + packet.uThrot = uThrot; + packet.uThrot2 = uThrot2; + packet.uAilL = uAilL; + packet.uAilR = uAilR; + packet.uRud = uRud; + packet.obctrl_status = obctrl_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ASL_OBCTRL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ASL_OBCTRL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASL_OBCTRL_MIN_LEN, MAVLINK_MSG_ID_ASL_OBCTRL_LEN, MAVLINK_MSG_ID_ASL_OBCTRL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASL_OBCTRL_MIN_LEN, MAVLINK_MSG_ID_ASL_OBCTRL_LEN); +#endif +} + /** * @brief Pack a asl_obctrl message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_asl_obctrl_encode_chan(uint8_t system_id, uin return mavlink_msg_asl_obctrl_pack_chan(system_id, component_id, chan, msg, asl_obctrl->timestamp, asl_obctrl->uElev, asl_obctrl->uThrot, asl_obctrl->uThrot2, asl_obctrl->uAilL, asl_obctrl->uAilR, asl_obctrl->uRud, asl_obctrl->obctrl_status); } +/** + * @brief Encode a asl_obctrl struct with provided status structure + * + * @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 asl_obctrl C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_asl_obctrl_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_asl_obctrl_t* asl_obctrl) +{ + return mavlink_msg_asl_obctrl_pack_status(system_id, component_id, _status, msg, asl_obctrl->timestamp, asl_obctrl->uElev, asl_obctrl->uThrot, asl_obctrl->uThrot2, asl_obctrl->uAilL, asl_obctrl->uAilR, asl_obctrl->uRud, asl_obctrl->obctrl_status); +} + /** * @brief Send a asl_obctrl message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_aslctrl_data.h b/ASLUAV/mavlink_msg_aslctrl_data.h index ecd9128e..930b34b5 100644 --- a/ASLUAV/mavlink_msg_aslctrl_data.h +++ b/ASLUAV/mavlink_msg_aslctrl_data.h @@ -207,6 +207,111 @@ static inline uint16_t mavlink_msg_aslctrl_data_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ASLCTRL_DATA_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DATA_LEN, MAVLINK_MSG_ID_ASLCTRL_DATA_CRC); } +/** + * @brief Pack a aslctrl_data 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 timestamp [us] Timestamp + * @param aslctrl_mode ASLCTRL control-mode (manual, stabilized, auto, etc...) + * @param h See sourcecode for a description of these values... + * @param hRef + * @param hRef_t + * @param PitchAngle [deg] Pitch angle + * @param PitchAngleRef [deg] Pitch angle reference + * @param q + * @param qRef + * @param uElev + * @param uThrot + * @param uThrot2 + * @param nZ + * @param AirspeedRef [m/s] Airspeed reference + * @param SpoilersEngaged + * @param YawAngle [deg] Yaw angle + * @param YawAngleRef [deg] Yaw angle reference + * @param RollAngle [deg] Roll angle + * @param RollAngleRef [deg] Roll angle reference + * @param p + * @param pRef + * @param r + * @param rRef + * @param uAil + * @param uRud + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_aslctrl_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t aslctrl_mode, float h, float hRef, float hRef_t, float PitchAngle, float PitchAngleRef, float q, float qRef, float uElev, float uThrot, float uThrot2, float nZ, float AirspeedRef, uint8_t SpoilersEngaged, float YawAngle, float YawAngleRef, float RollAngle, float RollAngleRef, float p, float pRef, float r, float rRef, float uAil, float uRud) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ASLCTRL_DATA_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, h); + _mav_put_float(buf, 12, hRef); + _mav_put_float(buf, 16, hRef_t); + _mav_put_float(buf, 20, PitchAngle); + _mav_put_float(buf, 24, PitchAngleRef); + _mav_put_float(buf, 28, q); + _mav_put_float(buf, 32, qRef); + _mav_put_float(buf, 36, uElev); + _mav_put_float(buf, 40, uThrot); + _mav_put_float(buf, 44, uThrot2); + _mav_put_float(buf, 48, nZ); + _mav_put_float(buf, 52, AirspeedRef); + _mav_put_float(buf, 56, YawAngle); + _mav_put_float(buf, 60, YawAngleRef); + _mav_put_float(buf, 64, RollAngle); + _mav_put_float(buf, 68, RollAngleRef); + _mav_put_float(buf, 72, p); + _mav_put_float(buf, 76, pRef); + _mav_put_float(buf, 80, r); + _mav_put_float(buf, 84, rRef); + _mav_put_float(buf, 88, uAil); + _mav_put_float(buf, 92, uRud); + _mav_put_uint8_t(buf, 96, aslctrl_mode); + _mav_put_uint8_t(buf, 97, SpoilersEngaged); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ASLCTRL_DATA_LEN); +#else + mavlink_aslctrl_data_t packet; + packet.timestamp = timestamp; + packet.h = h; + packet.hRef = hRef; + packet.hRef_t = hRef_t; + packet.PitchAngle = PitchAngle; + packet.PitchAngleRef = PitchAngleRef; + packet.q = q; + packet.qRef = qRef; + packet.uElev = uElev; + packet.uThrot = uThrot; + packet.uThrot2 = uThrot2; + packet.nZ = nZ; + packet.AirspeedRef = AirspeedRef; + packet.YawAngle = YawAngle; + packet.YawAngleRef = YawAngleRef; + packet.RollAngle = RollAngle; + packet.RollAngleRef = RollAngleRef; + packet.p = p; + packet.pRef = pRef; + packet.r = r; + packet.rRef = rRef; + packet.uAil = uAil; + packet.uRud = uRud; + packet.aslctrl_mode = aslctrl_mode; + packet.SpoilersEngaged = SpoilersEngaged; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ASLCTRL_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ASLCTRL_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLCTRL_DATA_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DATA_LEN, MAVLINK_MSG_ID_ASLCTRL_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLCTRL_DATA_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DATA_LEN); +#endif +} + /** * @brief Pack a aslctrl_data message on a channel * @param system_id ID of this system @@ -335,6 +440,20 @@ static inline uint16_t mavlink_msg_aslctrl_data_encode_chan(uint8_t system_id, u return mavlink_msg_aslctrl_data_pack_chan(system_id, component_id, chan, msg, aslctrl_data->timestamp, aslctrl_data->aslctrl_mode, aslctrl_data->h, aslctrl_data->hRef, aslctrl_data->hRef_t, aslctrl_data->PitchAngle, aslctrl_data->PitchAngleRef, aslctrl_data->q, aslctrl_data->qRef, aslctrl_data->uElev, aslctrl_data->uThrot, aslctrl_data->uThrot2, aslctrl_data->nZ, aslctrl_data->AirspeedRef, aslctrl_data->SpoilersEngaged, aslctrl_data->YawAngle, aslctrl_data->YawAngleRef, aslctrl_data->RollAngle, aslctrl_data->RollAngleRef, aslctrl_data->p, aslctrl_data->pRef, aslctrl_data->r, aslctrl_data->rRef, aslctrl_data->uAil, aslctrl_data->uRud); } +/** + * @brief Encode a aslctrl_data struct with provided status structure + * + * @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 aslctrl_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_aslctrl_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_aslctrl_data_t* aslctrl_data) +{ + return mavlink_msg_aslctrl_data_pack_status(system_id, component_id, _status, msg, aslctrl_data->timestamp, aslctrl_data->aslctrl_mode, aslctrl_data->h, aslctrl_data->hRef, aslctrl_data->hRef_t, aslctrl_data->PitchAngle, aslctrl_data->PitchAngleRef, aslctrl_data->q, aslctrl_data->qRef, aslctrl_data->uElev, aslctrl_data->uThrot, aslctrl_data->uThrot2, aslctrl_data->nZ, aslctrl_data->AirspeedRef, aslctrl_data->SpoilersEngaged, aslctrl_data->YawAngle, aslctrl_data->YawAngleRef, aslctrl_data->RollAngle, aslctrl_data->RollAngleRef, aslctrl_data->p, aslctrl_data->pRef, aslctrl_data->r, aslctrl_data->rRef, aslctrl_data->uAil, aslctrl_data->uRud); +} + /** * @brief Send a aslctrl_data message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_aslctrl_debug.h b/ASLUAV/mavlink_msg_aslctrl_debug.h index e4c4f4ec..ff8b2685 100644 --- a/ASLUAV/mavlink_msg_aslctrl_debug.h +++ b/ASLUAV/mavlink_msg_aslctrl_debug.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_aslctrl_debug_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ASLCTRL_DEBUG_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN, MAVLINK_MSG_ID_ASLCTRL_DEBUG_CRC); } +/** + * @brief Pack a aslctrl_debug 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 i32_1 Debug data + * @param i8_1 Debug data + * @param i8_2 Debug data + * @param f_1 Debug data + * @param f_2 Debug data + * @param f_3 Debug data + * @param f_4 Debug data + * @param f_5 Debug data + * @param f_6 Debug data + * @param f_7 Debug data + * @param f_8 Debug data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_aslctrl_debug_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t i32_1, uint8_t i8_1, uint8_t i8_2, float f_1, float f_2, float f_3, float f_4, float f_5, float f_6, float f_7, float f_8) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN]; + _mav_put_uint32_t(buf, 0, i32_1); + _mav_put_float(buf, 4, f_1); + _mav_put_float(buf, 8, f_2); + _mav_put_float(buf, 12, f_3); + _mav_put_float(buf, 16, f_4); + _mav_put_float(buf, 20, f_5); + _mav_put_float(buf, 24, f_6); + _mav_put_float(buf, 28, f_7); + _mav_put_float(buf, 32, f_8); + _mav_put_uint8_t(buf, 36, i8_1); + _mav_put_uint8_t(buf, 37, i8_2); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN); +#else + mavlink_aslctrl_debug_t packet; + packet.i32_1 = i32_1; + packet.f_1 = f_1; + packet.f_2 = f_2; + packet.f_3 = f_3; + packet.f_4 = f_4; + packet.f_5 = f_5; + packet.f_6 = f_6; + packet.f_7 = f_7; + packet.f_8 = f_8; + packet.i8_1 = i8_1; + packet.i8_2 = i8_2; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ASLCTRL_DEBUG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLCTRL_DEBUG_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN, MAVLINK_MSG_ID_ASLCTRL_DEBUG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLCTRL_DEBUG_MIN_LEN, MAVLINK_MSG_ID_ASLCTRL_DEBUG_LEN); +#endif +} + /** * @brief Pack a aslctrl_debug message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_aslctrl_debug_encode_chan(uint8_t system_id, return mavlink_msg_aslctrl_debug_pack_chan(system_id, component_id, chan, msg, aslctrl_debug->i32_1, aslctrl_debug->i8_1, aslctrl_debug->i8_2, aslctrl_debug->f_1, aslctrl_debug->f_2, aslctrl_debug->f_3, aslctrl_debug->f_4, aslctrl_debug->f_5, aslctrl_debug->f_6, aslctrl_debug->f_7, aslctrl_debug->f_8); } +/** + * @brief Encode a aslctrl_debug struct with provided status structure + * + * @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 aslctrl_debug C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_aslctrl_debug_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_aslctrl_debug_t* aslctrl_debug) +{ + return mavlink_msg_aslctrl_debug_pack_status(system_id, component_id, _status, msg, aslctrl_debug->i32_1, aslctrl_debug->i8_1, aslctrl_debug->i8_2, aslctrl_debug->f_1, aslctrl_debug->f_2, aslctrl_debug->f_3, aslctrl_debug->f_4, aslctrl_debug->f_5, aslctrl_debug->f_6, aslctrl_debug->f_7, aslctrl_debug->f_8); +} + /** * @brief Send a aslctrl_debug message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_asluav_status.h b/ASLUAV/mavlink_msg_asluav_status.h index 087f6250..8a4ebe92 100644 --- a/ASLUAV/mavlink_msg_asluav_status.h +++ b/ASLUAV/mavlink_msg_asluav_status.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_asluav_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ASLUAV_STATUS_MIN_LEN, MAVLINK_MSG_ID_ASLUAV_STATUS_LEN, MAVLINK_MSG_ID_ASLUAV_STATUS_CRC); } +/** + * @brief Pack a asluav_status 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 LED_status Status of the position-indicator LEDs + * @param SATCOM_status Status of the IRIDIUM satellite communication system + * @param Servo_status Status vector for up to 8 servos + * @param Motor_rpm Motor RPM + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_asluav_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t LED_status, uint8_t SATCOM_status, const uint8_t *Servo_status, float Motor_rpm) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ASLUAV_STATUS_LEN]; + _mav_put_float(buf, 0, Motor_rpm); + _mav_put_uint8_t(buf, 4, LED_status); + _mav_put_uint8_t(buf, 5, SATCOM_status); + _mav_put_uint8_t_array(buf, 6, Servo_status, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ASLUAV_STATUS_LEN); +#else + mavlink_asluav_status_t packet; + packet.Motor_rpm = Motor_rpm; + packet.LED_status = LED_status; + packet.SATCOM_status = SATCOM_status; + mav_array_memcpy(packet.Servo_status, Servo_status, sizeof(uint8_t)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ASLUAV_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ASLUAV_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLUAV_STATUS_MIN_LEN, MAVLINK_MSG_ID_ASLUAV_STATUS_LEN, MAVLINK_MSG_ID_ASLUAV_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ASLUAV_STATUS_MIN_LEN, MAVLINK_MSG_ID_ASLUAV_STATUS_LEN); +#endif +} + /** * @brief Pack a asluav_status message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_asluav_status_encode_chan(uint8_t system_id, return mavlink_msg_asluav_status_pack_chan(system_id, component_id, chan, msg, asluav_status->LED_status, asluav_status->SATCOM_status, asluav_status->Servo_status, asluav_status->Motor_rpm); } +/** + * @brief Encode a asluav_status struct with provided status structure + * + * @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 asluav_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_asluav_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_asluav_status_t* asluav_status) +{ + return mavlink_msg_asluav_status_pack_status(system_id, component_id, _status, msg, asluav_status->LED_status, asluav_status->SATCOM_status, asluav_status->Servo_status, asluav_status->Motor_rpm); +} + /** * @brief Send a asluav_status message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_command_int_stamped.h b/ASLUAV/mavlink_msg_command_int_stamped.h index 5f2a258d..729eca68 100644 --- a/ASLUAV/mavlink_msg_command_int_stamped.h +++ b/ASLUAV/mavlink_msg_command_int_stamped.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_command_int_stamped_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_CRC); } +/** + * @brief Pack a command_int_stamped 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 utc_time UTC time, seconds elapsed since 01.01.1970 + * @param vehicle_timestamp Microseconds elapsed since vehicle boot + * @param target_system System ID + * @param target_component Component ID + * @param frame The coordinate system of the COMMAND, as defined by MAV_FRAME enum + * @param command The scheduled action for the mission item, as defined by MAV_CMD enum + * @param current false:0, true:1 + * @param autocontinue autocontinue to next wp + * @param param1 PARAM1, see MAV_CMD enum + * @param param2 PARAM2, see MAV_CMD enum + * @param param3 PARAM3, see MAV_CMD enum + * @param param4 PARAM4, see MAV_CMD enum + * @param x PARAM5 / local: x position in meters * 1e4, global: latitude in degrees * 10^7 + * @param y PARAM6 / local: y position in meters * 1e4, global: longitude in degrees * 10^7 + * @param z PARAM7 / z position: global: altitude in meters (MSL, WGS84, AGL or relative to home - depending on frame). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_int_stamped_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t utc_time, uint64_t vehicle_timestamp, uint8_t target_system, uint8_t target_component, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, int32_t x, int32_t y, float z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN]; + _mav_put_uint64_t(buf, 0, vehicle_timestamp); + _mav_put_uint32_t(buf, 8, utc_time); + _mav_put_float(buf, 12, param1); + _mav_put_float(buf, 16, param2); + _mav_put_float(buf, 20, param3); + _mav_put_float(buf, 24, param4); + _mav_put_int32_t(buf, 28, x); + _mav_put_int32_t(buf, 32, y); + _mav_put_float(buf, 36, z); + _mav_put_uint16_t(buf, 40, command); + _mav_put_uint8_t(buf, 42, target_system); + _mav_put_uint8_t(buf, 43, target_component); + _mav_put_uint8_t(buf, 44, frame); + _mav_put_uint8_t(buf, 45, current); + _mav_put_uint8_t(buf, 46, autocontinue); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN); +#else + mavlink_command_int_stamped_t packet; + packet.vehicle_timestamp = vehicle_timestamp; + packet.utc_time = utc_time; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.x = x; + packet.y = y; + packet.z = z; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.frame = frame; + packet.current = current; + packet.autocontinue = autocontinue; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_INT_STAMPED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_STAMPED_LEN); +#endif +} + /** * @brief Pack a command_int_stamped message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_command_int_stamped_encode_chan(uint8_t syste return mavlink_msg_command_int_stamped_pack_chan(system_id, component_id, chan, msg, command_int_stamped->utc_time, command_int_stamped->vehicle_timestamp, command_int_stamped->target_system, command_int_stamped->target_component, command_int_stamped->frame, command_int_stamped->command, command_int_stamped->current, command_int_stamped->autocontinue, command_int_stamped->param1, command_int_stamped->param2, command_int_stamped->param3, command_int_stamped->param4, command_int_stamped->x, command_int_stamped->y, command_int_stamped->z); } +/** + * @brief Encode a command_int_stamped struct with provided status structure + * + * @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 command_int_stamped C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_int_stamped_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_int_stamped_t* command_int_stamped) +{ + return mavlink_msg_command_int_stamped_pack_status(system_id, component_id, _status, msg, command_int_stamped->utc_time, command_int_stamped->vehicle_timestamp, command_int_stamped->target_system, command_int_stamped->target_component, command_int_stamped->frame, command_int_stamped->command, command_int_stamped->current, command_int_stamped->autocontinue, command_int_stamped->param1, command_int_stamped->param2, command_int_stamped->param3, command_int_stamped->param4, command_int_stamped->x, command_int_stamped->y, command_int_stamped->z); +} + /** * @brief Send a command_int_stamped message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_command_long_stamped.h b/ASLUAV/mavlink_msg_command_long_stamped.h index dd2d18bf..68df7cf1 100644 --- a/ASLUAV/mavlink_msg_command_long_stamped.h +++ b/ASLUAV/mavlink_msg_command_long_stamped.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_command_long_stamped_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_CRC); } +/** + * @brief Pack a command_long_stamped 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 utc_time UTC time, seconds elapsed since 01.01.1970 + * @param vehicle_timestamp Microseconds elapsed since vehicle boot + * @param target_system System which should execute the command + * @param target_component Component which should execute the command, 0 for all components + * @param command Command ID, as defined by MAV_CMD enum. + * @param confirmation 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command) + * @param param1 Parameter 1, as defined by MAV_CMD enum. + * @param param2 Parameter 2, as defined by MAV_CMD enum. + * @param param3 Parameter 3, as defined by MAV_CMD enum. + * @param param4 Parameter 4, as defined by MAV_CMD enum. + * @param param5 Parameter 5, as defined by MAV_CMD enum. + * @param param6 Parameter 6, as defined by MAV_CMD enum. + * @param param7 Parameter 7, as defined by MAV_CMD enum. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_long_stamped_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t utc_time, uint64_t vehicle_timestamp, uint8_t target_system, uint8_t target_component, uint16_t command, uint8_t confirmation, float param1, float param2, float param3, float param4, float param5, float param6, float param7) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN]; + _mav_put_uint64_t(buf, 0, vehicle_timestamp); + _mav_put_uint32_t(buf, 8, utc_time); + _mav_put_float(buf, 12, param1); + _mav_put_float(buf, 16, param2); + _mav_put_float(buf, 20, param3); + _mav_put_float(buf, 24, param4); + _mav_put_float(buf, 28, param5); + _mav_put_float(buf, 32, param6); + _mav_put_float(buf, 36, param7); + _mav_put_uint16_t(buf, 40, command); + _mav_put_uint8_t(buf, 42, target_system); + _mav_put_uint8_t(buf, 43, target_component); + _mav_put_uint8_t(buf, 44, confirmation); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN); +#else + mavlink_command_long_stamped_t packet; + packet.vehicle_timestamp = vehicle_timestamp; + packet.utc_time = utc_time; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.param5 = param5; + packet.param6 = param6; + packet.param7 = param7; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.confirmation = confirmation; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_LONG_STAMPED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_STAMPED_LEN); +#endif +} + /** * @brief Pack a command_long_stamped message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_command_long_stamped_encode_chan(uint8_t syst return mavlink_msg_command_long_stamped_pack_chan(system_id, component_id, chan, msg, command_long_stamped->utc_time, command_long_stamped->vehicle_timestamp, command_long_stamped->target_system, command_long_stamped->target_component, command_long_stamped->command, command_long_stamped->confirmation, command_long_stamped->param1, command_long_stamped->param2, command_long_stamped->param3, command_long_stamped->param4, command_long_stamped->param5, command_long_stamped->param6, command_long_stamped->param7); } +/** + * @brief Encode a command_long_stamped struct with provided status structure + * + * @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 command_long_stamped C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_long_stamped_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_long_stamped_t* command_long_stamped) +{ + return mavlink_msg_command_long_stamped_pack_status(system_id, component_id, _status, msg, command_long_stamped->utc_time, command_long_stamped->vehicle_timestamp, command_long_stamped->target_system, command_long_stamped->target_component, command_long_stamped->command, command_long_stamped->confirmation, command_long_stamped->param1, command_long_stamped->param2, command_long_stamped->param3, command_long_stamped->param4, command_long_stamped->param5, command_long_stamped->param6, command_long_stamped->param7); +} + /** * @brief Send a command_long_stamped message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_ekf_ext.h b/ASLUAV/mavlink_msg_ekf_ext.h index a9952020..e5a3191d 100644 --- a/ASLUAV/mavlink_msg_ekf_ext.h +++ b/ASLUAV/mavlink_msg_ekf_ext.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_ekf_ext_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_EKF_EXT_MIN_LEN, MAVLINK_MSG_ID_EKF_EXT_LEN, MAVLINK_MSG_ID_EKF_EXT_CRC); } +/** + * @brief Pack a ekf_ext 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 timestamp [us] Time since system start + * @param Windspeed [m/s] Magnitude of wind velocity (in lateral inertial plane) + * @param WindDir [rad] Wind heading angle from North + * @param WindZ [m/s] Z (Down) component of inertial wind velocity + * @param Airspeed [m/s] Magnitude of air velocity + * @param beta [rad] Sideslip angle + * @param alpha [rad] Angle of attack + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ekf_ext_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, float Windspeed, float WindDir, float WindZ, float Airspeed, float beta, float alpha) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_EKF_EXT_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, Windspeed); + _mav_put_float(buf, 12, WindDir); + _mav_put_float(buf, 16, WindZ); + _mav_put_float(buf, 20, Airspeed); + _mav_put_float(buf, 24, beta); + _mav_put_float(buf, 28, alpha); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_EKF_EXT_LEN); +#else + mavlink_ekf_ext_t packet; + packet.timestamp = timestamp; + packet.Windspeed = Windspeed; + packet.WindDir = WindDir; + packet.WindZ = WindZ; + packet.Airspeed = Airspeed; + packet.beta = beta; + packet.alpha = alpha; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_EKF_EXT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_EKF_EXT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EKF_EXT_MIN_LEN, MAVLINK_MSG_ID_EKF_EXT_LEN, MAVLINK_MSG_ID_EKF_EXT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EKF_EXT_MIN_LEN, MAVLINK_MSG_ID_EKF_EXT_LEN); +#endif +} + /** * @brief Pack a ekf_ext message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_ekf_ext_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_ekf_ext_pack_chan(system_id, component_id, chan, msg, ekf_ext->timestamp, ekf_ext->Windspeed, ekf_ext->WindDir, ekf_ext->WindZ, ekf_ext->Airspeed, ekf_ext->beta, ekf_ext->alpha); } +/** + * @brief Encode a ekf_ext struct with provided status structure + * + * @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 ekf_ext C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ekf_ext_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ekf_ext_t* ekf_ext) +{ + return mavlink_msg_ekf_ext_pack_status(system_id, component_id, _status, msg, ekf_ext->timestamp, ekf_ext->Windspeed, ekf_ext->WindDir, ekf_ext->WindZ, ekf_ext->Airspeed, ekf_ext->beta, ekf_ext->alpha); +} + /** * @brief Send a ekf_ext message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_fw_soaring_data.h b/ASLUAV/mavlink_msg_fw_soaring_data.h index 02413bcd..58b073c5 100644 --- a/ASLUAV/mavlink_msg_fw_soaring_data.h +++ b/ASLUAV/mavlink_msg_fw_soaring_data.h @@ -207,6 +207,111 @@ static inline uint16_t mavlink_msg_fw_soaring_data_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FW_SOARING_DATA_MIN_LEN, MAVLINK_MSG_ID_FW_SOARING_DATA_LEN, MAVLINK_MSG_ID_FW_SOARING_DATA_CRC); } +/** + * @brief Pack a fw_soaring_data 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 timestamp [ms] Timestamp + * @param timestampModeChanged [ms] Timestamp since last mode change + * @param xW [m/s] Thermal core updraft strength + * @param xR [m] Thermal radius + * @param xLat [deg] Thermal center latitude + * @param xLon [deg] Thermal center longitude + * @param VarW Variance W + * @param VarR Variance R + * @param VarLat Variance Lat + * @param VarLon Variance Lon + * @param LoiterRadius [m] Suggested loiter radius + * @param LoiterDirection Suggested loiter direction + * @param DistToSoarPoint [m] Distance to soar point + * @param vSinkExp [m/s] Expected sink rate at current airspeed, roll and throttle + * @param z1_LocalUpdraftSpeed [m/s] Measurement / updraft speed at current/local airplane position + * @param z2_DeltaRoll [deg] Measurement / roll angle tracking error + * @param z1_exp Expected measurement 1 + * @param z2_exp Expected measurement 2 + * @param ThermalGSNorth [m/s] Thermal drift (from estimator prediction step only) + * @param ThermalGSEast [m/s] Thermal drift (from estimator prediction step only) + * @param TSE_dot [m/s] Total specific energy change (filtered) + * @param DebugVar1 Debug variable 1 + * @param DebugVar2 Debug variable 2 + * @param ControlMode Control Mode [-] + * @param valid Data valid [-] + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_fw_soaring_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint64_t timestampModeChanged, float xW, float xR, float xLat, float xLon, float VarW, float VarR, float VarLat, float VarLon, float LoiterRadius, float LoiterDirection, float DistToSoarPoint, float vSinkExp, float z1_LocalUpdraftSpeed, float z2_DeltaRoll, float z1_exp, float z2_exp, float ThermalGSNorth, float ThermalGSEast, float TSE_dot, float DebugVar1, float DebugVar2, uint8_t ControlMode, uint8_t valid) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FW_SOARING_DATA_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint64_t(buf, 8, timestampModeChanged); + _mav_put_float(buf, 16, xW); + _mav_put_float(buf, 20, xR); + _mav_put_float(buf, 24, xLat); + _mav_put_float(buf, 28, xLon); + _mav_put_float(buf, 32, VarW); + _mav_put_float(buf, 36, VarR); + _mav_put_float(buf, 40, VarLat); + _mav_put_float(buf, 44, VarLon); + _mav_put_float(buf, 48, LoiterRadius); + _mav_put_float(buf, 52, LoiterDirection); + _mav_put_float(buf, 56, DistToSoarPoint); + _mav_put_float(buf, 60, vSinkExp); + _mav_put_float(buf, 64, z1_LocalUpdraftSpeed); + _mav_put_float(buf, 68, z2_DeltaRoll); + _mav_put_float(buf, 72, z1_exp); + _mav_put_float(buf, 76, z2_exp); + _mav_put_float(buf, 80, ThermalGSNorth); + _mav_put_float(buf, 84, ThermalGSEast); + _mav_put_float(buf, 88, TSE_dot); + _mav_put_float(buf, 92, DebugVar1); + _mav_put_float(buf, 96, DebugVar2); + _mav_put_uint8_t(buf, 100, ControlMode); + _mav_put_uint8_t(buf, 101, valid); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FW_SOARING_DATA_LEN); +#else + mavlink_fw_soaring_data_t packet; + packet.timestamp = timestamp; + packet.timestampModeChanged = timestampModeChanged; + packet.xW = xW; + packet.xR = xR; + packet.xLat = xLat; + packet.xLon = xLon; + packet.VarW = VarW; + packet.VarR = VarR; + packet.VarLat = VarLat; + packet.VarLon = VarLon; + packet.LoiterRadius = LoiterRadius; + packet.LoiterDirection = LoiterDirection; + packet.DistToSoarPoint = DistToSoarPoint; + packet.vSinkExp = vSinkExp; + packet.z1_LocalUpdraftSpeed = z1_LocalUpdraftSpeed; + packet.z2_DeltaRoll = z2_DeltaRoll; + packet.z1_exp = z1_exp; + packet.z2_exp = z2_exp; + packet.ThermalGSNorth = ThermalGSNorth; + packet.ThermalGSEast = ThermalGSEast; + packet.TSE_dot = TSE_dot; + packet.DebugVar1 = DebugVar1; + packet.DebugVar2 = DebugVar2; + packet.ControlMode = ControlMode; + packet.valid = valid; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FW_SOARING_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FW_SOARING_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FW_SOARING_DATA_MIN_LEN, MAVLINK_MSG_ID_FW_SOARING_DATA_LEN, MAVLINK_MSG_ID_FW_SOARING_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FW_SOARING_DATA_MIN_LEN, MAVLINK_MSG_ID_FW_SOARING_DATA_LEN); +#endif +} + /** * @brief Pack a fw_soaring_data message on a channel * @param system_id ID of this system @@ -335,6 +440,20 @@ static inline uint16_t mavlink_msg_fw_soaring_data_encode_chan(uint8_t system_id return mavlink_msg_fw_soaring_data_pack_chan(system_id, component_id, chan, msg, fw_soaring_data->timestamp, fw_soaring_data->timestampModeChanged, fw_soaring_data->xW, fw_soaring_data->xR, fw_soaring_data->xLat, fw_soaring_data->xLon, fw_soaring_data->VarW, fw_soaring_data->VarR, fw_soaring_data->VarLat, fw_soaring_data->VarLon, fw_soaring_data->LoiterRadius, fw_soaring_data->LoiterDirection, fw_soaring_data->DistToSoarPoint, fw_soaring_data->vSinkExp, fw_soaring_data->z1_LocalUpdraftSpeed, fw_soaring_data->z2_DeltaRoll, fw_soaring_data->z1_exp, fw_soaring_data->z2_exp, fw_soaring_data->ThermalGSNorth, fw_soaring_data->ThermalGSEast, fw_soaring_data->TSE_dot, fw_soaring_data->DebugVar1, fw_soaring_data->DebugVar2, fw_soaring_data->ControlMode, fw_soaring_data->valid); } +/** + * @brief Encode a fw_soaring_data struct with provided status structure + * + * @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 fw_soaring_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_fw_soaring_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_fw_soaring_data_t* fw_soaring_data) +{ + return mavlink_msg_fw_soaring_data_pack_status(system_id, component_id, _status, msg, fw_soaring_data->timestamp, fw_soaring_data->timestampModeChanged, fw_soaring_data->xW, fw_soaring_data->xR, fw_soaring_data->xLat, fw_soaring_data->xLon, fw_soaring_data->VarW, fw_soaring_data->VarR, fw_soaring_data->VarLat, fw_soaring_data->VarLon, fw_soaring_data->LoiterRadius, fw_soaring_data->LoiterDirection, fw_soaring_data->DistToSoarPoint, fw_soaring_data->vSinkExp, fw_soaring_data->z1_LocalUpdraftSpeed, fw_soaring_data->z2_DeltaRoll, fw_soaring_data->z1_exp, fw_soaring_data->z2_exp, fw_soaring_data->ThermalGSNorth, fw_soaring_data->ThermalGSEast, fw_soaring_data->TSE_dot, fw_soaring_data->DebugVar1, fw_soaring_data->DebugVar2, fw_soaring_data->ControlMode, fw_soaring_data->valid); +} + /** * @brief Send a fw_soaring_data message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_gsm_link_status.h b/ASLUAV/mavlink_msg_gsm_link_status.h index eff27054..bd2a948d 100644 --- a/ASLUAV/mavlink_msg_gsm_link_status.h +++ b/ASLUAV/mavlink_msg_gsm_link_status.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_gsm_link_status_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GSM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN, MAVLINK_MSG_ID_GSM_LINK_STATUS_CRC); } +/** + * @brief Pack a gsm_link_status 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 timestamp [us] Timestamp (of OBC) + * @param gsm_modem_type GSM modem used + * @param gsm_link_type GSM link type + * @param rssi RSSI as reported by modem (unconverted) + * @param rsrp_rscp RSRP (LTE) or RSCP (WCDMA) as reported by modem (unconverted) + * @param sinr_ecio SINR (LTE) or ECIO (WCDMA) as reported by modem (unconverted) + * @param rsrq RSRQ (LTE only) as reported by modem (unconverted) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gsm_link_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t gsm_modem_type, uint8_t gsm_link_type, uint8_t rssi, uint8_t rsrp_rscp, uint8_t sinr_ecio, uint8_t rsrq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint8_t(buf, 8, gsm_modem_type); + _mav_put_uint8_t(buf, 9, gsm_link_type); + _mav_put_uint8_t(buf, 10, rssi); + _mav_put_uint8_t(buf, 11, rsrp_rscp); + _mav_put_uint8_t(buf, 12, sinr_ecio); + _mav_put_uint8_t(buf, 13, rsrq); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN); +#else + mavlink_gsm_link_status_t packet; + packet.timestamp = timestamp; + packet.gsm_modem_type = gsm_modem_type; + packet.gsm_link_type = gsm_link_type; + packet.rssi = rssi; + packet.rsrp_rscp = rsrp_rscp; + packet.sinr_ecio = sinr_ecio; + packet.rsrq = rsrq; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GSM_LINK_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GSM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN, MAVLINK_MSG_ID_GSM_LINK_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GSM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_GSM_LINK_STATUS_LEN); +#endif +} + /** * @brief Pack a gsm_link_status message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_gsm_link_status_encode_chan(uint8_t system_id return mavlink_msg_gsm_link_status_pack_chan(system_id, component_id, chan, msg, gsm_link_status->timestamp, gsm_link_status->gsm_modem_type, gsm_link_status->gsm_link_type, gsm_link_status->rssi, gsm_link_status->rsrp_rscp, gsm_link_status->sinr_ecio, gsm_link_status->rsrq); } +/** + * @brief Encode a gsm_link_status struct with provided status structure + * + * @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 gsm_link_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gsm_link_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gsm_link_status_t* gsm_link_status) +{ + return mavlink_msg_gsm_link_status_pack_status(system_id, component_id, _status, msg, gsm_link_status->timestamp, gsm_link_status->gsm_modem_type, gsm_link_status->gsm_link_type, gsm_link_status->rssi, gsm_link_status->rsrp_rscp, gsm_link_status->sinr_ecio, gsm_link_status->rsrq); +} + /** * @brief Send a gsm_link_status message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_satcom_link_status.h b/ASLUAV/mavlink_msg_satcom_link_status.h index f5422322..931050f7 100644 --- a/ASLUAV/mavlink_msg_satcom_link_status.h +++ b/ASLUAV/mavlink_msg_satcom_link_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_satcom_link_status_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_CRC); } +/** + * @brief Pack a satcom_link_status 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 timestamp [us] Timestamp + * @param last_heartbeat [us] Timestamp of the last successful sbd session + * @param failed_sessions Number of failed sessions + * @param successful_sessions Number of successful sessions + * @param signal_quality Signal quality + * @param ring_pending Ring call pending + * @param tx_session_pending Transmission session pending + * @param rx_session_pending Receiving session pending + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_satcom_link_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint64_t last_heartbeat, uint16_t failed_sessions, uint16_t successful_sessions, uint8_t signal_quality, uint8_t ring_pending, uint8_t tx_session_pending, uint8_t rx_session_pending) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint64_t(buf, 8, last_heartbeat); + _mav_put_uint16_t(buf, 16, failed_sessions); + _mav_put_uint16_t(buf, 18, successful_sessions); + _mav_put_uint8_t(buf, 20, signal_quality); + _mav_put_uint8_t(buf, 21, ring_pending); + _mav_put_uint8_t(buf, 22, tx_session_pending); + _mav_put_uint8_t(buf, 23, rx_session_pending); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN); +#else + mavlink_satcom_link_status_t packet; + packet.timestamp = timestamp; + packet.last_heartbeat = last_heartbeat; + packet.failed_sessions = failed_sessions; + packet.successful_sessions = successful_sessions; + packet.signal_quality = signal_quality; + packet.ring_pending = ring_pending; + packet.tx_session_pending = tx_session_pending; + packet.rx_session_pending = rx_session_pending; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SATCOM_LINK_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_SATCOM_LINK_STATUS_LEN); +#endif +} + /** * @brief Pack a satcom_link_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_satcom_link_status_encode_chan(uint8_t system return mavlink_msg_satcom_link_status_pack_chan(system_id, component_id, chan, msg, satcom_link_status->timestamp, satcom_link_status->last_heartbeat, satcom_link_status->failed_sessions, satcom_link_status->successful_sessions, satcom_link_status->signal_quality, satcom_link_status->ring_pending, satcom_link_status->tx_session_pending, satcom_link_status->rx_session_pending); } +/** + * @brief Encode a satcom_link_status struct with provided status structure + * + * @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 satcom_link_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_satcom_link_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_satcom_link_status_t* satcom_link_status) +{ + return mavlink_msg_satcom_link_status_pack_status(system_id, component_id, _status, msg, satcom_link_status->timestamp, satcom_link_status->last_heartbeat, satcom_link_status->failed_sessions, satcom_link_status->successful_sessions, satcom_link_status->signal_quality, satcom_link_status->ring_pending, satcom_link_status->tx_session_pending, satcom_link_status->rx_session_pending); +} + /** * @brief Send a satcom_link_status message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sens_atmos.h b/ASLUAV/mavlink_msg_sens_atmos.h index 5cd205b5..98409804 100644 --- a/ASLUAV/mavlink_msg_sens_atmos.h +++ b/ASLUAV/mavlink_msg_sens_atmos.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_sens_atmos_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_ATMOS_MIN_LEN, MAVLINK_MSG_ID_SENS_ATMOS_LEN, MAVLINK_MSG_ID_SENS_ATMOS_CRC); } +/** + * @brief Pack a sens_atmos 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 timestamp [us] Time since system boot + * @param TempAmbient [degC] Ambient temperature + * @param Humidity [%] Relative humidity + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sens_atmos_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, float TempAmbient, float Humidity) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENS_ATMOS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, TempAmbient); + _mav_put_float(buf, 12, Humidity); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_ATMOS_LEN); +#else + mavlink_sens_atmos_t packet; + packet.timestamp = timestamp; + packet.TempAmbient = TempAmbient; + packet.Humidity = Humidity; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_ATMOS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENS_ATMOS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_ATMOS_MIN_LEN, MAVLINK_MSG_ID_SENS_ATMOS_LEN, MAVLINK_MSG_ID_SENS_ATMOS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_ATMOS_MIN_LEN, MAVLINK_MSG_ID_SENS_ATMOS_LEN); +#endif +} + /** * @brief Pack a sens_atmos message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_sens_atmos_encode_chan(uint8_t system_id, uin return mavlink_msg_sens_atmos_pack_chan(system_id, component_id, chan, msg, sens_atmos->timestamp, sens_atmos->TempAmbient, sens_atmos->Humidity); } +/** + * @brief Encode a sens_atmos struct with provided status structure + * + * @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 sens_atmos C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sens_atmos_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sens_atmos_t* sens_atmos) +{ + return mavlink_msg_sens_atmos_pack_status(system_id, component_id, _status, msg, sens_atmos->timestamp, sens_atmos->TempAmbient, sens_atmos->Humidity); +} + /** * @brief Send a sens_atmos message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sens_batmon.h b/ASLUAV/mavlink_msg_sens_batmon.h index 6fe4ec62..2fc8e3a8 100644 --- a/ASLUAV/mavlink_msg_sens_batmon.h +++ b/ASLUAV/mavlink_msg_sens_batmon.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_sens_batmon_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_BATMON_MIN_LEN, MAVLINK_MSG_ID_SENS_BATMON_LEN, MAVLINK_MSG_ID_SENS_BATMON_CRC); } +/** + * @brief Pack a sens_batmon 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 batmon_timestamp [us] Time since system start + * @param temperature [degC] Battery pack temperature + * @param voltage [mV] Battery pack voltage + * @param current [mA] Battery pack current + * @param SoC Battery pack state-of-charge + * @param batterystatus Battery monitor status report bits in Hex + * @param serialnumber Battery monitor serial number in Hex + * @param safetystatus Battery monitor safetystatus report bits in Hex + * @param operationstatus Battery monitor operation status report bits in Hex + * @param cellvoltage1 [mV] Battery pack cell 1 voltage + * @param cellvoltage2 [mV] Battery pack cell 2 voltage + * @param cellvoltage3 [mV] Battery pack cell 3 voltage + * @param cellvoltage4 [mV] Battery pack cell 4 voltage + * @param cellvoltage5 [mV] Battery pack cell 5 voltage + * @param cellvoltage6 [mV] Battery pack cell 6 voltage + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sens_batmon_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t batmon_timestamp, float temperature, uint16_t voltage, int16_t current, uint8_t SoC, uint16_t batterystatus, uint16_t serialnumber, uint32_t safetystatus, uint32_t operationstatus, uint16_t cellvoltage1, uint16_t cellvoltage2, uint16_t cellvoltage3, uint16_t cellvoltage4, uint16_t cellvoltage5, uint16_t cellvoltage6) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENS_BATMON_LEN]; + _mav_put_uint64_t(buf, 0, batmon_timestamp); + _mav_put_float(buf, 8, temperature); + _mav_put_uint32_t(buf, 12, safetystatus); + _mav_put_uint32_t(buf, 16, operationstatus); + _mav_put_uint16_t(buf, 20, voltage); + _mav_put_int16_t(buf, 22, current); + _mav_put_uint16_t(buf, 24, batterystatus); + _mav_put_uint16_t(buf, 26, serialnumber); + _mav_put_uint16_t(buf, 28, cellvoltage1); + _mav_put_uint16_t(buf, 30, cellvoltage2); + _mav_put_uint16_t(buf, 32, cellvoltage3); + _mav_put_uint16_t(buf, 34, cellvoltage4); + _mav_put_uint16_t(buf, 36, cellvoltage5); + _mav_put_uint16_t(buf, 38, cellvoltage6); + _mav_put_uint8_t(buf, 40, SoC); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_BATMON_LEN); +#else + mavlink_sens_batmon_t packet; + packet.batmon_timestamp = batmon_timestamp; + packet.temperature = temperature; + packet.safetystatus = safetystatus; + packet.operationstatus = operationstatus; + packet.voltage = voltage; + packet.current = current; + packet.batterystatus = batterystatus; + packet.serialnumber = serialnumber; + packet.cellvoltage1 = cellvoltage1; + packet.cellvoltage2 = cellvoltage2; + packet.cellvoltage3 = cellvoltage3; + packet.cellvoltage4 = cellvoltage4; + packet.cellvoltage5 = cellvoltage5; + packet.cellvoltage6 = cellvoltage6; + packet.SoC = SoC; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_BATMON_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENS_BATMON; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_BATMON_MIN_LEN, MAVLINK_MSG_ID_SENS_BATMON_LEN, MAVLINK_MSG_ID_SENS_BATMON_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_BATMON_MIN_LEN, MAVLINK_MSG_ID_SENS_BATMON_LEN); +#endif +} + /** * @brief Pack a sens_batmon message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_sens_batmon_encode_chan(uint8_t system_id, ui return mavlink_msg_sens_batmon_pack_chan(system_id, component_id, chan, msg, sens_batmon->batmon_timestamp, sens_batmon->temperature, sens_batmon->voltage, sens_batmon->current, sens_batmon->SoC, sens_batmon->batterystatus, sens_batmon->serialnumber, sens_batmon->safetystatus, sens_batmon->operationstatus, sens_batmon->cellvoltage1, sens_batmon->cellvoltage2, sens_batmon->cellvoltage3, sens_batmon->cellvoltage4, sens_batmon->cellvoltage5, sens_batmon->cellvoltage6); } +/** + * @brief Encode a sens_batmon struct with provided status structure + * + * @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 sens_batmon C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sens_batmon_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sens_batmon_t* sens_batmon) +{ + return mavlink_msg_sens_batmon_pack_status(system_id, component_id, _status, msg, sens_batmon->batmon_timestamp, sens_batmon->temperature, sens_batmon->voltage, sens_batmon->current, sens_batmon->SoC, sens_batmon->batterystatus, sens_batmon->serialnumber, sens_batmon->safetystatus, sens_batmon->operationstatus, sens_batmon->cellvoltage1, sens_batmon->cellvoltage2, sens_batmon->cellvoltage3, sens_batmon->cellvoltage4, sens_batmon->cellvoltage5, sens_batmon->cellvoltage6); +} + /** * @brief Send a sens_batmon message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sens_mppt.h b/ASLUAV/mavlink_msg_sens_mppt.h index 4fe51c5c..dd529008 100644 --- a/ASLUAV/mavlink_msg_sens_mppt.h +++ b/ASLUAV/mavlink_msg_sens_mppt.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_sens_mppt_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_MPPT_MIN_LEN, MAVLINK_MSG_ID_SENS_MPPT_LEN, MAVLINK_MSG_ID_SENS_MPPT_CRC); } +/** + * @brief Pack a sens_mppt 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 mppt_timestamp [us] MPPT last timestamp + * @param mppt1_volt [V] MPPT1 voltage + * @param mppt1_amp [A] MPPT1 current + * @param mppt1_pwm [us] MPPT1 pwm + * @param mppt1_status MPPT1 status + * @param mppt2_volt [V] MPPT2 voltage + * @param mppt2_amp [A] MPPT2 current + * @param mppt2_pwm [us] MPPT2 pwm + * @param mppt2_status MPPT2 status + * @param mppt3_volt [V] MPPT3 voltage + * @param mppt3_amp [A] MPPT3 current + * @param mppt3_pwm [us] MPPT3 pwm + * @param mppt3_status MPPT3 status + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sens_mppt_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t mppt_timestamp, float mppt1_volt, float mppt1_amp, uint16_t mppt1_pwm, uint8_t mppt1_status, float mppt2_volt, float mppt2_amp, uint16_t mppt2_pwm, uint8_t mppt2_status, float mppt3_volt, float mppt3_amp, uint16_t mppt3_pwm, uint8_t mppt3_status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENS_MPPT_LEN]; + _mav_put_uint64_t(buf, 0, mppt_timestamp); + _mav_put_float(buf, 8, mppt1_volt); + _mav_put_float(buf, 12, mppt1_amp); + _mav_put_float(buf, 16, mppt2_volt); + _mav_put_float(buf, 20, mppt2_amp); + _mav_put_float(buf, 24, mppt3_volt); + _mav_put_float(buf, 28, mppt3_amp); + _mav_put_uint16_t(buf, 32, mppt1_pwm); + _mav_put_uint16_t(buf, 34, mppt2_pwm); + _mav_put_uint16_t(buf, 36, mppt3_pwm); + _mav_put_uint8_t(buf, 38, mppt1_status); + _mav_put_uint8_t(buf, 39, mppt2_status); + _mav_put_uint8_t(buf, 40, mppt3_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_MPPT_LEN); +#else + mavlink_sens_mppt_t packet; + packet.mppt_timestamp = mppt_timestamp; + packet.mppt1_volt = mppt1_volt; + packet.mppt1_amp = mppt1_amp; + packet.mppt2_volt = mppt2_volt; + packet.mppt2_amp = mppt2_amp; + packet.mppt3_volt = mppt3_volt; + packet.mppt3_amp = mppt3_amp; + packet.mppt1_pwm = mppt1_pwm; + packet.mppt2_pwm = mppt2_pwm; + packet.mppt3_pwm = mppt3_pwm; + packet.mppt1_status = mppt1_status; + packet.mppt2_status = mppt2_status; + packet.mppt3_status = mppt3_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_MPPT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENS_MPPT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_MPPT_MIN_LEN, MAVLINK_MSG_ID_SENS_MPPT_LEN, MAVLINK_MSG_ID_SENS_MPPT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_MPPT_MIN_LEN, MAVLINK_MSG_ID_SENS_MPPT_LEN); +#endif +} + /** * @brief Pack a sens_mppt message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_sens_mppt_encode_chan(uint8_t system_id, uint return mavlink_msg_sens_mppt_pack_chan(system_id, component_id, chan, msg, sens_mppt->mppt_timestamp, sens_mppt->mppt1_volt, sens_mppt->mppt1_amp, sens_mppt->mppt1_pwm, sens_mppt->mppt1_status, sens_mppt->mppt2_volt, sens_mppt->mppt2_amp, sens_mppt->mppt2_pwm, sens_mppt->mppt2_status, sens_mppt->mppt3_volt, sens_mppt->mppt3_amp, sens_mppt->mppt3_pwm, sens_mppt->mppt3_status); } +/** + * @brief Encode a sens_mppt struct with provided status structure + * + * @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 sens_mppt C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sens_mppt_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sens_mppt_t* sens_mppt) +{ + return mavlink_msg_sens_mppt_pack_status(system_id, component_id, _status, msg, sens_mppt->mppt_timestamp, sens_mppt->mppt1_volt, sens_mppt->mppt1_amp, sens_mppt->mppt1_pwm, sens_mppt->mppt1_status, sens_mppt->mppt2_volt, sens_mppt->mppt2_amp, sens_mppt->mppt2_pwm, sens_mppt->mppt2_status, sens_mppt->mppt3_volt, sens_mppt->mppt3_amp, sens_mppt->mppt3_pwm, sens_mppt->mppt3_status); +} + /** * @brief Send a sens_mppt message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sens_power.h b/ASLUAV/mavlink_msg_sens_power.h index 0b8ef5a5..b5625c29 100644 --- a/ASLUAV/mavlink_msg_sens_power.h +++ b/ASLUAV/mavlink_msg_sens_power.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_sens_power_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC); } +/** + * @brief Pack a sens_power 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 adc121_vspb_volt [V] Power board voltage sensor reading + * @param adc121_cspb_amp [A] Power board current sensor reading + * @param adc121_cs1_amp [A] Board current sensor 1 reading + * @param adc121_cs2_amp [A] Board current sensor 2 reading + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sens_power_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float adc121_vspb_volt, float adc121_cspb_amp, float adc121_cs1_amp, float adc121_cs2_amp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENS_POWER_LEN]; + _mav_put_float(buf, 0, adc121_vspb_volt); + _mav_put_float(buf, 4, adc121_cspb_amp); + _mav_put_float(buf, 8, adc121_cs1_amp); + _mav_put_float(buf, 12, adc121_cs2_amp); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_POWER_LEN); +#else + mavlink_sens_power_t packet; + packet.adc121_vspb_volt = adc121_vspb_volt; + packet.adc121_cspb_amp = adc121_cspb_amp; + packet.adc121_cs1_amp = adc121_cs1_amp; + packet.adc121_cs2_amp = adc121_cs2_amp; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_POWER_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENS_POWER; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN); +#endif +} + /** * @brief Pack a sens_power message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_sens_power_encode_chan(uint8_t system_id, uin return mavlink_msg_sens_power_pack_chan(system_id, component_id, chan, msg, sens_power->adc121_vspb_volt, sens_power->adc121_cspb_amp, sens_power->adc121_cs1_amp, sens_power->adc121_cs2_amp); } +/** + * @brief Encode a sens_power struct with provided status structure + * + * @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 sens_power C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sens_power_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sens_power_t* sens_power) +{ + return mavlink_msg_sens_power_pack_status(system_id, component_id, _status, msg, sens_power->adc121_vspb_volt, sens_power->adc121_cspb_amp, sens_power->adc121_cs1_amp, sens_power->adc121_cs2_amp); +} + /** * @brief Send a sens_power message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sens_power_board.h b/ASLUAV/mavlink_msg_sens_power_board.h index 7f20b906..eb630d18 100644 --- a/ASLUAV/mavlink_msg_sens_power_board.h +++ b/ASLUAV/mavlink_msg_sens_power_board.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_sens_power_board_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_POWER_BOARD_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN, MAVLINK_MSG_ID_SENS_POWER_BOARD_CRC); } +/** + * @brief Pack a sens_power_board 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 timestamp [us] Timestamp + * @param pwr_brd_status Power board status register + * @param pwr_brd_led_status Power board leds status + * @param pwr_brd_system_volt [V] Power board system voltage + * @param pwr_brd_servo_volt [V] Power board servo voltage + * @param pwr_brd_digital_volt [V] Power board digital voltage + * @param pwr_brd_mot_l_amp [A] Power board left motor current sensor + * @param pwr_brd_mot_r_amp [A] Power board right motor current sensor + * @param pwr_brd_analog_amp [A] Power board analog current sensor + * @param pwr_brd_digital_amp [A] Power board digital current sensor + * @param pwr_brd_ext_amp [A] Power board extension current sensor + * @param pwr_brd_aux_amp [A] Power board aux current sensor + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sens_power_board_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t pwr_brd_status, uint8_t pwr_brd_led_status, float pwr_brd_system_volt, float pwr_brd_servo_volt, float pwr_brd_digital_volt, float pwr_brd_mot_l_amp, float pwr_brd_mot_r_amp, float pwr_brd_analog_amp, float pwr_brd_digital_amp, float pwr_brd_ext_amp, float pwr_brd_aux_amp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, pwr_brd_system_volt); + _mav_put_float(buf, 12, pwr_brd_servo_volt); + _mav_put_float(buf, 16, pwr_brd_digital_volt); + _mav_put_float(buf, 20, pwr_brd_mot_l_amp); + _mav_put_float(buf, 24, pwr_brd_mot_r_amp); + _mav_put_float(buf, 28, pwr_brd_analog_amp); + _mav_put_float(buf, 32, pwr_brd_digital_amp); + _mav_put_float(buf, 36, pwr_brd_ext_amp); + _mav_put_float(buf, 40, pwr_brd_aux_amp); + _mav_put_uint8_t(buf, 44, pwr_brd_status); + _mav_put_uint8_t(buf, 45, pwr_brd_led_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN); +#else + mavlink_sens_power_board_t packet; + packet.timestamp = timestamp; + packet.pwr_brd_system_volt = pwr_brd_system_volt; + packet.pwr_brd_servo_volt = pwr_brd_servo_volt; + packet.pwr_brd_digital_volt = pwr_brd_digital_volt; + packet.pwr_brd_mot_l_amp = pwr_brd_mot_l_amp; + packet.pwr_brd_mot_r_amp = pwr_brd_mot_r_amp; + packet.pwr_brd_analog_amp = pwr_brd_analog_amp; + packet.pwr_brd_digital_amp = pwr_brd_digital_amp; + packet.pwr_brd_ext_amp = pwr_brd_ext_amp; + packet.pwr_brd_aux_amp = pwr_brd_aux_amp; + packet.pwr_brd_status = pwr_brd_status; + packet.pwr_brd_led_status = pwr_brd_led_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENS_POWER_BOARD; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_POWER_BOARD_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN, MAVLINK_MSG_ID_SENS_POWER_BOARD_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENS_POWER_BOARD_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_BOARD_LEN); +#endif +} + /** * @brief Pack a sens_power_board message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_sens_power_board_encode_chan(uint8_t system_i return mavlink_msg_sens_power_board_pack_chan(system_id, component_id, chan, msg, sens_power_board->timestamp, sens_power_board->pwr_brd_status, sens_power_board->pwr_brd_led_status, sens_power_board->pwr_brd_system_volt, sens_power_board->pwr_brd_servo_volt, sens_power_board->pwr_brd_digital_volt, sens_power_board->pwr_brd_mot_l_amp, sens_power_board->pwr_brd_mot_r_amp, sens_power_board->pwr_brd_analog_amp, sens_power_board->pwr_brd_digital_amp, sens_power_board->pwr_brd_ext_amp, sens_power_board->pwr_brd_aux_amp); } +/** + * @brief Encode a sens_power_board struct with provided status structure + * + * @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 sens_power_board C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sens_power_board_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sens_power_board_t* sens_power_board) +{ + return mavlink_msg_sens_power_board_pack_status(system_id, component_id, _status, msg, sens_power_board->timestamp, sens_power_board->pwr_brd_status, sens_power_board->pwr_brd_led_status, sens_power_board->pwr_brd_system_volt, sens_power_board->pwr_brd_servo_volt, sens_power_board->pwr_brd_digital_volt, sens_power_board->pwr_brd_mot_l_amp, sens_power_board->pwr_brd_mot_r_amp, sens_power_board->pwr_brd_analog_amp, sens_power_board->pwr_brd_digital_amp, sens_power_board->pwr_brd_ext_amp, sens_power_board->pwr_brd_aux_amp); +} + /** * @brief Send a sens_power_board message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sensor_airflow_angles.h b/ASLUAV/mavlink_msg_sensor_airflow_angles.h index ac997a14..77fcb893 100644 --- a/ASLUAV/mavlink_msg_sensor_airflow_angles.h +++ b/ASLUAV/mavlink_msg_sensor_airflow_angles.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_sensor_airflow_angles_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_MIN_LEN, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_CRC); } +/** + * @brief Pack a sensor_airflow_angles 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 timestamp [us] Timestamp + * @param angleofattack [deg] Angle of attack + * @param angleofattack_valid Angle of attack measurement valid + * @param sideslip [deg] Sideslip angle + * @param sideslip_valid Sideslip angle measurement valid + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sensor_airflow_angles_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, float angleofattack, uint8_t angleofattack_valid, float sideslip, uint8_t sideslip_valid) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, angleofattack); + _mav_put_float(buf, 12, sideslip); + _mav_put_uint8_t(buf, 16, angleofattack_valid); + _mav_put_uint8_t(buf, 17, sideslip_valid); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN); +#else + mavlink_sensor_airflow_angles_t packet; + packet.timestamp = timestamp; + packet.angleofattack = angleofattack; + packet.sideslip = sideslip; + packet.angleofattack_valid = angleofattack_valid; + packet.sideslip_valid = sideslip_valid; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_MIN_LEN, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_MIN_LEN, MAVLINK_MSG_ID_SENSOR_AIRFLOW_ANGLES_LEN); +#endif +} + /** * @brief Pack a sensor_airflow_angles message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_sensor_airflow_angles_encode_chan(uint8_t sys return mavlink_msg_sensor_airflow_angles_pack_chan(system_id, component_id, chan, msg, sensor_airflow_angles->timestamp, sensor_airflow_angles->angleofattack, sensor_airflow_angles->angleofattack_valid, sensor_airflow_angles->sideslip, sensor_airflow_angles->sideslip_valid); } +/** + * @brief Encode a sensor_airflow_angles struct with provided status structure + * + * @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 sensor_airflow_angles C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sensor_airflow_angles_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sensor_airflow_angles_t* sensor_airflow_angles) +{ + return mavlink_msg_sensor_airflow_angles_pack_status(system_id, component_id, _status, msg, sensor_airflow_angles->timestamp, sensor_airflow_angles->angleofattack, sensor_airflow_angles->angleofattack_valid, sensor_airflow_angles->sideslip, sensor_airflow_angles->sideslip_valid); +} + /** * @brief Send a sensor_airflow_angles message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/mavlink_msg_sensorpod_status.h b/ASLUAV/mavlink_msg_sensorpod_status.h index aa6b9039..1432be2a 100644 --- a/ASLUAV/mavlink_msg_sensorpod_status.h +++ b/ASLUAV/mavlink_msg_sensorpod_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_sensorpod_status_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSORPOD_STATUS_MIN_LEN, MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN, MAVLINK_MSG_ID_SENSORPOD_STATUS_CRC); } +/** + * @brief Pack a sensorpod_status 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 timestamp [ms] Timestamp in linuxtime (since 1.1.1970) + * @param visensor_rate_1 Rate of ROS topic 1 + * @param visensor_rate_2 Rate of ROS topic 2 + * @param visensor_rate_3 Rate of ROS topic 3 + * @param visensor_rate_4 Rate of ROS topic 4 + * @param recording_nodes_count Number of recording nodes + * @param cpu_temp [degC] Temperature of sensorpod CPU in + * @param free_space Free space available in recordings directory in [Gb] * 1e2 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sensorpod_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t visensor_rate_1, uint8_t visensor_rate_2, uint8_t visensor_rate_3, uint8_t visensor_rate_4, uint8_t recording_nodes_count, uint8_t cpu_temp, uint16_t free_space) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint16_t(buf, 8, free_space); + _mav_put_uint8_t(buf, 10, visensor_rate_1); + _mav_put_uint8_t(buf, 11, visensor_rate_2); + _mav_put_uint8_t(buf, 12, visensor_rate_3); + _mav_put_uint8_t(buf, 13, visensor_rate_4); + _mav_put_uint8_t(buf, 14, recording_nodes_count); + _mav_put_uint8_t(buf, 15, cpu_temp); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN); +#else + mavlink_sensorpod_status_t packet; + packet.timestamp = timestamp; + packet.free_space = free_space; + packet.visensor_rate_1 = visensor_rate_1; + packet.visensor_rate_2 = visensor_rate_2; + packet.visensor_rate_3 = visensor_rate_3; + packet.visensor_rate_4 = visensor_rate_4; + packet.recording_nodes_count = recording_nodes_count; + packet.cpu_temp = cpu_temp; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENSORPOD_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSORPOD_STATUS_MIN_LEN, MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN, MAVLINK_MSG_ID_SENSORPOD_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSORPOD_STATUS_MIN_LEN, MAVLINK_MSG_ID_SENSORPOD_STATUS_LEN); +#endif +} + /** * @brief Pack a sensorpod_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_sensorpod_status_encode_chan(uint8_t system_i return mavlink_msg_sensorpod_status_pack_chan(system_id, component_id, chan, msg, sensorpod_status->timestamp, sensorpod_status->visensor_rate_1, sensorpod_status->visensor_rate_2, sensorpod_status->visensor_rate_3, sensorpod_status->visensor_rate_4, sensorpod_status->recording_nodes_count, sensorpod_status->cpu_temp, sensorpod_status->free_space); } +/** + * @brief Encode a sensorpod_status struct with provided status structure + * + * @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 sensorpod_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sensorpod_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sensorpod_status_t* sensorpod_status) +{ + return mavlink_msg_sensorpod_status_pack_status(system_id, component_id, _status, msg, sensorpod_status->timestamp, sensorpod_status->visensor_rate_1, sensorpod_status->visensor_rate_2, sensorpod_status->visensor_rate_3, sensorpod_status->visensor_rate_4, sensorpod_status->recording_nodes_count, sensorpod_status->cpu_temp, sensorpod_status->free_space); +} + /** * @brief Send a sensorpod_status message * @param chan MAVLink channel to send the message diff --git a/ASLUAV/version.h b/ASLUAV/version.h index bd816484..a73431bb 100644 --- a/ASLUAV/version.h +++ b/ASLUAV/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/AVSSUAS/AVSSUAS.h b/AVSSUAS/AVSSUAS.h index 798a5611..ae6e4580 100644 --- a/AVSSUAS/AVSSUAS.h +++ b/AVSSUAS/AVSSUAS.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_AVSSUAS.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_AVSSUAS_XML_HASH -2785841859254114697 +#define MAVLINK_AVSSUAS_XML_HASH 6850650851455588663 #ifdef __cplusplus extern "C" { diff --git a/AVSSUAS/mavlink.h b/AVSSUAS/mavlink.h index a195c425..8a16ed7e 100644 --- a/AVSSUAS/mavlink.h +++ b/AVSSUAS/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -2785841859254114697 +#define MAVLINK_PRIMARY_XML_HASH 6850650851455588663 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/AVSSUAS/mavlink_msg_avss_drone_imu.h b/AVSSUAS/mavlink_msg_avss_drone_imu.h index 750e9b89..1fae7a17 100644 --- a/AVSSUAS/mavlink_msg_avss_drone_imu.h +++ b/AVSSUAS/mavlink_msg_avss_drone_imu.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_avss_drone_imu_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVSS_DRONE_IMU_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN, MAVLINK_MSG_ID_AVSS_DRONE_IMU_CRC); } +/** + * @brief Pack a avss_drone_imu 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 time_boot_ms [ms] Timestamp (time since FC boot). + * @param q1 Quaternion component 1, w (1 in null-rotation) + * @param q2 Quaternion component 2, x (0 in null-rotation) + * @param q3 Quaternion component 3, y (0 in null-rotation) + * @param q4 Quaternion component 4, z (0 in null-rotation) + * @param xacc [m/s/s] X acceleration + * @param yacc [m/s/s] Y acceleration + * @param zacc [m/s/s] Z acceleration + * @param xgyro [rad/s] Angular speed around X axis + * @param ygyro [rad/s] Angular speed around Y axis + * @param zgyro [rad/s] Angular speed around Z axis + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_avss_drone_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, q1); + _mav_put_float(buf, 8, q2); + _mav_put_float(buf, 12, q3); + _mav_put_float(buf, 16, q4); + _mav_put_float(buf, 20, xacc); + _mav_put_float(buf, 24, yacc); + _mav_put_float(buf, 28, zacc); + _mav_put_float(buf, 32, xgyro); + _mav_put_float(buf, 36, ygyro); + _mav_put_float(buf, 40, zgyro); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN); +#else + mavlink_avss_drone_imu_t packet; + packet.time_boot_ms = time_boot_ms; + packet.q1 = q1; + packet.q2 = q2; + packet.q3 = q3; + packet.q4 = q4; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVSS_DRONE_IMU; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_IMU_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN, MAVLINK_MSG_ID_AVSS_DRONE_IMU_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_IMU_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_IMU_LEN); +#endif +} + /** * @brief Pack a avss_drone_imu message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_avss_drone_imu_encode_chan(uint8_t system_id, return mavlink_msg_avss_drone_imu_pack_chan(system_id, component_id, chan, msg, avss_drone_imu->time_boot_ms, avss_drone_imu->q1, avss_drone_imu->q2, avss_drone_imu->q3, avss_drone_imu->q4, avss_drone_imu->xacc, avss_drone_imu->yacc, avss_drone_imu->zacc, avss_drone_imu->xgyro, avss_drone_imu->ygyro, avss_drone_imu->zgyro); } +/** + * @brief Encode a avss_drone_imu struct with provided status structure + * + * @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 avss_drone_imu C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_avss_drone_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_avss_drone_imu_t* avss_drone_imu) +{ + return mavlink_msg_avss_drone_imu_pack_status(system_id, component_id, _status, msg, avss_drone_imu->time_boot_ms, avss_drone_imu->q1, avss_drone_imu->q2, avss_drone_imu->q3, avss_drone_imu->q4, avss_drone_imu->xacc, avss_drone_imu->yacc, avss_drone_imu->zacc, avss_drone_imu->xgyro, avss_drone_imu->ygyro, avss_drone_imu->zgyro); +} + /** * @brief Send a avss_drone_imu message * @param chan MAVLink channel to send the message diff --git a/AVSSUAS/mavlink_msg_avss_drone_operation_mode.h b/AVSSUAS/mavlink_msg_avss_drone_operation_mode.h index c799e9d8..f2ed51bc 100644 --- a/AVSSUAS/mavlink_msg_avss_drone_operation_mode.h +++ b/AVSSUAS/mavlink_msg_avss_drone_operation_mode.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_avss_drone_operation_mode_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_CRC); } +/** + * @brief Pack a avss_drone_operation_mode 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 time_boot_ms [ms] Timestamp (time since FC boot). + * @param M300_operation_mode DJI M300 operation mode + * @param horsefly_operation_mode horsefly operation mode + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_avss_drone_operation_mode_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t M300_operation_mode, uint8_t horsefly_operation_mode) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint8_t(buf, 4, M300_operation_mode); + _mav_put_uint8_t(buf, 5, horsefly_operation_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN); +#else + mavlink_avss_drone_operation_mode_t packet; + packet.time_boot_ms = time_boot_ms; + packet.M300_operation_mode = M300_operation_mode; + packet.horsefly_operation_mode = horsefly_operation_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_OPERATION_MODE_LEN); +#endif +} + /** * @brief Pack a avss_drone_operation_mode message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_avss_drone_operation_mode_encode_chan(uint8_t return mavlink_msg_avss_drone_operation_mode_pack_chan(system_id, component_id, chan, msg, avss_drone_operation_mode->time_boot_ms, avss_drone_operation_mode->M300_operation_mode, avss_drone_operation_mode->horsefly_operation_mode); } +/** + * @brief Encode a avss_drone_operation_mode struct with provided status structure + * + * @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 avss_drone_operation_mode C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_avss_drone_operation_mode_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_avss_drone_operation_mode_t* avss_drone_operation_mode) +{ + return mavlink_msg_avss_drone_operation_mode_pack_status(system_id, component_id, _status, msg, avss_drone_operation_mode->time_boot_ms, avss_drone_operation_mode->M300_operation_mode, avss_drone_operation_mode->horsefly_operation_mode); +} + /** * @brief Send a avss_drone_operation_mode message * @param chan MAVLink channel to send the message diff --git a/AVSSUAS/mavlink_msg_avss_drone_position.h b/AVSSUAS/mavlink_msg_avss_drone_position.h index 1af3122a..40b320f8 100644 --- a/AVSSUAS/mavlink_msg_avss_drone_position.h +++ b/AVSSUAS/mavlink_msg_avss_drone_position.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_avss_drone_position_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_CRC); } +/** + * @brief Pack a avss_drone_position 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 time_boot_ms [ms] Timestamp (time since FC boot). + * @param lat [degE7] Latitude, expressed + * @param lon [degE7] Longitude, expressed + * @param alt [mm] Altitude (MSL). Note that virtually all GPS modules provide both WGS84 and MSL. + * @param ground_alt [m] Altitude above ground, This altitude is measured by a ultrasound, Laser rangefinder or millimeter-wave radar + * @param barometer_alt [m] This altitude is measured by a barometer + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_avss_drone_position_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, int32_t lat, int32_t lon, int32_t alt, float ground_alt, float barometer_alt) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat); + _mav_put_int32_t(buf, 8, lon); + _mav_put_int32_t(buf, 12, alt); + _mav_put_float(buf, 16, ground_alt); + _mav_put_float(buf, 20, barometer_alt); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN); +#else + mavlink_avss_drone_position_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.ground_alt = ground_alt; + packet.barometer_alt = barometer_alt; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVSS_DRONE_POSITION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_MIN_LEN, MAVLINK_MSG_ID_AVSS_DRONE_POSITION_LEN); +#endif +} + /** * @brief Pack a avss_drone_position message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_avss_drone_position_encode_chan(uint8_t syste return mavlink_msg_avss_drone_position_pack_chan(system_id, component_id, chan, msg, avss_drone_position->time_boot_ms, avss_drone_position->lat, avss_drone_position->lon, avss_drone_position->alt, avss_drone_position->ground_alt, avss_drone_position->barometer_alt); } +/** + * @brief Encode a avss_drone_position struct with provided status structure + * + * @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 avss_drone_position C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_avss_drone_position_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_avss_drone_position_t* avss_drone_position) +{ + return mavlink_msg_avss_drone_position_pack_status(system_id, component_id, _status, msg, avss_drone_position->time_boot_ms, avss_drone_position->lat, avss_drone_position->lon, avss_drone_position->alt, avss_drone_position->ground_alt, avss_drone_position->barometer_alt); +} + /** * @brief Send a avss_drone_position message * @param chan MAVLink channel to send the message diff --git a/AVSSUAS/mavlink_msg_avss_prs_sys_status.h b/AVSSUAS/mavlink_msg_avss_prs_sys_status.h index c782c9bf..6cbb5fb1 100644 --- a/AVSSUAS/mavlink_msg_avss_prs_sys_status.h +++ b/AVSSUAS/mavlink_msg_avss_prs_sys_status.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_avss_prs_sys_status_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_CRC); } +/** + * @brief Pack a avss_prs_sys_status 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 time_boot_ms [ms] Timestamp (time since PRS boot). + * @param error_status PRS error statuses + * @param battery_status Estimated battery run-time without a remote connection and PRS battery voltage + * @param arm_status PRS arm statuses + * @param charge_status PRS battery charge statuses + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_avss_prs_sys_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t error_status, uint32_t battery_status, uint8_t arm_status, uint8_t charge_status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, error_status); + _mav_put_uint32_t(buf, 8, battery_status); + _mav_put_uint8_t(buf, 12, arm_status); + _mav_put_uint8_t(buf, 13, charge_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN); +#else + mavlink_avss_prs_sys_status_t packet; + packet.time_boot_ms = time_boot_ms; + packet.error_status = error_status; + packet.battery_status = battery_status; + packet.arm_status = arm_status; + packet.charge_status = charge_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_AVSS_PRS_SYS_STATUS_LEN); +#endif +} + /** * @brief Pack a avss_prs_sys_status message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_avss_prs_sys_status_encode_chan(uint8_t syste return mavlink_msg_avss_prs_sys_status_pack_chan(system_id, component_id, chan, msg, avss_prs_sys_status->time_boot_ms, avss_prs_sys_status->error_status, avss_prs_sys_status->battery_status, avss_prs_sys_status->arm_status, avss_prs_sys_status->charge_status); } +/** + * @brief Encode a avss_prs_sys_status struct with provided status structure + * + * @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 avss_prs_sys_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_avss_prs_sys_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_avss_prs_sys_status_t* avss_prs_sys_status) +{ + return mavlink_msg_avss_prs_sys_status_pack_status(system_id, component_id, _status, msg, avss_prs_sys_status->time_boot_ms, avss_prs_sys_status->error_status, avss_prs_sys_status->battery_status, avss_prs_sys_status->arm_status, avss_prs_sys_status->charge_status); +} + /** * @brief Send a avss_prs_sys_status message * @param chan MAVLink channel to send the message diff --git a/AVSSUAS/version.h b/AVSSUAS/version.h index ef708429..a3336fd7 100644 --- a/AVSSUAS/version.h +++ b/AVSSUAS/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/all/all.h b/all/all.h index 4a9ab92e..621ddafd 100644 --- a/all/all.h +++ b/all/all.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_ALL.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_ALL_XML_HASH -8997877720262206605 +#define MAVLINK_ALL_XML_HASH -5517383316853678921 #ifdef __cplusplus extern "C" { diff --git a/all/mavlink.h b/all/mavlink.h index 0fa2ee4e..833adb25 100644 --- a/all/mavlink.h +++ b/all/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -8997877720262206605 +#define MAVLINK_PRIMARY_XML_HASH -5517383316853678921 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/all/version.h b/all/version.h index 04f8e36b..e85a1d8c 100644 --- a/all/version.h +++ b/all/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/ardupilotmega/ardupilotmega.h b/ardupilotmega/ardupilotmega.h index 5b33e9a5..a9bee11d 100644 --- a/ardupilotmega/ardupilotmega.h +++ b/ardupilotmega/ardupilotmega.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_ARDUPILOTMEGA.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_ARDUPILOTMEGA_XML_HASH 6469208098198518850 +#define MAVLINK_ARDUPILOTMEGA_XML_HASH 3080658263437269706 #ifdef __cplusplus extern "C" { diff --git a/ardupilotmega/mavlink.h b/ardupilotmega/mavlink.h index ab678c92..a667e1d0 100644 --- a/ardupilotmega/mavlink.h +++ b/ardupilotmega/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 6469208098198518850 +#define MAVLINK_PRIMARY_XML_HASH 3080658263437269706 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/ardupilotmega/mavlink_msg_adap_tuning.h b/ardupilotmega/mavlink_msg_adap_tuning.h index e0c75853..baa26368 100644 --- a/ardupilotmega/mavlink_msg_adap_tuning.h +++ b/ardupilotmega/mavlink_msg_adap_tuning.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_adap_tuning_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ADAP_TUNING_MIN_LEN, MAVLINK_MSG_ID_ADAP_TUNING_LEN, MAVLINK_MSG_ID_ADAP_TUNING_CRC); } +/** + * @brief Pack a adap_tuning 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 axis Axis. + * @param desired [deg/s] Desired rate. + * @param achieved [deg/s] Achieved rate. + * @param error Error between model and vehicle. + * @param theta Theta estimated state predictor. + * @param omega Omega estimated state predictor. + * @param sigma Sigma estimated state predictor. + * @param theta_dot Theta derivative. + * @param omega_dot Omega derivative. + * @param sigma_dot Sigma derivative. + * @param f Projection operator value. + * @param f_dot Projection operator derivative. + * @param u u adaptive controlled output command. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_adap_tuning_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t axis, float desired, float achieved, float error, float theta, float omega, float sigma, float theta_dot, float omega_dot, float sigma_dot, float f, float f_dot, float u) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ADAP_TUNING_LEN]; + _mav_put_float(buf, 0, desired); + _mav_put_float(buf, 4, achieved); + _mav_put_float(buf, 8, error); + _mav_put_float(buf, 12, theta); + _mav_put_float(buf, 16, omega); + _mav_put_float(buf, 20, sigma); + _mav_put_float(buf, 24, theta_dot); + _mav_put_float(buf, 28, omega_dot); + _mav_put_float(buf, 32, sigma_dot); + _mav_put_float(buf, 36, f); + _mav_put_float(buf, 40, f_dot); + _mav_put_float(buf, 44, u); + _mav_put_uint8_t(buf, 48, axis); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ADAP_TUNING_LEN); +#else + mavlink_adap_tuning_t packet; + packet.desired = desired; + packet.achieved = achieved; + packet.error = error; + packet.theta = theta; + packet.omega = omega; + packet.sigma = sigma; + packet.theta_dot = theta_dot; + packet.omega_dot = omega_dot; + packet.sigma_dot = sigma_dot; + packet.f = f; + packet.f_dot = f_dot; + packet.u = u; + packet.axis = axis; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ADAP_TUNING_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ADAP_TUNING; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADAP_TUNING_MIN_LEN, MAVLINK_MSG_ID_ADAP_TUNING_LEN, MAVLINK_MSG_ID_ADAP_TUNING_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADAP_TUNING_MIN_LEN, MAVLINK_MSG_ID_ADAP_TUNING_LEN); +#endif +} + /** * @brief Pack a adap_tuning message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_adap_tuning_encode_chan(uint8_t system_id, ui return mavlink_msg_adap_tuning_pack_chan(system_id, component_id, chan, msg, adap_tuning->axis, adap_tuning->desired, adap_tuning->achieved, adap_tuning->error, adap_tuning->theta, adap_tuning->omega, adap_tuning->sigma, adap_tuning->theta_dot, adap_tuning->omega_dot, adap_tuning->sigma_dot, adap_tuning->f, adap_tuning->f_dot, adap_tuning->u); } +/** + * @brief Encode a adap_tuning struct with provided status structure + * + * @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 adap_tuning C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_adap_tuning_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_adap_tuning_t* adap_tuning) +{ + return mavlink_msg_adap_tuning_pack_status(system_id, component_id, _status, msg, adap_tuning->axis, adap_tuning->desired, adap_tuning->achieved, adap_tuning->error, adap_tuning->theta, adap_tuning->omega, adap_tuning->sigma, adap_tuning->theta_dot, adap_tuning->omega_dot, adap_tuning->sigma_dot, adap_tuning->f, adap_tuning->f_dot, adap_tuning->u); +} + /** * @brief Send a adap_tuning message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_ahrs.h b/ardupilotmega/mavlink_msg_ahrs.h index 4378c24a..0d4e85f7 100644 --- a/ardupilotmega/mavlink_msg_ahrs.h +++ b/ardupilotmega/mavlink_msg_ahrs.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_ahrs_pack(uint8_t system_id, uint8_t componen return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC); } +/** + * @brief Pack a ahrs 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 omegaIx [rad/s] X gyro drift estimate. + * @param omegaIy [rad/s] Y gyro drift estimate. + * @param omegaIz [rad/s] Z gyro drift estimate. + * @param accel_weight Average accel_weight. + * @param renorm_val Average renormalisation value. + * @param error_rp Average error_roll_pitch value. + * @param error_yaw Average error_yaw value. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ahrs_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AHRS_LEN]; + _mav_put_float(buf, 0, omegaIx); + _mav_put_float(buf, 4, omegaIy); + _mav_put_float(buf, 8, omegaIz); + _mav_put_float(buf, 12, accel_weight); + _mav_put_float(buf, 16, renorm_val); + _mav_put_float(buf, 20, error_rp); + _mav_put_float(buf, 24, error_yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS_LEN); +#else + mavlink_ahrs_t packet; + packet.omegaIx = omegaIx; + packet.omegaIy = omegaIy; + packet.omegaIz = omegaIz; + packet.accel_weight = accel_weight; + packet.renorm_val = renorm_val; + packet.error_rp = error_rp; + packet.error_yaw = error_yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AHRS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN); +#endif +} + /** * @brief Pack a ahrs message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_ahrs_encode_chan(uint8_t system_id, uint8_t c return mavlink_msg_ahrs_pack_chan(system_id, component_id, chan, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw); } +/** + * @brief Encode a ahrs struct with provided status structure + * + * @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 ahrs C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ahrs_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs) +{ + return mavlink_msg_ahrs_pack_status(system_id, component_id, _status, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw); +} + /** * @brief Send a ahrs message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_ahrs2.h b/ardupilotmega/mavlink_msg_ahrs2.h index 909010ad..800b9b1b 100644 --- a/ardupilotmega/mavlink_msg_ahrs2.h +++ b/ardupilotmega/mavlink_msg_ahrs2.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_ahrs2_pack(uint8_t system_id, uint8_t compone return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC); } +/** + * @brief Pack a ahrs2 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 roll [rad] Roll angle. + * @param pitch [rad] Pitch angle. + * @param yaw [rad] Yaw angle. + * @param altitude [m] Altitude (MSL). + * @param lat [degE7] Latitude. + * @param lng [degE7] Longitude. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ahrs2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AHRS2_LEN]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, altitude); + _mav_put_int32_t(buf, 16, lat); + _mav_put_int32_t(buf, 20, lng); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS2_LEN); +#else + mavlink_ahrs2_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.altitude = altitude; + packet.lat = lat; + packet.lng = lng; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AHRS2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN); +#endif +} + /** * @brief Pack a ahrs2 message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_ahrs2_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_ahrs2_pack_chan(system_id, component_id, chan, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng); } +/** + * @brief Encode a ahrs2 struct with provided status structure + * + * @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 ahrs2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ahrs2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2) +{ + return mavlink_msg_ahrs2_pack_status(system_id, component_id, _status, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng); +} + /** * @brief Send a ahrs2 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_ahrs3.h b/ardupilotmega/mavlink_msg_ahrs3.h index 606e5b06..9e057c98 100644 --- a/ardupilotmega/mavlink_msg_ahrs3.h +++ b/ardupilotmega/mavlink_msg_ahrs3.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_ahrs3_pack(uint8_t system_id, uint8_t compone return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS3_MIN_LEN, MAVLINK_MSG_ID_AHRS3_LEN, MAVLINK_MSG_ID_AHRS3_CRC); } +/** + * @brief Pack a ahrs3 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 roll [rad] Roll angle. + * @param pitch [rad] Pitch angle. + * @param yaw [rad] Yaw angle. + * @param altitude [m] Altitude (MSL). + * @param lat [degE7] Latitude. + * @param lng [degE7] Longitude. + * @param v1 Test variable1. + * @param v2 Test variable2. + * @param v3 Test variable3. + * @param v4 Test variable4. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ahrs3_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng, float v1, float v2, float v3, float v4) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AHRS3_LEN]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, altitude); + _mav_put_int32_t(buf, 16, lat); + _mav_put_int32_t(buf, 20, lng); + _mav_put_float(buf, 24, v1); + _mav_put_float(buf, 28, v2); + _mav_put_float(buf, 32, v3); + _mav_put_float(buf, 36, v4); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS3_LEN); +#else + mavlink_ahrs3_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.altitude = altitude; + packet.lat = lat; + packet.lng = lng; + packet.v1 = v1; + packet.v2 = v2; + packet.v3 = v3; + packet.v4 = v4; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS3_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AHRS3; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS3_MIN_LEN, MAVLINK_MSG_ID_AHRS3_LEN, MAVLINK_MSG_ID_AHRS3_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AHRS3_MIN_LEN, MAVLINK_MSG_ID_AHRS3_LEN); +#endif +} + /** * @brief Pack a ahrs3 message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_ahrs3_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_ahrs3_pack_chan(system_id, component_id, chan, msg, ahrs3->roll, ahrs3->pitch, ahrs3->yaw, ahrs3->altitude, ahrs3->lat, ahrs3->lng, ahrs3->v1, ahrs3->v2, ahrs3->v3, ahrs3->v4); } +/** + * @brief Encode a ahrs3 struct with provided status structure + * + * @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 ahrs3 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ahrs3_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ahrs3_t* ahrs3) +{ + return mavlink_msg_ahrs3_pack_status(system_id, component_id, _status, msg, ahrs3->roll, ahrs3->pitch, ahrs3->yaw, ahrs3->altitude, ahrs3->lat, ahrs3->lng, ahrs3->v1, ahrs3->v2, ahrs3->v3, ahrs3->v4); +} + /** * @brief Send a ahrs3 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_airspeed_autocal.h b/ardupilotmega/mavlink_msg_airspeed_autocal.h index 322f8865..be10b85f 100644 --- a/ardupilotmega/mavlink_msg_airspeed_autocal.h +++ b/ardupilotmega/mavlink_msg_airspeed_autocal.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_airspeed_autocal_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_CRC); } +/** + * @brief Pack a airspeed_autocal 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 vx [m/s] GPS velocity north. + * @param vy [m/s] GPS velocity east. + * @param vz [m/s] GPS velocity down. + * @param diff_pressure [Pa] Differential pressure. + * @param EAS2TAS Estimated to true airspeed ratio. + * @param ratio Airspeed ratio. + * @param state_x EKF state x. + * @param state_y EKF state y. + * @param state_z EKF state z. + * @param Pax EKF Pax. + * @param Pby EKF Pby. + * @param Pcz EKF Pcz. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airspeed_autocal_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float vx, float vy, float vz, float diff_pressure, float EAS2TAS, float ratio, float state_x, float state_y, float state_z, float Pax, float Pby, float Pcz) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN]; + _mav_put_float(buf, 0, vx); + _mav_put_float(buf, 4, vy); + _mav_put_float(buf, 8, vz); + _mav_put_float(buf, 12, diff_pressure); + _mav_put_float(buf, 16, EAS2TAS); + _mav_put_float(buf, 20, ratio); + _mav_put_float(buf, 24, state_x); + _mav_put_float(buf, 28, state_y); + _mav_put_float(buf, 32, state_z); + _mav_put_float(buf, 36, Pax); + _mav_put_float(buf, 40, Pby); + _mav_put_float(buf, 44, Pcz); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN); +#else + mavlink_airspeed_autocal_t packet; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.diff_pressure = diff_pressure; + packet.EAS2TAS = EAS2TAS; + packet.ratio = ratio; + packet.state_x = state_x; + packet.state_y = state_y; + packet.state_z = state_z; + packet.Pax = Pax; + packet.Pby = Pby; + packet.Pcz = Pcz; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRSPEED_AUTOCAL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_AUTOCAL_LEN); +#endif +} + /** * @brief Pack a airspeed_autocal message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_airspeed_autocal_encode_chan(uint8_t system_i return mavlink_msg_airspeed_autocal_pack_chan(system_id, component_id, chan, msg, airspeed_autocal->vx, airspeed_autocal->vy, airspeed_autocal->vz, airspeed_autocal->diff_pressure, airspeed_autocal->EAS2TAS, airspeed_autocal->ratio, airspeed_autocal->state_x, airspeed_autocal->state_y, airspeed_autocal->state_z, airspeed_autocal->Pax, airspeed_autocal->Pby, airspeed_autocal->Pcz); } +/** + * @brief Encode a airspeed_autocal struct with provided status structure + * + * @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 airspeed_autocal C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airspeed_autocal_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airspeed_autocal_t* airspeed_autocal) +{ + return mavlink_msg_airspeed_autocal_pack_status(system_id, component_id, _status, msg, airspeed_autocal->vx, airspeed_autocal->vy, airspeed_autocal->vz, airspeed_autocal->diff_pressure, airspeed_autocal->EAS2TAS, airspeed_autocal->ratio, airspeed_autocal->state_x, airspeed_autocal->state_y, airspeed_autocal->state_z, airspeed_autocal->Pax, airspeed_autocal->Pby, airspeed_autocal->Pcz); +} + /** * @brief Send a airspeed_autocal message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_aoa_ssa.h b/ardupilotmega/mavlink_msg_aoa_ssa.h index c4a7ec0e..13dff194 100644 --- a/ardupilotmega/mavlink_msg_aoa_ssa.h +++ b/ardupilotmega/mavlink_msg_aoa_ssa.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_aoa_ssa_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AOA_SSA_MIN_LEN, MAVLINK_MSG_ID_AOA_SSA_LEN, MAVLINK_MSG_ID_AOA_SSA_CRC); } +/** + * @brief Pack a aoa_ssa 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 time_usec [us] Timestamp (since boot or Unix epoch). + * @param AOA [deg] Angle of Attack. + * @param SSA [deg] Side Slip Angle. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_aoa_ssa_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float AOA, float SSA) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AOA_SSA_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, AOA); + _mav_put_float(buf, 12, SSA); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AOA_SSA_LEN); +#else + mavlink_aoa_ssa_t packet; + packet.time_usec = time_usec; + packet.AOA = AOA; + packet.SSA = SSA; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AOA_SSA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AOA_SSA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AOA_SSA_MIN_LEN, MAVLINK_MSG_ID_AOA_SSA_LEN, MAVLINK_MSG_ID_AOA_SSA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AOA_SSA_MIN_LEN, MAVLINK_MSG_ID_AOA_SSA_LEN); +#endif +} + /** * @brief Pack a aoa_ssa message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_aoa_ssa_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_aoa_ssa_pack_chan(system_id, component_id, chan, msg, aoa_ssa->time_usec, aoa_ssa->AOA, aoa_ssa->SSA); } +/** + * @brief Encode a aoa_ssa struct with provided status structure + * + * @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 aoa_ssa C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_aoa_ssa_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_aoa_ssa_t* aoa_ssa) +{ + return mavlink_msg_aoa_ssa_pack_status(system_id, component_id, _status, msg, aoa_ssa->time_usec, aoa_ssa->AOA, aoa_ssa->SSA); +} + /** * @brief Send a aoa_ssa message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_ap_adc.h b/ardupilotmega/mavlink_msg_ap_adc.h index 37a69c76..771df466 100644 --- a/ardupilotmega/mavlink_msg_ap_adc.h +++ b/ardupilotmega/mavlink_msg_ap_adc.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_ap_adc_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC); } +/** + * @brief Pack a ap_adc 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 adc1 ADC output 1. + * @param adc2 ADC output 2. + * @param adc3 ADC output 3. + * @param adc4 ADC output 4. + * @param adc5 ADC output 5. + * @param adc6 ADC output 6. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ap_adc_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t adc5, uint16_t adc6) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AP_ADC_LEN]; + _mav_put_uint16_t(buf, 0, adc1); + _mav_put_uint16_t(buf, 2, adc2); + _mav_put_uint16_t(buf, 4, adc3); + _mav_put_uint16_t(buf, 6, adc4); + _mav_put_uint16_t(buf, 8, adc5); + _mav_put_uint16_t(buf, 10, adc6); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AP_ADC_LEN); +#else + mavlink_ap_adc_t packet; + packet.adc1 = adc1; + packet.adc2 = adc2; + packet.adc3 = adc3; + packet.adc4 = adc4; + packet.adc5 = adc5; + packet.adc6 = adc6; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AP_ADC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AP_ADC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN, MAVLINK_MSG_ID_AP_ADC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AP_ADC_MIN_LEN, MAVLINK_MSG_ID_AP_ADC_LEN); +#endif +} + /** * @brief Pack a ap_adc message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_ap_adc_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_ap_adc_pack_chan(system_id, component_id, chan, msg, ap_adc->adc1, ap_adc->adc2, ap_adc->adc3, ap_adc->adc4, ap_adc->adc5, ap_adc->adc6); } +/** + * @brief Encode a ap_adc struct with provided status structure + * + * @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 ap_adc C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ap_adc_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ap_adc_t* ap_adc) +{ + return mavlink_msg_ap_adc_pack_status(system_id, component_id, _status, msg, ap_adc->adc1, ap_adc->adc2, ap_adc->adc3, ap_adc->adc4, ap_adc->adc5, ap_adc->adc6); +} + /** * @brief Send a ap_adc message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_autopilot_version_request.h b/ardupilotmega/mavlink_msg_autopilot_version_request.h index ab63d885..2444224f 100644 --- a/ardupilotmega/mavlink_msg_autopilot_version_request.h +++ b/ardupilotmega/mavlink_msg_autopilot_version_request.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_autopilot_version_request_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_CRC); } +/** + * @brief Pack a autopilot_version_request 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 target_system System ID. + * @param target_component Component ID. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_autopilot_version_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN); +#else + mavlink_autopilot_version_request_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST_LEN); +#endif +} + /** * @brief Pack a autopilot_version_request message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_autopilot_version_request_encode_chan(uint8_t return mavlink_msg_autopilot_version_request_pack_chan(system_id, component_id, chan, msg, autopilot_version_request->target_system, autopilot_version_request->target_component); } +/** + * @brief Encode a autopilot_version_request struct with provided status structure + * + * @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 autopilot_version_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_autopilot_version_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_autopilot_version_request_t* autopilot_version_request) +{ + return mavlink_msg_autopilot_version_request_pack_status(system_id, component_id, _status, msg, autopilot_version_request->target_system, autopilot_version_request->target_component); +} + /** * @brief Send a autopilot_version_request message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_battery2.h b/ardupilotmega/mavlink_msg_battery2.h index ac027150..1e48501b 100644 --- a/ardupilotmega/mavlink_msg_battery2.h +++ b/ardupilotmega/mavlink_msg_battery2.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_battery2_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BATTERY2_MIN_LEN, MAVLINK_MSG_ID_BATTERY2_LEN, MAVLINK_MSG_ID_BATTERY2_CRC); } +/** + * @brief Pack a battery2 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 voltage [mV] Voltage. + * @param current_battery [cA] Battery current, -1: autopilot does not measure the current. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t voltage, int16_t current_battery) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_BATTERY2_LEN]; + _mav_put_uint16_t(buf, 0, voltage); + _mav_put_int16_t(buf, 2, current_battery); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY2_LEN); +#else + mavlink_battery2_t packet; + packet.voltage = voltage; + packet.current_battery = current_battery; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY2_MIN_LEN, MAVLINK_MSG_ID_BATTERY2_LEN, MAVLINK_MSG_ID_BATTERY2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY2_MIN_LEN, MAVLINK_MSG_ID_BATTERY2_LEN); +#endif +} + /** * @brief Pack a battery2 message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_battery2_encode_chan(uint8_t system_id, uint8 return mavlink_msg_battery2_pack_chan(system_id, component_id, chan, msg, battery2->voltage, battery2->current_battery); } +/** + * @brief Encode a battery2 struct with provided status structure + * + * @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 battery2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_battery2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_battery2_t* battery2) +{ + return mavlink_msg_battery2_pack_status(system_id, component_id, _status, msg, battery2->voltage, battery2->current_battery); +} + /** * @brief Send a battery2 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_camera_feedback.h b/ardupilotmega/mavlink_msg_camera_feedback.h index e1926801..1e9230ef 100644 --- a/ardupilotmega/mavlink_msg_camera_feedback.h +++ b/ardupilotmega/mavlink_msg_camera_feedback.h @@ -141,6 +141,78 @@ static inline uint16_t mavlink_msg_camera_feedback_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_FEEDBACK_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN, MAVLINK_MSG_ID_CAMERA_FEEDBACK_CRC); } +/** + * @brief Pack a camera_feedback 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 time_usec [us] Image timestamp (since UNIX epoch), as passed in by CAMERA_STATUS message (or autopilot if no CCB). + * @param target_system System ID. + * @param cam_idx Camera ID. + * @param img_idx Image index. + * @param lat [degE7] Latitude. + * @param lng [degE7] Longitude. + * @param alt_msl [m] Altitude (MSL). + * @param alt_rel [m] Altitude (Relative to HOME location). + * @param roll [deg] Camera Roll angle (earth frame, +-180). + * @param pitch [deg] Camera Pitch angle (earth frame, +-180). + * @param yaw [deg] Camera Yaw (earth frame, 0-360, true). + * @param foc_len [mm] Focal Length. + * @param flags Feedback flags. + * @param completed_captures Completed image captures. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_feedback_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t target_system, uint8_t cam_idx, uint16_t img_idx, int32_t lat, int32_t lng, float alt_msl, float alt_rel, float roll, float pitch, float yaw, float foc_len, uint8_t flags, uint16_t completed_captures) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lng); + _mav_put_float(buf, 16, alt_msl); + _mav_put_float(buf, 20, alt_rel); + _mav_put_float(buf, 24, roll); + _mav_put_float(buf, 28, pitch); + _mav_put_float(buf, 32, yaw); + _mav_put_float(buf, 36, foc_len); + _mav_put_uint16_t(buf, 40, img_idx); + _mav_put_uint8_t(buf, 42, target_system); + _mav_put_uint8_t(buf, 43, cam_idx); + _mav_put_uint8_t(buf, 44, flags); + _mav_put_uint16_t(buf, 45, completed_captures); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN); +#else + mavlink_camera_feedback_t packet; + packet.time_usec = time_usec; + packet.lat = lat; + packet.lng = lng; + packet.alt_msl = alt_msl; + packet.alt_rel = alt_rel; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.foc_len = foc_len; + packet.img_idx = img_idx; + packet.target_system = target_system; + packet.cam_idx = cam_idx; + packet.flags = flags; + packet.completed_captures = completed_captures; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_FEEDBACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_FEEDBACK_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN, MAVLINK_MSG_ID_CAMERA_FEEDBACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_FEEDBACK_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FEEDBACK_LEN); +#endif +} + /** * @brief Pack a camera_feedback message on a channel * @param system_id ID of this system @@ -236,6 +308,20 @@ static inline uint16_t mavlink_msg_camera_feedback_encode_chan(uint8_t system_id return mavlink_msg_camera_feedback_pack_chan(system_id, component_id, chan, msg, camera_feedback->time_usec, camera_feedback->target_system, camera_feedback->cam_idx, camera_feedback->img_idx, camera_feedback->lat, camera_feedback->lng, camera_feedback->alt_msl, camera_feedback->alt_rel, camera_feedback->roll, camera_feedback->pitch, camera_feedback->yaw, camera_feedback->foc_len, camera_feedback->flags, camera_feedback->completed_captures); } +/** + * @brief Encode a camera_feedback struct with provided status structure + * + * @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 camera_feedback C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_feedback_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_feedback_t* camera_feedback) +{ + return mavlink_msg_camera_feedback_pack_status(system_id, component_id, _status, msg, camera_feedback->time_usec, camera_feedback->target_system, camera_feedback->cam_idx, camera_feedback->img_idx, camera_feedback->lat, camera_feedback->lng, camera_feedback->alt_msl, camera_feedback->alt_rel, camera_feedback->roll, camera_feedback->pitch, camera_feedback->yaw, camera_feedback->foc_len, camera_feedback->flags, camera_feedback->completed_captures); +} + /** * @brief Send a camera_feedback message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_camera_status.h b/ardupilotmega/mavlink_msg_camera_status.h index 813b14b9..af34e922 100644 --- a/ardupilotmega/mavlink_msg_camera_status.h +++ b/ardupilotmega/mavlink_msg_camera_status.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_camera_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_STATUS_CRC); } +/** + * @brief Pack a camera_status 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 time_usec [us] Image timestamp (since UNIX epoch, according to camera clock). + * @param target_system System ID. + * @param cam_idx Camera ID. + * @param img_idx Image index. + * @param event_id Event type. + * @param p1 Parameter 1 (meaning depends on event_id, see CAMERA_STATUS_TYPES enum). + * @param p2 Parameter 2 (meaning depends on event_id, see CAMERA_STATUS_TYPES enum). + * @param p3 Parameter 3 (meaning depends on event_id, see CAMERA_STATUS_TYPES enum). + * @param p4 Parameter 4 (meaning depends on event_id, see CAMERA_STATUS_TYPES enum). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t target_system, uint8_t cam_idx, uint16_t img_idx, uint8_t event_id, float p1, float p2, float p3, float p4) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, p1); + _mav_put_float(buf, 12, p2); + _mav_put_float(buf, 16, p3); + _mav_put_float(buf, 20, p4); + _mav_put_uint16_t(buf, 24, img_idx); + _mav_put_uint8_t(buf, 26, target_system); + _mav_put_uint8_t(buf, 27, cam_idx); + _mav_put_uint8_t(buf, 28, event_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_STATUS_LEN); +#else + mavlink_camera_status_t packet; + packet.time_usec = time_usec; + packet.p1 = p1; + packet.p2 = p2; + packet.p3 = p3; + packet.p4 = p4; + packet.img_idx = img_idx; + packet.target_system = target_system; + packet.cam_idx = cam_idx; + packet.event_id = event_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_STATUS_LEN); +#endif +} + /** * @brief Pack a camera_status message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_camera_status_encode_chan(uint8_t system_id, return mavlink_msg_camera_status_pack_chan(system_id, component_id, chan, msg, camera_status->time_usec, camera_status->target_system, camera_status->cam_idx, camera_status->img_idx, camera_status->event_id, camera_status->p1, camera_status->p2, camera_status->p3, camera_status->p4); } +/** + * @brief Encode a camera_status struct with provided status structure + * + * @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 camera_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_status_t* camera_status) +{ + return mavlink_msg_camera_status_pack_status(system_id, component_id, _status, msg, camera_status->time_usec, camera_status->target_system, camera_status->cam_idx, camera_status->img_idx, camera_status->event_id, camera_status->p1, camera_status->p2, camera_status->p3, camera_status->p4); +} + /** * @brief Send a camera_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_compassmot_status.h b/ardupilotmega/mavlink_msg_compassmot_status.h index a074afbd..e5ac72ff 100644 --- a/ardupilotmega/mavlink_msg_compassmot_status.h +++ b/ardupilotmega/mavlink_msg_compassmot_status.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_compassmot_status_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMPASSMOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN, MAVLINK_MSG_ID_COMPASSMOT_STATUS_CRC); } +/** + * @brief Pack a compassmot_status 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 throttle [d%] Throttle. + * @param current [A] Current. + * @param interference [%] Interference. + * @param CompensationX Motor Compensation X. + * @param CompensationY Motor Compensation Y. + * @param CompensationZ Motor Compensation Z. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_compassmot_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t throttle, float current, uint16_t interference, float CompensationX, float CompensationY, float CompensationZ) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN]; + _mav_put_float(buf, 0, current); + _mav_put_float(buf, 4, CompensationX); + _mav_put_float(buf, 8, CompensationY); + _mav_put_float(buf, 12, CompensationZ); + _mav_put_uint16_t(buf, 16, throttle); + _mav_put_uint16_t(buf, 18, interference); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN); +#else + mavlink_compassmot_status_t packet; + packet.current = current; + packet.CompensationX = CompensationX; + packet.CompensationY = CompensationY; + packet.CompensationZ = CompensationZ; + packet.throttle = throttle; + packet.interference = interference; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMPASSMOT_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPASSMOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN, MAVLINK_MSG_ID_COMPASSMOT_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPASSMOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_COMPASSMOT_STATUS_LEN); +#endif +} + /** * @brief Pack a compassmot_status message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_compassmot_status_encode_chan(uint8_t system_ return mavlink_msg_compassmot_status_pack_chan(system_id, component_id, chan, msg, compassmot_status->throttle, compassmot_status->current, compassmot_status->interference, compassmot_status->CompensationX, compassmot_status->CompensationY, compassmot_status->CompensationZ); } +/** + * @brief Encode a compassmot_status struct with provided status structure + * + * @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 compassmot_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_compassmot_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_compassmot_status_t* compassmot_status) +{ + return mavlink_msg_compassmot_status_pack_status(system_id, component_id, _status, msg, compassmot_status->throttle, compassmot_status->current, compassmot_status->interference, compassmot_status->CompensationX, compassmot_status->CompensationY, compassmot_status->CompensationZ); +} + /** * @brief Send a compassmot_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_data16.h b/ardupilotmega/mavlink_msg_data16.h index d0049754..fd57f34f 100644 --- a/ardupilotmega/mavlink_msg_data16.h +++ b/ardupilotmega/mavlink_msg_data16.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_data16_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA16_MIN_LEN, MAVLINK_MSG_ID_DATA16_LEN, MAVLINK_MSG_ID_DATA16_CRC); } +/** + * @brief Pack a data16 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 type Data type. + * @param len [bytes] Data length. + * @param data Raw data. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data16_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA16_LEN]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA16_LEN); +#else + mavlink_data16_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA16_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA16; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA16_MIN_LEN, MAVLINK_MSG_ID_DATA16_LEN, MAVLINK_MSG_ID_DATA16_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA16_MIN_LEN, MAVLINK_MSG_ID_DATA16_LEN); +#endif +} + /** * @brief Pack a data16 message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_data16_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_data16_pack_chan(system_id, component_id, chan, msg, data16->type, data16->len, data16->data); } +/** + * @brief Encode a data16 struct with provided status structure + * + * @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 data16 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data16_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data16_t* data16) +{ + return mavlink_msg_data16_pack_status(system_id, component_id, _status, msg, data16->type, data16->len, data16->data); +} + /** * @brief Send a data16 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_data32.h b/ardupilotmega/mavlink_msg_data32.h index fc7b84c6..53fed180 100644 --- a/ardupilotmega/mavlink_msg_data32.h +++ b/ardupilotmega/mavlink_msg_data32.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_data32_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA32_MIN_LEN, MAVLINK_MSG_ID_DATA32_LEN, MAVLINK_MSG_ID_DATA32_CRC); } +/** + * @brief Pack a data32 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 type Data type. + * @param len [bytes] Data length. + * @param data Raw data. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data32_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA32_LEN]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA32_LEN); +#else + mavlink_data32_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA32_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA32; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA32_MIN_LEN, MAVLINK_MSG_ID_DATA32_LEN, MAVLINK_MSG_ID_DATA32_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA32_MIN_LEN, MAVLINK_MSG_ID_DATA32_LEN); +#endif +} + /** * @brief Pack a data32 message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_data32_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_data32_pack_chan(system_id, component_id, chan, msg, data32->type, data32->len, data32->data); } +/** + * @brief Encode a data32 struct with provided status structure + * + * @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 data32 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data32_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data32_t* data32) +{ + return mavlink_msg_data32_pack_status(system_id, component_id, _status, msg, data32->type, data32->len, data32->data); +} + /** * @brief Send a data32 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_data64.h b/ardupilotmega/mavlink_msg_data64.h index 4ee7ebb9..8f6e5fd1 100644 --- a/ardupilotmega/mavlink_msg_data64.h +++ b/ardupilotmega/mavlink_msg_data64.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_data64_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA64_MIN_LEN, MAVLINK_MSG_ID_DATA64_LEN, MAVLINK_MSG_ID_DATA64_CRC); } +/** + * @brief Pack a data64 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 type Data type. + * @param len [bytes] Data length. + * @param data Raw data. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data64_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA64_LEN]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA64_LEN); +#else + mavlink_data64_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA64_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA64; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA64_MIN_LEN, MAVLINK_MSG_ID_DATA64_LEN, MAVLINK_MSG_ID_DATA64_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA64_MIN_LEN, MAVLINK_MSG_ID_DATA64_LEN); +#endif +} + /** * @brief Pack a data64 message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_data64_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_data64_pack_chan(system_id, component_id, chan, msg, data64->type, data64->len, data64->data); } +/** + * @brief Encode a data64 struct with provided status structure + * + * @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 data64 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data64_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data64_t* data64) +{ + return mavlink_msg_data64_pack_status(system_id, component_id, _status, msg, data64->type, data64->len, data64->data); +} + /** * @brief Send a data64 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_data96.h b/ardupilotmega/mavlink_msg_data96.h index 8c198715..4a42192d 100644 --- a/ardupilotmega/mavlink_msg_data96.h +++ b/ardupilotmega/mavlink_msg_data96.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_data96_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA96_MIN_LEN, MAVLINK_MSG_ID_DATA96_LEN, MAVLINK_MSG_ID_DATA96_CRC); } +/** + * @brief Pack a data96 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 type Data type. + * @param len [bytes] Data length. + * @param data Raw data. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data96_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA96_LEN]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA96_LEN); +#else + mavlink_data96_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA96_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA96; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA96_MIN_LEN, MAVLINK_MSG_ID_DATA96_LEN, MAVLINK_MSG_ID_DATA96_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA96_MIN_LEN, MAVLINK_MSG_ID_DATA96_LEN); +#endif +} + /** * @brief Pack a data96 message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_data96_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_data96_pack_chan(system_id, component_id, chan, msg, data96->type, data96->len, data96->data); } +/** + * @brief Encode a data96 struct with provided status structure + * + * @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 data96 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data96_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data96_t* data96) +{ + return mavlink_msg_data96_pack_status(system_id, component_id, _status, msg, data96->type, data96->len, data96->data); +} + /** * @brief Send a data96 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_deepstall.h b/ardupilotmega/mavlink_msg_deepstall.h index 3e5bd1d6..6fb4ea59 100644 --- a/ardupilotmega/mavlink_msg_deepstall.h +++ b/ardupilotmega/mavlink_msg_deepstall.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_deepstall_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEEPSTALL_MIN_LEN, MAVLINK_MSG_ID_DEEPSTALL_LEN, MAVLINK_MSG_ID_DEEPSTALL_CRC); } +/** + * @brief Pack a deepstall 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 landing_lat [degE7] Landing latitude. + * @param landing_lon [degE7] Landing longitude. + * @param path_lat [degE7] Final heading start point, latitude. + * @param path_lon [degE7] Final heading start point, longitude. + * @param arc_entry_lat [degE7] Arc entry point, latitude. + * @param arc_entry_lon [degE7] Arc entry point, longitude. + * @param altitude [m] Altitude. + * @param expected_travel_distance [m] Distance the aircraft expects to travel during the deepstall. + * @param cross_track_error [m] Deepstall cross track error (only valid when in DEEPSTALL_STAGE_LAND). + * @param stage Deepstall stage. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_deepstall_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t landing_lat, int32_t landing_lon, int32_t path_lat, int32_t path_lon, int32_t arc_entry_lat, int32_t arc_entry_lon, float altitude, float expected_travel_distance, float cross_track_error, uint8_t stage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEEPSTALL_LEN]; + _mav_put_int32_t(buf, 0, landing_lat); + _mav_put_int32_t(buf, 4, landing_lon); + _mav_put_int32_t(buf, 8, path_lat); + _mav_put_int32_t(buf, 12, path_lon); + _mav_put_int32_t(buf, 16, arc_entry_lat); + _mav_put_int32_t(buf, 20, arc_entry_lon); + _mav_put_float(buf, 24, altitude); + _mav_put_float(buf, 28, expected_travel_distance); + _mav_put_float(buf, 32, cross_track_error); + _mav_put_uint8_t(buf, 36, stage); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEEPSTALL_LEN); +#else + mavlink_deepstall_t packet; + packet.landing_lat = landing_lat; + packet.landing_lon = landing_lon; + packet.path_lat = path_lat; + packet.path_lon = path_lon; + packet.arc_entry_lat = arc_entry_lat; + packet.arc_entry_lon = arc_entry_lon; + packet.altitude = altitude; + packet.expected_travel_distance = expected_travel_distance; + packet.cross_track_error = cross_track_error; + packet.stage = stage; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEEPSTALL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEEPSTALL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEEPSTALL_MIN_LEN, MAVLINK_MSG_ID_DEEPSTALL_LEN, MAVLINK_MSG_ID_DEEPSTALL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEEPSTALL_MIN_LEN, MAVLINK_MSG_ID_DEEPSTALL_LEN); +#endif +} + /** * @brief Pack a deepstall message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_deepstall_encode_chan(uint8_t system_id, uint return mavlink_msg_deepstall_pack_chan(system_id, component_id, chan, msg, deepstall->landing_lat, deepstall->landing_lon, deepstall->path_lat, deepstall->path_lon, deepstall->arc_entry_lat, deepstall->arc_entry_lon, deepstall->altitude, deepstall->expected_travel_distance, deepstall->cross_track_error, deepstall->stage); } +/** + * @brief Encode a deepstall struct with provided status structure + * + * @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 deepstall C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_deepstall_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_deepstall_t* deepstall) +{ + return mavlink_msg_deepstall_pack_status(system_id, component_id, _status, msg, deepstall->landing_lat, deepstall->landing_lon, deepstall->path_lat, deepstall->path_lon, deepstall->arc_entry_lat, deepstall->arc_entry_lon, deepstall->altitude, deepstall->expected_travel_distance, deepstall->cross_track_error, deepstall->stage); +} + /** * @brief Send a deepstall message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_device_op_read.h b/ardupilotmega/mavlink_msg_device_op_read.h index 7c9bd94c..47bc21e4 100644 --- a/ardupilotmega/mavlink_msg_device_op_read.h +++ b/ardupilotmega/mavlink_msg_device_op_read.h @@ -115,6 +115,64 @@ static inline uint16_t mavlink_msg_device_op_read_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_READ_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_CRC); } +/** + * @brief Pack a device_op_read 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 target_system System ID. + * @param target_component Component ID. + * @param request_id Request ID - copied to reply. + * @param bustype The bus type. + * @param bus Bus number. + * @param address Bus address. + * @param busname Name of device on bus (for SPI). + * @param regstart First register to read. + * @param count Count of registers to read. + * @param bank Bank number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_device_op_read_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t bustype, uint8_t bus, uint8_t address, const char *busname, uint8_t regstart, uint8_t count, uint8_t bank) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEVICE_OP_READ_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, bustype); + _mav_put_uint8_t(buf, 7, bus); + _mav_put_uint8_t(buf, 8, address); + _mav_put_uint8_t(buf, 49, regstart); + _mav_put_uint8_t(buf, 50, count); + _mav_put_uint8_t(buf, 51, bank); + _mav_put_char_array(buf, 9, busname, 40); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_READ_LEN); +#else + mavlink_device_op_read_t packet; + packet.request_id = request_id; + packet.target_system = target_system; + packet.target_component = target_component; + packet.bustype = bustype; + packet.bus = bus; + packet.address = address; + packet.regstart = regstart; + packet.count = count; + packet.bank = bank; + mav_array_memcpy(packet.busname, busname, sizeof(char)*40); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_READ_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_READ; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_READ_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_READ_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_LEN); +#endif +} + /** * @brief Pack a device_op_read message on a channel * @param system_id ID of this system @@ -196,6 +254,20 @@ static inline uint16_t mavlink_msg_device_op_read_encode_chan(uint8_t system_id, return mavlink_msg_device_op_read_pack_chan(system_id, component_id, chan, msg, device_op_read->target_system, device_op_read->target_component, device_op_read->request_id, device_op_read->bustype, device_op_read->bus, device_op_read->address, device_op_read->busname, device_op_read->regstart, device_op_read->count, device_op_read->bank); } +/** + * @brief Encode a device_op_read struct with provided status structure + * + * @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 device_op_read C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_device_op_read_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_device_op_read_t* device_op_read) +{ + return mavlink_msg_device_op_read_pack_status(system_id, component_id, _status, msg, device_op_read->target_system, device_op_read->target_component, device_op_read->request_id, device_op_read->bustype, device_op_read->bus, device_op_read->address, device_op_read->busname, device_op_read->regstart, device_op_read->count, device_op_read->bank); +} + /** * @brief Send a device_op_read message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_device_op_read_reply.h b/ardupilotmega/mavlink_msg_device_op_read_reply.h index 5af17221..0259871b 100644 --- a/ardupilotmega/mavlink_msg_device_op_read_reply.h +++ b/ardupilotmega/mavlink_msg_device_op_read_reply.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_device_op_read_reply_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC); } +/** + * @brief Pack a device_op_read_reply 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 request_id Request ID - copied from request. + * @param result 0 for success, anything else is failure code. + * @param regstart Starting register. + * @param count Count of bytes read. + * @param data Reply data. + * @param bank Bank number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_device_op_read_reply_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t request_id, uint8_t result, uint8_t regstart, uint8_t count, const uint8_t *data, uint8_t bank) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, result); + _mav_put_uint8_t(buf, 5, regstart); + _mav_put_uint8_t(buf, 6, count); + _mav_put_uint8_t(buf, 135, bank); + _mav_put_uint8_t_array(buf, 7, data, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN); +#else + mavlink_device_op_read_reply_t packet; + packet.request_id = request_id; + packet.result = result; + packet.regstart = regstart; + packet.count = count; + packet.bank = bank; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_READ_REPLY_LEN); +#endif +} + /** * @brief Pack a device_op_read_reply message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_device_op_read_reply_encode_chan(uint8_t syst return mavlink_msg_device_op_read_reply_pack_chan(system_id, component_id, chan, msg, device_op_read_reply->request_id, device_op_read_reply->result, device_op_read_reply->regstart, device_op_read_reply->count, device_op_read_reply->data, device_op_read_reply->bank); } +/** + * @brief Encode a device_op_read_reply struct with provided status structure + * + * @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 device_op_read_reply C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_device_op_read_reply_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_device_op_read_reply_t* device_op_read_reply) +{ + return mavlink_msg_device_op_read_reply_pack_status(system_id, component_id, _status, msg, device_op_read_reply->request_id, device_op_read_reply->result, device_op_read_reply->regstart, device_op_read_reply->count, device_op_read_reply->data, device_op_read_reply->bank); +} + /** * @brief Send a device_op_read_reply message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_device_op_write.h b/ardupilotmega/mavlink_msg_device_op_write.h index bf10129f..2ccf8b43 100644 --- a/ardupilotmega/mavlink_msg_device_op_write.h +++ b/ardupilotmega/mavlink_msg_device_op_write.h @@ -122,6 +122,67 @@ static inline uint16_t mavlink_msg_device_op_write_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC); } +/** + * @brief Pack a device_op_write 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 target_system System ID. + * @param target_component Component ID. + * @param request_id Request ID - copied to reply. + * @param bustype The bus type. + * @param bus Bus number. + * @param address Bus address. + * @param busname Name of device on bus (for SPI). + * @param regstart First register to write. + * @param count Count of registers to write. + * @param data Write data. + * @param bank Bank number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_device_op_write_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t bustype, uint8_t bus, uint8_t address, const char *busname, uint8_t regstart, uint8_t count, const uint8_t *data, uint8_t bank) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, bustype); + _mav_put_uint8_t(buf, 7, bus); + _mav_put_uint8_t(buf, 8, address); + _mav_put_uint8_t(buf, 49, regstart); + _mav_put_uint8_t(buf, 50, count); + _mav_put_uint8_t(buf, 179, bank); + _mav_put_char_array(buf, 9, busname, 40); + _mav_put_uint8_t_array(buf, 51, data, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN); +#else + mavlink_device_op_write_t packet; + packet.request_id = request_id; + packet.target_system = target_system; + packet.target_component = target_component; + packet.bustype = bustype; + packet.bus = bus; + packet.address = address; + packet.regstart = regstart; + packet.count = count; + packet.bank = bank; + mav_array_memcpy(packet.busname, busname, sizeof(char)*40); + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_WRITE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_WRITE_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_LEN); +#endif +} + /** * @brief Pack a device_op_write message on a channel * @param system_id ID of this system @@ -206,6 +267,20 @@ static inline uint16_t mavlink_msg_device_op_write_encode_chan(uint8_t system_id return mavlink_msg_device_op_write_pack_chan(system_id, component_id, chan, msg, device_op_write->target_system, device_op_write->target_component, device_op_write->request_id, device_op_write->bustype, device_op_write->bus, device_op_write->address, device_op_write->busname, device_op_write->regstart, device_op_write->count, device_op_write->data, device_op_write->bank); } +/** + * @brief Encode a device_op_write struct with provided status structure + * + * @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 device_op_write C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_device_op_write_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_device_op_write_t* device_op_write) +{ + return mavlink_msg_device_op_write_pack_status(system_id, component_id, _status, msg, device_op_write->target_system, device_op_write->target_component, device_op_write->request_id, device_op_write->bustype, device_op_write->bus, device_op_write->address, device_op_write->busname, device_op_write->regstart, device_op_write->count, device_op_write->data, device_op_write->bank); +} + /** * @brief Send a device_op_write message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_device_op_write_reply.h b/ardupilotmega/mavlink_msg_device_op_write_reply.h index 751cd6ce..459abfa8 100644 --- a/ardupilotmega/mavlink_msg_device_op_write_reply.h +++ b/ardupilotmega/mavlink_msg_device_op_write_reply.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_device_op_write_reply_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_CRC); } +/** + * @brief Pack a device_op_write_reply 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 request_id Request ID - copied from request. + * @param result 0 for success, anything else is failure code. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_device_op_write_reply_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t request_id, uint8_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, result); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN); +#else + mavlink_device_op_write_reply_t packet; + packet.request_id = request_id; + packet.result = result; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_MIN_LEN, MAVLINK_MSG_ID_DEVICE_OP_WRITE_REPLY_LEN); +#endif +} + /** * @brief Pack a device_op_write_reply message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_device_op_write_reply_encode_chan(uint8_t sys return mavlink_msg_device_op_write_reply_pack_chan(system_id, component_id, chan, msg, device_op_write_reply->request_id, device_op_write_reply->result); } +/** + * @brief Encode a device_op_write_reply struct with provided status structure + * + * @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 device_op_write_reply C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_device_op_write_reply_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_device_op_write_reply_t* device_op_write_reply) +{ + return mavlink_msg_device_op_write_reply_pack_status(system_id, component_id, _status, msg, device_op_write_reply->request_id, device_op_write_reply->result); +} + /** * @brief Send a device_op_write_reply message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_digicam_configure.h b/ardupilotmega/mavlink_msg_digicam_configure.h index ab1c26ba..69c34051 100644 --- a/ardupilotmega/mavlink_msg_digicam_configure.h +++ b/ardupilotmega/mavlink_msg_digicam_configure.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_digicam_configure_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_CRC); } +/** + * @brief Pack a digicam_configure 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 target_system System ID. + * @param target_component Component ID. + * @param mode Mode enumeration from 1 to N //P, TV, AV, M, etc. (0 means ignore). + * @param shutter_speed Divisor number //e.g. 1000 means 1/1000 (0 means ignore). + * @param aperture F stop number x 10 //e.g. 28 means 2.8 (0 means ignore). + * @param iso ISO enumeration from 1 to N //e.g. 80, 100, 200, Etc (0 means ignore). + * @param exposure_type Exposure type enumeration from 1 to N (0 means ignore). + * @param command_id Command Identity (incremental loop: 0 to 255). //A command sent multiple times will be executed or pooled just once. + * @param engine_cut_off [ds] Main engine cut-off time before camera trigger (0 means no cut-off). + * @param extra_param Extra parameters enumeration (0 means ignore). + * @param extra_value Correspondent value to given extra_param. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_digicam_configure_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t mode, uint16_t shutter_speed, uint8_t aperture, uint8_t iso, uint8_t exposure_type, uint8_t command_id, uint8_t engine_cut_off, uint8_t extra_param, float extra_value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN]; + _mav_put_float(buf, 0, extra_value); + _mav_put_uint16_t(buf, 4, shutter_speed); + _mav_put_uint8_t(buf, 6, target_system); + _mav_put_uint8_t(buf, 7, target_component); + _mav_put_uint8_t(buf, 8, mode); + _mav_put_uint8_t(buf, 9, aperture); + _mav_put_uint8_t(buf, 10, iso); + _mav_put_uint8_t(buf, 11, exposure_type); + _mav_put_uint8_t(buf, 12, command_id); + _mav_put_uint8_t(buf, 13, engine_cut_off); + _mav_put_uint8_t(buf, 14, extra_param); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN); +#else + mavlink_digicam_configure_t packet; + packet.extra_value = extra_value; + packet.shutter_speed = shutter_speed; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mode = mode; + packet.aperture = aperture; + packet.iso = iso; + packet.exposure_type = exposure_type; + packet.command_id = command_id; + packet.engine_cut_off = engine_cut_off; + packet.extra_param = extra_param; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONFIGURE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONFIGURE_LEN); +#endif +} + /** * @brief Pack a digicam_configure message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_digicam_configure_encode_chan(uint8_t system_ return mavlink_msg_digicam_configure_pack_chan(system_id, component_id, chan, msg, digicam_configure->target_system, digicam_configure->target_component, digicam_configure->mode, digicam_configure->shutter_speed, digicam_configure->aperture, digicam_configure->iso, digicam_configure->exposure_type, digicam_configure->command_id, digicam_configure->engine_cut_off, digicam_configure->extra_param, digicam_configure->extra_value); } +/** + * @brief Encode a digicam_configure struct with provided status structure + * + * @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 digicam_configure C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_digicam_configure_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_digicam_configure_t* digicam_configure) +{ + return mavlink_msg_digicam_configure_pack_status(system_id, component_id, _status, msg, digicam_configure->target_system, digicam_configure->target_component, digicam_configure->mode, digicam_configure->shutter_speed, digicam_configure->aperture, digicam_configure->iso, digicam_configure->exposure_type, digicam_configure->command_id, digicam_configure->engine_cut_off, digicam_configure->extra_param, digicam_configure->extra_value); +} + /** * @brief Send a digicam_configure message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_digicam_control.h b/ardupilotmega/mavlink_msg_digicam_control.h index 1845a06f..254c0491 100644 --- a/ardupilotmega/mavlink_msg_digicam_control.h +++ b/ardupilotmega/mavlink_msg_digicam_control.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_digicam_control_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DIGICAM_CONTROL_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN, MAVLINK_MSG_ID_DIGICAM_CONTROL_CRC); } +/** + * @brief Pack a digicam_control 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 target_system System ID. + * @param target_component Component ID. + * @param session 0: stop, 1: start or keep it up //Session control e.g. show/hide lens. + * @param zoom_pos 1 to N //Zoom's absolute position (0 means ignore). + * @param zoom_step -100 to 100 //Zooming step value to offset zoom from the current position. + * @param focus_lock 0: unlock focus or keep unlocked, 1: lock focus or keep locked, 3: re-lock focus. + * @param shot 0: ignore, 1: shot or start filming. + * @param command_id Command Identity (incremental loop: 0 to 255)//A command sent multiple times will be executed or pooled just once. + * @param extra_param Extra parameters enumeration (0 means ignore). + * @param extra_value Correspondent value to given extra_param. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_digicam_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t session, uint8_t zoom_pos, int8_t zoom_step, uint8_t focus_lock, uint8_t shot, uint8_t command_id, uint8_t extra_param, float extra_value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN]; + _mav_put_float(buf, 0, extra_value); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, session); + _mav_put_uint8_t(buf, 7, zoom_pos); + _mav_put_int8_t(buf, 8, zoom_step); + _mav_put_uint8_t(buf, 9, focus_lock); + _mav_put_uint8_t(buf, 10, shot); + _mav_put_uint8_t(buf, 11, command_id); + _mav_put_uint8_t(buf, 12, extra_param); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN); +#else + mavlink_digicam_control_t packet; + packet.extra_value = extra_value; + packet.target_system = target_system; + packet.target_component = target_component; + packet.session = session; + packet.zoom_pos = zoom_pos; + packet.zoom_step = zoom_step; + packet.focus_lock = focus_lock; + packet.shot = shot; + packet.command_id = command_id; + packet.extra_param = extra_param; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DIGICAM_CONTROL_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN, MAVLINK_MSG_ID_DIGICAM_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DIGICAM_CONTROL_MIN_LEN, MAVLINK_MSG_ID_DIGICAM_CONTROL_LEN); +#endif +} + /** * @brief Pack a digicam_control message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_digicam_control_encode_chan(uint8_t system_id return mavlink_msg_digicam_control_pack_chan(system_id, component_id, chan, msg, digicam_control->target_system, digicam_control->target_component, digicam_control->session, digicam_control->zoom_pos, digicam_control->zoom_step, digicam_control->focus_lock, digicam_control->shot, digicam_control->command_id, digicam_control->extra_param, digicam_control->extra_value); } +/** + * @brief Encode a digicam_control struct with provided status structure + * + * @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 digicam_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_digicam_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_digicam_control_t* digicam_control) +{ + return mavlink_msg_digicam_control_pack_status(system_id, component_id, _status, msg, digicam_control->target_system, digicam_control->target_component, digicam_control->session, digicam_control->zoom_pos, digicam_control->zoom_step, digicam_control->focus_lock, digicam_control->shot, digicam_control->command_id, digicam_control->extra_param, digicam_control->extra_value); +} + /** * @brief Send a digicam_control message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_ekf_status_report.h b/ardupilotmega/mavlink_msg_ekf_status_report.h index 0cc99a84..cccb4fee 100644 --- a/ardupilotmega/mavlink_msg_ekf_status_report.h +++ b/ardupilotmega/mavlink_msg_ekf_status_report.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_ekf_status_report_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_EKF_STATUS_REPORT_MIN_LEN, MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN, MAVLINK_MSG_ID_EKF_STATUS_REPORT_CRC); } +/** + * @brief Pack a ekf_status_report 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 flags Flags. + * @param velocity_variance Velocity variance. + * @param pos_horiz_variance Horizontal Position variance. + * @param pos_vert_variance Vertical Position variance. + * @param compass_variance Compass variance. + * @param terrain_alt_variance Terrain Altitude variance. + * @param airspeed_variance Airspeed variance. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ekf_status_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t flags, float velocity_variance, float pos_horiz_variance, float pos_vert_variance, float compass_variance, float terrain_alt_variance, float airspeed_variance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN]; + _mav_put_float(buf, 0, velocity_variance); + _mav_put_float(buf, 4, pos_horiz_variance); + _mav_put_float(buf, 8, pos_vert_variance); + _mav_put_float(buf, 12, compass_variance); + _mav_put_float(buf, 16, terrain_alt_variance); + _mav_put_uint16_t(buf, 20, flags); + _mav_put_float(buf, 22, airspeed_variance); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN); +#else + mavlink_ekf_status_report_t packet; + packet.velocity_variance = velocity_variance; + packet.pos_horiz_variance = pos_horiz_variance; + packet.pos_vert_variance = pos_vert_variance; + packet.compass_variance = compass_variance; + packet.terrain_alt_variance = terrain_alt_variance; + packet.flags = flags; + packet.airspeed_variance = airspeed_variance; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_EKF_STATUS_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EKF_STATUS_REPORT_MIN_LEN, MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN, MAVLINK_MSG_ID_EKF_STATUS_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EKF_STATUS_REPORT_MIN_LEN, MAVLINK_MSG_ID_EKF_STATUS_REPORT_LEN); +#endif +} + /** * @brief Pack a ekf_status_report message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_ekf_status_report_encode_chan(uint8_t system_ return mavlink_msg_ekf_status_report_pack_chan(system_id, component_id, chan, msg, ekf_status_report->flags, ekf_status_report->velocity_variance, ekf_status_report->pos_horiz_variance, ekf_status_report->pos_vert_variance, ekf_status_report->compass_variance, ekf_status_report->terrain_alt_variance, ekf_status_report->airspeed_variance); } +/** + * @brief Encode a ekf_status_report struct with provided status structure + * + * @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 ekf_status_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ekf_status_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ekf_status_report_t* ekf_status_report) +{ + return mavlink_msg_ekf_status_report_pack_status(system_id, component_id, _status, msg, ekf_status_report->flags, ekf_status_report->velocity_variance, ekf_status_report->pos_horiz_variance, ekf_status_report->pos_vert_variance, ekf_status_report->compass_variance, ekf_status_report->terrain_alt_variance, ekf_status_report->airspeed_variance); +} + /** * @brief Send a ekf_status_report message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_esc_telemetry_1_to_4.h b/ardupilotmega/mavlink_msg_esc_telemetry_1_to_4.h index 4178184f..7aace650 100644 --- a/ardupilotmega/mavlink_msg_esc_telemetry_1_to_4.h +++ b/ardupilotmega/mavlink_msg_esc_telemetry_1_to_4.h @@ -98,6 +98,54 @@ static inline uint16_t mavlink_msg_esc_telemetry_1_to_4_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_CRC); } +/** + * @brief Pack a esc_telemetry_1_to_4 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 temperature [degC] Temperature. + * @param voltage [cV] Voltage. + * @param current [cA] Current. + * @param totalcurrent [mAh] Total current. + * @param rpm [rpm] RPM (eRPM). + * @param count count of telemetry packets received (wraps at 65535). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_esc_telemetry_1_to_4_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *temperature, const uint16_t *voltage, const uint16_t *current, const uint16_t *totalcurrent, const uint16_t *rpm, const uint16_t *count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN]; + + _mav_put_uint16_t_array(buf, 0, voltage, 4); + _mav_put_uint16_t_array(buf, 8, current, 4); + _mav_put_uint16_t_array(buf, 16, totalcurrent, 4); + _mav_put_uint16_t_array(buf, 24, rpm, 4); + _mav_put_uint16_t_array(buf, 32, count, 4); + _mav_put_uint8_t_array(buf, 40, temperature, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN); +#else + mavlink_esc_telemetry_1_to_4_t packet; + + mav_array_memcpy(packet.voltage, voltage, sizeof(uint16_t)*4); + mav_array_memcpy(packet.current, current, sizeof(uint16_t)*4); + mav_array_memcpy(packet.totalcurrent, totalcurrent, sizeof(uint16_t)*4); + mav_array_memcpy(packet.rpm, rpm, sizeof(uint16_t)*4); + mav_array_memcpy(packet.count, count, sizeof(uint16_t)*4); + mav_array_memcpy(packet.temperature, temperature, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_1_TO_4_LEN); +#endif +} + /** * @brief Pack a esc_telemetry_1_to_4 message on a channel * @param system_id ID of this system @@ -169,6 +217,20 @@ static inline uint16_t mavlink_msg_esc_telemetry_1_to_4_encode_chan(uint8_t syst return mavlink_msg_esc_telemetry_1_to_4_pack_chan(system_id, component_id, chan, msg, esc_telemetry_1_to_4->temperature, esc_telemetry_1_to_4->voltage, esc_telemetry_1_to_4->current, esc_telemetry_1_to_4->totalcurrent, esc_telemetry_1_to_4->rpm, esc_telemetry_1_to_4->count); } +/** + * @brief Encode a esc_telemetry_1_to_4 struct with provided status structure + * + * @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 esc_telemetry_1_to_4 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_esc_telemetry_1_to_4_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_telemetry_1_to_4_t* esc_telemetry_1_to_4) +{ + return mavlink_msg_esc_telemetry_1_to_4_pack_status(system_id, component_id, _status, msg, esc_telemetry_1_to_4->temperature, esc_telemetry_1_to_4->voltage, esc_telemetry_1_to_4->current, esc_telemetry_1_to_4->totalcurrent, esc_telemetry_1_to_4->rpm, esc_telemetry_1_to_4->count); +} + /** * @brief Send a esc_telemetry_1_to_4 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_esc_telemetry_5_to_8.h b/ardupilotmega/mavlink_msg_esc_telemetry_5_to_8.h index 45a6ca12..21f01a70 100644 --- a/ardupilotmega/mavlink_msg_esc_telemetry_5_to_8.h +++ b/ardupilotmega/mavlink_msg_esc_telemetry_5_to_8.h @@ -98,6 +98,54 @@ static inline uint16_t mavlink_msg_esc_telemetry_5_to_8_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_CRC); } +/** + * @brief Pack a esc_telemetry_5_to_8 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 temperature [degC] Temperature. + * @param voltage [cV] Voltage. + * @param current [cA] Current. + * @param totalcurrent [mAh] Total current. + * @param rpm [rpm] RPM (eRPM). + * @param count count of telemetry packets received (wraps at 65535). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_esc_telemetry_5_to_8_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *temperature, const uint16_t *voltage, const uint16_t *current, const uint16_t *totalcurrent, const uint16_t *rpm, const uint16_t *count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN]; + + _mav_put_uint16_t_array(buf, 0, voltage, 4); + _mav_put_uint16_t_array(buf, 8, current, 4); + _mav_put_uint16_t_array(buf, 16, totalcurrent, 4); + _mav_put_uint16_t_array(buf, 24, rpm, 4); + _mav_put_uint16_t_array(buf, 32, count, 4); + _mav_put_uint8_t_array(buf, 40, temperature, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN); +#else + mavlink_esc_telemetry_5_to_8_t packet; + + mav_array_memcpy(packet.voltage, voltage, sizeof(uint16_t)*4); + mav_array_memcpy(packet.current, current, sizeof(uint16_t)*4); + mav_array_memcpy(packet.totalcurrent, totalcurrent, sizeof(uint16_t)*4); + mav_array_memcpy(packet.rpm, rpm, sizeof(uint16_t)*4); + mav_array_memcpy(packet.count, count, sizeof(uint16_t)*4); + mav_array_memcpy(packet.temperature, temperature, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_5_TO_8_LEN); +#endif +} + /** * @brief Pack a esc_telemetry_5_to_8 message on a channel * @param system_id ID of this system @@ -169,6 +217,20 @@ static inline uint16_t mavlink_msg_esc_telemetry_5_to_8_encode_chan(uint8_t syst return mavlink_msg_esc_telemetry_5_to_8_pack_chan(system_id, component_id, chan, msg, esc_telemetry_5_to_8->temperature, esc_telemetry_5_to_8->voltage, esc_telemetry_5_to_8->current, esc_telemetry_5_to_8->totalcurrent, esc_telemetry_5_to_8->rpm, esc_telemetry_5_to_8->count); } +/** + * @brief Encode a esc_telemetry_5_to_8 struct with provided status structure + * + * @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 esc_telemetry_5_to_8 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_esc_telemetry_5_to_8_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_telemetry_5_to_8_t* esc_telemetry_5_to_8) +{ + return mavlink_msg_esc_telemetry_5_to_8_pack_status(system_id, component_id, _status, msg, esc_telemetry_5_to_8->temperature, esc_telemetry_5_to_8->voltage, esc_telemetry_5_to_8->current, esc_telemetry_5_to_8->totalcurrent, esc_telemetry_5_to_8->rpm, esc_telemetry_5_to_8->count); +} + /** * @brief Send a esc_telemetry_5_to_8 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_esc_telemetry_9_to_12.h b/ardupilotmega/mavlink_msg_esc_telemetry_9_to_12.h index 58d06ffd..fe4c8c80 100644 --- a/ardupilotmega/mavlink_msg_esc_telemetry_9_to_12.h +++ b/ardupilotmega/mavlink_msg_esc_telemetry_9_to_12.h @@ -98,6 +98,54 @@ static inline uint16_t mavlink_msg_esc_telemetry_9_to_12_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_CRC); } +/** + * @brief Pack a esc_telemetry_9_to_12 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 temperature [degC] Temperature. + * @param voltage [cV] Voltage. + * @param current [cA] Current. + * @param totalcurrent [mAh] Total current. + * @param rpm [rpm] RPM (eRPM). + * @param count count of telemetry packets received (wraps at 65535). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_esc_telemetry_9_to_12_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *temperature, const uint16_t *voltage, const uint16_t *current, const uint16_t *totalcurrent, const uint16_t *rpm, const uint16_t *count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN]; + + _mav_put_uint16_t_array(buf, 0, voltage, 4); + _mav_put_uint16_t_array(buf, 8, current, 4); + _mav_put_uint16_t_array(buf, 16, totalcurrent, 4); + _mav_put_uint16_t_array(buf, 24, rpm, 4); + _mav_put_uint16_t_array(buf, 32, count, 4); + _mav_put_uint8_t_array(buf, 40, temperature, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN); +#else + mavlink_esc_telemetry_9_to_12_t packet; + + mav_array_memcpy(packet.voltage, voltage, sizeof(uint16_t)*4); + mav_array_memcpy(packet.current, current, sizeof(uint16_t)*4); + mav_array_memcpy(packet.totalcurrent, totalcurrent, sizeof(uint16_t)*4); + mav_array_memcpy(packet.rpm, rpm, sizeof(uint16_t)*4); + mav_array_memcpy(packet.count, count, sizeof(uint16_t)*4); + mav_array_memcpy(packet.temperature, temperature, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_MIN_LEN, MAVLINK_MSG_ID_ESC_TELEMETRY_9_TO_12_LEN); +#endif +} + /** * @brief Pack a esc_telemetry_9_to_12 message on a channel * @param system_id ID of this system @@ -169,6 +217,20 @@ static inline uint16_t mavlink_msg_esc_telemetry_9_to_12_encode_chan(uint8_t sys return mavlink_msg_esc_telemetry_9_to_12_pack_chan(system_id, component_id, chan, msg, esc_telemetry_9_to_12->temperature, esc_telemetry_9_to_12->voltage, esc_telemetry_9_to_12->current, esc_telemetry_9_to_12->totalcurrent, esc_telemetry_9_to_12->rpm, esc_telemetry_9_to_12->count); } +/** + * @brief Encode a esc_telemetry_9_to_12 struct with provided status structure + * + * @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 esc_telemetry_9_to_12 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_esc_telemetry_9_to_12_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_telemetry_9_to_12_t* esc_telemetry_9_to_12) +{ + return mavlink_msg_esc_telemetry_9_to_12_pack_status(system_id, component_id, _status, msg, esc_telemetry_9_to_12->temperature, esc_telemetry_9_to_12->voltage, esc_telemetry_9_to_12->current, esc_telemetry_9_to_12->totalcurrent, esc_telemetry_9_to_12->rpm, esc_telemetry_9_to_12->count); +} + /** * @brief Send a esc_telemetry_9_to_12 message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_fence_fetch_point.h b/ardupilotmega/mavlink_msg_fence_fetch_point.h index f6521001..7e8ad8c6 100644 --- a/ardupilotmega/mavlink_msg_fence_fetch_point.h +++ b/ardupilotmega/mavlink_msg_fence_fetch_point.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_fence_fetch_point_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN, MAVLINK_MSG_ID_FENCE_FETCH_POINT_CRC); } +/** + * @brief Pack a fence_fetch_point 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 target_system System ID. + * @param target_component Component ID. + * @param idx Point index (first point is 1, 0 is for return point). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_fence_fetch_point_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t idx) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, idx); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN); +#else + mavlink_fence_fetch_point_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.idx = idx; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FENCE_FETCH_POINT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN, MAVLINK_MSG_ID_FENCE_FETCH_POINT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_FETCH_POINT_LEN); +#endif +} + /** * @brief Pack a fence_fetch_point message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_fence_fetch_point_encode_chan(uint8_t system_ return mavlink_msg_fence_fetch_point_pack_chan(system_id, component_id, chan, msg, fence_fetch_point->target_system, fence_fetch_point->target_component, fence_fetch_point->idx); } +/** + * @brief Encode a fence_fetch_point struct with provided status structure + * + * @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 fence_fetch_point C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_fence_fetch_point_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_fence_fetch_point_t* fence_fetch_point) +{ + return mavlink_msg_fence_fetch_point_pack_status(system_id, component_id, _status, msg, fence_fetch_point->target_system, fence_fetch_point->target_component, fence_fetch_point->idx); +} + /** * @brief Send a fence_fetch_point message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_fence_point.h b/ardupilotmega/mavlink_msg_fence_point.h index 486c432e..3651092c 100644 --- a/ardupilotmega/mavlink_msg_fence_point.h +++ b/ardupilotmega/mavlink_msg_fence_point.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_fence_point_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC); } +/** + * @brief Pack a fence_point 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 target_system System ID. + * @param target_component Component ID. + * @param idx Point index (first point is 1, 0 is for return point). + * @param count Total number of points (for sanity checking). + * @param lat [deg] Latitude of point. + * @param lng [deg] Longitude of point. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_fence_point_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN]; + _mav_put_float(buf, 0, lat); + _mav_put_float(buf, 4, lng); + _mav_put_uint8_t(buf, 8, target_system); + _mav_put_uint8_t(buf, 9, target_component); + _mav_put_uint8_t(buf, 10, idx); + _mav_put_uint8_t(buf, 11, count); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_POINT_LEN); +#else + mavlink_fence_point_t packet; + packet.lat = lat; + packet.lng = lng; + packet.target_system = target_system; + packet.target_component = target_component; + packet.idx = idx; + packet.count = count; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_POINT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FENCE_POINT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN); +#endif +} + /** * @brief Pack a fence_point message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_fence_point_encode_chan(uint8_t system_id, ui return mavlink_msg_fence_point_pack_chan(system_id, component_id, chan, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng); } +/** + * @brief Encode a fence_point struct with provided status structure + * + * @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 fence_point C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_fence_point_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_fence_point_t* fence_point) +{ + return mavlink_msg_fence_point_pack_status(system_id, component_id, _status, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng); +} + /** * @brief Send a fence_point message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gimbal_control.h b/ardupilotmega/mavlink_msg_gimbal_control.h index 10ce7d9c..6f5a2bfd 100644 --- a/ardupilotmega/mavlink_msg_gimbal_control.h +++ b/ardupilotmega/mavlink_msg_gimbal_control.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_gimbal_control_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN, MAVLINK_MSG_ID_GIMBAL_CONTROL_CRC); } +/** + * @brief Pack a gimbal_control 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 target_system System ID. + * @param target_component Component ID. + * @param demanded_rate_x [rad/s] Demanded angular rate X. + * @param demanded_rate_y [rad/s] Demanded angular rate Y. + * @param demanded_rate_z [rad/s] Demanded angular rate Z. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, float demanded_rate_x, float demanded_rate_y, float demanded_rate_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN]; + _mav_put_float(buf, 0, demanded_rate_x); + _mav_put_float(buf, 4, demanded_rate_y); + _mav_put_float(buf, 8, demanded_rate_z); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint8_t(buf, 13, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN); +#else + mavlink_gimbal_control_t packet; + packet.demanded_rate_x = demanded_rate_x; + packet.demanded_rate_y = demanded_rate_y; + packet.demanded_rate_z = demanded_rate_z; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN, MAVLINK_MSG_ID_GIMBAL_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_CONTROL_LEN); +#endif +} + /** * @brief Pack a gimbal_control message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_gimbal_control_encode_chan(uint8_t system_id, return mavlink_msg_gimbal_control_pack_chan(system_id, component_id, chan, msg, gimbal_control->target_system, gimbal_control->target_component, gimbal_control->demanded_rate_x, gimbal_control->demanded_rate_y, gimbal_control->demanded_rate_z); } +/** + * @brief Encode a gimbal_control struct with provided status structure + * + * @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 gimbal_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_control_t* gimbal_control) +{ + return mavlink_msg_gimbal_control_pack_status(system_id, component_id, _status, msg, gimbal_control->target_system, gimbal_control->target_component, gimbal_control->demanded_rate_x, gimbal_control->demanded_rate_y, gimbal_control->demanded_rate_z); +} + /** * @brief Send a gimbal_control message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gimbal_report.h b/ardupilotmega/mavlink_msg_gimbal_report.h index 206e0321..e7e6f72c 100644 --- a/ardupilotmega/mavlink_msg_gimbal_report.h +++ b/ardupilotmega/mavlink_msg_gimbal_report.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_gimbal_report_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_REPORT_LEN, MAVLINK_MSG_ID_GIMBAL_REPORT_CRC); } +/** + * @brief Pack a gimbal_report 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 target_system System ID. + * @param target_component Component ID. + * @param delta_time [s] Time since last update. + * @param delta_angle_x [rad] Delta angle X. + * @param delta_angle_y [rad] Delta angle Y. + * @param delta_angle_z [rad] Delta angle X. + * @param delta_velocity_x [m/s] Delta velocity X. + * @param delta_velocity_y [m/s] Delta velocity Y. + * @param delta_velocity_z [m/s] Delta velocity Z. + * @param joint_roll [rad] Joint ROLL. + * @param joint_el [rad] Joint EL. + * @param joint_az [rad] Joint AZ. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, float delta_time, float delta_angle_x, float delta_angle_y, float delta_angle_z, float delta_velocity_x, float delta_velocity_y, float delta_velocity_z, float joint_roll, float joint_el, float joint_az) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_REPORT_LEN]; + _mav_put_float(buf, 0, delta_time); + _mav_put_float(buf, 4, delta_angle_x); + _mav_put_float(buf, 8, delta_angle_y); + _mav_put_float(buf, 12, delta_angle_z); + _mav_put_float(buf, 16, delta_velocity_x); + _mav_put_float(buf, 20, delta_velocity_y); + _mav_put_float(buf, 24, delta_velocity_z); + _mav_put_float(buf, 28, joint_roll); + _mav_put_float(buf, 32, joint_el); + _mav_put_float(buf, 36, joint_az); + _mav_put_uint8_t(buf, 40, target_system); + _mav_put_uint8_t(buf, 41, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_REPORT_LEN); +#else + mavlink_gimbal_report_t packet; + packet.delta_time = delta_time; + packet.delta_angle_x = delta_angle_x; + packet.delta_angle_y = delta_angle_y; + packet.delta_angle_z = delta_angle_z; + packet.delta_velocity_x = delta_velocity_x; + packet.delta_velocity_y = delta_velocity_y; + packet.delta_velocity_z = delta_velocity_z; + packet.joint_roll = joint_roll; + packet.joint_el = joint_el; + packet.joint_az = joint_az; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_REPORT_LEN, MAVLINK_MSG_ID_GIMBAL_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_REPORT_LEN); +#endif +} + /** * @brief Pack a gimbal_report message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_gimbal_report_encode_chan(uint8_t system_id, return mavlink_msg_gimbal_report_pack_chan(system_id, component_id, chan, msg, gimbal_report->target_system, gimbal_report->target_component, gimbal_report->delta_time, gimbal_report->delta_angle_x, gimbal_report->delta_angle_y, gimbal_report->delta_angle_z, gimbal_report->delta_velocity_x, gimbal_report->delta_velocity_y, gimbal_report->delta_velocity_z, gimbal_report->joint_roll, gimbal_report->joint_el, gimbal_report->joint_az); } +/** + * @brief Encode a gimbal_report struct with provided status structure + * + * @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 gimbal_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_report_t* gimbal_report) +{ + return mavlink_msg_gimbal_report_pack_status(system_id, component_id, _status, msg, gimbal_report->target_system, gimbal_report->target_component, gimbal_report->delta_time, gimbal_report->delta_angle_x, gimbal_report->delta_angle_y, gimbal_report->delta_angle_z, gimbal_report->delta_velocity_x, gimbal_report->delta_velocity_y, gimbal_report->delta_velocity_z, gimbal_report->joint_roll, gimbal_report->joint_el, gimbal_report->joint_az); +} + /** * @brief Send a gimbal_report message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gimbal_torque_cmd_report.h b/ardupilotmega/mavlink_msg_gimbal_torque_cmd_report.h index 1ced0499..b8983f90 100644 --- a/ardupilotmega/mavlink_msg_gimbal_torque_cmd_report.h +++ b/ardupilotmega/mavlink_msg_gimbal_torque_cmd_report.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_gimbal_torque_cmd_report_pack(uint8_t system_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_CRC); } +/** + * @brief Pack a gimbal_torque_cmd_report 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 target_system System ID. + * @param target_component Component ID. + * @param rl_torque_cmd Roll Torque Command. + * @param el_torque_cmd Elevation Torque Command. + * @param az_torque_cmd Azimuth Torque Command. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_torque_cmd_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int16_t rl_torque_cmd, int16_t el_torque_cmd, int16_t az_torque_cmd) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN]; + _mav_put_int16_t(buf, 0, rl_torque_cmd); + _mav_put_int16_t(buf, 2, el_torque_cmd); + _mav_put_int16_t(buf, 4, az_torque_cmd); + _mav_put_uint8_t(buf, 6, target_system); + _mav_put_uint8_t(buf, 7, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN); +#else + mavlink_gimbal_torque_cmd_report_t packet; + packet.rl_torque_cmd = rl_torque_cmd; + packet.el_torque_cmd = el_torque_cmd; + packet.az_torque_cmd = az_torque_cmd; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_TORQUE_CMD_REPORT_LEN); +#endif +} + /** * @brief Pack a gimbal_torque_cmd_report message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_gimbal_torque_cmd_report_encode_chan(uint8_t return mavlink_msg_gimbal_torque_cmd_report_pack_chan(system_id, component_id, chan, msg, gimbal_torque_cmd_report->target_system, gimbal_torque_cmd_report->target_component, gimbal_torque_cmd_report->rl_torque_cmd, gimbal_torque_cmd_report->el_torque_cmd, gimbal_torque_cmd_report->az_torque_cmd); } +/** + * @brief Encode a gimbal_torque_cmd_report struct with provided status structure + * + * @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 gimbal_torque_cmd_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_torque_cmd_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_torque_cmd_report_t* gimbal_torque_cmd_report) +{ + return mavlink_msg_gimbal_torque_cmd_report_pack_status(system_id, component_id, _status, msg, gimbal_torque_cmd_report->target_system, gimbal_torque_cmd_report->target_component, gimbal_torque_cmd_report->rl_torque_cmd, gimbal_torque_cmd_report->el_torque_cmd, gimbal_torque_cmd_report->az_torque_cmd); +} + /** * @brief Send a gimbal_torque_cmd_report message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gopro_get_request.h b/ardupilotmega/mavlink_msg_gopro_get_request.h index 87728349..b9c61292 100644 --- a/ardupilotmega/mavlink_msg_gopro_get_request.h +++ b/ardupilotmega/mavlink_msg_gopro_get_request.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_gopro_get_request_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_CRC); } +/** + * @brief Pack a gopro_get_request 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 target_system System ID. + * @param target_component Component ID. + * @param cmd_id Command ID. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gopro_get_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t cmd_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, cmd_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN); +#else + mavlink_gopro_get_request_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.cmd_id = cmd_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GOPRO_GET_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_REQUEST_LEN); +#endif +} + /** * @brief Pack a gopro_get_request message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_gopro_get_request_encode_chan(uint8_t system_ return mavlink_msg_gopro_get_request_pack_chan(system_id, component_id, chan, msg, gopro_get_request->target_system, gopro_get_request->target_component, gopro_get_request->cmd_id); } +/** + * @brief Encode a gopro_get_request struct with provided status structure + * + * @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 gopro_get_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gopro_get_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gopro_get_request_t* gopro_get_request) +{ + return mavlink_msg_gopro_get_request_pack_status(system_id, component_id, _status, msg, gopro_get_request->target_system, gopro_get_request->target_component, gopro_get_request->cmd_id); +} + /** * @brief Send a gopro_get_request message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gopro_get_response.h b/ardupilotmega/mavlink_msg_gopro_get_response.h index 39ad341b..5f7b79df 100644 --- a/ardupilotmega/mavlink_msg_gopro_get_response.h +++ b/ardupilotmega/mavlink_msg_gopro_get_response.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_gopro_get_response_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_CRC); } +/** + * @brief Pack a gopro_get_response 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 cmd_id Command ID. + * @param status Status. + * @param value Value. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gopro_get_response_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t cmd_id, uint8_t status, const uint8_t *value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN]; + _mav_put_uint8_t(buf, 0, cmd_id); + _mav_put_uint8_t(buf, 1, status); + _mav_put_uint8_t_array(buf, 2, value, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN); +#else + mavlink_gopro_get_response_t packet; + packet.cmd_id = cmd_id; + packet.status = status; + mav_array_memcpy(packet.value, value, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GOPRO_GET_RESPONSE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_GET_RESPONSE_LEN); +#endif +} + /** * @brief Pack a gopro_get_response message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_gopro_get_response_encode_chan(uint8_t system return mavlink_msg_gopro_get_response_pack_chan(system_id, component_id, chan, msg, gopro_get_response->cmd_id, gopro_get_response->status, gopro_get_response->value); } +/** + * @brief Encode a gopro_get_response struct with provided status structure + * + * @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 gopro_get_response C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gopro_get_response_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gopro_get_response_t* gopro_get_response) +{ + return mavlink_msg_gopro_get_response_pack_status(system_id, component_id, _status, msg, gopro_get_response->cmd_id, gopro_get_response->status, gopro_get_response->value); +} + /** * @brief Send a gopro_get_response message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gopro_heartbeat.h b/ardupilotmega/mavlink_msg_gopro_heartbeat.h index 9e82cb22..6b0c1f7a 100644 --- a/ardupilotmega/mavlink_msg_gopro_heartbeat.h +++ b/ardupilotmega/mavlink_msg_gopro_heartbeat.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_gopro_heartbeat_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_CRC); } +/** + * @brief Pack a gopro_heartbeat 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 status Status. + * @param capture_mode Current capture mode. + * @param flags Additional status bits. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gopro_heartbeat_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t status, uint8_t capture_mode, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN]; + _mav_put_uint8_t(buf, 0, status); + _mav_put_uint8_t(buf, 1, capture_mode); + _mav_put_uint8_t(buf, 2, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN); +#else + mavlink_gopro_heartbeat_t packet; + packet.status = status; + packet.capture_mode = capture_mode; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GOPRO_HEARTBEAT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_GOPRO_HEARTBEAT_LEN); +#endif +} + /** * @brief Pack a gopro_heartbeat message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_gopro_heartbeat_encode_chan(uint8_t system_id return mavlink_msg_gopro_heartbeat_pack_chan(system_id, component_id, chan, msg, gopro_heartbeat->status, gopro_heartbeat->capture_mode, gopro_heartbeat->flags); } +/** + * @brief Encode a gopro_heartbeat struct with provided status structure + * + * @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 gopro_heartbeat C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gopro_heartbeat_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gopro_heartbeat_t* gopro_heartbeat) +{ + return mavlink_msg_gopro_heartbeat_pack_status(system_id, component_id, _status, msg, gopro_heartbeat->status, gopro_heartbeat->capture_mode, gopro_heartbeat->flags); +} + /** * @brief Send a gopro_heartbeat message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gopro_set_request.h b/ardupilotmega/mavlink_msg_gopro_set_request.h index 49eab02d..8c31b1ea 100644 --- a/ardupilotmega/mavlink_msg_gopro_set_request.h +++ b/ardupilotmega/mavlink_msg_gopro_set_request.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_gopro_set_request_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_CRC); } +/** + * @brief Pack a gopro_set_request 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 target_system System ID. + * @param target_component Component ID. + * @param cmd_id Command ID. + * @param value Value. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gopro_set_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t cmd_id, const uint8_t *value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, cmd_id); + _mav_put_uint8_t_array(buf, 3, value, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN); +#else + mavlink_gopro_set_request_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.cmd_id = cmd_id; + mav_array_memcpy(packet.value, value, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GOPRO_SET_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_REQUEST_LEN); +#endif +} + /** * @brief Pack a gopro_set_request message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_gopro_set_request_encode_chan(uint8_t system_ return mavlink_msg_gopro_set_request_pack_chan(system_id, component_id, chan, msg, gopro_set_request->target_system, gopro_set_request->target_component, gopro_set_request->cmd_id, gopro_set_request->value); } +/** + * @brief Encode a gopro_set_request struct with provided status structure + * + * @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 gopro_set_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gopro_set_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gopro_set_request_t* gopro_set_request) +{ + return mavlink_msg_gopro_set_request_pack_status(system_id, component_id, _status, msg, gopro_set_request->target_system, gopro_set_request->target_component, gopro_set_request->cmd_id, gopro_set_request->value); +} + /** * @brief Send a gopro_set_request message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_gopro_set_response.h b/ardupilotmega/mavlink_msg_gopro_set_response.h index a49ba354..64de1816 100644 --- a/ardupilotmega/mavlink_msg_gopro_set_response.h +++ b/ardupilotmega/mavlink_msg_gopro_set_response.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_gopro_set_response_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_CRC); } +/** + * @brief Pack a gopro_set_response 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 cmd_id Command ID. + * @param status Status. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gopro_set_response_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t cmd_id, uint8_t status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN]; + _mav_put_uint8_t(buf, 0, cmd_id); + _mav_put_uint8_t(buf, 1, status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN); +#else + mavlink_gopro_set_response_t packet; + packet.cmd_id = cmd_id; + packet.status = status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GOPRO_SET_RESPONSE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_GOPRO_SET_RESPONSE_LEN); +#endif +} + /** * @brief Pack a gopro_set_response message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_gopro_set_response_encode_chan(uint8_t system return mavlink_msg_gopro_set_response_pack_chan(system_id, component_id, chan, msg, gopro_set_response->cmd_id, gopro_set_response->status); } +/** + * @brief Encode a gopro_set_response struct with provided status structure + * + * @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 gopro_set_response C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gopro_set_response_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gopro_set_response_t* gopro_set_response) +{ + return mavlink_msg_gopro_set_response_pack_status(system_id, component_id, _status, msg, gopro_set_response->cmd_id, gopro_set_response->status); +} + /** * @brief Send a gopro_set_response message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_hwstatus.h b/ardupilotmega/mavlink_msg_hwstatus.h index 86a7e408..00799f21 100644 --- a/ardupilotmega/mavlink_msg_hwstatus.h +++ b/ardupilotmega/mavlink_msg_hwstatus.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_hwstatus_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HWSTATUS_MIN_LEN, MAVLINK_MSG_ID_HWSTATUS_LEN, MAVLINK_MSG_ID_HWSTATUS_CRC); } +/** + * @brief Pack a hwstatus 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 Vcc [mV] Board voltage. + * @param I2Cerr I2C error count. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hwstatus_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t Vcc, uint8_t I2Cerr) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HWSTATUS_LEN]; + _mav_put_uint16_t(buf, 0, Vcc); + _mav_put_uint8_t(buf, 2, I2Cerr); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HWSTATUS_LEN); +#else + mavlink_hwstatus_t packet; + packet.Vcc = Vcc; + packet.I2Cerr = I2Cerr; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HWSTATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HWSTATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HWSTATUS_MIN_LEN, MAVLINK_MSG_ID_HWSTATUS_LEN, MAVLINK_MSG_ID_HWSTATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HWSTATUS_MIN_LEN, MAVLINK_MSG_ID_HWSTATUS_LEN); +#endif +} + /** * @brief Pack a hwstatus message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_hwstatus_encode_chan(uint8_t system_id, uint8 return mavlink_msg_hwstatus_pack_chan(system_id, component_id, chan, msg, hwstatus->Vcc, hwstatus->I2Cerr); } +/** + * @brief Encode a hwstatus struct with provided status structure + * + * @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 hwstatus C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hwstatus_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hwstatus_t* hwstatus) +{ + return mavlink_msg_hwstatus_pack_status(system_id, component_id, _status, msg, hwstatus->Vcc, hwstatus->I2Cerr); +} + /** * @brief Send a hwstatus message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_led_control.h b/ardupilotmega/mavlink_msg_led_control.h index 58825c7e..7af601d5 100644 --- a/ardupilotmega/mavlink_msg_led_control.h +++ b/ardupilotmega/mavlink_msg_led_control.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_led_control_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC); } +/** + * @brief Pack a led_control 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 target_system System ID. + * @param target_component Component ID. + * @param instance Instance (LED instance to control or 255 for all LEDs). + * @param pattern Pattern (see LED_PATTERN_ENUM). + * @param custom_len Custom Byte Length. + * @param custom_bytes Custom Bytes. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_led_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t instance, uint8_t pattern, uint8_t custom_len, const uint8_t *custom_bytes) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LED_CONTROL_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, instance); + _mav_put_uint8_t(buf, 3, pattern); + _mav_put_uint8_t(buf, 4, custom_len); + _mav_put_uint8_t_array(buf, 5, custom_bytes, 24); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LED_CONTROL_LEN); +#else + mavlink_led_control_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.instance = instance; + packet.pattern = pattern; + packet.custom_len = custom_len; + mav_array_memcpy(packet.custom_bytes, custom_bytes, sizeof(uint8_t)*24); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LED_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LED_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN); +#endif +} + /** * @brief Pack a led_control message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_led_control_encode_chan(uint8_t system_id, ui return mavlink_msg_led_control_pack_chan(system_id, component_id, chan, msg, led_control->target_system, led_control->target_component, led_control->instance, led_control->pattern, led_control->custom_len, led_control->custom_bytes); } +/** + * @brief Encode a led_control struct with provided status structure + * + * @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 led_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_led_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_led_control_t* led_control) +{ + return mavlink_msg_led_control_pack_status(system_id, component_id, _status, msg, led_control->target_system, led_control->target_component, led_control->instance, led_control->pattern, led_control->custom_len, led_control->custom_bytes); +} + /** * @brief Send a led_control message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_limits_status.h b/ardupilotmega/mavlink_msg_limits_status.h index 69661789..a36b08da 100644 --- a/ardupilotmega/mavlink_msg_limits_status.h +++ b/ardupilotmega/mavlink_msg_limits_status.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_limits_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LIMITS_STATUS_MIN_LEN, MAVLINK_MSG_ID_LIMITS_STATUS_LEN, MAVLINK_MSG_ID_LIMITS_STATUS_CRC); } +/** + * @brief Pack a limits_status 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 limits_state State of AP_Limits. + * @param last_trigger [ms] Time (since boot) of last breach. + * @param last_action [ms] Time (since boot) of last recovery action. + * @param last_recovery [ms] Time (since boot) of last successful recovery. + * @param last_clear [ms] Time (since boot) of last all-clear. + * @param breach_count Number of fence breaches. + * @param mods_enabled AP_Limit_Module bitfield of enabled modules. + * @param mods_required AP_Limit_Module bitfield of required modules. + * @param mods_triggered AP_Limit_Module bitfield of triggered modules. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_limits_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t limits_state, uint32_t last_trigger, uint32_t last_action, uint32_t last_recovery, uint32_t last_clear, uint16_t breach_count, uint8_t mods_enabled, uint8_t mods_required, uint8_t mods_triggered) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LIMITS_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, last_trigger); + _mav_put_uint32_t(buf, 4, last_action); + _mav_put_uint32_t(buf, 8, last_recovery); + _mav_put_uint32_t(buf, 12, last_clear); + _mav_put_uint16_t(buf, 16, breach_count); + _mav_put_uint8_t(buf, 18, limits_state); + _mav_put_uint8_t(buf, 19, mods_enabled); + _mav_put_uint8_t(buf, 20, mods_required); + _mav_put_uint8_t(buf, 21, mods_triggered); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LIMITS_STATUS_LEN); +#else + mavlink_limits_status_t packet; + packet.last_trigger = last_trigger; + packet.last_action = last_action; + packet.last_recovery = last_recovery; + packet.last_clear = last_clear; + packet.breach_count = breach_count; + packet.limits_state = limits_state; + packet.mods_enabled = mods_enabled; + packet.mods_required = mods_required; + packet.mods_triggered = mods_triggered; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LIMITS_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LIMITS_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LIMITS_STATUS_MIN_LEN, MAVLINK_MSG_ID_LIMITS_STATUS_LEN, MAVLINK_MSG_ID_LIMITS_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LIMITS_STATUS_MIN_LEN, MAVLINK_MSG_ID_LIMITS_STATUS_LEN); +#endif +} + /** * @brief Pack a limits_status message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_limits_status_encode_chan(uint8_t system_id, return mavlink_msg_limits_status_pack_chan(system_id, component_id, chan, msg, limits_status->limits_state, limits_status->last_trigger, limits_status->last_action, limits_status->last_recovery, limits_status->last_clear, limits_status->breach_count, limits_status->mods_enabled, limits_status->mods_required, limits_status->mods_triggered); } +/** + * @brief Encode a limits_status struct with provided status structure + * + * @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 limits_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_limits_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_limits_status_t* limits_status) +{ + return mavlink_msg_limits_status_pack_status(system_id, component_id, _status, msg, limits_status->limits_state, limits_status->last_trigger, limits_status->last_action, limits_status->last_recovery, limits_status->last_clear, limits_status->breach_count, limits_status->mods_enabled, limits_status->mods_required, limits_status->mods_triggered); +} + /** * @brief Send a limits_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_mag_cal_progress.h b/ardupilotmega/mavlink_msg_mag_cal_progress.h index 2210c921..96580b83 100644 --- a/ardupilotmega/mavlink_msg_mag_cal_progress.h +++ b/ardupilotmega/mavlink_msg_mag_cal_progress.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_mag_cal_progress_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_CRC); } +/** + * @brief Pack a mag_cal_progress 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 compass_id Compass being calibrated. + * @param cal_mask Bitmask of compasses being calibrated. + * @param cal_status Calibration Status. + * @param attempt Attempt number. + * @param completion_pct [%] Completion percentage. + * @param completion_mask Bitmask of sphere sections (see http://en.wikipedia.org/wiki/Geodesic_grid). + * @param direction_x Body frame direction vector for display. + * @param direction_y Body frame direction vector for display. + * @param direction_z Body frame direction vector for display. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mag_cal_progress_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t attempt, uint8_t completion_pct, const uint8_t *completion_mask, float direction_x, float direction_y, float direction_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN]; + _mav_put_float(buf, 0, direction_x); + _mav_put_float(buf, 4, direction_y); + _mav_put_float(buf, 8, direction_z); + _mav_put_uint8_t(buf, 12, compass_id); + _mav_put_uint8_t(buf, 13, cal_mask); + _mav_put_uint8_t(buf, 14, cal_status); + _mav_put_uint8_t(buf, 15, attempt); + _mav_put_uint8_t(buf, 16, completion_pct); + _mav_put_uint8_t_array(buf, 17, completion_mask, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN); +#else + mavlink_mag_cal_progress_t packet; + packet.direction_x = direction_x; + packet.direction_y = direction_y; + packet.direction_z = direction_z; + packet.compass_id = compass_id; + packet.cal_mask = cal_mask; + packet.cal_status = cal_status; + packet.attempt = attempt; + packet.completion_pct = completion_pct; + mav_array_memcpy(packet.completion_mask, completion_mask, sizeof(uint8_t)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MAG_CAL_PROGRESS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_PROGRESS_LEN); +#endif +} + /** * @brief Pack a mag_cal_progress message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_mag_cal_progress_encode_chan(uint8_t system_i return mavlink_msg_mag_cal_progress_pack_chan(system_id, component_id, chan, msg, mag_cal_progress->compass_id, mag_cal_progress->cal_mask, mag_cal_progress->cal_status, mag_cal_progress->attempt, mag_cal_progress->completion_pct, mag_cal_progress->completion_mask, mag_cal_progress->direction_x, mag_cal_progress->direction_y, mag_cal_progress->direction_z); } +/** + * @brief Encode a mag_cal_progress struct with provided status structure + * + * @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 mag_cal_progress C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mag_cal_progress_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mag_cal_progress_t* mag_cal_progress) +{ + return mavlink_msg_mag_cal_progress_pack_status(system_id, component_id, _status, msg, mag_cal_progress->compass_id, mag_cal_progress->cal_mask, mag_cal_progress->cal_status, mag_cal_progress->attempt, mag_cal_progress->completion_pct, mag_cal_progress->completion_mask, mag_cal_progress->direction_x, mag_cal_progress->direction_y, mag_cal_progress->direction_z); +} + /** * @brief Send a mag_cal_progress message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_mcu_status.h b/ardupilotmega/mavlink_msg_mcu_status.h index a6b15d70..e4c9293e 100644 --- a/ardupilotmega/mavlink_msg_mcu_status.h +++ b/ardupilotmega/mavlink_msg_mcu_status.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_mcu_status_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MCU_STATUS_MIN_LEN, MAVLINK_MSG_ID_MCU_STATUS_LEN, MAVLINK_MSG_ID_MCU_STATUS_CRC); } +/** + * @brief Pack a mcu_status 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 id MCU instance + * @param MCU_temperature [cdegC] MCU Internal temperature + * @param MCU_voltage [mV] MCU voltage + * @param MCU_voltage_min [mV] MCU voltage minimum + * @param MCU_voltage_max [mV] MCU voltage maximum + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mcu_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, int16_t MCU_temperature, uint16_t MCU_voltage, uint16_t MCU_voltage_min, uint16_t MCU_voltage_max) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MCU_STATUS_LEN]; + _mav_put_int16_t(buf, 0, MCU_temperature); + _mav_put_uint16_t(buf, 2, MCU_voltage); + _mav_put_uint16_t(buf, 4, MCU_voltage_min); + _mav_put_uint16_t(buf, 6, MCU_voltage_max); + _mav_put_uint8_t(buf, 8, id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MCU_STATUS_LEN); +#else + mavlink_mcu_status_t packet; + packet.MCU_temperature = MCU_temperature; + packet.MCU_voltage = MCU_voltage; + packet.MCU_voltage_min = MCU_voltage_min; + packet.MCU_voltage_max = MCU_voltage_max; + packet.id = id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MCU_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MCU_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MCU_STATUS_MIN_LEN, MAVLINK_MSG_ID_MCU_STATUS_LEN, MAVLINK_MSG_ID_MCU_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MCU_STATUS_MIN_LEN, MAVLINK_MSG_ID_MCU_STATUS_LEN); +#endif +} + /** * @brief Pack a mcu_status message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_mcu_status_encode_chan(uint8_t system_id, uin return mavlink_msg_mcu_status_pack_chan(system_id, component_id, chan, msg, mcu_status->id, mcu_status->MCU_temperature, mcu_status->MCU_voltage, mcu_status->MCU_voltage_min, mcu_status->MCU_voltage_max); } +/** + * @brief Encode a mcu_status struct with provided status structure + * + * @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 mcu_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mcu_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mcu_status_t* mcu_status) +{ + return mavlink_msg_mcu_status_pack_status(system_id, component_id, _status, msg, mcu_status->id, mcu_status->MCU_temperature, mcu_status->MCU_voltage, mcu_status->MCU_voltage_min, mcu_status->MCU_voltage_max); +} + /** * @brief Send a mcu_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_meminfo.h b/ardupilotmega/mavlink_msg_meminfo.h index 1eaf6096..716ade7e 100644 --- a/ardupilotmega/mavlink_msg_meminfo.h +++ b/ardupilotmega/mavlink_msg_meminfo.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_meminfo_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MEMINFO_MIN_LEN, MAVLINK_MSG_ID_MEMINFO_LEN, MAVLINK_MSG_ID_MEMINFO_CRC); } +/** + * @brief Pack a meminfo 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 brkval Heap top. + * @param freemem [bytes] Free memory. + * @param freemem32 [bytes] Free memory (32 bit). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_meminfo_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t brkval, uint16_t freemem, uint32_t freemem32) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MEMINFO_LEN]; + _mav_put_uint16_t(buf, 0, brkval); + _mav_put_uint16_t(buf, 2, freemem); + _mav_put_uint32_t(buf, 4, freemem32); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MEMINFO_LEN); +#else + mavlink_meminfo_t packet; + packet.brkval = brkval; + packet.freemem = freemem; + packet.freemem32 = freemem32; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MEMINFO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MEMINFO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMINFO_MIN_LEN, MAVLINK_MSG_ID_MEMINFO_LEN, MAVLINK_MSG_ID_MEMINFO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMINFO_MIN_LEN, MAVLINK_MSG_ID_MEMINFO_LEN); +#endif +} + /** * @brief Pack a meminfo message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_meminfo_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_meminfo_pack_chan(system_id, component_id, chan, msg, meminfo->brkval, meminfo->freemem, meminfo->freemem32); } +/** + * @brief Encode a meminfo struct with provided status structure + * + * @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 meminfo C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_meminfo_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_meminfo_t* meminfo) +{ + return mavlink_msg_meminfo_pack_status(system_id, component_id, _status, msg, meminfo->brkval, meminfo->freemem, meminfo->freemem32); +} + /** * @brief Send a meminfo message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_mount_configure.h b/ardupilotmega/mavlink_msg_mount_configure.h index 0965a394..bece779c 100644 --- a/ardupilotmega/mavlink_msg_mount_configure.h +++ b/ardupilotmega/mavlink_msg_mount_configure.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_mount_configure_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MOUNT_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN, MAVLINK_MSG_ID_MOUNT_CONFIGURE_CRC); } +/** + * @brief Pack a mount_configure 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 target_system System ID. + * @param target_component Component ID. + * @param mount_mode Mount operating mode. + * @param stab_roll (1 = yes, 0 = no). + * @param stab_pitch (1 = yes, 0 = no). + * @param stab_yaw (1 = yes, 0 = no). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mount_configure_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t mount_mode, uint8_t stab_roll, uint8_t stab_pitch, uint8_t stab_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, mount_mode); + _mav_put_uint8_t(buf, 3, stab_roll); + _mav_put_uint8_t(buf, 4, stab_pitch); + _mav_put_uint8_t(buf, 5, stab_yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN); +#else + mavlink_mount_configure_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mount_mode = mount_mode; + packet.stab_roll = stab_roll; + packet.stab_pitch = stab_pitch; + packet.stab_yaw = stab_yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MOUNT_CONFIGURE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN, MAVLINK_MSG_ID_MOUNT_CONFIGURE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_CONFIGURE_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONFIGURE_LEN); +#endif +} + /** * @brief Pack a mount_configure message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_mount_configure_encode_chan(uint8_t system_id return mavlink_msg_mount_configure_pack_chan(system_id, component_id, chan, msg, mount_configure->target_system, mount_configure->target_component, mount_configure->mount_mode, mount_configure->stab_roll, mount_configure->stab_pitch, mount_configure->stab_yaw); } +/** + * @brief Encode a mount_configure struct with provided status structure + * + * @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 mount_configure C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mount_configure_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mount_configure_t* mount_configure) +{ + return mavlink_msg_mount_configure_pack_status(system_id, component_id, _status, msg, mount_configure->target_system, mount_configure->target_component, mount_configure->mount_mode, mount_configure->stab_roll, mount_configure->stab_pitch, mount_configure->stab_yaw); +} + /** * @brief Send a mount_configure message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_mount_control.h b/ardupilotmega/mavlink_msg_mount_control.h index 000bbcd7..2010225b 100644 --- a/ardupilotmega/mavlink_msg_mount_control.h +++ b/ardupilotmega/mavlink_msg_mount_control.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_mount_control_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MOUNT_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONTROL_LEN, MAVLINK_MSG_ID_MOUNT_CONTROL_CRC); } +/** + * @brief Pack a mount_control 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 target_system System ID. + * @param target_component Component ID. + * @param input_a Pitch (centi-degrees) or lat (degE7), depending on mount mode. + * @param input_b Roll (centi-degrees) or lon (degE7) depending on mount mode. + * @param input_c Yaw (centi-degrees) or alt (cm) depending on mount mode. + * @param save_position If "1" it will save current trimmed position on EEPROM (just valid for NEUTRAL and LANDING). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mount_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int32_t input_a, int32_t input_b, int32_t input_c, uint8_t save_position) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MOUNT_CONTROL_LEN]; + _mav_put_int32_t(buf, 0, input_a); + _mav_put_int32_t(buf, 4, input_b); + _mav_put_int32_t(buf, 8, input_c); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint8_t(buf, 13, target_component); + _mav_put_uint8_t(buf, 14, save_position); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MOUNT_CONTROL_LEN); +#else + mavlink_mount_control_t packet; + packet.input_a = input_a; + packet.input_b = input_b; + packet.input_c = input_c; + packet.target_system = target_system; + packet.target_component = target_component; + packet.save_position = save_position; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MOUNT_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MOUNT_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONTROL_LEN, MAVLINK_MSG_ID_MOUNT_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MOUNT_CONTROL_LEN); +#endif +} + /** * @brief Pack a mount_control message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_mount_control_encode_chan(uint8_t system_id, return mavlink_msg_mount_control_pack_chan(system_id, component_id, chan, msg, mount_control->target_system, mount_control->target_component, mount_control->input_a, mount_control->input_b, mount_control->input_c, mount_control->save_position); } +/** + * @brief Encode a mount_control struct with provided status structure + * + * @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 mount_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mount_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mount_control_t* mount_control) +{ + return mavlink_msg_mount_control_pack_status(system_id, component_id, _status, msg, mount_control->target_system, mount_control->target_component, mount_control->input_a, mount_control->input_b, mount_control->input_c, mount_control->save_position); +} + /** * @brief Send a mount_control message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_mount_status.h b/ardupilotmega/mavlink_msg_mount_status.h index eb5bed90..24f0b087 100644 --- a/ardupilotmega/mavlink_msg_mount_status.h +++ b/ardupilotmega/mavlink_msg_mount_status.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_mount_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MOUNT_STATUS_MIN_LEN, MAVLINK_MSG_ID_MOUNT_STATUS_LEN, MAVLINK_MSG_ID_MOUNT_STATUS_CRC); } +/** + * @brief Pack a mount_status 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 target_system System ID. + * @param target_component Component ID. + * @param pointing_a [cdeg] Pitch. + * @param pointing_b [cdeg] Roll. + * @param pointing_c [cdeg] Yaw. + * @param mount_mode Mount operating mode. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mount_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int32_t pointing_a, int32_t pointing_b, int32_t pointing_c, uint8_t mount_mode) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MOUNT_STATUS_LEN]; + _mav_put_int32_t(buf, 0, pointing_a); + _mav_put_int32_t(buf, 4, pointing_b); + _mav_put_int32_t(buf, 8, pointing_c); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint8_t(buf, 13, target_component); + _mav_put_uint8_t(buf, 14, mount_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MOUNT_STATUS_LEN); +#else + mavlink_mount_status_t packet; + packet.pointing_a = pointing_a; + packet.pointing_b = pointing_b; + packet.pointing_c = pointing_c; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mount_mode = mount_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MOUNT_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MOUNT_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_STATUS_MIN_LEN, MAVLINK_MSG_ID_MOUNT_STATUS_LEN, MAVLINK_MSG_ID_MOUNT_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_STATUS_MIN_LEN, MAVLINK_MSG_ID_MOUNT_STATUS_LEN); +#endif +} + /** * @brief Pack a mount_status message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_mount_status_encode_chan(uint8_t system_id, u return mavlink_msg_mount_status_pack_chan(system_id, component_id, chan, msg, mount_status->target_system, mount_status->target_component, mount_status->pointing_a, mount_status->pointing_b, mount_status->pointing_c, mount_status->mount_mode); } +/** + * @brief Encode a mount_status struct with provided status structure + * + * @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 mount_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mount_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mount_status_t* mount_status) +{ + return mavlink_msg_mount_status_pack_status(system_id, component_id, _status, msg, mount_status->target_system, mount_status->target_component, mount_status->pointing_a, mount_status->pointing_b, mount_status->pointing_c, mount_status->mount_mode); +} + /** * @brief Send a mount_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_obstacle_distance_3d.h b/ardupilotmega/mavlink_msg_obstacle_distance_3d.h index ac5a55be..17abb6f2 100644 --- a/ardupilotmega/mavlink_msg_obstacle_distance_3d.h +++ b/ardupilotmega/mavlink_msg_obstacle_distance_3d.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_obstacle_distance_3d_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); } +/** + * @brief Pack a obstacle_distance_3d 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param sensor_type Class id of the distance sensor type. + * @param frame Coordinate frame of reference. + * @param obstacle_id Unique ID given to each obstacle so that its movement can be tracked. Use UINT16_MAX if object ID is unknown or cannot be determined. + * @param x [m] X position of the obstacle. + * @param y [m] Y position of the obstacle. + * @param z [m] Z position of the obstacle. + * @param min_distance [m] Minimum distance the sensor can measure. + * @param max_distance [m] Maximum distance the sensor can measure. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_obstacle_distance_3d_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t sensor_type, uint8_t frame, uint16_t obstacle_id, float x, float y, float z, float min_distance, float max_distance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, min_distance); + _mav_put_float(buf, 20, max_distance); + _mav_put_uint16_t(buf, 24, obstacle_id); + _mav_put_uint8_t(buf, 26, sensor_type); + _mav_put_uint8_t(buf, 27, frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); +#else + mavlink_obstacle_distance_3d_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.min_distance = min_distance; + packet.max_distance = max_distance; + packet.obstacle_id = obstacle_id; + packet.sensor_type = sensor_type; + packet.frame = frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_3D_LEN); +#endif +} + /** * @brief Pack a obstacle_distance_3d message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_obstacle_distance_3d_encode_chan(uint8_t syst return mavlink_msg_obstacle_distance_3d_pack_chan(system_id, component_id, chan, msg, obstacle_distance_3d->time_boot_ms, obstacle_distance_3d->sensor_type, obstacle_distance_3d->frame, obstacle_distance_3d->obstacle_id, obstacle_distance_3d->x, obstacle_distance_3d->y, obstacle_distance_3d->z, obstacle_distance_3d->min_distance, obstacle_distance_3d->max_distance); } +/** + * @brief Encode a obstacle_distance_3d struct with provided status structure + * + * @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 obstacle_distance_3d C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_obstacle_distance_3d_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_obstacle_distance_3d_t* obstacle_distance_3d) +{ + return mavlink_msg_obstacle_distance_3d_pack_status(system_id, component_id, _status, msg, obstacle_distance_3d->time_boot_ms, obstacle_distance_3d->sensor_type, obstacle_distance_3d->frame, obstacle_distance_3d->obstacle_id, obstacle_distance_3d->x, obstacle_distance_3d->y, obstacle_distance_3d->z, obstacle_distance_3d->min_distance, obstacle_distance_3d->max_distance); +} + /** * @brief Send a obstacle_distance_3d message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_osd_param_config.h b/ardupilotmega/mavlink_msg_osd_param_config.h index c19d3db8..b3324076 100644 --- a/ardupilotmega/mavlink_msg_osd_param_config.h +++ b/ardupilotmega/mavlink_msg_osd_param_config.h @@ -115,6 +115,64 @@ static inline uint16_t mavlink_msg_osd_param_config_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_CRC); } +/** + * @brief Pack a osd_param_config 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 target_system System ID. + * @param target_component Component ID. + * @param request_id Request ID - copied to reply. + * @param osd_screen OSD parameter screen index. + * @param osd_index OSD parameter display index. + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param config_type Config type. + * @param min_value OSD parameter minimum value. + * @param max_value OSD parameter maximum value. + * @param increment OSD parameter increment. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_osd_param_config_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t osd_screen, uint8_t osd_index, const char *param_id, uint8_t config_type, float min_value, float max_value, float increment) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_float(buf, 4, min_value); + _mav_put_float(buf, 8, max_value); + _mav_put_float(buf, 12, increment); + _mav_put_uint8_t(buf, 16, target_system); + _mav_put_uint8_t(buf, 17, target_component); + _mav_put_uint8_t(buf, 18, osd_screen); + _mav_put_uint8_t(buf, 19, osd_index); + _mav_put_uint8_t(buf, 36, config_type); + _mav_put_char_array(buf, 20, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN); +#else + mavlink_osd_param_config_t packet; + packet.request_id = request_id; + packet.min_value = min_value; + packet.max_value = max_value; + packet.increment = increment; + packet.target_system = target_system; + packet.target_component = target_component; + packet.osd_screen = osd_screen; + packet.osd_index = osd_index; + packet.config_type = config_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OSD_PARAM_CONFIG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_LEN); +#endif +} + /** * @brief Pack a osd_param_config message on a channel * @param system_id ID of this system @@ -196,6 +254,20 @@ static inline uint16_t mavlink_msg_osd_param_config_encode_chan(uint8_t system_i return mavlink_msg_osd_param_config_pack_chan(system_id, component_id, chan, msg, osd_param_config->target_system, osd_param_config->target_component, osd_param_config->request_id, osd_param_config->osd_screen, osd_param_config->osd_index, osd_param_config->param_id, osd_param_config->config_type, osd_param_config->min_value, osd_param_config->max_value, osd_param_config->increment); } +/** + * @brief Encode a osd_param_config struct with provided status structure + * + * @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 osd_param_config C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_osd_param_config_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_osd_param_config_t* osd_param_config) +{ + return mavlink_msg_osd_param_config_pack_status(system_id, component_id, _status, msg, osd_param_config->target_system, osd_param_config->target_component, osd_param_config->request_id, osd_param_config->osd_screen, osd_param_config->osd_index, osd_param_config->param_id, osd_param_config->config_type, osd_param_config->min_value, osd_param_config->max_value, osd_param_config->increment); +} + /** * @brief Send a osd_param_config message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_osd_param_config_reply.h b/ardupilotmega/mavlink_msg_osd_param_config_reply.h index e8e5e747..06360106 100644 --- a/ardupilotmega/mavlink_msg_osd_param_config_reply.h +++ b/ardupilotmega/mavlink_msg_osd_param_config_reply.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_osd_param_config_reply_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_CRC); } +/** + * @brief Pack a osd_param_config_reply 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 request_id Request ID - copied from request. + * @param result Config error type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_osd_param_config_reply_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t request_id, uint8_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, result); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN); +#else + mavlink_osd_param_config_reply_t packet; + packet.request_id = request_id; + packet.result = result; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_CONFIG_REPLY_LEN); +#endif +} + /** * @brief Pack a osd_param_config_reply message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_osd_param_config_reply_encode_chan(uint8_t sy return mavlink_msg_osd_param_config_reply_pack_chan(system_id, component_id, chan, msg, osd_param_config_reply->request_id, osd_param_config_reply->result); } +/** + * @brief Encode a osd_param_config_reply struct with provided status structure + * + * @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 osd_param_config_reply C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_osd_param_config_reply_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_osd_param_config_reply_t* osd_param_config_reply) +{ + return mavlink_msg_osd_param_config_reply_pack_status(system_id, component_id, _status, msg, osd_param_config_reply->request_id, osd_param_config_reply->result); +} + /** * @brief Send a osd_param_config_reply message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_osd_param_show_config.h b/ardupilotmega/mavlink_msg_osd_param_show_config.h index feb6f111..40eeec4d 100644 --- a/ardupilotmega/mavlink_msg_osd_param_show_config.h +++ b/ardupilotmega/mavlink_msg_osd_param_show_config.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_osd_param_show_config_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_CRC); } +/** + * @brief Pack a osd_param_show_config 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 target_system System ID. + * @param target_component Component ID. + * @param request_id Request ID - copied to reply. + * @param osd_screen OSD parameter screen index. + * @param osd_index OSD parameter display index. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_osd_param_show_config_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t request_id, uint8_t osd_screen, uint8_t osd_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, osd_screen); + _mav_put_uint8_t(buf, 7, osd_index); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN); +#else + mavlink_osd_param_show_config_t packet; + packet.request_id = request_id; + packet.target_system = target_system; + packet.target_component = target_component; + packet.osd_screen = osd_screen; + packet.osd_index = osd_index; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_LEN); +#endif +} + /** * @brief Pack a osd_param_show_config message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_osd_param_show_config_encode_chan(uint8_t sys return mavlink_msg_osd_param_show_config_pack_chan(system_id, component_id, chan, msg, osd_param_show_config->target_system, osd_param_show_config->target_component, osd_param_show_config->request_id, osd_param_show_config->osd_screen, osd_param_show_config->osd_index); } +/** + * @brief Encode a osd_param_show_config struct with provided status structure + * + * @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 osd_param_show_config C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_osd_param_show_config_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_osd_param_show_config_t* osd_param_show_config) +{ + return mavlink_msg_osd_param_show_config_pack_status(system_id, component_id, _status, msg, osd_param_show_config->target_system, osd_param_show_config->target_component, osd_param_show_config->request_id, osd_param_show_config->osd_screen, osd_param_show_config->osd_index); +} + /** * @brief Send a osd_param_show_config message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_osd_param_show_config_reply.h b/ardupilotmega/mavlink_msg_osd_param_show_config_reply.h index 92c448f8..42eeaab6 100644 --- a/ardupilotmega/mavlink_msg_osd_param_show_config_reply.h +++ b/ardupilotmega/mavlink_msg_osd_param_show_config_reply.h @@ -97,6 +97,55 @@ static inline uint16_t mavlink_msg_osd_param_show_config_reply_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_CRC); } +/** + * @brief Pack a osd_param_show_config_reply 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 request_id Request ID - copied from request. + * @param result Config error type. + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param config_type Config type. + * @param min_value OSD parameter minimum value. + * @param max_value OSD parameter maximum value. + * @param increment OSD parameter increment. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_osd_param_show_config_reply_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t request_id, uint8_t result, const char *param_id, uint8_t config_type, float min_value, float max_value, float increment) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN]; + _mav_put_uint32_t(buf, 0, request_id); + _mav_put_float(buf, 4, min_value); + _mav_put_float(buf, 8, max_value); + _mav_put_float(buf, 12, increment); + _mav_put_uint8_t(buf, 16, result); + _mav_put_uint8_t(buf, 33, config_type); + _mav_put_char_array(buf, 17, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN); +#else + mavlink_osd_param_show_config_reply_t packet; + packet.request_id = request_id; + packet.min_value = min_value; + packet.max_value = max_value; + packet.increment = increment; + packet.result = result; + packet.config_type = config_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_MIN_LEN, MAVLINK_MSG_ID_OSD_PARAM_SHOW_CONFIG_REPLY_LEN); +#endif +} + /** * @brief Pack a osd_param_show_config_reply message on a channel * @param system_id ID of this system @@ -169,6 +218,20 @@ static inline uint16_t mavlink_msg_osd_param_show_config_reply_encode_chan(uint8 return mavlink_msg_osd_param_show_config_reply_pack_chan(system_id, component_id, chan, msg, osd_param_show_config_reply->request_id, osd_param_show_config_reply->result, osd_param_show_config_reply->param_id, osd_param_show_config_reply->config_type, osd_param_show_config_reply->min_value, osd_param_show_config_reply->max_value, osd_param_show_config_reply->increment); } +/** + * @brief Encode a osd_param_show_config_reply struct with provided status structure + * + * @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 osd_param_show_config_reply C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_osd_param_show_config_reply_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_osd_param_show_config_reply_t* osd_param_show_config_reply) +{ + return mavlink_msg_osd_param_show_config_reply_pack_status(system_id, component_id, _status, msg, osd_param_show_config_reply->request_id, osd_param_show_config_reply->result, osd_param_show_config_reply->param_id, osd_param_show_config_reply->config_type, osd_param_show_config_reply->min_value, osd_param_show_config_reply->max_value, osd_param_show_config_reply->increment); +} + /** * @brief Send a osd_param_show_config_reply message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_pid_tuning.h b/ardupilotmega/mavlink_msg_pid_tuning.h index fb88e60f..e6385222 100644 --- a/ardupilotmega/mavlink_msg_pid_tuning.h +++ b/ardupilotmega/mavlink_msg_pid_tuning.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_pid_tuning_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC); } +/** + * @brief Pack a pid_tuning 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 axis Axis. + * @param desired Desired rate. + * @param achieved Achieved rate. + * @param FF FF component. + * @param P P component. + * @param I I component. + * @param D D component. + * @param SRate Slew rate. + * @param PDmod P/D oscillation modifier. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_pid_tuning_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t axis, float desired, float achieved, float FF, float P, float I, float D, float SRate, float PDmod) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PID_TUNING_LEN]; + _mav_put_float(buf, 0, desired); + _mav_put_float(buf, 4, achieved); + _mav_put_float(buf, 8, FF); + _mav_put_float(buf, 12, P); + _mav_put_float(buf, 16, I); + _mav_put_float(buf, 20, D); + _mav_put_uint8_t(buf, 24, axis); + _mav_put_float(buf, 25, SRate); + _mav_put_float(buf, 29, PDmod); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PID_TUNING_LEN); +#else + mavlink_pid_tuning_t packet; + packet.desired = desired; + packet.achieved = achieved; + packet.FF = FF; + packet.P = P; + packet.I = I; + packet.D = D; + packet.axis = axis; + packet.SRate = SRate; + packet.PDmod = PDmod; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PID_TUNING_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PID_TUNING; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN, MAVLINK_MSG_ID_PID_TUNING_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PID_TUNING_MIN_LEN, MAVLINK_MSG_ID_PID_TUNING_LEN); +#endif +} + /** * @brief Pack a pid_tuning message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_pid_tuning_encode_chan(uint8_t system_id, uin return mavlink_msg_pid_tuning_pack_chan(system_id, component_id, chan, msg, pid_tuning->axis, pid_tuning->desired, pid_tuning->achieved, pid_tuning->FF, pid_tuning->P, pid_tuning->I, pid_tuning->D, pid_tuning->SRate, pid_tuning->PDmod); } +/** + * @brief Encode a pid_tuning struct with provided status structure + * + * @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 pid_tuning C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_pid_tuning_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_pid_tuning_t* pid_tuning) +{ + return mavlink_msg_pid_tuning_pack_status(system_id, component_id, _status, msg, pid_tuning->axis, pid_tuning->desired, pid_tuning->achieved, pid_tuning->FF, pid_tuning->P, pid_tuning->I, pid_tuning->D, pid_tuning->SRate, pid_tuning->PDmod); +} + /** * @brief Send a pid_tuning message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_radio.h b/ardupilotmega/mavlink_msg_radio.h index 1afb4d73..737789ff 100644 --- a/ardupilotmega/mavlink_msg_radio.h +++ b/ardupilotmega/mavlink_msg_radio.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_radio_pack(uint8_t system_id, uint8_t compone return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC); } +/** + * @brief Pack a radio 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 rssi Local signal strength. + * @param remrssi Remote signal strength. + * @param txbuf [%] How full the tx buffer is. + * @param noise Background noise level. + * @param remnoise Remote background noise level. + * @param rxerrors Receive errors. + * @param fixed Count of error corrected packets. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RADIO_LEN]; + _mav_put_uint16_t(buf, 0, rxerrors); + _mav_put_uint16_t(buf, 2, fixed); + _mav_put_uint8_t(buf, 4, rssi); + _mav_put_uint8_t(buf, 5, remrssi); + _mav_put_uint8_t(buf, 6, txbuf); + _mav_put_uint8_t(buf, 7, noise); + _mav_put_uint8_t(buf, 8, remnoise); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_LEN); +#else + mavlink_radio_t packet; + packet.rxerrors = rxerrors; + packet.fixed = fixed; + packet.rssi = rssi; + packet.remrssi = remrssi; + packet.txbuf = txbuf; + packet.noise = noise; + packet.remnoise = remnoise; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN); +#endif +} + /** * @brief Pack a radio message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_radio_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_radio_pack_chan(system_id, component_id, chan, msg, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed); } +/** + * @brief Encode a radio struct with provided status structure + * + * @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 radio C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_radio_t* radio) +{ + return mavlink_msg_radio_pack_status(system_id, component_id, _status, msg, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed); +} + /** * @brief Send a radio message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_rally_fetch_point.h b/ardupilotmega/mavlink_msg_rally_fetch_point.h index 29111e0b..e32750e5 100644 --- a/ardupilotmega/mavlink_msg_rally_fetch_point.h +++ b/ardupilotmega/mavlink_msg_rally_fetch_point.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_rally_fetch_point_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RALLY_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN, MAVLINK_MSG_ID_RALLY_FETCH_POINT_CRC); } +/** + * @brief Pack a rally_fetch_point 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 target_system System ID. + * @param target_component Component ID. + * @param idx Point index (first point is 0). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rally_fetch_point_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t idx) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, idx); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN); +#else + mavlink_rally_fetch_point_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.idx = idx; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RALLY_FETCH_POINT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RALLY_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN, MAVLINK_MSG_ID_RALLY_FETCH_POINT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RALLY_FETCH_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_FETCH_POINT_LEN); +#endif +} + /** * @brief Pack a rally_fetch_point message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_rally_fetch_point_encode_chan(uint8_t system_ return mavlink_msg_rally_fetch_point_pack_chan(system_id, component_id, chan, msg, rally_fetch_point->target_system, rally_fetch_point->target_component, rally_fetch_point->idx); } +/** + * @brief Encode a rally_fetch_point struct with provided status structure + * + * @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 rally_fetch_point C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rally_fetch_point_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rally_fetch_point_t* rally_fetch_point) +{ + return mavlink_msg_rally_fetch_point_pack_status(system_id, component_id, _status, msg, rally_fetch_point->target_system, rally_fetch_point->target_component, rally_fetch_point->idx); +} + /** * @brief Send a rally_fetch_point message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_rally_point.h b/ardupilotmega/mavlink_msg_rally_point.h index d16440ed..4c5ad89a 100644 --- a/ardupilotmega/mavlink_msg_rally_point.h +++ b/ardupilotmega/mavlink_msg_rally_point.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_rally_point_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RALLY_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_POINT_LEN, MAVLINK_MSG_ID_RALLY_POINT_CRC); } +/** + * @brief Pack a rally_point 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 target_system System ID. + * @param target_component Component ID. + * @param idx Point index (first point is 0). + * @param count Total number of points (for sanity checking). + * @param lat [degE7] Latitude of point. + * @param lng [degE7] Longitude of point. + * @param alt [m] Transit / loiter altitude relative to home. + * @param break_alt [m] Break altitude relative to home. + * @param land_dir [cdeg] Heading to aim for when landing. + * @param flags Configuration flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rally_point_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, int32_t lat, int32_t lng, int16_t alt, int16_t break_alt, uint16_t land_dir, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RALLY_POINT_LEN]; + _mav_put_int32_t(buf, 0, lat); + _mav_put_int32_t(buf, 4, lng); + _mav_put_int16_t(buf, 8, alt); + _mav_put_int16_t(buf, 10, break_alt); + _mav_put_uint16_t(buf, 12, land_dir); + _mav_put_uint8_t(buf, 14, target_system); + _mav_put_uint8_t(buf, 15, target_component); + _mav_put_uint8_t(buf, 16, idx); + _mav_put_uint8_t(buf, 17, count); + _mav_put_uint8_t(buf, 18, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RALLY_POINT_LEN); +#else + mavlink_rally_point_t packet; + packet.lat = lat; + packet.lng = lng; + packet.alt = alt; + packet.break_alt = break_alt; + packet.land_dir = land_dir; + packet.target_system = target_system; + packet.target_component = target_component; + packet.idx = idx; + packet.count = count; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RALLY_POINT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RALLY_POINT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RALLY_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_POINT_LEN, MAVLINK_MSG_ID_RALLY_POINT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RALLY_POINT_MIN_LEN, MAVLINK_MSG_ID_RALLY_POINT_LEN); +#endif +} + /** * @brief Pack a rally_point message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_rally_point_encode_chan(uint8_t system_id, ui return mavlink_msg_rally_point_pack_chan(system_id, component_id, chan, msg, rally_point->target_system, rally_point->target_component, rally_point->idx, rally_point->count, rally_point->lat, rally_point->lng, rally_point->alt, rally_point->break_alt, rally_point->land_dir, rally_point->flags); } +/** + * @brief Encode a rally_point struct with provided status structure + * + * @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 rally_point C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rally_point_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rally_point_t* rally_point) +{ + return mavlink_msg_rally_point_pack_status(system_id, component_id, _status, msg, rally_point->target_system, rally_point->target_component, rally_point->idx, rally_point->count, rally_point->lat, rally_point->lng, rally_point->alt, rally_point->break_alt, rally_point->land_dir, rally_point->flags); +} + /** * @brief Send a rally_point message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_rangefinder.h b/ardupilotmega/mavlink_msg_rangefinder.h index 88476b16..d59d2731 100644 --- a/ardupilotmega/mavlink_msg_rangefinder.h +++ b/ardupilotmega/mavlink_msg_rangefinder.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_rangefinder_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RANGEFINDER_MIN_LEN, MAVLINK_MSG_ID_RANGEFINDER_LEN, MAVLINK_MSG_ID_RANGEFINDER_CRC); } +/** + * @brief Pack a rangefinder 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 distance [m] Distance. + * @param voltage [V] Raw voltage if available, zero otherwise. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rangefinder_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float distance, float voltage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RANGEFINDER_LEN]; + _mav_put_float(buf, 0, distance); + _mav_put_float(buf, 4, voltage); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RANGEFINDER_LEN); +#else + mavlink_rangefinder_t packet; + packet.distance = distance; + packet.voltage = voltage; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RANGEFINDER_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RANGEFINDER; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RANGEFINDER_MIN_LEN, MAVLINK_MSG_ID_RANGEFINDER_LEN, MAVLINK_MSG_ID_RANGEFINDER_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RANGEFINDER_MIN_LEN, MAVLINK_MSG_ID_RANGEFINDER_LEN); +#endif +} + /** * @brief Pack a rangefinder message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_rangefinder_encode_chan(uint8_t system_id, ui return mavlink_msg_rangefinder_pack_chan(system_id, component_id, chan, msg, rangefinder->distance, rangefinder->voltage); } +/** + * @brief Encode a rangefinder struct with provided status structure + * + * @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 rangefinder C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rangefinder_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rangefinder_t* rangefinder) +{ + return mavlink_msg_rangefinder_pack_status(system_id, component_id, _status, msg, rangefinder->distance, rangefinder->voltage); +} + /** * @brief Send a rangefinder message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_remote_log_block_status.h b/ardupilotmega/mavlink_msg_remote_log_block_status.h index 521e9fba..53b288af 100644 --- a/ardupilotmega/mavlink_msg_remote_log_block_status.h +++ b/ardupilotmega/mavlink_msg_remote_log_block_status.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_remote_log_block_status_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_CRC); } +/** + * @brief Pack a remote_log_block_status 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 target_system System ID. + * @param target_component Component ID. + * @param seqno Log data block sequence number. + * @param status Log data block status. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_remote_log_block_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t seqno, uint8_t status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, seqno); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN); +#else + mavlink_remote_log_block_status_t packet; + packet.seqno = seqno; + packet.target_system = target_system; + packet.target_component = target_component; + packet.status = status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS_LEN); +#endif +} + /** * @brief Pack a remote_log_block_status message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_remote_log_block_status_encode_chan(uint8_t s return mavlink_msg_remote_log_block_status_pack_chan(system_id, component_id, chan, msg, remote_log_block_status->target_system, remote_log_block_status->target_component, remote_log_block_status->seqno, remote_log_block_status->status); } +/** + * @brief Encode a remote_log_block_status struct with provided status structure + * + * @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 remote_log_block_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_remote_log_block_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_remote_log_block_status_t* remote_log_block_status) +{ + return mavlink_msg_remote_log_block_status_pack_status(system_id, component_id, _status, msg, remote_log_block_status->target_system, remote_log_block_status->target_component, remote_log_block_status->seqno, remote_log_block_status->status); +} + /** * @brief Send a remote_log_block_status message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_remote_log_data_block.h b/ardupilotmega/mavlink_msg_remote_log_data_block.h index 7fcc6ba1..5fcc6d97 100644 --- a/ardupilotmega/mavlink_msg_remote_log_data_block.h +++ b/ardupilotmega/mavlink_msg_remote_log_data_block.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_remote_log_data_block_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_CRC); } +/** + * @brief Pack a remote_log_data_block 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 target_system System ID. + * @param target_component Component ID. + * @param seqno Log data block sequence number. + * @param data Log data block. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_remote_log_data_block_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t seqno, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN]; + _mav_put_uint32_t(buf, 0, seqno); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t_array(buf, 6, data, 200); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN); +#else + mavlink_remote_log_data_block_t packet; + packet.seqno = seqno; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*200); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_MIN_LEN, MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK_LEN); +#endif +} + /** * @brief Pack a remote_log_data_block message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_remote_log_data_block_encode_chan(uint8_t sys return mavlink_msg_remote_log_data_block_pack_chan(system_id, component_id, chan, msg, remote_log_data_block->target_system, remote_log_data_block->target_component, remote_log_data_block->seqno, remote_log_data_block->data); } +/** + * @brief Encode a remote_log_data_block struct with provided status structure + * + * @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 remote_log_data_block C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_remote_log_data_block_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_remote_log_data_block_t* remote_log_data_block) +{ + return mavlink_msg_remote_log_data_block_pack_status(system_id, component_id, _status, msg, remote_log_data_block->target_system, remote_log_data_block->target_component, remote_log_data_block->seqno, remote_log_data_block->data); +} + /** * @brief Send a remote_log_data_block message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_rpm.h b/ardupilotmega/mavlink_msg_rpm.h index 480b5b80..dc4c05ce 100644 --- a/ardupilotmega/mavlink_msg_rpm.h +++ b/ardupilotmega/mavlink_msg_rpm.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_rpm_pack(uint8_t system_id, uint8_t component return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RPM_MIN_LEN, MAVLINK_MSG_ID_RPM_LEN, MAVLINK_MSG_ID_RPM_CRC); } +/** + * @brief Pack a rpm 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 rpm1 RPM Sensor1. + * @param rpm2 RPM Sensor2. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rpm_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float rpm1, float rpm2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RPM_LEN]; + _mav_put_float(buf, 0, rpm1); + _mav_put_float(buf, 4, rpm2); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RPM_LEN); +#else + mavlink_rpm_t packet; + packet.rpm1 = rpm1; + packet.rpm2 = rpm2; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RPM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RPM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RPM_MIN_LEN, MAVLINK_MSG_ID_RPM_LEN, MAVLINK_MSG_ID_RPM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RPM_MIN_LEN, MAVLINK_MSG_ID_RPM_LEN); +#endif +} + /** * @brief Pack a rpm message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_rpm_encode_chan(uint8_t system_id, uint8_t co return mavlink_msg_rpm_pack_chan(system_id, component_id, chan, msg, rpm->rpm1, rpm->rpm2); } +/** + * @brief Encode a rpm struct with provided status structure + * + * @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 rpm C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rpm_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rpm_t* rpm) +{ + return mavlink_msg_rpm_pack_status(system_id, component_id, _status, msg, rpm->rpm1, rpm->rpm2); +} + /** * @brief Send a rpm message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_sensor_offsets.h b/ardupilotmega/mavlink_msg_sensor_offsets.h index cb92007d..b37a02f6 100644 --- a/ardupilotmega/mavlink_msg_sensor_offsets.h +++ b/ardupilotmega/mavlink_msg_sensor_offsets.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSOR_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_CRC); } +/** + * @brief Pack a sensor_offsets 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 mag_ofs_x Magnetometer X offset. + * @param mag_ofs_y Magnetometer Y offset. + * @param mag_ofs_z Magnetometer Z offset. + * @param mag_declination [rad] Magnetic declination. + * @param raw_press Raw pressure from barometer. + * @param raw_temp Raw temperature from barometer. + * @param gyro_cal_x Gyro X calibration. + * @param gyro_cal_y Gyro Y calibration. + * @param gyro_cal_z Gyro Z calibration. + * @param accel_cal_x Accel X calibration. + * @param accel_cal_y Accel Y calibration. + * @param accel_cal_z Accel Z calibration. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sensor_offsets_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN]; + _mav_put_float(buf, 0, mag_declination); + _mav_put_int32_t(buf, 4, raw_press); + _mav_put_int32_t(buf, 8, raw_temp); + _mav_put_float(buf, 12, gyro_cal_x); + _mav_put_float(buf, 16, gyro_cal_y); + _mav_put_float(buf, 20, gyro_cal_z); + _mav_put_float(buf, 24, accel_cal_x); + _mav_put_float(buf, 28, accel_cal_y); + _mav_put_float(buf, 32, accel_cal_z); + _mav_put_int16_t(buf, 36, mag_ofs_x); + _mav_put_int16_t(buf, 38, mag_ofs_y); + _mav_put_int16_t(buf, 40, mag_ofs_z); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN); +#else + mavlink_sensor_offsets_t packet; + packet.mag_declination = mag_declination; + packet.raw_press = raw_press; + packet.raw_temp = raw_temp; + packet.gyro_cal_x = gyro_cal_x; + packet.gyro_cal_y = gyro_cal_y; + packet.gyro_cal_z = gyro_cal_z; + packet.accel_cal_x = accel_cal_x; + packet.accel_cal_y = accel_cal_y; + packet.accel_cal_z = accel_cal_z; + packet.mag_ofs_x = mag_ofs_x; + packet.mag_ofs_y = mag_ofs_y; + packet.mag_ofs_z = mag_ofs_z; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSOR_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SENSOR_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN); +#endif +} + /** * @brief Pack a sensor_offsets message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_sensor_offsets_encode_chan(uint8_t system_id, return mavlink_msg_sensor_offsets_pack_chan(system_id, component_id, chan, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z); } +/** + * @brief Encode a sensor_offsets struct with provided status structure + * + * @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 sensor_offsets C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sensor_offsets_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sensor_offsets_t* sensor_offsets) +{ + return mavlink_msg_sensor_offsets_pack_status(system_id, component_id, _status, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z); +} + /** * @brief Send a sensor_offsets message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_set_mag_offsets.h b/ardupilotmega/mavlink_msg_set_mag_offsets.h index 37308590..113891c6 100644 --- a/ardupilotmega/mavlink_msg_set_mag_offsets.h +++ b/ardupilotmega/mavlink_msg_set_mag_offsets.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_set_mag_offsets_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_MAG_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN, MAVLINK_MSG_ID_SET_MAG_OFFSETS_CRC); } +/** + * @brief Pack a set_mag_offsets 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 target_system System ID. + * @param target_component Component ID. + * @param mag_ofs_x Magnetometer X offset. + * @param mag_ofs_y Magnetometer Y offset. + * @param mag_ofs_z Magnetometer Z offset. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_mag_offsets_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN]; + _mav_put_int16_t(buf, 0, mag_ofs_x); + _mav_put_int16_t(buf, 2, mag_ofs_y); + _mav_put_int16_t(buf, 4, mag_ofs_z); + _mav_put_uint8_t(buf, 6, target_system); + _mav_put_uint8_t(buf, 7, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN); +#else + mavlink_set_mag_offsets_t packet; + packet.mag_ofs_x = mag_ofs_x; + packet.mag_ofs_y = mag_ofs_y; + packet.mag_ofs_z = mag_ofs_z; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_MAG_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN, MAVLINK_MSG_ID_SET_MAG_OFFSETS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_MAG_OFFSETS_MIN_LEN, MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN); +#endif +} + /** * @brief Pack a set_mag_offsets message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_set_mag_offsets_encode_chan(uint8_t system_id return mavlink_msg_set_mag_offsets_pack_chan(system_id, component_id, chan, msg, set_mag_offsets->target_system, set_mag_offsets->target_component, set_mag_offsets->mag_ofs_x, set_mag_offsets->mag_ofs_y, set_mag_offsets->mag_ofs_z); } +/** + * @brief Encode a set_mag_offsets struct with provided status structure + * + * @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 set_mag_offsets C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_mag_offsets_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_mag_offsets_t* set_mag_offsets) +{ + return mavlink_msg_set_mag_offsets_pack_status(system_id, component_id, _status, msg, set_mag_offsets->target_system, set_mag_offsets->target_component, set_mag_offsets->mag_ofs_x, set_mag_offsets->mag_ofs_y, set_mag_offsets->mag_ofs_z); +} + /** * @brief Send a set_mag_offsets message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_simstate.h b/ardupilotmega/mavlink_msg_simstate.h index 795d595b..5745aea1 100644 --- a/ardupilotmega/mavlink_msg_simstate.h +++ b/ardupilotmega/mavlink_msg_simstate.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_simstate_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC); } +/** + * @brief Pack a simstate 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 roll [rad] Roll angle. + * @param pitch [rad] Pitch angle. + * @param yaw [rad] Yaw angle. + * @param xacc [m/s/s] X acceleration. + * @param yacc [m/s/s] Y acceleration. + * @param zacc [m/s/s] Z acceleration. + * @param xgyro [rad/s] Angular speed around X axis. + * @param ygyro [rad/s] Angular speed around Y axis. + * @param zgyro [rad/s] Angular speed around Z axis. + * @param lat [degE7] Latitude. + * @param lng [degE7] Longitude. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_simstate_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, int32_t lat, int32_t lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SIMSTATE_LEN]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, xacc); + _mav_put_float(buf, 16, yacc); + _mav_put_float(buf, 20, zacc); + _mav_put_float(buf, 24, xgyro); + _mav_put_float(buf, 28, ygyro); + _mav_put_float(buf, 32, zgyro); + _mav_put_int32_t(buf, 36, lat); + _mav_put_int32_t(buf, 40, lng); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIMSTATE_LEN); +#else + mavlink_simstate_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.lat = lat; + packet.lng = lng; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIMSTATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SIMSTATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN); +#endif +} + /** * @brief Pack a simstate message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_simstate_encode_chan(uint8_t system_id, uint8 return mavlink_msg_simstate_pack_chan(system_id, component_id, chan, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng); } +/** + * @brief Encode a simstate struct with provided status structure + * + * @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 simstate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_simstate_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_simstate_t* simstate) +{ + return mavlink_msg_simstate_pack_status(system_id, component_id, _status, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng); +} + /** * @brief Send a simstate message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_vision_position_delta.h b/ardupilotmega/mavlink_msg_vision_position_delta.h index abc3e93b..973093c3 100644 --- a/ardupilotmega/mavlink_msg_vision_position_delta.h +++ b/ardupilotmega/mavlink_msg_vision_position_delta.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_vision_position_delta_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VISION_POSITION_DELTA_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN, MAVLINK_MSG_ID_VISION_POSITION_DELTA_CRC); } +/** + * @brief Pack a vision_position_delta 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 time_usec [us] Timestamp (synced to UNIX time or since system boot). + * @param time_delta_usec [us] Time since the last reported camera frame. + * @param angle_delta [rad] Defines a rotation vector [roll, pitch, yaw] to the current MAV_FRAME_BODY_FRD from the previous MAV_FRAME_BODY_FRD. + * @param position_delta [m] Change in position to the current MAV_FRAME_BODY_FRD from the previous FRAME_BODY_FRD rotated to the current MAV_FRAME_BODY_FRD. + * @param confidence [%] Normalised confidence value from 0 to 100. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vision_position_delta_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint64_t time_delta_usec, const float *angle_delta, const float *position_delta, float confidence) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint64_t(buf, 8, time_delta_usec); + _mav_put_float(buf, 40, confidence); + _mav_put_float_array(buf, 16, angle_delta, 3); + _mav_put_float_array(buf, 28, position_delta, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN); +#else + mavlink_vision_position_delta_t packet; + packet.time_usec = time_usec; + packet.time_delta_usec = time_delta_usec; + packet.confidence = confidence; + mav_array_memcpy(packet.angle_delta, angle_delta, sizeof(float)*3); + mav_array_memcpy(packet.position_delta, position_delta, sizeof(float)*3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VISION_POSITION_DELTA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_POSITION_DELTA_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN, MAVLINK_MSG_ID_VISION_POSITION_DELTA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_POSITION_DELTA_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_DELTA_LEN); +#endif +} + /** * @brief Pack a vision_position_delta message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_vision_position_delta_encode_chan(uint8_t sys return mavlink_msg_vision_position_delta_pack_chan(system_id, component_id, chan, msg, vision_position_delta->time_usec, vision_position_delta->time_delta_usec, vision_position_delta->angle_delta, vision_position_delta->position_delta, vision_position_delta->confidence); } +/** + * @brief Encode a vision_position_delta struct with provided status structure + * + * @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 vision_position_delta C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vision_position_delta_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vision_position_delta_t* vision_position_delta) +{ + return mavlink_msg_vision_position_delta_pack_status(system_id, component_id, _status, msg, vision_position_delta->time_usec, vision_position_delta->time_delta_usec, vision_position_delta->angle_delta, vision_position_delta->position_delta, vision_position_delta->confidence); +} + /** * @brief Send a vision_position_delta message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_water_depth.h b/ardupilotmega/mavlink_msg_water_depth.h index 3b6fa8da..7c13fbbd 100644 --- a/ardupilotmega/mavlink_msg_water_depth.h +++ b/ardupilotmega/mavlink_msg_water_depth.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_water_depth_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WATER_DEPTH_MIN_LEN, MAVLINK_MSG_ID_WATER_DEPTH_LEN, MAVLINK_MSG_ID_WATER_DEPTH_CRC); } +/** + * @brief Pack a water_depth 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 time_boot_ms [ms] Timestamp (time since system boot) + * @param id Onboard ID of the sensor + * @param healthy Sensor data healthy (0=unhealthy, 1=healthy) + * @param lat [degE7] Latitude + * @param lng [degE7] Longitude + * @param alt [m] Altitude (MSL) of vehicle + * @param roll [rad] Roll angle + * @param pitch [rad] Pitch angle + * @param yaw [rad] Yaw angle + * @param distance [m] Distance (uncorrected) + * @param temperature [degC] Water temperature + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_water_depth_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t id, uint8_t healthy, int32_t lat, int32_t lng, float alt, float roll, float pitch, float yaw, float distance, float temperature) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WATER_DEPTH_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat); + _mav_put_int32_t(buf, 8, lng); + _mav_put_float(buf, 12, alt); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + _mav_put_float(buf, 28, distance); + _mav_put_float(buf, 32, temperature); + _mav_put_uint8_t(buf, 36, id); + _mav_put_uint8_t(buf, 37, healthy); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WATER_DEPTH_LEN); +#else + mavlink_water_depth_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat = lat; + packet.lng = lng; + packet.alt = alt; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.distance = distance; + packet.temperature = temperature; + packet.id = id; + packet.healthy = healthy; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WATER_DEPTH_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WATER_DEPTH; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WATER_DEPTH_MIN_LEN, MAVLINK_MSG_ID_WATER_DEPTH_LEN, MAVLINK_MSG_ID_WATER_DEPTH_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WATER_DEPTH_MIN_LEN, MAVLINK_MSG_ID_WATER_DEPTH_LEN); +#endif +} + /** * @brief Pack a water_depth message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_water_depth_encode_chan(uint8_t system_id, ui return mavlink_msg_water_depth_pack_chan(system_id, component_id, chan, msg, water_depth->time_boot_ms, water_depth->id, water_depth->healthy, water_depth->lat, water_depth->lng, water_depth->alt, water_depth->roll, water_depth->pitch, water_depth->yaw, water_depth->distance, water_depth->temperature); } +/** + * @brief Encode a water_depth struct with provided status structure + * + * @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 water_depth C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_water_depth_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_water_depth_t* water_depth) +{ + return mavlink_msg_water_depth_pack_status(system_id, component_id, _status, msg, water_depth->time_boot_ms, water_depth->id, water_depth->healthy, water_depth->lat, water_depth->lng, water_depth->alt, water_depth->roll, water_depth->pitch, water_depth->yaw, water_depth->distance, water_depth->temperature); +} + /** * @brief Send a water_depth message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/mavlink_msg_wind.h b/ardupilotmega/mavlink_msg_wind.h index d10b05d0..ed086da3 100644 --- a/ardupilotmega/mavlink_msg_wind.h +++ b/ardupilotmega/mavlink_msg_wind.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_wind_pack(uint8_t system_id, uint8_t componen return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WIND_MIN_LEN, MAVLINK_MSG_ID_WIND_LEN, MAVLINK_MSG_ID_WIND_CRC); } +/** + * @brief Pack a wind 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 direction [deg] Wind direction (that wind is coming from). + * @param speed [m/s] Wind speed in ground plane. + * @param speed_z [m/s] Vertical wind speed. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wind_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float direction, float speed, float speed_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WIND_LEN]; + _mav_put_float(buf, 0, direction); + _mav_put_float(buf, 4, speed); + _mav_put_float(buf, 8, speed_z); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIND_LEN); +#else + mavlink_wind_t packet; + packet.direction = direction; + packet.speed = speed; + packet.speed_z = speed_z; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIND_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIND; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIND_MIN_LEN, MAVLINK_MSG_ID_WIND_LEN, MAVLINK_MSG_ID_WIND_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIND_MIN_LEN, MAVLINK_MSG_ID_WIND_LEN); +#endif +} + /** * @brief Pack a wind message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_wind_encode_chan(uint8_t system_id, uint8_t c return mavlink_msg_wind_pack_chan(system_id, component_id, chan, msg, wind->direction, wind->speed, wind->speed_z); } +/** + * @brief Encode a wind struct with provided status structure + * + * @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 wind C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wind_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wind_t* wind) +{ + return mavlink_msg_wind_pack_status(system_id, component_id, _status, msg, wind->direction, wind->speed, wind->speed_z); +} + /** * @brief Send a wind message * @param chan MAVLink channel to send the message diff --git a/ardupilotmega/version.h b/ardupilotmega/version.h index 634233d2..a9bd2343 100644 --- a/ardupilotmega/version.h +++ b/ardupilotmega/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/common/common.h b/common/common.h index 0060679e..092d3dfe 100644 --- a/common/common.h +++ b/common/common.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_COMMON.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_COMMON_XML_HASH -8883233578418662464 +#define MAVLINK_COMMON_XML_HASH 5594176508389277203 #ifdef __cplusplus extern "C" { diff --git a/common/mavlink.h b/common/mavlink.h index 458e165f..a232a5a9 100644 --- a/common/mavlink.h +++ b/common/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -8883233578418662464 +#define MAVLINK_PRIMARY_XML_HASH 5594176508389277203 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/common/mavlink_msg_actuator_control_target.h b/common/mavlink_msg_actuator_control_target.h index c5ad9f65..9845d5d3 100644 --- a/common/mavlink_msg_actuator_control_target.h +++ b/common/mavlink_msg_actuator_control_target.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_actuator_control_target_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC); } +/** + * @brief Pack a actuator_control_target 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances. + * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_actuator_control_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t group_mlx, const float *controls) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 40, group_mlx); + _mav_put_float_array(buf, 8, controls, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN); +#else + mavlink_actuator_control_target_t packet; + packet.time_usec = time_usec; + packet.group_mlx = group_mlx; + mav_array_memcpy(packet.controls, controls, sizeof(float)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN); +#endif +} + /** * @brief Pack a actuator_control_target message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_actuator_control_target_encode_chan(uint8_t s return mavlink_msg_actuator_control_target_pack_chan(system_id, component_id, chan, msg, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls); } +/** + * @brief Encode a actuator_control_target struct with provided status structure + * + * @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 actuator_control_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_actuator_control_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_actuator_control_target_t* actuator_control_target) +{ + return mavlink_msg_actuator_control_target_pack_status(system_id, component_id, _status, msg, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls); +} + /** * @brief Send a actuator_control_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_actuator_output_status.h b/common/mavlink_msg_actuator_output_status.h index 4fc1069b..47a73e26 100644 --- a/common/mavlink_msg_actuator_output_status.h +++ b/common/mavlink_msg_actuator_output_status.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_actuator_output_status_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_CRC); } +/** + * @brief Pack a actuator_output_status 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 time_usec [us] Timestamp (since system boot). + * @param active Active outputs + * @param actuator Servo / motor output array values. Zero values indicate unused channels. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_actuator_output_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t active, const float *actuator) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, active); + _mav_put_float_array(buf, 12, actuator, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN); +#else + mavlink_actuator_output_status_t packet; + packet.time_usec = time_usec; + packet.active = active; + mav_array_memcpy(packet.actuator, actuator, sizeof(float)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_OUTPUT_STATUS_LEN); +#endif +} + /** * @brief Pack a actuator_output_status message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_actuator_output_status_encode_chan(uint8_t sy return mavlink_msg_actuator_output_status_pack_chan(system_id, component_id, chan, msg, actuator_output_status->time_usec, actuator_output_status->active, actuator_output_status->actuator); } +/** + * @brief Encode a actuator_output_status struct with provided status structure + * + * @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 actuator_output_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_actuator_output_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_actuator_output_status_t* actuator_output_status) +{ + return mavlink_msg_actuator_output_status_pack_status(system_id, component_id, _status, msg, actuator_output_status->time_usec, actuator_output_status->active, actuator_output_status->actuator); +} + /** * @brief Send a actuator_output_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_adsb_vehicle.h b/common/mavlink_msg_adsb_vehicle.h index d6220289..a97bb6f4 100644 --- a/common/mavlink_msg_adsb_vehicle.h +++ b/common/mavlink_msg_adsb_vehicle.h @@ -133,6 +133,73 @@ static inline uint16_t mavlink_msg_adsb_vehicle_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC); } +/** + * @brief Pack a adsb_vehicle 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 ICAO_address ICAO address + * @param lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param altitude_type ADSB altitude type. + * @param altitude [mm] Altitude(ASL) + * @param heading [cdeg] Course over ground + * @param hor_velocity [cm/s] The horizontal velocity + * @param ver_velocity [cm/s] The vertical velocity. Positive is up + * @param callsign The callsign, 8+null + * @param emitter_type ADSB emitter type. + * @param tslc [s] Time since last communication in seconds + * @param flags Bitmap to indicate various statuses including valid data fields + * @param squawk Squawk code + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_adsb_vehicle_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t ICAO_address, int32_t lat, int32_t lon, uint8_t altitude_type, int32_t altitude, uint16_t heading, uint16_t hor_velocity, int16_t ver_velocity, const char *callsign, uint8_t emitter_type, uint8_t tslc, uint16_t flags, uint16_t squawk) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ADSB_VEHICLE_LEN]; + _mav_put_uint32_t(buf, 0, ICAO_address); + _mav_put_int32_t(buf, 4, lat); + _mav_put_int32_t(buf, 8, lon); + _mav_put_int32_t(buf, 12, altitude); + _mav_put_uint16_t(buf, 16, heading); + _mav_put_uint16_t(buf, 18, hor_velocity); + _mav_put_int16_t(buf, 20, ver_velocity); + _mav_put_uint16_t(buf, 22, flags); + _mav_put_uint16_t(buf, 24, squawk); + _mav_put_uint8_t(buf, 26, altitude_type); + _mav_put_uint8_t(buf, 36, emitter_type); + _mav_put_uint8_t(buf, 37, tslc); + _mav_put_char_array(buf, 27, callsign, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN); +#else + mavlink_adsb_vehicle_t packet; + packet.ICAO_address = ICAO_address; + packet.lat = lat; + packet.lon = lon; + packet.altitude = altitude; + packet.heading = heading; + packet.hor_velocity = hor_velocity; + packet.ver_velocity = ver_velocity; + packet.flags = flags; + packet.squawk = squawk; + packet.altitude_type = altitude_type; + packet.emitter_type = emitter_type; + packet.tslc = tslc; + mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ADSB_VEHICLE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN); +#endif +} + /** * @brief Pack a adsb_vehicle message on a channel * @param system_id ID of this system @@ -223,6 +290,20 @@ static inline uint16_t mavlink_msg_adsb_vehicle_encode_chan(uint8_t system_id, u return mavlink_msg_adsb_vehicle_pack_chan(system_id, component_id, chan, msg, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk); } +/** + * @brief Encode a adsb_vehicle struct with provided status structure + * + * @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 adsb_vehicle C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_adsb_vehicle_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_adsb_vehicle_t* adsb_vehicle) +{ + return mavlink_msg_adsb_vehicle_pack_status(system_id, component_id, _status, msg, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk); +} + /** * @brief Send a adsb_vehicle message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_ais_vessel.h b/common/mavlink_msg_ais_vessel.h index 1e1287b7..fdc3bb5b 100644 --- a/common/mavlink_msg_ais_vessel.h +++ b/common/mavlink_msg_ais_vessel.h @@ -158,6 +158,85 @@ static inline uint16_t mavlink_msg_ais_vessel_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIS_VESSEL_MIN_LEN, MAVLINK_MSG_ID_AIS_VESSEL_LEN, MAVLINK_MSG_ID_AIS_VESSEL_CRC); } +/** + * @brief Pack a ais_vessel 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 MMSI Mobile Marine Service Identifier, 9 decimal digits + * @param lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param COG [cdeg] Course over ground + * @param heading [cdeg] True heading + * @param velocity [cm/s] Speed over ground + * @param turn_rate [cdeg/s] Turn rate + * @param navigational_status Navigational status + * @param type Type of vessels + * @param dimension_bow [m] Distance from lat/lon location to bow + * @param dimension_stern [m] Distance from lat/lon location to stern + * @param dimension_port [m] Distance from lat/lon location to port side + * @param dimension_starboard [m] Distance from lat/lon location to starboard side + * @param callsign The vessel callsign + * @param name The vessel name + * @param tslc [s] Time since last communication in seconds + * @param flags Bitmask to indicate various statuses including valid data fields + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ais_vessel_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t MMSI, int32_t lat, int32_t lon, uint16_t COG, uint16_t heading, uint16_t velocity, int8_t turn_rate, uint8_t navigational_status, uint8_t type, uint16_t dimension_bow, uint16_t dimension_stern, uint8_t dimension_port, uint8_t dimension_starboard, const char *callsign, const char *name, uint16_t tslc, uint16_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIS_VESSEL_LEN]; + _mav_put_uint32_t(buf, 0, MMSI); + _mav_put_int32_t(buf, 4, lat); + _mav_put_int32_t(buf, 8, lon); + _mav_put_uint16_t(buf, 12, COG); + _mav_put_uint16_t(buf, 14, heading); + _mav_put_uint16_t(buf, 16, velocity); + _mav_put_uint16_t(buf, 18, dimension_bow); + _mav_put_uint16_t(buf, 20, dimension_stern); + _mav_put_uint16_t(buf, 22, tslc); + _mav_put_uint16_t(buf, 24, flags); + _mav_put_int8_t(buf, 26, turn_rate); + _mav_put_uint8_t(buf, 27, navigational_status); + _mav_put_uint8_t(buf, 28, type); + _mav_put_uint8_t(buf, 29, dimension_port); + _mav_put_uint8_t(buf, 30, dimension_starboard); + _mav_put_char_array(buf, 31, callsign, 7); + _mav_put_char_array(buf, 38, name, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIS_VESSEL_LEN); +#else + mavlink_ais_vessel_t packet; + packet.MMSI = MMSI; + packet.lat = lat; + packet.lon = lon; + packet.COG = COG; + packet.heading = heading; + packet.velocity = velocity; + packet.dimension_bow = dimension_bow; + packet.dimension_stern = dimension_stern; + packet.tslc = tslc; + packet.flags = flags; + packet.turn_rate = turn_rate; + packet.navigational_status = navigational_status; + packet.type = type; + packet.dimension_port = dimension_port; + packet.dimension_starboard = dimension_starboard; + mav_array_memcpy(packet.callsign, callsign, sizeof(char)*7); + mav_array_memcpy(packet.name, name, sizeof(char)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIS_VESSEL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIS_VESSEL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIS_VESSEL_MIN_LEN, MAVLINK_MSG_ID_AIS_VESSEL_LEN, MAVLINK_MSG_ID_AIS_VESSEL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIS_VESSEL_MIN_LEN, MAVLINK_MSG_ID_AIS_VESSEL_LEN); +#endif +} + /** * @brief Pack a ais_vessel message on a channel * @param system_id ID of this system @@ -260,6 +339,20 @@ static inline uint16_t mavlink_msg_ais_vessel_encode_chan(uint8_t system_id, uin return mavlink_msg_ais_vessel_pack_chan(system_id, component_id, chan, msg, ais_vessel->MMSI, ais_vessel->lat, ais_vessel->lon, ais_vessel->COG, ais_vessel->heading, ais_vessel->velocity, ais_vessel->turn_rate, ais_vessel->navigational_status, ais_vessel->type, ais_vessel->dimension_bow, ais_vessel->dimension_stern, ais_vessel->dimension_port, ais_vessel->dimension_starboard, ais_vessel->callsign, ais_vessel->name, ais_vessel->tslc, ais_vessel->flags); } +/** + * @brief Encode a ais_vessel struct with provided status structure + * + * @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 ais_vessel C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ais_vessel_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ais_vessel_t* ais_vessel) +{ + return mavlink_msg_ais_vessel_pack_status(system_id, component_id, _status, msg, ais_vessel->MMSI, ais_vessel->lat, ais_vessel->lon, ais_vessel->COG, ais_vessel->heading, ais_vessel->velocity, ais_vessel->turn_rate, ais_vessel->navigational_status, ais_vessel->type, ais_vessel->dimension_bow, ais_vessel->dimension_stern, ais_vessel->dimension_port, ais_vessel->dimension_starboard, ais_vessel->callsign, ais_vessel->name, ais_vessel->tslc, ais_vessel->flags); +} + /** * @brief Send a ais_vessel message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_altitude.h b/common/mavlink_msg_altitude.h index 41f61274..d72cfbd8 100644 --- a/common/mavlink_msg_altitude.h +++ b/common/mavlink_msg_altitude.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_altitude_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ALTITUDE_MIN_LEN, MAVLINK_MSG_ID_ALTITUDE_LEN, MAVLINK_MSG_ID_ALTITUDE_CRC); } +/** + * @brief Pack a altitude 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param altitude_monotonic [m] This altitude measure is initialized on system boot and monotonic (it is never reset, but represents the local altitude change). The only guarantee on this field is that it will never be reset and is consistent within a flight. The recommended value for this field is the uncorrected barometric altitude at boot time. This altitude will also drift and vary between flights. + * @param altitude_amsl [m] This altitude measure is strictly above mean sea level and might be non-monotonic (it might reset on events like GPS lock or when a new QNH value is set). It should be the altitude to which global altitude waypoints are compared to. Note that it is *not* the GPS altitude, however, most GPS modules already output MSL by default and not the WGS84 altitude. + * @param altitude_local [m] This is the local altitude in the local coordinate frame. It is not the altitude above home, but in reference to the coordinate origin (0, 0, 0). It is up-positive. + * @param altitude_relative [m] This is the altitude above the home position. It resets on each change of the current home position. + * @param altitude_terrain [m] This is the altitude above terrain. It might be fed by a terrain database or an altimeter. Values smaller than -1000 should be interpreted as unknown. + * @param bottom_clearance [m] This is not the altitude, but the clear space below the system according to the fused clearance estimate. It generally should max out at the maximum range of e.g. the laser altimeter. It is generally a moving target. A negative value indicates no measurement available. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_altitude_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float altitude_monotonic, float altitude_amsl, float altitude_local, float altitude_relative, float altitude_terrain, float bottom_clearance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ALTITUDE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, altitude_monotonic); + _mav_put_float(buf, 12, altitude_amsl); + _mav_put_float(buf, 16, altitude_local); + _mav_put_float(buf, 20, altitude_relative); + _mav_put_float(buf, 24, altitude_terrain); + _mav_put_float(buf, 28, bottom_clearance); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ALTITUDE_LEN); +#else + mavlink_altitude_t packet; + packet.time_usec = time_usec; + packet.altitude_monotonic = altitude_monotonic; + packet.altitude_amsl = altitude_amsl; + packet.altitude_local = altitude_local; + packet.altitude_relative = altitude_relative; + packet.altitude_terrain = altitude_terrain; + packet.bottom_clearance = bottom_clearance; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ALTITUDE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ALTITUDE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ALTITUDE_MIN_LEN, MAVLINK_MSG_ID_ALTITUDE_LEN, MAVLINK_MSG_ID_ALTITUDE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ALTITUDE_MIN_LEN, MAVLINK_MSG_ID_ALTITUDE_LEN); +#endif +} + /** * @brief Pack a altitude message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_altitude_encode_chan(uint8_t system_id, uint8 return mavlink_msg_altitude_pack_chan(system_id, component_id, chan, msg, altitude->time_usec, altitude->altitude_monotonic, altitude->altitude_amsl, altitude->altitude_local, altitude->altitude_relative, altitude->altitude_terrain, altitude->bottom_clearance); } +/** + * @brief Encode a altitude struct with provided status structure + * + * @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 altitude C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_altitude_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_altitude_t* altitude) +{ + return mavlink_msg_altitude_pack_status(system_id, component_id, _status, msg, altitude->time_usec, altitude->altitude_monotonic, altitude->altitude_amsl, altitude->altitude_local, altitude->altitude_relative, altitude->altitude_terrain, altitude->bottom_clearance); +} + /** * @brief Send a altitude message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_att_pos_mocap.h b/common/mavlink_msg_att_pos_mocap.h index 277acc78..de01fcfa 100644 --- a/common/mavlink_msg_att_pos_mocap.h +++ b/common/mavlink_msg_att_pos_mocap.h @@ -92,6 +92,52 @@ static inline uint16_t mavlink_msg_att_pos_mocap_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC); } +/** + * @brief Pack a att_pos_mocap 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param x [m] X position (NED) + * @param y [m] Y position (NED) + * @param z [m] Z position (NED) + * @param covariance Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_att_pos_mocap_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, const float *q, float x, float y, float z, const float *covariance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 24, x); + _mav_put_float(buf, 28, y); + _mav_put_float(buf, 32, z); + _mav_put_float_array(buf, 8, q, 4); + _mav_put_float_array(buf, 36, covariance, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN); +#else + mavlink_att_pos_mocap_t packet; + packet.time_usec = time_usec; + packet.x = x; + packet.y = y; + packet.z = z; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ATT_POS_MOCAP; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN); +#endif +} + /** * @brief Pack a att_pos_mocap message on a channel * @param system_id ID of this system @@ -161,6 +207,20 @@ static inline uint16_t mavlink_msg_att_pos_mocap_encode_chan(uint8_t system_id, return mavlink_msg_att_pos_mocap_pack_chan(system_id, component_id, chan, msg, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance); } +/** + * @brief Encode a att_pos_mocap struct with provided status structure + * + * @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 att_pos_mocap C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_att_pos_mocap_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_att_pos_mocap_t* att_pos_mocap) +{ + return mavlink_msg_att_pos_mocap_pack_status(system_id, component_id, _status, msg, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance); +} + /** * @brief Send a att_pos_mocap message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_attitude.h b/common/mavlink_msg_attitude.h index 21c1a9f1..f5b9a479 100644 --- a/common/mavlink_msg_attitude.h +++ b/common/mavlink_msg_attitude.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_LEN, MAVLINK_MSG_ID_ATTITUDE_CRC); } +/** + * @brief Pack a attitude 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param roll [rad] Roll angle (-pi..+pi) + * @param pitch [rad] Pitch angle (-pi..+pi) + * @param yaw [rad] Yaw angle (-pi..+pi) + * @param rollspeed [rad/s] Roll angular speed + * @param pitchspeed [rad/s] Pitch angular speed + * @param yawspeed [rad/s] Yaw angular speed + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_attitude_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ATTITUDE_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, rollspeed); + _mav_put_float(buf, 20, pitchspeed); + _mav_put_float(buf, 24, yawspeed); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_LEN); +#else + mavlink_attitude_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ATTITUDE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_LEN, MAVLINK_MSG_ID_ATTITUDE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_LEN); +#endif +} + /** * @brief Pack a attitude message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_attitude_encode_chan(uint8_t system_id, uint8 return mavlink_msg_attitude_pack_chan(system_id, component_id, chan, msg, attitude->time_boot_ms, attitude->roll, attitude->pitch, attitude->yaw, attitude->rollspeed, attitude->pitchspeed, attitude->yawspeed); } +/** + * @brief Encode a attitude struct with provided status structure + * + * @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 attitude C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_attitude_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_attitude_t* attitude) +{ + return mavlink_msg_attitude_pack_status(system_id, component_id, _status, msg, attitude->time_boot_ms, attitude->roll, attitude->pitch, attitude->yaw, attitude->rollspeed, attitude->pitchspeed, attitude->yawspeed); +} + /** * @brief Send a attitude message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_attitude_quaternion.h b/common/mavlink_msg_attitude_quaternion.h index c22721d3..e6a8a854 100644 --- a/common/mavlink_msg_attitude_quaternion.h +++ b/common/mavlink_msg_attitude_quaternion.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); } +/** + * @brief Pack a attitude_quaternion 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param q1 Quaternion component 1, w (1 in null-rotation) + * @param q2 Quaternion component 2, x (0 in null-rotation) + * @param q3 Quaternion component 3, y (0 in null-rotation) + * @param q4 Quaternion component 4, z (0 in null-rotation) + * @param rollspeed [rad/s] Roll angular speed + * @param pitchspeed [rad/s] Pitch angular speed + * @param yawspeed [rad/s] Yaw angular speed + * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_attitude_quaternion_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, q1); + _mav_put_float(buf, 8, q2); + _mav_put_float(buf, 12, q3); + _mav_put_float(buf, 16, q4); + _mav_put_float(buf, 20, rollspeed); + _mav_put_float(buf, 24, pitchspeed); + _mav_put_float(buf, 28, yawspeed); + _mav_put_float_array(buf, 32, repr_offset_q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); +#else + mavlink_attitude_quaternion_t packet; + packet.time_boot_ms = time_boot_ms; + packet.q1 = q1; + packet.q2 = q2; + packet.q3 = q3; + packet.q4 = q4; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN); +#endif +} + /** * @brief Pack a attitude_quaternion message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_attitude_quaternion_encode_chan(uint8_t syste return mavlink_msg_attitude_quaternion_pack_chan(system_id, component_id, chan, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed, attitude_quaternion->repr_offset_q); } +/** + * @brief Encode a attitude_quaternion struct with provided status structure + * + * @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 attitude_quaternion C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_attitude_quaternion_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion) +{ + return mavlink_msg_attitude_quaternion_pack_status(system_id, component_id, _status, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed, attitude_quaternion->repr_offset_q); +} + /** * @brief Send a attitude_quaternion message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_attitude_quaternion_cov.h b/common/mavlink_msg_attitude_quaternion_cov.h index 766f070a..33b69dc5 100644 --- a/common/mavlink_msg_attitude_quaternion_cov.h +++ b/common/mavlink_msg_attitude_quaternion_cov.h @@ -92,6 +92,52 @@ static inline uint16_t mavlink_msg_attitude_quaternion_cov_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_CRC); } +/** + * @brief Pack a attitude_quaternion_cov 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation) + * @param rollspeed [rad/s] Roll angular speed + * @param pitchspeed [rad/s] Pitch angular speed + * @param yawspeed [rad/s] Yaw angular speed + * @param covariance Row-major representation of a 3x3 attitude covariance matrix (states: roll, pitch, yaw; first three entries are the first ROW, next three entries are the second row, etc.). If unknown, assign NaN value to first element in the array. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_attitude_quaternion_cov_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, const float *q, float rollspeed, float pitchspeed, float yawspeed, const float *covariance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 24, rollspeed); + _mav_put_float(buf, 28, pitchspeed); + _mav_put_float(buf, 32, yawspeed); + _mav_put_float_array(buf, 8, q, 4); + _mav_put_float_array(buf, 36, covariance, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN); +#else + mavlink_attitude_quaternion_cov_t packet; + packet.time_usec = time_usec; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV_LEN); +#endif +} + /** * @brief Pack a attitude_quaternion_cov message on a channel * @param system_id ID of this system @@ -161,6 +207,20 @@ static inline uint16_t mavlink_msg_attitude_quaternion_cov_encode_chan(uint8_t s return mavlink_msg_attitude_quaternion_cov_pack_chan(system_id, component_id, chan, msg, attitude_quaternion_cov->time_usec, attitude_quaternion_cov->q, attitude_quaternion_cov->rollspeed, attitude_quaternion_cov->pitchspeed, attitude_quaternion_cov->yawspeed, attitude_quaternion_cov->covariance); } +/** + * @brief Encode a attitude_quaternion_cov struct with provided status structure + * + * @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 attitude_quaternion_cov C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_attitude_quaternion_cov_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_attitude_quaternion_cov_t* attitude_quaternion_cov) +{ + return mavlink_msg_attitude_quaternion_cov_pack_status(system_id, component_id, _status, msg, attitude_quaternion_cov->time_usec, attitude_quaternion_cov->q, attitude_quaternion_cov->rollspeed, attitude_quaternion_cov->pitchspeed, attitude_quaternion_cov->yawspeed, attitude_quaternion_cov->covariance); +} + /** * @brief Send a attitude_quaternion_cov message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_attitude_target.h b/common/mavlink_msg_attitude_target.h index b67c07c8..93859ee8 100644 --- a/common/mavlink_msg_attitude_target.h +++ b/common/mavlink_msg_attitude_target.h @@ -97,6 +97,55 @@ static inline uint16_t mavlink_msg_attitude_target_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC); } +/** + * @brief Pack a attitude_target 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param body_roll_rate [rad/s] Body roll rate + * @param body_pitch_rate [rad/s] Body pitch rate + * @param body_yaw_rate [rad/s] Body yaw rate + * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_attitude_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 20, body_roll_rate); + _mav_put_float(buf, 24, body_pitch_rate); + _mav_put_float(buf, 28, body_yaw_rate); + _mav_put_float(buf, 32, thrust); + _mav_put_uint8_t(buf, 36, type_mask); + _mav_put_float_array(buf, 4, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN); +#else + mavlink_attitude_target_t packet; + packet.time_boot_ms = time_boot_ms; + packet.body_roll_rate = body_roll_rate; + packet.body_pitch_rate = body_pitch_rate; + packet.body_yaw_rate = body_yaw_rate; + packet.thrust = thrust; + packet.type_mask = type_mask; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ATTITUDE_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN); +#endif +} + /** * @brief Pack a attitude_target message on a channel * @param system_id ID of this system @@ -169,6 +218,20 @@ static inline uint16_t mavlink_msg_attitude_target_encode_chan(uint8_t system_id return mavlink_msg_attitude_target_pack_chan(system_id, component_id, chan, msg, attitude_target->time_boot_ms, attitude_target->type_mask, attitude_target->q, attitude_target->body_roll_rate, attitude_target->body_pitch_rate, attitude_target->body_yaw_rate, attitude_target->thrust); } +/** + * @brief Encode a attitude_target struct with provided status structure + * + * @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 attitude_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_attitude_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_attitude_target_t* attitude_target) +{ + return mavlink_msg_attitude_target_pack_status(system_id, component_id, _status, msg, attitude_target->time_boot_ms, attitude_target->type_mask, attitude_target->q, attitude_target->body_roll_rate, attitude_target->body_pitch_rate, attitude_target->body_yaw_rate, attitude_target->thrust); +} + /** * @brief Send a attitude_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_auth_key.h b/common/mavlink_msg_auth_key.h index 9dd7007f..5db4abdd 100644 --- a/common/mavlink_msg_auth_key.h +++ b/common/mavlink_msg_auth_key.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t comp 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) + */ +static inline uint16_t mavlink_msg_auth_key_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *key) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; + + _mav_put_char_array(buf, 0, key, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN); +#else + mavlink_auth_key_t packet; + + mav_array_memcpy(packet.key, key, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN); +#endif +} + /** * @brief Pack a auth_key message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_auth_key_encode_chan(uint8_t system_id, uint8 return mavlink_msg_auth_key_pack_chan(system_id, component_id, chan, msg, auth_key->key); } +/** + * @brief Encode a auth_key struct with provided status structure + * + * @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 auth_key C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_auth_key_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key) +{ + return mavlink_msg_auth_key_pack_status(system_id, component_id, _status, msg, auth_key->key); +} + /** * @brief Send a auth_key message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_autopilot_state_for_gimbal_device.h b/common/mavlink_msg_autopilot_state_for_gimbal_device.h index 062f6a02..1de32104 100644 --- a/common/mavlink_msg_autopilot_state_for_gimbal_device.h +++ b/common/mavlink_msg_autopilot_state_for_gimbal_device.h @@ -133,6 +133,73 @@ static inline uint16_t mavlink_msg_autopilot_state_for_gimbal_device_pack(uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_CRC); } +/** + * @brief Pack a autopilot_state_for_gimbal_device 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 target_system System ID + * @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_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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); + _mav_put_float(buf, 28, vx); + _mav_put_float(buf, 32, vy); + _mav_put_float(buf, 36, vz); + _mav_put_uint32_t(buf, 40, v_estimated_delay_us); + _mav_put_float(buf, 44, feed_forward_angular_velocity_z); + _mav_put_uint16_t(buf, 48, estimator_status); + _mav_put_uint8_t(buf, 50, target_system); + _mav_put_uint8_t(buf, 51, target_component); + _mav_put_uint8_t(buf, 52, landed_state); + _mav_put_float(buf, 53, angular_velocity_z); + _mav_put_float_array(buf, 8, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN); +#else + mavlink_autopilot_state_for_gimbal_device_t packet; + packet.time_boot_us = time_boot_us; + packet.q_estimated_delay_us = q_estimated_delay_us; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.v_estimated_delay_us = v_estimated_delay_us; + packet.feed_forward_angular_velocity_z = feed_forward_angular_velocity_z; + packet.estimator_status = estimator_status; + packet.target_system = target_system; + packet.target_component = target_component; + packet.landed_state = landed_state; + packet.angular_velocity_z = angular_velocity_z; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_STATE_FOR_GIMBAL_DEVICE_LEN); +#endif +} + /** * @brief Pack a autopilot_state_for_gimbal_device message on a channel * @param system_id ID of this system @@ -223,6 +290,20 @@ static inline uint16_t mavlink_msg_autopilot_state_for_gimbal_device_encode_chan return mavlink_msg_autopilot_state_for_gimbal_device_pack_chan(system_id, component_id, chan, msg, autopilot_state_for_gimbal_device->target_system, autopilot_state_for_gimbal_device->target_component, autopilot_state_for_gimbal_device->time_boot_us, autopilot_state_for_gimbal_device->q, autopilot_state_for_gimbal_device->q_estimated_delay_us, autopilot_state_for_gimbal_device->vx, autopilot_state_for_gimbal_device->vy, autopilot_state_for_gimbal_device->vz, autopilot_state_for_gimbal_device->v_estimated_delay_us, autopilot_state_for_gimbal_device->feed_forward_angular_velocity_z, autopilot_state_for_gimbal_device->estimator_status, autopilot_state_for_gimbal_device->landed_state, autopilot_state_for_gimbal_device->angular_velocity_z); } +/** + * @brief Encode a autopilot_state_for_gimbal_device struct with provided status structure + * + * @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 autopilot_state_for_gimbal_device C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_autopilot_state_for_gimbal_device_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_autopilot_state_for_gimbal_device_t* autopilot_state_for_gimbal_device) +{ + return mavlink_msg_autopilot_state_for_gimbal_device_pack_status(system_id, component_id, _status, msg, autopilot_state_for_gimbal_device->target_system, autopilot_state_for_gimbal_device->target_component, autopilot_state_for_gimbal_device->time_boot_us, autopilot_state_for_gimbal_device->q, autopilot_state_for_gimbal_device->q_estimated_delay_us, autopilot_state_for_gimbal_device->vx, autopilot_state_for_gimbal_device->vy, autopilot_state_for_gimbal_device->vz, autopilot_state_for_gimbal_device->v_estimated_delay_us, autopilot_state_for_gimbal_device->feed_forward_angular_velocity_z, autopilot_state_for_gimbal_device->estimator_status, autopilot_state_for_gimbal_device->landed_state, autopilot_state_for_gimbal_device->angular_velocity_z); +} + /** * @brief Send a autopilot_state_for_gimbal_device message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_autopilot_version.h b/common/mavlink_msg_autopilot_version.h index 85df0d4e..b406ff27 100644 --- a/common/mavlink_msg_autopilot_version.h +++ b/common/mavlink_msg_autopilot_version.h @@ -130,6 +130,70 @@ static inline uint16_t mavlink_msg_autopilot_version_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTOPILOT_VERSION_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_CRC); } +/** + * @brief Pack a autopilot_version 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 capabilities Bitmap of capabilities + * @param flight_sw_version Firmware version number + * @param middleware_sw_version Middleware version number + * @param os_sw_version Operating system version number + * @param board_version HW / board version (last 8 bits should be silicon ID, if any). The first 16 bits of this field specify https://github.com/PX4/PX4-Bootloader/blob/master/board_types.txt + * @param flight_custom_version Custom version field, commonly the first 8 bytes of the git hash. This is not an unique identifier, but should allow to identify the commit using the main version number even for very large code bases. + * @param middleware_custom_version Custom version field, commonly the first 8 bytes of the git hash. This is not an unique identifier, but should allow to identify the commit using the main version number even for very large code bases. + * @param os_custom_version Custom version field, commonly the first 8 bytes of the git hash. This is not an unique identifier, but should allow to identify the commit using the main version number even for very large code bases. + * @param vendor_id ID of the board vendor + * @param product_id ID of the product + * @param uid UID if provided by hardware (see uid2) + * @param uid2 UID if provided by hardware (supersedes the uid field. If this is non-zero, use this field, otherwise use uid) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_autopilot_version_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t capabilities, uint32_t flight_sw_version, uint32_t middleware_sw_version, uint32_t os_sw_version, uint32_t board_version, const uint8_t *flight_custom_version, const uint8_t *middleware_custom_version, const uint8_t *os_custom_version, uint16_t vendor_id, uint16_t product_id, uint64_t uid, const uint8_t *uid2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN]; + _mav_put_uint64_t(buf, 0, capabilities); + _mav_put_uint64_t(buf, 8, uid); + _mav_put_uint32_t(buf, 16, flight_sw_version); + _mav_put_uint32_t(buf, 20, middleware_sw_version); + _mav_put_uint32_t(buf, 24, os_sw_version); + _mav_put_uint32_t(buf, 28, board_version); + _mav_put_uint16_t(buf, 32, vendor_id); + _mav_put_uint16_t(buf, 34, product_id); + _mav_put_uint8_t_array(buf, 36, flight_custom_version, 8); + _mav_put_uint8_t_array(buf, 44, middleware_custom_version, 8); + _mav_put_uint8_t_array(buf, 52, os_custom_version, 8); + _mav_put_uint8_t_array(buf, 60, uid2, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN); +#else + mavlink_autopilot_version_t packet; + packet.capabilities = capabilities; + packet.uid = uid; + packet.flight_sw_version = flight_sw_version; + packet.middleware_sw_version = middleware_sw_version; + packet.os_sw_version = os_sw_version; + packet.board_version = board_version; + packet.vendor_id = vendor_id; + packet.product_id = product_id; + mav_array_memcpy(packet.flight_custom_version, flight_custom_version, sizeof(uint8_t)*8); + mav_array_memcpy(packet.middleware_custom_version, middleware_custom_version, sizeof(uint8_t)*8); + mav_array_memcpy(packet.os_custom_version, os_custom_version, sizeof(uint8_t)*8); + mav_array_memcpy(packet.uid2, uid2, sizeof(uint8_t)*18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AUTOPILOT_VERSION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_VERSION_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTOPILOT_VERSION_MIN_LEN, MAVLINK_MSG_ID_AUTOPILOT_VERSION_LEN); +#endif +} + /** * @brief Pack a autopilot_version message on a channel * @param system_id ID of this system @@ -217,6 +281,20 @@ static inline uint16_t mavlink_msg_autopilot_version_encode_chan(uint8_t system_ return mavlink_msg_autopilot_version_pack_chan(system_id, component_id, chan, msg, autopilot_version->capabilities, autopilot_version->flight_sw_version, autopilot_version->middleware_sw_version, autopilot_version->os_sw_version, autopilot_version->board_version, autopilot_version->flight_custom_version, autopilot_version->middleware_custom_version, autopilot_version->os_custom_version, autopilot_version->vendor_id, autopilot_version->product_id, autopilot_version->uid, autopilot_version->uid2); } +/** + * @brief Encode a autopilot_version struct with provided status structure + * + * @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 autopilot_version C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_autopilot_version_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_autopilot_version_t* autopilot_version) +{ + return mavlink_msg_autopilot_version_pack_status(system_id, component_id, _status, msg, autopilot_version->capabilities, autopilot_version->flight_sw_version, autopilot_version->middleware_sw_version, autopilot_version->os_sw_version, autopilot_version->board_version, autopilot_version->flight_custom_version, autopilot_version->middleware_custom_version, autopilot_version->os_custom_version, autopilot_version->vendor_id, autopilot_version->product_id, autopilot_version->uid, autopilot_version->uid2); +} + /** * @brief Send a autopilot_version message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_battery_info.h b/common/mavlink_msg_battery_info.h index 3fc51d59..10817f5c 100644 --- a/common/mavlink_msg_battery_info.h +++ b/common/mavlink_msg_battery_info.h @@ -177,6 +177,94 @@ static inline uint16_t mavlink_msg_battery_info_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BATTERY_INFO_MIN_LEN, MAVLINK_MSG_ID_BATTERY_INFO_LEN, MAVLINK_MSG_ID_BATTERY_INFO_CRC); } +/** + * @brief Pack a battery_info 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 id Battery ID + * @param battery_function Function of the battery. + * @param type Type (chemistry) of the battery. + * @param 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. + * @param cells_in_series Number of battery cells in series. 0: field not provided. + * @param cycle_count Lifetime count of the number of charge/discharge cycles (https://en.wikipedia.org/wiki/Charge_cycle). UINT16_MAX: field not provided. + * @param weight [g] Battery weight. 0: field not provided. + * @param discharge_minimum_voltage [V] Minimum per-cell voltage when discharging. 0: field not provided. + * @param charging_minimum_voltage [V] Minimum per-cell voltage when charging. 0: field not provided. + * @param resting_minimum_voltage [V] Minimum per-cell voltage when resting. 0: field not provided. + * @param charging_maximum_voltage [V] Maximum per-cell voltage when charged. 0: field not provided. + * @param charging_maximum_current [A] Maximum pack continuous charge current. 0: field not provided. + * @param nominal_voltage [V] Battery nominal voltage. Used for conversion between Wh and Ah. 0: field not provided. + * @param discharge_maximum_current [A] Maximum pack discharge current. 0: field not provided. + * @param discharge_maximum_burst_current [A] Maximum pack discharge burst current. 0: field not provided. + * @param design_capacity [Ah] Fully charged design capacity. 0: field not provided. + * @param full_charge_capacity [Ah] Predicted battery capacity when fully charged (accounting for battery degradation). NAN: field not provided. + * @param manufacture_date Manufacture date (DDMMYYYY) in ASCII characters, 0 terminated. All 0: field not provided. + * @param serial_number Serial number in ASCII characters, 0 terminated. All 0: field not provided. + * @param name Battery device name. Formatted as manufacturer name then product name, separated with an underscore (in ASCII characters), 0 terminated. All 0: field not provided. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery_info_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, uint8_t battery_function, uint8_t type, uint8_t state_of_health, uint8_t cells_in_series, uint16_t cycle_count, uint16_t weight, float discharge_minimum_voltage, float charging_minimum_voltage, float resting_minimum_voltage, float charging_maximum_voltage, float charging_maximum_current, float nominal_voltage, float discharge_maximum_current, float discharge_maximum_burst_current, float design_capacity, float full_charge_capacity, const char *manufacture_date, const char *serial_number, const char *name) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_BATTERY_INFO_LEN]; + _mav_put_float(buf, 0, discharge_minimum_voltage); + _mav_put_float(buf, 4, charging_minimum_voltage); + _mav_put_float(buf, 8, resting_minimum_voltage); + _mav_put_float(buf, 12, charging_maximum_voltage); + _mav_put_float(buf, 16, charging_maximum_current); + _mav_put_float(buf, 20, nominal_voltage); + _mav_put_float(buf, 24, discharge_maximum_current); + _mav_put_float(buf, 28, discharge_maximum_burst_current); + _mav_put_float(buf, 32, design_capacity); + _mav_put_float(buf, 36, full_charge_capacity); + _mav_put_uint16_t(buf, 40, cycle_count); + _mav_put_uint16_t(buf, 42, weight); + _mav_put_uint8_t(buf, 44, id); + _mav_put_uint8_t(buf, 45, battery_function); + _mav_put_uint8_t(buf, 46, type); + _mav_put_uint8_t(buf, 47, state_of_health); + _mav_put_uint8_t(buf, 48, cells_in_series); + _mav_put_char_array(buf, 49, manufacture_date, 9); + _mav_put_char_array(buf, 58, serial_number, 32); + _mav_put_char_array(buf, 90, name, 50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY_INFO_LEN); +#else + mavlink_battery_info_t packet; + packet.discharge_minimum_voltage = discharge_minimum_voltage; + packet.charging_minimum_voltage = charging_minimum_voltage; + packet.resting_minimum_voltage = resting_minimum_voltage; + packet.charging_maximum_voltage = charging_maximum_voltage; + packet.charging_maximum_current = charging_maximum_current; + packet.nominal_voltage = nominal_voltage; + packet.discharge_maximum_current = discharge_maximum_current; + packet.discharge_maximum_burst_current = discharge_maximum_burst_current; + packet.design_capacity = design_capacity; + packet.full_charge_capacity = full_charge_capacity; + packet.cycle_count = cycle_count; + packet.weight = weight; + packet.id = id; + packet.battery_function = battery_function; + packet.type = type; + packet.state_of_health = state_of_health; + packet.cells_in_series = cells_in_series; + 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); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY_INFO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY_INFO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_INFO_MIN_LEN, MAVLINK_MSG_ID_BATTERY_INFO_LEN, MAVLINK_MSG_ID_BATTERY_INFO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_INFO_MIN_LEN, MAVLINK_MSG_ID_BATTERY_INFO_LEN); +#endif +} + /** * @brief Pack a battery_info message on a channel * @param system_id ID of this system @@ -288,6 +376,20 @@ static inline uint16_t mavlink_msg_battery_info_encode_chan(uint8_t system_id, u return mavlink_msg_battery_info_pack_chan(system_id, component_id, chan, msg, battery_info->id, battery_info->battery_function, battery_info->type, battery_info->state_of_health, battery_info->cells_in_series, battery_info->cycle_count, battery_info->weight, battery_info->discharge_minimum_voltage, battery_info->charging_minimum_voltage, battery_info->resting_minimum_voltage, battery_info->charging_maximum_voltage, battery_info->charging_maximum_current, battery_info->nominal_voltage, battery_info->discharge_maximum_current, battery_info->discharge_maximum_burst_current, battery_info->design_capacity, battery_info->full_charge_capacity, battery_info->manufacture_date, battery_info->serial_number, battery_info->name); } +/** + * @brief Encode a battery_info struct with provided status structure + * + * @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 battery_info C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_battery_info_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_battery_info_t* battery_info) +{ + return mavlink_msg_battery_info_pack_status(system_id, component_id, _status, msg, battery_info->id, battery_info->battery_function, battery_info->type, battery_info->state_of_health, battery_info->cells_in_series, battery_info->cycle_count, battery_info->weight, battery_info->discharge_minimum_voltage, battery_info->charging_minimum_voltage, battery_info->resting_minimum_voltage, battery_info->charging_maximum_voltage, battery_info->charging_maximum_current, battery_info->nominal_voltage, battery_info->discharge_maximum_current, battery_info->discharge_maximum_burst_current, battery_info->design_capacity, battery_info->full_charge_capacity, battery_info->manufacture_date, battery_info->serial_number, battery_info->name); +} + /** * @brief Send a battery_info message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_battery_status.h b/common/mavlink_msg_battery_status.h index 357c483e..4d85d9c9 100644 --- a/common/mavlink_msg_battery_status.h +++ b/common/mavlink_msg_battery_status.h @@ -140,6 +140,76 @@ static inline uint16_t mavlink_msg_battery_status_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC); } +/** + * @brief Pack a battery_status 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 id Battery ID + * @param battery_function Function of the battery + * @param type Type (chemistry) of the battery + * @param temperature [cdegC] Temperature of the battery. INT16_MAX for unknown temperature. + * @param voltages [mV] Battery voltage of cells 1 to 10 (see voltages_ext for cells 11-14). Cells in this field above the valid cell count for this battery should have the UINT16_MAX value. If individual cell voltages are unknown or not measured for this battery, then the overall battery voltage should be filled in cell 0, with all others set to UINT16_MAX. If the voltage of the battery is greater than (UINT16_MAX - 1), then cell 0 should be set to (UINT16_MAX - 1), and cell 1 to the remaining voltage. This can be extended to multiple cells if the total voltage is greater than 2 * (UINT16_MAX - 1). + * @param current_battery [cA] Battery current, -1: autopilot does not measure the current + * @param current_consumed [mAh] Consumed charge, -1: autopilot does not provide consumption estimate + * @param energy_consumed [hJ] Consumed energy, -1: autopilot does not provide energy consumption estimate + * @param battery_remaining [%] Remaining battery energy. Values: [0-100], -1: autopilot does not estimate the remaining battery. + * @param time_remaining [s] Remaining battery time, 0: autopilot does not provide remaining battery time estimate + * @param charge_state State for extent of discharge, provided by autopilot for warning or external reactions + * @param voltages_ext [mV] Battery voltages for cells 11 to 14. Cells above the valid cell count for this battery should have a value of 0, where zero indicates not supported (note, this is different than for the voltages field and allows empty byte truncation). If the measured value is 0 then 1 should be sent instead. + * @param mode Battery mode. Default (0) is that battery mode reporting is not supported or battery is in normal-use mode. + * @param fault_bitmask Fault/health indications. These should be set when charge_state is MAV_BATTERY_CHARGE_STATE_FAILED or MAV_BATTERY_CHARGE_STATE_UNHEALTHY (if not, fault reporting is not supported). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, uint8_t battery_function, uint8_t type, int16_t temperature, const uint16_t *voltages, int16_t current_battery, int32_t current_consumed, int32_t energy_consumed, int8_t battery_remaining, int32_t time_remaining, uint8_t charge_state, const uint16_t *voltages_ext, uint8_t mode, uint32_t fault_bitmask) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_BATTERY_STATUS_LEN]; + _mav_put_int32_t(buf, 0, current_consumed); + _mav_put_int32_t(buf, 4, energy_consumed); + _mav_put_int16_t(buf, 8, temperature); + _mav_put_int16_t(buf, 30, current_battery); + _mav_put_uint8_t(buf, 32, id); + _mav_put_uint8_t(buf, 33, battery_function); + _mav_put_uint8_t(buf, 34, type); + _mav_put_int8_t(buf, 35, battery_remaining); + _mav_put_int32_t(buf, 36, time_remaining); + _mav_put_uint8_t(buf, 40, charge_state); + _mav_put_uint8_t(buf, 49, mode); + _mav_put_uint32_t(buf, 50, fault_bitmask); + _mav_put_uint16_t_array(buf, 10, voltages, 10); + _mav_put_uint16_t_array(buf, 41, voltages_ext, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY_STATUS_LEN); +#else + mavlink_battery_status_t packet; + packet.current_consumed = current_consumed; + packet.energy_consumed = energy_consumed; + packet.temperature = temperature; + packet.current_battery = current_battery; + packet.id = id; + packet.battery_function = battery_function; + packet.type = type; + packet.battery_remaining = battery_remaining; + packet.time_remaining = time_remaining; + packet.charge_state = charge_state; + packet.mode = mode; + packet.fault_bitmask = fault_bitmask; + mav_array_memcpy(packet.voltages, voltages, sizeof(uint16_t)*10); + mav_array_memcpy(packet.voltages_ext, voltages_ext, sizeof(uint16_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN); +#endif +} + /** * @brief Pack a battery_status message on a channel * @param system_id ID of this system @@ -233,6 +303,20 @@ static inline uint16_t mavlink_msg_battery_status_encode_chan(uint8_t system_id, return mavlink_msg_battery_status_pack_chan(system_id, component_id, chan, msg, battery_status->id, battery_status->battery_function, battery_status->type, battery_status->temperature, battery_status->voltages, battery_status->current_battery, battery_status->current_consumed, battery_status->energy_consumed, battery_status->battery_remaining, battery_status->time_remaining, battery_status->charge_state, battery_status->voltages_ext, battery_status->mode, battery_status->fault_bitmask); } +/** + * @brief Encode a battery_status struct with provided status structure + * + * @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 battery_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_battery_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_battery_status_t* battery_status) +{ + return mavlink_msg_battery_status_pack_status(system_id, component_id, _status, msg, battery_status->id, battery_status->battery_function, battery_status->type, battery_status->temperature, battery_status->voltages, battery_status->current_battery, battery_status->current_consumed, battery_status->energy_consumed, battery_status->battery_remaining, battery_status->time_remaining, battery_status->charge_state, battery_status->voltages_ext, battery_status->mode, battery_status->fault_bitmask); +} + /** * @brief Send a battery_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_button_change.h b/common/mavlink_msg_button_change.h index 8de4add2..0b18617d 100644 --- a/common/mavlink_msg_button_change.h +++ b/common/mavlink_msg_button_change.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_button_change_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC); } +/** + * @brief Pack a button_change 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param last_change_ms [ms] Time of last change of button state. + * @param state Bitmap for state of buttons. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_button_change_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t last_change_ms, uint8_t state) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, last_change_ms); + _mav_put_uint8_t(buf, 8, state); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN); +#else + mavlink_button_change_t packet; + packet.time_boot_ms = time_boot_ms; + packet.last_change_ms = last_change_ms; + packet.state = state; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_BUTTON_CHANGE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN); +#endif +} + /** * @brief Pack a button_change message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_button_change_encode_chan(uint8_t system_id, return mavlink_msg_button_change_pack_chan(system_id, component_id, chan, msg, button_change->time_boot_ms, button_change->last_change_ms, button_change->state); } +/** + * @brief Encode a button_change struct with provided status structure + * + * @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 button_change C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_button_change_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_button_change_t* button_change) +{ + return mavlink_msg_button_change_pack_status(system_id, component_id, _status, msg, button_change->time_boot_ms, button_change->last_change_ms, button_change->state); +} + /** * @brief Send a button_change message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_capture_status.h b/common/mavlink_msg_camera_capture_status.h index 87c3a8c5..95cf41ad 100644 --- a/common/mavlink_msg_camera_capture_status.h +++ b/common/mavlink_msg_camera_capture_status.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_camera_capture_status_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_CRC); } +/** + * @brief Pack a camera_capture_status 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param image_status Current status of image capturing (0: idle, 1: capture in progress, 2: interval set but idle, 3: interval set and capture in progress) + * @param video_status Current status of video capturing (0: idle, 1: capture in progress) + * @param image_interval [s] Image capture interval + * @param recording_time_ms [ms] Elapsed time since recording started (0: Not supported/available). A GCS should compute recording time and use non-zero values of this field to correct any discrepancy. + * @param available_capacity [MiB] Available storage capacity. + * @param image_count Total number of images captured ('forever', or until reset using MAV_CMD_STORAGE_FORMAT). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_capture_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t image_status, uint8_t video_status, float image_interval, uint32_t recording_time_ms, float available_capacity, int32_t image_count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, image_interval); + _mav_put_uint32_t(buf, 8, recording_time_ms); + _mav_put_float(buf, 12, available_capacity); + _mav_put_uint8_t(buf, 16, image_status); + _mav_put_uint8_t(buf, 17, video_status); + _mav_put_int32_t(buf, 18, image_count); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN); +#else + mavlink_camera_capture_status_t packet; + packet.time_boot_ms = time_boot_ms; + packet.image_interval = image_interval; + packet.recording_time_ms = recording_time_ms; + packet.available_capacity = available_capacity; + packet.image_status = image_status; + packet.video_status = video_status; + packet.image_count = image_count; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_CAPTURE_STATUS_LEN); +#endif +} + /** * @brief Pack a camera_capture_status message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_camera_capture_status_encode_chan(uint8_t sys return mavlink_msg_camera_capture_status_pack_chan(system_id, component_id, chan, msg, camera_capture_status->time_boot_ms, camera_capture_status->image_status, camera_capture_status->video_status, camera_capture_status->image_interval, camera_capture_status->recording_time_ms, camera_capture_status->available_capacity, camera_capture_status->image_count); } +/** + * @brief Encode a camera_capture_status struct with provided status structure + * + * @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 camera_capture_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_capture_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_capture_status_t* camera_capture_status) +{ + return mavlink_msg_camera_capture_status_pack_status(system_id, component_id, _status, msg, camera_capture_status->time_boot_ms, camera_capture_status->image_status, camera_capture_status->video_status, camera_capture_status->image_interval, camera_capture_status->recording_time_ms, camera_capture_status->available_capacity, camera_capture_status->image_count); +} + /** * @brief Send a camera_capture_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_fov_status.h b/common/mavlink_msg_camera_fov_status.h index 8562973f..920fb046 100644 --- a/common/mavlink_msg_camera_fov_status.h +++ b/common/mavlink_msg_camera_fov_status.h @@ -115,6 +115,64 @@ static inline uint16_t mavlink_msg_camera_fov_status_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_CRC); } +/** + * @brief Pack a camera_fov_status 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param lat_camera [degE7] Latitude of camera (INT32_MAX if unknown). + * @param lon_camera [degE7] Longitude of camera (INT32_MAX if unknown). + * @param alt_camera [mm] Altitude (MSL) of camera (INT32_MAX if unknown). + * @param lat_image [degE7] Latitude of center of image (INT32_MAX if unknown, INT32_MIN if at infinity, not intersecting with horizon). + * @param lon_image [degE7] Longitude of center of image (INT32_MAX if unknown, INT32_MIN if at infinity, not intersecting with horizon). + * @param alt_image [mm] Altitude (MSL) of center of image (INT32_MAX if unknown, INT32_MIN if at infinity, not intersecting with horizon). + * @param q Quaternion of camera orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param hfov [deg] Horizontal field of view (NaN if unknown). + * @param vfov [deg] Vertical field of view (NaN if unknown). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_fov_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, int32_t lat_camera, int32_t lon_camera, int32_t alt_camera, int32_t lat_image, int32_t lon_image, int32_t alt_image, const float *q, float hfov, float vfov) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat_camera); + _mav_put_int32_t(buf, 8, lon_camera); + _mav_put_int32_t(buf, 12, alt_camera); + _mav_put_int32_t(buf, 16, lat_image); + _mav_put_int32_t(buf, 20, lon_image); + _mav_put_int32_t(buf, 24, alt_image); + _mav_put_float(buf, 44, hfov); + _mav_put_float(buf, 48, vfov); + _mav_put_float_array(buf, 28, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN); +#else + mavlink_camera_fov_status_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat_camera = lat_camera; + packet.lon_camera = lon_camera; + packet.alt_camera = alt_camera; + packet.lat_image = lat_image; + packet.lon_image = lon_image; + packet.alt_image = alt_image; + packet.hfov = hfov; + packet.vfov = vfov; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_FOV_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_FOV_STATUS_LEN); +#endif +} + /** * @brief Pack a camera_fov_status message on a channel * @param system_id ID of this system @@ -196,6 +254,20 @@ static inline uint16_t mavlink_msg_camera_fov_status_encode_chan(uint8_t system_ return mavlink_msg_camera_fov_status_pack_chan(system_id, component_id, chan, msg, camera_fov_status->time_boot_ms, camera_fov_status->lat_camera, camera_fov_status->lon_camera, camera_fov_status->alt_camera, camera_fov_status->lat_image, camera_fov_status->lon_image, camera_fov_status->alt_image, camera_fov_status->q, camera_fov_status->hfov, camera_fov_status->vfov); } +/** + * @brief Encode a camera_fov_status struct with provided status structure + * + * @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 camera_fov_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_fov_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_fov_status_t* camera_fov_status) +{ + return mavlink_msg_camera_fov_status_pack_status(system_id, component_id, _status, msg, camera_fov_status->time_boot_ms, camera_fov_status->lat_camera, camera_fov_status->lon_camera, camera_fov_status->alt_camera, camera_fov_status->lat_image, camera_fov_status->lon_image, camera_fov_status->alt_image, camera_fov_status->q, camera_fov_status->hfov, camera_fov_status->vfov); +} + /** * @brief Send a camera_fov_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_image_captured.h b/common/mavlink_msg_camera_image_captured.h index 0169740b..086570ec 100644 --- a/common/mavlink_msg_camera_image_captured.h +++ b/common/mavlink_msg_camera_image_captured.h @@ -122,6 +122,67 @@ static inline uint16_t mavlink_msg_camera_image_captured_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_MIN_LEN, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_CRC); } +/** + * @brief Pack a camera_image_captured 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param time_utc [us] Timestamp (time since UNIX epoch) in UTC. 0 for unknown. + * @param camera_id Deprecated/unused. Component IDs are used to differentiate multiple cameras. + * @param lat [degE7] Latitude where image was taken + * @param lon [degE7] Longitude where capture was taken + * @param alt [mm] Altitude (MSL) where image was taken + * @param relative_alt [mm] Altitude above ground + * @param q Quaternion of camera orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param image_index Zero based index of this image (i.e. a new image will have index CAMERA_CAPTURE_STATUS.image count -1) + * @param capture_result Boolean indicating success (1) or failure (0) while capturing this image. + * @param file_url URL of image taken. Either local storage or http://foo.jpg if camera provides an HTTP interface. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_image_captured_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint64_t time_utc, uint8_t camera_id, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, const float *q, int32_t image_index, int8_t capture_result, const char *file_url) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN]; + _mav_put_uint64_t(buf, 0, time_utc); + _mav_put_uint32_t(buf, 8, time_boot_ms); + _mav_put_int32_t(buf, 12, lat); + _mav_put_int32_t(buf, 16, lon); + _mav_put_int32_t(buf, 20, alt); + _mav_put_int32_t(buf, 24, relative_alt); + _mav_put_int32_t(buf, 44, image_index); + _mav_put_uint8_t(buf, 48, camera_id); + _mav_put_int8_t(buf, 49, capture_result); + _mav_put_float_array(buf, 28, q, 4); + _mav_put_char_array(buf, 50, file_url, 205); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN); +#else + mavlink_camera_image_captured_t packet; + packet.time_utc = time_utc; + packet.time_boot_ms = time_boot_ms; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.relative_alt = relative_alt; + packet.image_index = image_index; + packet.camera_id = camera_id; + packet.capture_result = capture_result; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + mav_array_memcpy(packet.file_url, file_url, sizeof(char)*205); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_MIN_LEN, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_MIN_LEN, MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED_LEN); +#endif +} + /** * @brief Pack a camera_image_captured message on a channel * @param system_id ID of this system @@ -206,6 +267,20 @@ static inline uint16_t mavlink_msg_camera_image_captured_encode_chan(uint8_t sys return mavlink_msg_camera_image_captured_pack_chan(system_id, component_id, chan, msg, camera_image_captured->time_boot_ms, camera_image_captured->time_utc, camera_image_captured->camera_id, camera_image_captured->lat, camera_image_captured->lon, camera_image_captured->alt, camera_image_captured->relative_alt, camera_image_captured->q, camera_image_captured->image_index, camera_image_captured->capture_result, camera_image_captured->file_url); } +/** + * @brief Encode a camera_image_captured struct with provided status structure + * + * @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 camera_image_captured C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_image_captured_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_image_captured_t* camera_image_captured) +{ + return mavlink_msg_camera_image_captured_pack_status(system_id, component_id, _status, msg, camera_image_captured->time_boot_ms, camera_image_captured->time_utc, camera_image_captured->camera_id, camera_image_captured->lat, camera_image_captured->lon, camera_image_captured->alt, camera_image_captured->relative_alt, camera_image_captured->q, camera_image_captured->image_index, camera_image_captured->capture_result, camera_image_captured->file_url); +} + /** * @brief Send a camera_image_captured message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_information.h b/common/mavlink_msg_camera_information.h index 1b1e4458..769521e3 100644 --- a/common/mavlink_msg_camera_information.h +++ b/common/mavlink_msg_camera_information.h @@ -141,6 +141,76 @@ static inline uint16_t mavlink_msg_camera_information_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN, MAVLINK_MSG_ID_CAMERA_INFORMATION_CRC); } +/** + * @brief Pack a camera_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param vendor_name Name of the camera vendor + * @param model_name Name of the camera model + * @param firmware_version Version of the camera firmware, encoded as: (Dev & 0xff) << 24 | (Patch & 0xff) << 16 | (Minor & 0xff) << 8 | (Major & 0xff). Use 0 if not known. + * @param focal_length [mm] Focal length. Use NaN if not known. + * @param sensor_size_h [mm] Image sensor size horizontal. Use NaN if not known. + * @param sensor_size_v [mm] Image sensor size vertical. Use NaN if not known. + * @param resolution_h [pix] Horizontal image resolution. Use 0 if not known. + * @param resolution_v [pix] Vertical image resolution. Use 0 if not known. + * @param lens_id Reserved for a lens ID. Use 0 if not known. + * @param flags Bitmap of camera capability flags. + * @param cam_definition_version Camera definition version (iteration). Use 0 if not known. + * @param cam_definition_uri Camera definition URI (if any, otherwise only basic functions will be available). HTTP- (http://) and MAVLink FTP- (mavlinkftp://) formatted URIs are allowed (and both must be supported by any GCS that implements the Camera Protocol). The definition file may be xz compressed, which will be indicated by the file extension .xml.xz (a GCS that implements the protocol must support decompressing the file). The string needs to be zero terminated. Use a zero-length string if not known. + * @param gimbal_device_id Gimbal id of a gimbal associated with this camera. This is the component id of the gimbal device, or 1-6 for non mavlink gimbals. Use 0 if no gimbal is associated with the camera. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, const uint8_t *vendor_name, const uint8_t *model_name, uint32_t firmware_version, float focal_length, float sensor_size_h, float sensor_size_v, uint16_t resolution_h, uint16_t resolution_v, uint8_t lens_id, uint32_t flags, uint16_t cam_definition_version, const char *cam_definition_uri, uint8_t gimbal_device_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, firmware_version); + _mav_put_float(buf, 8, focal_length); + _mav_put_float(buf, 12, sensor_size_h); + _mav_put_float(buf, 16, sensor_size_v); + _mav_put_uint32_t(buf, 20, flags); + _mav_put_uint16_t(buf, 24, resolution_h); + _mav_put_uint16_t(buf, 26, resolution_v); + _mav_put_uint16_t(buf, 28, cam_definition_version); + _mav_put_uint8_t(buf, 94, lens_id); + _mav_put_uint8_t(buf, 235, gimbal_device_id); + _mav_put_uint8_t_array(buf, 30, vendor_name, 32); + _mav_put_uint8_t_array(buf, 62, model_name, 32); + _mav_put_char_array(buf, 95, cam_definition_uri, 140); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN); +#else + mavlink_camera_information_t packet; + packet.time_boot_ms = time_boot_ms; + packet.firmware_version = firmware_version; + packet.focal_length = focal_length; + packet.sensor_size_h = sensor_size_h; + packet.sensor_size_v = sensor_size_v; + packet.flags = flags; + packet.resolution_h = resolution_h; + packet.resolution_v = resolution_v; + packet.cam_definition_version = cam_definition_version; + packet.lens_id = lens_id; + packet.gimbal_device_id = gimbal_device_id; + 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); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN, MAVLINK_MSG_ID_CAMERA_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_CAMERA_INFORMATION_LEN); +#endif +} + /** * @brief Pack a camera_information message on a channel * @param system_id ID of this system @@ -234,6 +304,20 @@ static inline uint16_t mavlink_msg_camera_information_encode_chan(uint8_t system return mavlink_msg_camera_information_pack_chan(system_id, component_id, chan, msg, camera_information->time_boot_ms, camera_information->vendor_name, camera_information->model_name, camera_information->firmware_version, camera_information->focal_length, camera_information->sensor_size_h, camera_information->sensor_size_v, camera_information->resolution_h, camera_information->resolution_v, camera_information->lens_id, camera_information->flags, camera_information->cam_definition_version, camera_information->cam_definition_uri, camera_information->gimbal_device_id); } +/** + * @brief Encode a camera_information struct with provided status structure + * + * @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 camera_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_information_t* camera_information) +{ + return mavlink_msg_camera_information_pack_status(system_id, component_id, _status, msg, camera_information->time_boot_ms, camera_information->vendor_name, camera_information->model_name, camera_information->firmware_version, camera_information->focal_length, camera_information->sensor_size_h, camera_information->sensor_size_v, camera_information->resolution_h, camera_information->resolution_v, camera_information->lens_id, camera_information->flags, camera_information->cam_definition_version, camera_information->cam_definition_uri, camera_information->gimbal_device_id); +} + /** * @brief Send a camera_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_settings.h b/common/mavlink_msg_camera_settings.h index 9ccba6eb..743a07c0 100644 --- a/common/mavlink_msg_camera_settings.h +++ b/common/mavlink_msg_camera_settings.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_camera_settings_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_SETTINGS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN, MAVLINK_MSG_ID_CAMERA_SETTINGS_CRC); } +/** + * @brief Pack a camera_settings 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param mode_id Camera mode + * @param zoomLevel Current zoom level as a percentage of the full range (0.0 to 100.0, NaN if not known) + * @param focusLevel Current focus level as a percentage of the full range (0.0 to 100.0, NaN if not known) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_settings_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t mode_id, float zoomLevel, float focusLevel) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint8_t(buf, 4, mode_id); + _mav_put_float(buf, 5, zoomLevel); + _mav_put_float(buf, 9, focusLevel); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN); +#else + mavlink_camera_settings_t packet; + packet.time_boot_ms = time_boot_ms; + packet.mode_id = mode_id; + packet.zoomLevel = zoomLevel; + packet.focusLevel = focusLevel; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_SETTINGS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_SETTINGS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN, MAVLINK_MSG_ID_CAMERA_SETTINGS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_SETTINGS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_SETTINGS_LEN); +#endif +} + /** * @brief Pack a camera_settings message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_camera_settings_encode_chan(uint8_t system_id return mavlink_msg_camera_settings_pack_chan(system_id, component_id, chan, msg, camera_settings->time_boot_ms, camera_settings->mode_id, camera_settings->zoomLevel, camera_settings->focusLevel); } +/** + * @brief Encode a camera_settings struct with provided status structure + * + * @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 camera_settings C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_settings_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_settings_t* camera_settings) +{ + return mavlink_msg_camera_settings_pack_status(system_id, component_id, _status, msg, camera_settings->time_boot_ms, camera_settings->mode_id, camera_settings->zoomLevel, camera_settings->focusLevel); +} + /** * @brief Send a camera_settings message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_tracking_geo_status.h b/common/mavlink_msg_camera_tracking_geo_status.h index 120b1e3d..f31e7c8a 100644 --- a/common/mavlink_msg_camera_tracking_geo_status.h +++ b/common/mavlink_msg_camera_tracking_geo_status.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_camera_tracking_geo_status_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_CRC); } +/** + * @brief Pack a camera_tracking_geo_status 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 tracking_status Current tracking status + * @param lat [degE7] Latitude of tracked object + * @param lon [degE7] Longitude of tracked object + * @param alt [m] Altitude of tracked object(AMSL, WGS84) + * @param h_acc [m] Horizontal accuracy. NAN if unknown + * @param v_acc [m] Vertical accuracy. NAN if unknown + * @param vel_n [m/s] North velocity of tracked object. NAN if unknown + * @param vel_e [m/s] East velocity of tracked object. NAN if unknown + * @param vel_d [m/s] Down velocity of tracked object. NAN if unknown + * @param vel_acc [m/s] Velocity accuracy. NAN if unknown + * @param dist [m] Distance between camera and tracked object. NAN if unknown + * @param hdg [rad] Heading in radians, in NED. NAN if unknown + * @param hdg_acc [rad] Accuracy of heading, in NED. NAN if unknown + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_tracking_geo_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t tracking_status, int32_t lat, int32_t lon, float alt, float h_acc, float v_acc, float vel_n, float vel_e, float vel_d, float vel_acc, float dist, float hdg, float hdg_acc) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN]; + _mav_put_int32_t(buf, 0, lat); + _mav_put_int32_t(buf, 4, lon); + _mav_put_float(buf, 8, alt); + _mav_put_float(buf, 12, h_acc); + _mav_put_float(buf, 16, v_acc); + _mav_put_float(buf, 20, vel_n); + _mav_put_float(buf, 24, vel_e); + _mav_put_float(buf, 28, vel_d); + _mav_put_float(buf, 32, vel_acc); + _mav_put_float(buf, 36, dist); + _mav_put_float(buf, 40, hdg); + _mav_put_float(buf, 44, hdg_acc); + _mav_put_uint8_t(buf, 48, tracking_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN); +#else + mavlink_camera_tracking_geo_status_t packet; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.h_acc = h_acc; + packet.v_acc = v_acc; + packet.vel_n = vel_n; + packet.vel_e = vel_e; + packet.vel_d = vel_d; + packet.vel_acc = vel_acc; + packet.dist = dist; + packet.hdg = hdg; + packet.hdg_acc = hdg_acc; + packet.tracking_status = tracking_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_GEO_STATUS_LEN); +#endif +} + /** * @brief Pack a camera_tracking_geo_status message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_camera_tracking_geo_status_encode_chan(uint8_ return mavlink_msg_camera_tracking_geo_status_pack_chan(system_id, component_id, chan, msg, camera_tracking_geo_status->tracking_status, camera_tracking_geo_status->lat, camera_tracking_geo_status->lon, camera_tracking_geo_status->alt, camera_tracking_geo_status->h_acc, camera_tracking_geo_status->v_acc, camera_tracking_geo_status->vel_n, camera_tracking_geo_status->vel_e, camera_tracking_geo_status->vel_d, camera_tracking_geo_status->vel_acc, camera_tracking_geo_status->dist, camera_tracking_geo_status->hdg, camera_tracking_geo_status->hdg_acc); } +/** + * @brief Encode a camera_tracking_geo_status struct with provided status structure + * + * @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 camera_tracking_geo_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_tracking_geo_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_tracking_geo_status_t* camera_tracking_geo_status) +{ + return mavlink_msg_camera_tracking_geo_status_pack_status(system_id, component_id, _status, msg, camera_tracking_geo_status->tracking_status, camera_tracking_geo_status->lat, camera_tracking_geo_status->lon, camera_tracking_geo_status->alt, camera_tracking_geo_status->h_acc, camera_tracking_geo_status->v_acc, camera_tracking_geo_status->vel_n, camera_tracking_geo_status->vel_e, camera_tracking_geo_status->vel_d, camera_tracking_geo_status->vel_acc, camera_tracking_geo_status->dist, camera_tracking_geo_status->hdg, camera_tracking_geo_status->hdg_acc); +} + /** * @brief Send a camera_tracking_geo_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_tracking_image_status.h b/common/mavlink_msg_camera_tracking_image_status.h index bd5f0607..4f0cbb43 100644 --- a/common/mavlink_msg_camera_tracking_image_status.h +++ b/common/mavlink_msg_camera_tracking_image_status.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_camera_tracking_image_status_pack(uint8_t sys return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_CRC); } +/** + * @brief Pack a camera_tracking_image_status 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 tracking_status Current tracking status + * @param tracking_mode Current tracking mode + * @param target_data Defines location of target data + * @param point_x Current tracked point x value if CAMERA_TRACKING_MODE_POINT (normalized 0..1, 0 is left, 1 is right), NAN if unknown + * @param point_y Current tracked point y value if CAMERA_TRACKING_MODE_POINT (normalized 0..1, 0 is top, 1 is bottom), NAN if unknown + * @param radius Current tracked radius if CAMERA_TRACKING_MODE_POINT (normalized 0..1, 0 is image left, 1 is image right), NAN if unknown + * @param rec_top_x Current tracked rectangle top x value if CAMERA_TRACKING_MODE_RECTANGLE (normalized 0..1, 0 is left, 1 is right), NAN if unknown + * @param rec_top_y Current tracked rectangle top y value if CAMERA_TRACKING_MODE_RECTANGLE (normalized 0..1, 0 is top, 1 is bottom), NAN if unknown + * @param rec_bottom_x Current tracked rectangle bottom x value if CAMERA_TRACKING_MODE_RECTANGLE (normalized 0..1, 0 is left, 1 is right), NAN if unknown + * @param rec_bottom_y Current tracked rectangle bottom y value if CAMERA_TRACKING_MODE_RECTANGLE (normalized 0..1, 0 is top, 1 is bottom), NAN if unknown + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_tracking_image_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t tracking_status, uint8_t tracking_mode, uint8_t target_data, float point_x, float point_y, float radius, float rec_top_x, float rec_top_y, float rec_bottom_x, float rec_bottom_y) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN]; + _mav_put_float(buf, 0, point_x); + _mav_put_float(buf, 4, point_y); + _mav_put_float(buf, 8, radius); + _mav_put_float(buf, 12, rec_top_x); + _mav_put_float(buf, 16, rec_top_y); + _mav_put_float(buf, 20, rec_bottom_x); + _mav_put_float(buf, 24, rec_bottom_y); + _mav_put_uint8_t(buf, 28, tracking_status); + _mav_put_uint8_t(buf, 29, tracking_mode); + _mav_put_uint8_t(buf, 30, target_data); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN); +#else + mavlink_camera_tracking_image_status_t packet; + packet.point_x = point_x; + packet.point_y = point_y; + packet.radius = radius; + packet.rec_top_x = rec_top_x; + packet.rec_top_y = rec_top_y; + packet.rec_bottom_x = rec_bottom_x; + packet.rec_bottom_y = rec_bottom_y; + packet.tracking_status = tracking_status; + packet.tracking_mode = tracking_mode; + packet.target_data = target_data; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS_LEN); +#endif +} + /** * @brief Pack a camera_tracking_image_status message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_camera_tracking_image_status_encode_chan(uint return mavlink_msg_camera_tracking_image_status_pack_chan(system_id, component_id, chan, msg, camera_tracking_image_status->tracking_status, camera_tracking_image_status->tracking_mode, camera_tracking_image_status->target_data, camera_tracking_image_status->point_x, camera_tracking_image_status->point_y, camera_tracking_image_status->radius, camera_tracking_image_status->rec_top_x, camera_tracking_image_status->rec_top_y, camera_tracking_image_status->rec_bottom_x, camera_tracking_image_status->rec_bottom_y); } +/** + * @brief Encode a camera_tracking_image_status struct with provided status structure + * + * @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 camera_tracking_image_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_tracking_image_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_tracking_image_status_t* camera_tracking_image_status) +{ + return mavlink_msg_camera_tracking_image_status_pack_status(system_id, component_id, _status, msg, camera_tracking_image_status->tracking_status, camera_tracking_image_status->tracking_mode, camera_tracking_image_status->target_data, camera_tracking_image_status->point_x, camera_tracking_image_status->point_y, camera_tracking_image_status->radius, camera_tracking_image_status->rec_top_x, camera_tracking_image_status->rec_top_y, camera_tracking_image_status->rec_bottom_x, camera_tracking_image_status->rec_bottom_y); +} + /** * @brief Send a camera_tracking_image_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_camera_trigger.h b/common/mavlink_msg_camera_trigger.h index 781ef441..de53243c 100644 --- a/common/mavlink_msg_camera_trigger.h +++ b/common/mavlink_msg_camera_trigger.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_camera_trigger_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); } +/** + * @brief Pack a camera_trigger 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 time_usec [us] Timestamp for image frame (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param seq Image frame sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_camera_trigger_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, seq); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); +#else + mavlink_camera_trigger_t packet; + packet.time_usec = time_usec; + packet.seq = seq; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAMERA_TRIGGER; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); +#endif +} + /** * @brief Pack a camera_trigger message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_camera_trigger_encode_chan(uint8_t system_id, return mavlink_msg_camera_trigger_pack_chan(system_id, component_id, chan, msg, camera_trigger->time_usec, camera_trigger->seq); } +/** + * @brief Encode a camera_trigger struct with provided status structure + * + * @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 camera_trigger C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_camera_trigger_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_camera_trigger_t* camera_trigger) +{ + return mavlink_msg_camera_trigger_pack_status(system_id, component_id, _status, msg, camera_trigger->time_usec, camera_trigger->seq); +} + /** * @brief Send a camera_trigger message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_can_filter_modify.h b/common/mavlink_msg_can_filter_modify.h index b0c945e9..d992f0f1 100644 --- a/common/mavlink_msg_can_filter_modify.h +++ b/common/mavlink_msg_can_filter_modify.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_can_filter_modify_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_MIN_LEN, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_CRC); } +/** + * @brief Pack a can_filter_modify 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 target_system System ID. + * @param target_component Component ID. + * @param bus bus number + * @param operation what operation to perform on the filter list. See CAN_FILTER_OP enum. + * @param num_ids number of IDs in filter list + * @param ids filter IDs, length num_ids + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_can_filter_modify_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t bus, uint8_t operation, uint8_t num_ids, const uint16_t *ids) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN]; + _mav_put_uint8_t(buf, 32, target_system); + _mav_put_uint8_t(buf, 33, target_component); + _mav_put_uint8_t(buf, 34, bus); + _mav_put_uint8_t(buf, 35, operation); + _mav_put_uint8_t(buf, 36, num_ids); + _mav_put_uint16_t_array(buf, 0, ids, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN); +#else + mavlink_can_filter_modify_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.bus = bus; + packet.operation = operation; + packet.num_ids = num_ids; + mav_array_memcpy(packet.ids, ids, sizeof(uint16_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAN_FILTER_MODIFY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_MIN_LEN, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_MIN_LEN, MAVLINK_MSG_ID_CAN_FILTER_MODIFY_LEN); +#endif +} + /** * @brief Pack a can_filter_modify message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_can_filter_modify_encode_chan(uint8_t system_ return mavlink_msg_can_filter_modify_pack_chan(system_id, component_id, chan, msg, can_filter_modify->target_system, can_filter_modify->target_component, can_filter_modify->bus, can_filter_modify->operation, can_filter_modify->num_ids, can_filter_modify->ids); } +/** + * @brief Encode a can_filter_modify struct with provided status structure + * + * @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 can_filter_modify C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_can_filter_modify_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_can_filter_modify_t* can_filter_modify) +{ + return mavlink_msg_can_filter_modify_pack_status(system_id, component_id, _status, msg, can_filter_modify->target_system, can_filter_modify->target_component, can_filter_modify->bus, can_filter_modify->operation, can_filter_modify->num_ids, can_filter_modify->ids); +} + /** * @brief Send a can_filter_modify message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_can_frame.h b/common/mavlink_msg_can_frame.h index 849f7074..80777d0b 100644 --- a/common/mavlink_msg_can_frame.h +++ b/common/mavlink_msg_can_frame.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_can_frame_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CAN_FRAME_MIN_LEN, MAVLINK_MSG_ID_CAN_FRAME_LEN, MAVLINK_MSG_ID_CAN_FRAME_CRC); } +/** + * @brief Pack a can_frame 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 target_system System ID. + * @param target_component Component ID. + * @param bus Bus number + * @param len Frame length + * @param id Frame ID + * @param data Frame data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_can_frame_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t bus, uint8_t len, uint32_t id, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CAN_FRAME_LEN]; + _mav_put_uint32_t(buf, 0, id); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, bus); + _mav_put_uint8_t(buf, 7, len); + _mav_put_uint8_t_array(buf, 8, data, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAN_FRAME_LEN); +#else + mavlink_can_frame_t packet; + packet.id = id; + packet.target_system = target_system; + packet.target_component = target_component; + packet.bus = bus; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAN_FRAME_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CAN_FRAME; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAN_FRAME_MIN_LEN, MAVLINK_MSG_ID_CAN_FRAME_LEN, MAVLINK_MSG_ID_CAN_FRAME_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CAN_FRAME_MIN_LEN, MAVLINK_MSG_ID_CAN_FRAME_LEN); +#endif +} + /** * @brief Pack a can_frame message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_can_frame_encode_chan(uint8_t system_id, uint return mavlink_msg_can_frame_pack_chan(system_id, component_id, chan, msg, can_frame->target_system, can_frame->target_component, can_frame->bus, can_frame->len, can_frame->id, can_frame->data); } +/** + * @brief Encode a can_frame struct with provided status structure + * + * @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 can_frame C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_can_frame_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_can_frame_t* can_frame) +{ + return mavlink_msg_can_frame_pack_status(system_id, component_id, _status, msg, can_frame->target_system, can_frame->target_component, can_frame->bus, can_frame->len, can_frame->id, can_frame->data); +} + /** * @brief Send a can_frame message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_canfd_frame.h b/common/mavlink_msg_canfd_frame.h index 000b11d7..574f2031 100644 --- a/common/mavlink_msg_canfd_frame.h +++ b/common/mavlink_msg_canfd_frame.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_canfd_frame_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CANFD_FRAME_MIN_LEN, MAVLINK_MSG_ID_CANFD_FRAME_LEN, MAVLINK_MSG_ID_CANFD_FRAME_CRC); } +/** + * @brief Pack a canfd_frame 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 target_system System ID. + * @param target_component Component ID. + * @param bus bus number + * @param len Frame length + * @param id Frame ID + * @param data Frame data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_canfd_frame_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t bus, uint8_t len, uint32_t id, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CANFD_FRAME_LEN]; + _mav_put_uint32_t(buf, 0, id); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, bus); + _mav_put_uint8_t(buf, 7, len); + _mav_put_uint8_t_array(buf, 8, data, 64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CANFD_FRAME_LEN); +#else + mavlink_canfd_frame_t packet; + packet.id = id; + packet.target_system = target_system; + packet.target_component = target_component; + packet.bus = bus; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CANFD_FRAME_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CANFD_FRAME; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CANFD_FRAME_MIN_LEN, MAVLINK_MSG_ID_CANFD_FRAME_LEN, MAVLINK_MSG_ID_CANFD_FRAME_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CANFD_FRAME_MIN_LEN, MAVLINK_MSG_ID_CANFD_FRAME_LEN); +#endif +} + /** * @brief Pack a canfd_frame message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_canfd_frame_encode_chan(uint8_t system_id, ui return mavlink_msg_canfd_frame_pack_chan(system_id, component_id, chan, msg, canfd_frame->target_system, canfd_frame->target_component, canfd_frame->bus, canfd_frame->len, canfd_frame->id, canfd_frame->data); } +/** + * @brief Encode a canfd_frame struct with provided status structure + * + * @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 canfd_frame C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_canfd_frame_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_canfd_frame_t* canfd_frame) +{ + return mavlink_msg_canfd_frame_pack_status(system_id, component_id, _status, msg, canfd_frame->target_system, canfd_frame->target_component, canfd_frame->bus, canfd_frame->len, canfd_frame->id, canfd_frame->data); +} + /** * @brief Send a canfd_frame message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_cellular_config.h b/common/mavlink_msg_cellular_config.h index 54fc480c..5fb2c2ed 100644 --- a/common/mavlink_msg_cellular_config.h +++ b/common/mavlink_msg_cellular_config.h @@ -106,6 +106,58 @@ static inline uint16_t mavlink_msg_cellular_config_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CELLULAR_CONFIG_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN, MAVLINK_MSG_ID_CELLULAR_CONFIG_CRC); } +/** + * @brief Pack a cellular_config 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 enable_lte Enable/disable LTE. 0: setting unchanged, 1: disabled, 2: enabled. Current setting when sent back as a response. + * @param enable_pin Enable/disable PIN on the SIM card. 0: setting unchanged, 1: disabled, 2: enabled. Current setting when sent back as a response. + * @param pin PIN sent to the SIM card. Blank when PIN is disabled. Empty when message is sent back as a response. + * @param new_pin New PIN when changing the PIN. Blank to leave it unchanged. Empty when message is sent back as a response. + * @param apn Name of the cellular APN. Blank to leave it unchanged. Current APN when sent back as a response. + * @param puk Required PUK code in case the user failed to authenticate 3 times with the PIN. Empty when message is sent back as a response. + * @param roaming Enable/disable roaming. 0: setting unchanged, 1: disabled, 2: enabled. Current setting when sent back as a response. + * @param response Message acceptance response (sent back to GS). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_cellular_config_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t enable_lte, uint8_t enable_pin, const char *pin, const char *new_pin, const char *apn, const char *puk, uint8_t roaming, uint8_t response) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN]; + _mav_put_uint8_t(buf, 0, enable_lte); + _mav_put_uint8_t(buf, 1, enable_pin); + _mav_put_uint8_t(buf, 82, roaming); + _mav_put_uint8_t(buf, 83, response); + _mav_put_char_array(buf, 2, pin, 16); + _mav_put_char_array(buf, 18, new_pin, 16); + _mav_put_char_array(buf, 34, apn, 32); + _mav_put_char_array(buf, 66, puk, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN); +#else + mavlink_cellular_config_t packet; + packet.enable_lte = enable_lte; + packet.enable_pin = enable_pin; + packet.roaming = roaming; + packet.response = response; + mav_array_memcpy(packet.pin, pin, sizeof(char)*16); + mav_array_memcpy(packet.new_pin, new_pin, sizeof(char)*16); + mav_array_memcpy(packet.apn, apn, sizeof(char)*32); + mav_array_memcpy(packet.puk, puk, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CELLULAR_CONFIG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_CONFIG_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN, MAVLINK_MSG_ID_CELLULAR_CONFIG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_CONFIG_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_CONFIG_LEN); +#endif +} + /** * @brief Pack a cellular_config message on a channel * @param system_id ID of this system @@ -181,6 +233,20 @@ static inline uint16_t mavlink_msg_cellular_config_encode_chan(uint8_t system_id return mavlink_msg_cellular_config_pack_chan(system_id, component_id, chan, msg, cellular_config->enable_lte, cellular_config->enable_pin, cellular_config->pin, cellular_config->new_pin, cellular_config->apn, cellular_config->puk, cellular_config->roaming, cellular_config->response); } +/** + * @brief Encode a cellular_config struct with provided status structure + * + * @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 cellular_config C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_cellular_config_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cellular_config_t* cellular_config) +{ + return mavlink_msg_cellular_config_pack_status(system_id, component_id, _status, msg, cellular_config->enable_lte, cellular_config->enable_pin, cellular_config->pin, cellular_config->new_pin, cellular_config->apn, cellular_config->puk, cellular_config->roaming, cellular_config->response); +} + /** * @brief Send a cellular_config message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_cellular_status.h b/common/mavlink_msg_cellular_status.h index 1528ad5f..63ab299f 100644 --- a/common/mavlink_msg_cellular_status.h +++ b/common/mavlink_msg_cellular_status.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_cellular_status_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC); } +/** + * @brief Pack a cellular_status 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 status Cellular modem status + * @param failure_reason Failure reason when status in in CELLULAR_STATUS_FLAG_FAILED + * @param type Cellular network radio type: gsm, cdma, lte... + * @param quality Signal quality in percent. If unknown, set to UINT8_MAX + * @param mcc Mobile country code. If unknown, set to UINT16_MAX + * @param mnc Mobile network code. If unknown, set to UINT16_MAX + * @param lac Location area code. If unknown, set to 0 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_cellular_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t status, uint8_t failure_reason, uint8_t type, uint8_t quality, uint16_t mcc, uint16_t mnc, uint16_t lac) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CELLULAR_STATUS_LEN]; + _mav_put_uint16_t(buf, 0, mcc); + _mav_put_uint16_t(buf, 2, mnc); + _mav_put_uint16_t(buf, 4, lac); + _mav_put_uint8_t(buf, 6, status); + _mav_put_uint8_t(buf, 7, failure_reason); + _mav_put_uint8_t(buf, 8, type); + _mav_put_uint8_t(buf, 9, quality); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN); +#else + mavlink_cellular_status_t packet; + packet.mcc = mcc; + packet.mnc = mnc; + packet.lac = lac; + packet.status = status; + packet.failure_reason = failure_reason; + packet.type = type; + packet.quality = quality; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CELLULAR_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN); +#endif +} + /** * @brief Pack a cellular_status message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_cellular_status_encode_chan(uint8_t system_id return mavlink_msg_cellular_status_pack_chan(system_id, component_id, chan, msg, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac); } +/** + * @brief Encode a cellular_status struct with provided status structure + * + * @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 cellular_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_cellular_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cellular_status_t* cellular_status) +{ + return mavlink_msg_cellular_status_pack_status(system_id, component_id, _status, msg, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac); +} + /** * @brief Send a cellular_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_change_operator_control.h b/common/mavlink_msg_change_operator_control.h index b36014fb..722b3c56 100644 --- a/common/mavlink_msg_change_operator_control.h +++ b/common/mavlink_msg_change_operator_control.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_change_operator_control_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_CRC); } +/** + * @brief Pack a change_operator_control 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 target_system System the GCS requests control for + * @param control_request 0: request control of this MAV, 1: Release control of this MAV + * @param version [rad] 0: key as plaintext, 1-255: future, different hashing/encryption variants. The GCS should in general use the safest mode possible initially and then gradually move down the encryption level if it gets a NACK message indicating an encryption mismatch. + * @param passkey Password / Key, depending on version plaintext or encrypted. 25 or less characters, NULL terminated. The characters may involve A-Z, a-z, 0-9, and "!?,.-" + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_change_operator_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t control_request, uint8_t version, const char *passkey) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, control_request); + _mav_put_uint8_t(buf, 2, version); + _mav_put_char_array(buf, 3, passkey, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN); +#else + mavlink_change_operator_control_t packet; + packet.target_system = target_system; + packet.control_request = control_request; + packet.version = version; + mav_array_memcpy(packet.passkey, passkey, sizeof(char)*25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_LEN); +#endif +} + /** * @brief Pack a change_operator_control message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_change_operator_control_encode_chan(uint8_t s return mavlink_msg_change_operator_control_pack_chan(system_id, component_id, chan, msg, change_operator_control->target_system, change_operator_control->control_request, change_operator_control->version, change_operator_control->passkey); } +/** + * @brief Encode a change_operator_control struct with provided status structure + * + * @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 change_operator_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_change_operator_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_change_operator_control_t* change_operator_control) +{ + return mavlink_msg_change_operator_control_pack_status(system_id, component_id, _status, msg, change_operator_control->target_system, change_operator_control->control_request, change_operator_control->version, change_operator_control->passkey); +} + /** * @brief Send a change_operator_control message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_change_operator_control_ack.h b/common/mavlink_msg_change_operator_control_ack.h index 5eb073ef..b988e238 100644 --- a/common/mavlink_msg_change_operator_control_ack.h +++ b/common/mavlink_msg_change_operator_control_ack.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_change_operator_control_ack_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_CRC); } +/** + * @brief Pack a change_operator_control_ack 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 gcs_system_id ID of the GCS this message + * @param control_request 0: request control of this MAV, 1: Release control of this MAV + * @param ack 0: ACK, 1: NACK: Wrong passkey, 2: NACK: Unsupported passkey encryption method, 3: NACK: Already under control + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_change_operator_control_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t gcs_system_id, uint8_t control_request, uint8_t ack) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN]; + _mav_put_uint8_t(buf, 0, gcs_system_id); + _mav_put_uint8_t(buf, 1, control_request); + _mav_put_uint8_t(buf, 2, ack); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN); +#else + mavlink_change_operator_control_ack_t packet; + packet.gcs_system_id = gcs_system_id; + packet.control_request = control_request; + packet.ack = ack; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_MIN_LEN, MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK_LEN); +#endif +} + /** * @brief Pack a change_operator_control_ack message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_change_operator_control_ack_encode_chan(uint8 return mavlink_msg_change_operator_control_ack_pack_chan(system_id, component_id, chan, msg, change_operator_control_ack->gcs_system_id, change_operator_control_ack->control_request, change_operator_control_ack->ack); } +/** + * @brief Encode a change_operator_control_ack struct with provided status structure + * + * @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 change_operator_control_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_change_operator_control_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_change_operator_control_ack_t* change_operator_control_ack) +{ + return mavlink_msg_change_operator_control_ack_pack_status(system_id, component_id, _status, msg, change_operator_control_ack->gcs_system_id, change_operator_control_ack->control_request, change_operator_control_ack->ack); +} + /** * @brief Send a change_operator_control_ack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_collision.h b/common/mavlink_msg_collision.h index 38759563..7571e879 100644 --- a/common/mavlink_msg_collision.h +++ b/common/mavlink_msg_collision.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_collision_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COLLISION_MIN_LEN, MAVLINK_MSG_ID_COLLISION_LEN, MAVLINK_MSG_ID_COLLISION_CRC); } +/** + * @brief Pack a collision 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 src Collision data source + * @param id Unique identifier, domain based on src field + * @param action Action that is being taken to avoid this collision + * @param threat_level How concerned the aircraft is about this collision + * @param time_to_minimum_delta [s] Estimated time until collision occurs + * @param altitude_minimum_delta [m] Closest vertical distance between vehicle and object + * @param horizontal_minimum_delta [m] Closest horizontal distance between vehicle and object + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_collision_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t src, uint32_t id, uint8_t action, uint8_t threat_level, float time_to_minimum_delta, float altitude_minimum_delta, float horizontal_minimum_delta) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COLLISION_LEN]; + _mav_put_uint32_t(buf, 0, id); + _mav_put_float(buf, 4, time_to_minimum_delta); + _mav_put_float(buf, 8, altitude_minimum_delta); + _mav_put_float(buf, 12, horizontal_minimum_delta); + _mav_put_uint8_t(buf, 16, src); + _mav_put_uint8_t(buf, 17, action); + _mav_put_uint8_t(buf, 18, threat_level); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COLLISION_LEN); +#else + mavlink_collision_t packet; + packet.id = id; + packet.time_to_minimum_delta = time_to_minimum_delta; + packet.altitude_minimum_delta = altitude_minimum_delta; + packet.horizontal_minimum_delta = horizontal_minimum_delta; + packet.src = src; + packet.action = action; + packet.threat_level = threat_level; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COLLISION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COLLISION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COLLISION_MIN_LEN, MAVLINK_MSG_ID_COLLISION_LEN, MAVLINK_MSG_ID_COLLISION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COLLISION_MIN_LEN, MAVLINK_MSG_ID_COLLISION_LEN); +#endif +} + /** * @brief Pack a collision message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_collision_encode_chan(uint8_t system_id, uint return mavlink_msg_collision_pack_chan(system_id, component_id, chan, msg, collision->src, collision->id, collision->action, collision->threat_level, collision->time_to_minimum_delta, collision->altitude_minimum_delta, collision->horizontal_minimum_delta); } +/** + * @brief Encode a collision struct with provided status structure + * + * @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 collision C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_collision_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_collision_t* collision) +{ + return mavlink_msg_collision_pack_status(system_id, component_id, _status, msg, collision->src, collision->id, collision->action, collision->threat_level, collision->time_to_minimum_delta, collision->altitude_minimum_delta, collision->horizontal_minimum_delta); +} + /** * @brief Send a collision message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_command_ack.h b/common/mavlink_msg_command_ack.h index fa524760..933bb33d 100644 --- a/common/mavlink_msg_command_ack.h +++ b/common/mavlink_msg_command_ack.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); } +/** + * @brief Pack a command_ack 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 command Command ID (of acknowledged command). + * @param result Result of command. + * @param progress [%] The progress percentage when result is MAV_RESULT_IN_PROGRESS. Values: [0-100], or UINT8_MAX if the progress is unknown. + * @param result_param2 Additional result information. Can be set with a command-specific enum containing command-specific error reasons for why the command might be denied. If used, the associated enum must be documented in the corresponding MAV_CMD (this enum should have a 0 value to indicate "unused" or "unknown"). + * @param target_system System ID of the target recipient. This is the ID of the system that sent the command for which this COMMAND_ACK is an acknowledgement. + * @param target_component Component ID of the target recipient. This is the ID of the system that sent the command for which this COMMAND_ACK is an acknowledgement. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t command, uint8_t result, uint8_t progress, int32_t result_param2, uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN]; + _mav_put_uint16_t(buf, 0, command); + _mav_put_uint8_t(buf, 2, result); + _mav_put_uint8_t(buf, 3, progress); + _mav_put_int32_t(buf, 4, result_param2); + _mav_put_uint8_t(buf, 8, target_system); + _mav_put_uint8_t(buf, 9, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN); +#else + mavlink_command_ack_t packet; + packet.command = command; + packet.result = result; + packet.progress = progress; + packet.result_param2 = result_param2; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN); +#endif +} + /** * @brief Pack a command_ack message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_command_ack_encode_chan(uint8_t system_id, ui return mavlink_msg_command_ack_pack_chan(system_id, component_id, chan, msg, command_ack->command, command_ack->result, command_ack->progress, command_ack->result_param2, command_ack->target_system, command_ack->target_component); } +/** + * @brief Encode a command_ack struct with provided status structure + * + * @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 command_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack) +{ + return mavlink_msg_command_ack_pack_status(system_id, component_id, _status, msg, command_ack->command, command_ack->result, command_ack->progress, command_ack->result_param2, command_ack->target_system, command_ack->target_component); +} + /** * @brief Send a command_ack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_command_cancel.h b/common/mavlink_msg_command_cancel.h index 3dc955de..25940b96 100644 --- a/common/mavlink_msg_command_cancel.h +++ b/common/mavlink_msg_command_cancel.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_command_cancel_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC); } +/** + * @brief Pack a command_cancel 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 target_system System executing long running command. Should not be broadcast (0). + * @param target_component Component executing long running command. + * @param command Command ID (of command to cancel). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_cancel_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t command) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN]; + _mav_put_uint16_t(buf, 0, command); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN); +#else + mavlink_command_cancel_t packet; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_CANCEL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN); +#endif +} + /** * @brief Pack a command_cancel message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_command_cancel_encode_chan(uint8_t system_id, return mavlink_msg_command_cancel_pack_chan(system_id, component_id, chan, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command); } +/** + * @brief Encode a command_cancel struct with provided status structure + * + * @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 command_cancel C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_cancel_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel) +{ + return mavlink_msg_command_cancel_pack_status(system_id, component_id, _status, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command); +} + /** * @brief Send a command_cancel message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_command_int.h b/common/mavlink_msg_command_int.h index 946a5b57..1cbc409a 100644 --- a/common/mavlink_msg_command_int.h +++ b/common/mavlink_msg_command_int.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_command_int_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_INT_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_LEN, MAVLINK_MSG_ID_COMMAND_INT_CRC); } +/** + * @brief Pack a command_int 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 target_system System ID + * @param target_component Component ID + * @param frame The coordinate system of the COMMAND. + * @param command The scheduled action for the mission item. + * @param current Not used. + * @param autocontinue Not used (set 0). + * @param param1 PARAM1, see MAV_CMD enum + * @param param2 PARAM2, see MAV_CMD enum + * @param param3 PARAM3, see MAV_CMD enum + * @param param4 PARAM4, see MAV_CMD enum + * @param x PARAM5 / local: x position in meters * 1e4, global: latitude in degrees * 10^7 + * @param y PARAM6 / local: y position in meters * 1e4, global: longitude in degrees * 10^7 + * @param z PARAM7 / z position: global: altitude in meters (relative or absolute, depending on frame). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, int32_t x, int32_t y, float z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_INT_LEN]; + _mav_put_float(buf, 0, param1); + _mav_put_float(buf, 4, param2); + _mav_put_float(buf, 8, param3); + _mav_put_float(buf, 12, param4); + _mav_put_int32_t(buf, 16, x); + _mav_put_int32_t(buf, 20, y); + _mav_put_float(buf, 24, z); + _mav_put_uint16_t(buf, 28, command); + _mav_put_uint8_t(buf, 30, target_system); + _mav_put_uint8_t(buf, 31, target_component); + _mav_put_uint8_t(buf, 32, frame); + _mav_put_uint8_t(buf, 33, current); + _mav_put_uint8_t(buf, 34, autocontinue); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_INT_LEN); +#else + mavlink_command_int_t packet; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.x = x; + packet.y = y; + packet.z = z; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.frame = frame; + packet.current = current; + packet.autocontinue = autocontinue; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_INT_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_LEN, MAVLINK_MSG_ID_COMMAND_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_INT_MIN_LEN, MAVLINK_MSG_ID_COMMAND_INT_LEN); +#endif +} + /** * @brief Pack a command_int message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_command_int_encode_chan(uint8_t system_id, ui return mavlink_msg_command_int_pack_chan(system_id, component_id, chan, msg, command_int->target_system, command_int->target_component, command_int->frame, command_int->command, command_int->current, command_int->autocontinue, command_int->param1, command_int->param2, command_int->param3, command_int->param4, command_int->x, command_int->y, command_int->z); } +/** + * @brief Encode a command_int struct with provided status structure + * + * @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 command_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_int_t* command_int) +{ + return mavlink_msg_command_int_pack_status(system_id, component_id, _status, msg, command_int->target_system, command_int->target_component, command_int->frame, command_int->command, command_int->current, command_int->autocontinue, command_int->param1, command_int->param2, command_int->param3, command_int->param4, command_int->x, command_int->y, command_int->z); +} + /** * @brief Send a command_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_command_long.h b/common/mavlink_msg_command_long.h index b7683778..d59e4380 100644 --- a/common/mavlink_msg_command_long.h +++ b/common/mavlink_msg_command_long.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_command_long_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_LONG_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_LEN, MAVLINK_MSG_ID_COMMAND_LONG_CRC); } +/** + * @brief Pack a command_long 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 target_system System which should execute the command + * @param target_component Component which should execute the command, 0 for all components + * @param command Command ID (of command to send). + * @param confirmation 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command) + * @param param1 Parameter 1 (for the specific command). + * @param param2 Parameter 2 (for the specific command). + * @param param3 Parameter 3 (for the specific command). + * @param param4 Parameter 4 (for the specific command). + * @param param5 Parameter 5 (for the specific command). + * @param param6 Parameter 6 (for the specific command). + * @param param7 Parameter 7 (for the specific command). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_command_long_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t command, uint8_t confirmation, float param1, float param2, float param3, float param4, float param5, float param6, float param7) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMMAND_LONG_LEN]; + _mav_put_float(buf, 0, param1); + _mav_put_float(buf, 4, param2); + _mav_put_float(buf, 8, param3); + _mav_put_float(buf, 12, param4); + _mav_put_float(buf, 16, param5); + _mav_put_float(buf, 20, param6); + _mav_put_float(buf, 24, param7); + _mav_put_uint16_t(buf, 28, command); + _mav_put_uint8_t(buf, 30, target_system); + _mav_put_uint8_t(buf, 31, target_component); + _mav_put_uint8_t(buf, 32, confirmation); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_LONG_LEN); +#else + mavlink_command_long_t packet; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.param5 = param5; + packet.param6 = param6; + packet.param7 = param7; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.confirmation = confirmation; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_LONG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMMAND_LONG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_LONG_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_LEN, MAVLINK_MSG_ID_COMMAND_LONG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_LONG_MIN_LEN, MAVLINK_MSG_ID_COMMAND_LONG_LEN); +#endif +} + /** * @brief Pack a command_long message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_command_long_encode_chan(uint8_t system_id, u return mavlink_msg_command_long_pack_chan(system_id, component_id, chan, msg, command_long->target_system, command_long->target_component, command_long->command, command_long->confirmation, command_long->param1, command_long->param2, command_long->param3, command_long->param4, command_long->param5, command_long->param6, command_long->param7); } +/** + * @brief Encode a command_long struct with provided status structure + * + * @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 command_long C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_command_long_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_long_t* command_long) +{ + return mavlink_msg_command_long_pack_status(system_id, component_id, _status, msg, command_long->target_system, command_long->target_component, command_long->command, command_long->confirmation, command_long->param1, command_long->param2, command_long->param3, command_long->param4, command_long->param5, command_long->param6, command_long->param7); +} + /** * @brief Send a command_long message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_component_information.h b/common/mavlink_msg_component_information.h index 05ef49f2..7a3f7928 100644 --- a/common/mavlink_msg_component_information.h +++ b/common/mavlink_msg_component_information.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_component_information_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMPONENT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_CRC); } +/** + * @brief Pack a component_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param general_metadata_file_crc CRC32 of the general metadata file (general_metadata_uri). + * @param general_metadata_uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated. + * @param peripherals_metadata_file_crc CRC32 of peripherals metadata file (peripherals_metadata_uri). + * @param peripherals_metadata_uri (Optional) MAVLink FTP URI for the peripherals metadata file (COMP_METADATA_TYPE_PERIPHERALS), which may be compressed with xz. This contains data about "attached components" such as UAVCAN nodes. The peripherals are in a separate file because the information must be generated dynamically at runtime. The string needs to be zero terminated. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_component_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t general_metadata_file_crc, const char *general_metadata_uri, uint32_t peripherals_metadata_file_crc, const char *peripherals_metadata_uri) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, general_metadata_file_crc); + _mav_put_uint32_t(buf, 8, peripherals_metadata_file_crc); + _mav_put_char_array(buf, 12, general_metadata_uri, 100); + _mav_put_char_array(buf, 112, peripherals_metadata_uri, 100); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN); +#else + mavlink_component_information_t packet; + packet.time_boot_ms = time_boot_ms; + packet.general_metadata_file_crc = general_metadata_file_crc; + packet.peripherals_metadata_file_crc = peripherals_metadata_file_crc; + mav_array_memcpy(packet.general_metadata_uri, general_metadata_uri, sizeof(char)*100); + mav_array_memcpy(packet.peripherals_metadata_uri, peripherals_metadata_uri, sizeof(char)*100); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMPONENT_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_LEN); +#endif +} + /** * @brief Pack a component_information message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_component_information_encode_chan(uint8_t sys return mavlink_msg_component_information_pack_chan(system_id, component_id, chan, msg, component_information->time_boot_ms, component_information->general_metadata_file_crc, component_information->general_metadata_uri, component_information->peripherals_metadata_file_crc, component_information->peripherals_metadata_uri); } +/** + * @brief Encode a component_information struct with provided status structure + * + * @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 component_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_component_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_component_information_t* component_information) +{ + return mavlink_msg_component_information_pack_status(system_id, component_id, _status, msg, component_information->time_boot_ms, component_information->general_metadata_file_crc, component_information->general_metadata_uri, component_information->peripherals_metadata_file_crc, component_information->peripherals_metadata_uri); +} + /** * @brief Send a component_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_component_metadata.h b/common/mavlink_msg_component_metadata.h index 57afc9ab..aa4c1520 100644 --- a/common/mavlink_msg_component_metadata.h +++ b/common/mavlink_msg_component_metadata.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_component_metadata_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC); } +/** + * @brief Pack a component_metadata 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param file_crc CRC32 of the general metadata file. + * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_component_metadata_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t file_crc, const char *uri) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, file_crc); + _mav_put_char_array(buf, 8, uri, 100); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN); +#else + mavlink_component_metadata_t packet; + packet.time_boot_ms = time_boot_ms; + packet.file_crc = file_crc; + mav_array_memcpy(packet.uri, uri, sizeof(char)*100); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMPONENT_METADATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN); +#endif +} + /** * @brief Pack a component_metadata message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_component_metadata_encode_chan(uint8_t system return mavlink_msg_component_metadata_pack_chan(system_id, component_id, chan, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri); } +/** + * @brief Encode a component_metadata struct with provided status structure + * + * @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 component_metadata C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_component_metadata_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata) +{ + return mavlink_msg_component_metadata_pack_status(system_id, component_id, _status, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri); +} + /** * @brief Send a component_metadata message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_control_system_state.h b/common/mavlink_msg_control_system_state.h index 2e0d6b7a..316d1232 100644 --- a/common/mavlink_msg_control_system_state.h +++ b/common/mavlink_msg_control_system_state.h @@ -159,6 +159,85 @@ static inline uint16_t mavlink_msg_control_system_state_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_MIN_LEN, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_CRC); } +/** + * @brief Pack a control_system_state 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param x_acc [m/s/s] X acceleration in body frame + * @param y_acc [m/s/s] Y acceleration in body frame + * @param z_acc [m/s/s] Z acceleration in body frame + * @param x_vel [m/s] X velocity in body frame + * @param y_vel [m/s] Y velocity in body frame + * @param z_vel [m/s] Z velocity in body frame + * @param x_pos [m] X position in local frame + * @param y_pos [m] Y position in local frame + * @param z_pos [m] Z position in local frame + * @param airspeed [m/s] Airspeed, set to -1 if unknown + * @param vel_variance Variance of body velocity estimate + * @param pos_variance Variance in local position + * @param q The attitude, represented as Quaternion + * @param roll_rate [rad/s] Angular rate in roll axis + * @param pitch_rate [rad/s] Angular rate in pitch axis + * @param yaw_rate [rad/s] Angular rate in yaw axis + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_control_system_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float x_acc, float y_acc, float z_acc, float x_vel, float y_vel, float z_vel, float x_pos, float y_pos, float z_pos, float airspeed, const float *vel_variance, const float *pos_variance, const float *q, float roll_rate, float pitch_rate, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, x_acc); + _mav_put_float(buf, 12, y_acc); + _mav_put_float(buf, 16, z_acc); + _mav_put_float(buf, 20, x_vel); + _mav_put_float(buf, 24, y_vel); + _mav_put_float(buf, 28, z_vel); + _mav_put_float(buf, 32, x_pos); + _mav_put_float(buf, 36, y_pos); + _mav_put_float(buf, 40, z_pos); + _mav_put_float(buf, 44, airspeed); + _mav_put_float(buf, 88, roll_rate); + _mav_put_float(buf, 92, pitch_rate); + _mav_put_float(buf, 96, yaw_rate); + _mav_put_float_array(buf, 48, vel_variance, 3); + _mav_put_float_array(buf, 60, pos_variance, 3); + _mav_put_float_array(buf, 72, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN); +#else + mavlink_control_system_state_t packet; + packet.time_usec = time_usec; + packet.x_acc = x_acc; + packet.y_acc = y_acc; + packet.z_acc = z_acc; + packet.x_vel = x_vel; + packet.y_vel = y_vel; + packet.z_vel = z_vel; + packet.x_pos = x_pos; + packet.y_pos = y_pos; + packet.z_pos = z_pos; + packet.airspeed = airspeed; + packet.roll_rate = roll_rate; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + mav_array_memcpy(packet.vel_variance, vel_variance, sizeof(float)*3); + mav_array_memcpy(packet.pos_variance, pos_variance, sizeof(float)*3); + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_MIN_LEN, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_MIN_LEN, MAVLINK_MSG_ID_CONTROL_SYSTEM_STATE_LEN); +#endif +} + /** * @brief Pack a control_system_state message on a channel * @param system_id ID of this system @@ -261,6 +340,20 @@ static inline uint16_t mavlink_msg_control_system_state_encode_chan(uint8_t syst return mavlink_msg_control_system_state_pack_chan(system_id, component_id, chan, msg, control_system_state->time_usec, control_system_state->x_acc, control_system_state->y_acc, control_system_state->z_acc, control_system_state->x_vel, control_system_state->y_vel, control_system_state->z_vel, control_system_state->x_pos, control_system_state->y_pos, control_system_state->z_pos, control_system_state->airspeed, control_system_state->vel_variance, control_system_state->pos_variance, control_system_state->q, control_system_state->roll_rate, control_system_state->pitch_rate, control_system_state->yaw_rate); } +/** + * @brief Encode a control_system_state struct with provided status structure + * + * @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 control_system_state C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_control_system_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_control_system_state_t* control_system_state) +{ + return mavlink_msg_control_system_state_pack_status(system_id, component_id, _status, msg, control_system_state->time_usec, control_system_state->x_acc, control_system_state->y_acc, control_system_state->z_acc, control_system_state->x_vel, control_system_state->y_vel, control_system_state->z_vel, control_system_state->x_pos, control_system_state->y_pos, control_system_state->z_pos, control_system_state->airspeed, control_system_state->vel_variance, control_system_state->pos_variance, control_system_state->q, control_system_state->roll_rate, control_system_state->pitch_rate, control_system_state->yaw_rate); +} + /** * @brief Send a control_system_state message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_current_event_sequence.h b/common/mavlink_msg_current_event_sequence.h index 0c1ee1f4..e15d2929 100644 --- a/common/mavlink_msg_current_event_sequence.h +++ b/common/mavlink_msg_current_event_sequence.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_current_event_sequence_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); } +/** + * @brief Pack a current_event_sequence 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 sequence Sequence number. + * @param flags Flag bitset. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_current_event_sequence_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t sequence, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN]; + _mav_put_uint16_t(buf, 0, sequence); + _mav_put_uint8_t(buf, 2, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); +#else + mavlink_current_event_sequence_t packet; + packet.sequence = sequence; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); +#endif +} + /** * @brief Pack a current_event_sequence message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_current_event_sequence_encode_chan(uint8_t sy return mavlink_msg_current_event_sequence_pack_chan(system_id, component_id, chan, msg, current_event_sequence->sequence, current_event_sequence->flags); } +/** + * @brief Encode a current_event_sequence struct with provided status structure + * + * @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 current_event_sequence C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_current_event_sequence_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_current_event_sequence_t* current_event_sequence) +{ + return mavlink_msg_current_event_sequence_pack_status(system_id, component_id, _status, msg, current_event_sequence->sequence, current_event_sequence->flags); +} + /** * @brief Send a current_event_sequence message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_data_stream.h b/common/mavlink_msg_data_stream.h index b8cd6985..f247db3c 100644 --- a/common/mavlink_msg_data_stream.h +++ b/common/mavlink_msg_data_stream.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_data_stream_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); } +/** + * @brief Pack a data_stream 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 stream_id The ID of the requested data stream + * @param message_rate [Hz] The message rate + * @param on_off 1 stream is enabled, 0 stream is stopped. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data_stream_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t stream_id, uint16_t message_rate, uint8_t on_off) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN]; + _mav_put_uint16_t(buf, 0, message_rate); + _mav_put_uint8_t(buf, 2, stream_id); + _mav_put_uint8_t(buf, 3, on_off); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_STREAM_LEN); +#else + mavlink_data_stream_t packet; + packet.message_rate = message_rate; + packet.stream_id = stream_id; + packet.on_off = on_off; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_STREAM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA_STREAM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN); +#endif +} + /** * @brief Pack a data_stream message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_data_stream_encode_chan(uint8_t system_id, ui return mavlink_msg_data_stream_pack_chan(system_id, component_id, chan, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off); } +/** + * @brief Encode a data_stream struct with provided status structure + * + * @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 data_stream C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data_stream_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data_stream_t* data_stream) +{ + return mavlink_msg_data_stream_pack_status(system_id, component_id, _status, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off); +} + /** * @brief Send a data_stream message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_data_transmission_handshake.h b/common/mavlink_msg_data_transmission_handshake.h index f6a383c1..4e4d5898 100644 --- a/common/mavlink_msg_data_transmission_handshake.h +++ b/common/mavlink_msg_data_transmission_handshake.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_data_transmission_handshake_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC); } +/** + * @brief Pack a data_transmission_handshake 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 type Type of requested/acknowledged data. + * @param size [bytes] total data size (set on ACK only). + * @param width Width of a matrix or image. + * @param height Height of a matrix or image. + * @param packets Number of packets being sent (set on ACK only). + * @param payload [bytes] Payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only). + * @param jpg_quality [%] JPEG quality. Values: [1-100]. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data_transmission_handshake_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint32_t size, uint16_t width, uint16_t height, uint16_t packets, uint8_t payload, uint8_t jpg_quality) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN]; + _mav_put_uint32_t(buf, 0, size); + _mav_put_uint16_t(buf, 4, width); + _mav_put_uint16_t(buf, 6, height); + _mav_put_uint16_t(buf, 8, packets); + _mav_put_uint8_t(buf, 10, type); + _mav_put_uint8_t(buf, 11, payload); + _mav_put_uint8_t(buf, 12, jpg_quality); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN); +#else + mavlink_data_transmission_handshake_t packet; + packet.size = size; + packet.width = width; + packet.height = height; + packet.packets = packets; + packet.type = type; + packet.payload = payload; + packet.jpg_quality = jpg_quality; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN); +#endif +} + /** * @brief Pack a data_transmission_handshake message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_data_transmission_handshake_encode_chan(uint8 return mavlink_msg_data_transmission_handshake_pack_chan(system_id, component_id, chan, msg, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->width, data_transmission_handshake->height, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality); } +/** + * @brief Encode a data_transmission_handshake struct with provided status structure + * + * @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 data_transmission_handshake C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data_transmission_handshake_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_data_transmission_handshake_t* data_transmission_handshake) +{ + return mavlink_msg_data_transmission_handshake_pack_status(system_id, component_id, _status, msg, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->width, data_transmission_handshake->height, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality); +} + /** * @brief Send a data_transmission_handshake message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_debug.h b/common/mavlink_msg_debug.h index 57884d84..8c0af445 100644 --- a/common/mavlink_msg_debug.h +++ b/common/mavlink_msg_debug.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t compone return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); } +/** + * @brief Pack a debug 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param ind index of debug variable + * @param value DEBUG value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_debug_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t ind, float value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEBUG_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, value); + _mav_put_uint8_t(buf, 8, ind); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_LEN); +#else + mavlink_debug_t packet; + packet.time_boot_ms = time_boot_ms; + packet.value = value; + packet.ind = ind; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEBUG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN); +#endif +} + /** * @brief Pack a debug message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_debug_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_debug_pack_chan(system_id, component_id, chan, msg, debug->time_boot_ms, debug->ind, debug->value); } +/** + * @brief Encode a debug struct with provided status structure + * + * @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 debug C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_debug_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_debug_t* debug) +{ + return mavlink_msg_debug_pack_status(system_id, component_id, _status, msg, debug->time_boot_ms, debug->ind, debug->value); +} + /** * @brief Send a debug message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_debug_float_array.h b/common/mavlink_msg_debug_float_array.h index f18063e6..49c11036 100644 --- a/common/mavlink_msg_debug_float_array.h +++ b/common/mavlink_msg_debug_float_array.h @@ -80,6 +80,46 @@ static inline uint16_t mavlink_msg_debug_float_array_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_MIN_LEN, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_CRC); } +/** + * @brief Pack a debug_float_array 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param name Name, for human-friendly display in a Ground Control Station + * @param array_id Unique ID used to discriminate between arrays + * @param data data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_debug_float_array_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, const char *name, uint16_t array_id, const float *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint16_t(buf, 8, array_id); + _mav_put_char_array(buf, 10, name, 10); + _mav_put_float_array(buf, 20, data, 58); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN); +#else + mavlink_debug_float_array_t packet; + packet.time_usec = time_usec; + packet.array_id = array_id; + mav_array_memcpy(packet.name, name, sizeof(char)*10); + mav_array_memcpy(packet.data, data, sizeof(float)*58); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_MIN_LEN, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_MIN_LEN, MAVLINK_MSG_ID_DEBUG_FLOAT_ARRAY_LEN); +#endif +} + /** * @brief Pack a debug_float_array message on a channel * @param system_id ID of this system @@ -143,6 +183,20 @@ static inline uint16_t mavlink_msg_debug_float_array_encode_chan(uint8_t system_ return mavlink_msg_debug_float_array_pack_chan(system_id, component_id, chan, msg, debug_float_array->time_usec, debug_float_array->name, debug_float_array->array_id, debug_float_array->data); } +/** + * @brief Encode a debug_float_array struct with provided status structure + * + * @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 debug_float_array C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_debug_float_array_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_debug_float_array_t* debug_float_array) +{ + return mavlink_msg_debug_float_array_pack_status(system_id, component_id, _status, msg, debug_float_array->time_usec, debug_float_array->name, debug_float_array->array_id, debug_float_array->data); +} + /** * @brief Send a debug_float_array message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_debug_vect.h b/common/mavlink_msg_debug_vect.h index bef35f8c..d1057b06 100644 --- a/common/mavlink_msg_debug_vect.h +++ b/common/mavlink_msg_debug_vect.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_debug_vect_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DEBUG_VECT_MIN_LEN, MAVLINK_MSG_ID_DEBUG_VECT_LEN, MAVLINK_MSG_ID_DEBUG_VECT_CRC); } +/** + * @brief Pack a debug_vect 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 name Name + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param x x + * @param y y + * @param z z + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_debug_vect_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *name, uint64_t time_usec, float x, float y, float z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DEBUG_VECT_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_char_array(buf, 20, name, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_VECT_LEN); +#else + mavlink_debug_vect_t packet; + packet.time_usec = time_usec; + packet.x = x; + packet.y = y; + packet.z = z; + mav_array_memcpy(packet.name, name, sizeof(char)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_VECT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_VECT_MIN_LEN, MAVLINK_MSG_ID_DEBUG_VECT_LEN, MAVLINK_MSG_ID_DEBUG_VECT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DEBUG_VECT_MIN_LEN, MAVLINK_MSG_ID_DEBUG_VECT_LEN); +#endif +} + /** * @brief Pack a debug_vect message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_debug_vect_encode_chan(uint8_t system_id, uin return mavlink_msg_debug_vect_pack_chan(system_id, component_id, chan, msg, debug_vect->name, debug_vect->time_usec, debug_vect->x, debug_vect->y, debug_vect->z); } +/** + * @brief Encode a debug_vect struct with provided status structure + * + * @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 debug_vect C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_debug_vect_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_debug_vect_t* debug_vect) +{ + return mavlink_msg_debug_vect_pack_status(system_id, component_id, _status, msg, debug_vect->name, debug_vect->time_usec, debug_vect->x, debug_vect->y, debug_vect->z); +} + /** * @brief Send a debug_vect message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_distance_sensor.h b/common/mavlink_msg_distance_sensor.h index 601257ca..8a58fc0f 100644 --- a/common/mavlink_msg_distance_sensor.h +++ b/common/mavlink_msg_distance_sensor.h @@ -127,6 +127,70 @@ static inline uint16_t mavlink_msg_distance_sensor_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC); } +/** + * @brief Pack a distance_sensor 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param min_distance [cm] Minimum distance the sensor can measure + * @param max_distance [cm] Maximum distance the sensor can measure + * @param current_distance [cm] Current distance reading + * @param type Type of distance sensor. + * @param id Onboard ID of the sensor + * @param orientation Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270 + * @param covariance [cm^2] Measurement variance. Max standard deviation is 6cm. UINT8_MAX if unknown. + * @param horizontal_fov [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0. + * @param vertical_fov [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0. + * @param quaternion Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid." + * @param signal_quality [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_distance_sensor_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance, float horizontal_fov, float vertical_fov, const float *quaternion, uint8_t signal_quality) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint16_t(buf, 4, min_distance); + _mav_put_uint16_t(buf, 6, max_distance); + _mav_put_uint16_t(buf, 8, current_distance); + _mav_put_uint8_t(buf, 10, type); + _mav_put_uint8_t(buf, 11, id); + _mav_put_uint8_t(buf, 12, orientation); + _mav_put_uint8_t(buf, 13, covariance); + _mav_put_float(buf, 14, horizontal_fov); + _mav_put_float(buf, 18, vertical_fov); + _mav_put_uint8_t(buf, 38, signal_quality); + _mav_put_float_array(buf, 22, quaternion, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN); +#else + mavlink_distance_sensor_t packet; + packet.time_boot_ms = time_boot_ms; + packet.min_distance = min_distance; + packet.max_distance = max_distance; + packet.current_distance = current_distance; + packet.type = type; + packet.id = id; + packet.orientation = orientation; + packet.covariance = covariance; + packet.horizontal_fov = horizontal_fov; + packet.vertical_fov = vertical_fov; + packet.signal_quality = signal_quality; + mav_array_memcpy(packet.quaternion, quaternion, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN); +#endif +} + /** * @brief Pack a distance_sensor message on a channel * @param system_id ID of this system @@ -214,6 +278,20 @@ static inline uint16_t mavlink_msg_distance_sensor_encode_chan(uint8_t system_id return mavlink_msg_distance_sensor_pack_chan(system_id, component_id, chan, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance, distance_sensor->horizontal_fov, distance_sensor->vertical_fov, distance_sensor->quaternion, distance_sensor->signal_quality); } +/** + * @brief Encode a distance_sensor struct with provided status structure + * + * @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 distance_sensor C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_distance_sensor_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_distance_sensor_t* distance_sensor) +{ + return mavlink_msg_distance_sensor_pack_status(system_id, component_id, _status, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance, distance_sensor->horizontal_fov, distance_sensor->vertical_fov, distance_sensor->quaternion, distance_sensor->signal_quality); +} + /** * @brief Send a distance_sensor message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_efi_status.h b/common/mavlink_msg_efi_status.h index 6affcb2b..a96228c1 100644 --- a/common/mavlink_msg_efi_status.h +++ b/common/mavlink_msg_efi_status.h @@ -171,6 +171,93 @@ static inline uint16_t mavlink_msg_efi_status_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_EFI_STATUS_MIN_LEN, MAVLINK_MSG_ID_EFI_STATUS_LEN, MAVLINK_MSG_ID_EFI_STATUS_CRC); } +/** + * @brief Pack a efi_status 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 health EFI health status + * @param ecu_index ECU index + * @param rpm RPM + * @param fuel_consumed [cm^3] Fuel consumed + * @param fuel_flow [cm^3/min] Fuel flow rate + * @param engine_load [%] Engine load + * @param throttle_position [%] Throttle position + * @param spark_dwell_time [ms] Spark dwell time + * @param barometric_pressure [kPa] Barometric pressure + * @param intake_manifold_pressure [kPa] Intake manifold pressure( + * @param intake_manifold_temperature [degC] Intake manifold temperature + * @param cylinder_head_temperature [degC] Cylinder head temperature + * @param ignition_timing [deg] Ignition timing (Crank angle degrees) + * @param injection_time [ms] Injection time + * @param exhaust_gas_temperature [degC] Exhaust gas temperature + * @param throttle_out [%] Output throttle + * @param pt_compensation Pressure/temperature compensation + * @param ignition_voltage [V] Supply voltage to EFI sparking system. Zero in this value means "unknown", so if the supply voltage really is zero volts use 0.0001 instead. + * @param fuel_pressure [kPa] Fuel pressure. Zero in this value means "unknown", so if the fuel pressure really is zero kPa use 0.0001 instead. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_efi_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t health, float ecu_index, float rpm, float fuel_consumed, float fuel_flow, float engine_load, float throttle_position, float spark_dwell_time, float barometric_pressure, float intake_manifold_pressure, float intake_manifold_temperature, float cylinder_head_temperature, float ignition_timing, float injection_time, float exhaust_gas_temperature, float throttle_out, float pt_compensation, float ignition_voltage, float fuel_pressure) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_EFI_STATUS_LEN]; + _mav_put_float(buf, 0, ecu_index); + _mav_put_float(buf, 4, rpm); + _mav_put_float(buf, 8, fuel_consumed); + _mav_put_float(buf, 12, fuel_flow); + _mav_put_float(buf, 16, engine_load); + _mav_put_float(buf, 20, throttle_position); + _mav_put_float(buf, 24, spark_dwell_time); + _mav_put_float(buf, 28, barometric_pressure); + _mav_put_float(buf, 32, intake_manifold_pressure); + _mav_put_float(buf, 36, intake_manifold_temperature); + _mav_put_float(buf, 40, cylinder_head_temperature); + _mav_put_float(buf, 44, ignition_timing); + _mav_put_float(buf, 48, injection_time); + _mav_put_float(buf, 52, exhaust_gas_temperature); + _mav_put_float(buf, 56, throttle_out); + _mav_put_float(buf, 60, pt_compensation); + _mav_put_uint8_t(buf, 64, health); + _mav_put_float(buf, 65, ignition_voltage); + _mav_put_float(buf, 69, fuel_pressure); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_EFI_STATUS_LEN); +#else + mavlink_efi_status_t packet; + packet.ecu_index = ecu_index; + packet.rpm = rpm; + packet.fuel_consumed = fuel_consumed; + packet.fuel_flow = fuel_flow; + packet.engine_load = engine_load; + packet.throttle_position = throttle_position; + packet.spark_dwell_time = spark_dwell_time; + packet.barometric_pressure = barometric_pressure; + packet.intake_manifold_pressure = intake_manifold_pressure; + packet.intake_manifold_temperature = intake_manifold_temperature; + packet.cylinder_head_temperature = cylinder_head_temperature; + packet.ignition_timing = ignition_timing; + packet.injection_time = injection_time; + packet.exhaust_gas_temperature = exhaust_gas_temperature; + packet.throttle_out = throttle_out; + packet.pt_compensation = pt_compensation; + packet.health = health; + packet.ignition_voltage = ignition_voltage; + packet.fuel_pressure = fuel_pressure; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_EFI_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_EFI_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EFI_STATUS_MIN_LEN, MAVLINK_MSG_ID_EFI_STATUS_LEN, MAVLINK_MSG_ID_EFI_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EFI_STATUS_MIN_LEN, MAVLINK_MSG_ID_EFI_STATUS_LEN); +#endif +} + /** * @brief Pack a efi_status message on a channel * @param system_id ID of this system @@ -281,6 +368,20 @@ static inline uint16_t mavlink_msg_efi_status_encode_chan(uint8_t system_id, uin return mavlink_msg_efi_status_pack_chan(system_id, component_id, chan, msg, efi_status->health, efi_status->ecu_index, efi_status->rpm, efi_status->fuel_consumed, efi_status->fuel_flow, efi_status->engine_load, efi_status->throttle_position, efi_status->spark_dwell_time, efi_status->barometric_pressure, efi_status->intake_manifold_pressure, efi_status->intake_manifold_temperature, efi_status->cylinder_head_temperature, efi_status->ignition_timing, efi_status->injection_time, efi_status->exhaust_gas_temperature, efi_status->throttle_out, efi_status->pt_compensation, efi_status->ignition_voltage, efi_status->fuel_pressure); } +/** + * @brief Encode a efi_status struct with provided status structure + * + * @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 efi_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_efi_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_efi_status_t* efi_status) +{ + return mavlink_msg_efi_status_pack_status(system_id, component_id, _status, msg, efi_status->health, efi_status->ecu_index, efi_status->rpm, efi_status->fuel_consumed, efi_status->fuel_flow, efi_status->engine_load, efi_status->throttle_position, efi_status->spark_dwell_time, efi_status->barometric_pressure, efi_status->intake_manifold_pressure, efi_status->intake_manifold_temperature, efi_status->cylinder_head_temperature, efi_status->ignition_timing, efi_status->injection_time, efi_status->exhaust_gas_temperature, efi_status->throttle_out, efi_status->pt_compensation, efi_status->ignition_voltage, efi_status->fuel_pressure); +} + /** * @brief Send a efi_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_encapsulated_data.h b/common/mavlink_msg_encapsulated_data.h index 5f69c898..da58952f 100644 --- a/common/mavlink_msg_encapsulated_data.h +++ b/common/mavlink_msg_encapsulated_data.h @@ -67,6 +67,40 @@ static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); } +/** + * @brief Pack a encapsulated_data 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 seqnr sequence number (starting with 0 on every transmission) + * @param data image data bytes + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_encapsulated_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t seqnr, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; + _mav_put_uint16_t(buf, 0, seqnr); + _mav_put_uint8_t_array(buf, 2, data, 253); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); +#else + mavlink_encapsulated_data_t packet; + packet.seqnr = seqnr; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); +#endif +} + /** * @brief Pack a encapsulated_data message on a channel * @param system_id ID of this system @@ -124,6 +158,20 @@ static inline uint16_t mavlink_msg_encapsulated_data_encode_chan(uint8_t system_ return mavlink_msg_encapsulated_data_pack_chan(system_id, component_id, chan, msg, encapsulated_data->seqnr, encapsulated_data->data); } +/** + * @brief Encode a encapsulated_data struct with provided status structure + * + * @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 encapsulated_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_encapsulated_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data) +{ + return mavlink_msg_encapsulated_data_pack_status(system_id, component_id, _status, msg, encapsulated_data->seqnr, encapsulated_data->data); +} + /** * @brief Send a encapsulated_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_esc_info.h b/common/mavlink_msg_esc_info.h index ba1f2eb0..5db19139 100644 --- a/common/mavlink_msg_esc_info.h +++ b/common/mavlink_msg_esc_info.h @@ -111,6 +111,61 @@ static inline uint16_t mavlink_msg_esc_info_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC); } +/** + * @brief Pack a esc_info 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 index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number. + * @param counter Counter of data packets received. + * @param count Total number of ESCs in all messages of this type. Message fields with an index higher than this should be ignored because they contain invalid data. + * @param connection_type Connection type protocol for all ESC. + * @param info Information regarding online/offline status of each ESC. + * @param failure_flags Bitmap of ESC failure flags. + * @param error_count Number of reported errors by each ESC since boot. + * @param temperature [cdegC] Temperature of each ESC. INT16_MAX: if data not supplied by ESC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_esc_info_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t index, uint64_t time_usec, uint16_t counter, uint8_t count, uint8_t connection_type, uint8_t info, const uint16_t *failure_flags, const uint32_t *error_count, const int16_t *temperature) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESC_INFO_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint16_t(buf, 24, counter); + _mav_put_uint8_t(buf, 42, index); + _mav_put_uint8_t(buf, 43, count); + _mav_put_uint8_t(buf, 44, connection_type); + _mav_put_uint8_t(buf, 45, info); + _mav_put_uint32_t_array(buf, 8, error_count, 4); + _mav_put_uint16_t_array(buf, 26, failure_flags, 4); + _mav_put_int16_t_array(buf, 34, temperature, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_INFO_LEN); +#else + mavlink_esc_info_t packet; + packet.time_usec = time_usec; + packet.counter = counter; + packet.index = index; + packet.count = count; + packet.connection_type = connection_type; + packet.info = info; + mav_array_memcpy(packet.error_count, error_count, sizeof(uint32_t)*4); + mav_array_memcpy(packet.failure_flags, failure_flags, sizeof(uint16_t)*4); + mav_array_memcpy(packet.temperature, temperature, sizeof(int16_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_INFO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESC_INFO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN, MAVLINK_MSG_ID_ESC_INFO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_INFO_MIN_LEN, MAVLINK_MSG_ID_ESC_INFO_LEN); +#endif +} + /** * @brief Pack a esc_info message on a channel * @param system_id ID of this system @@ -189,6 +244,20 @@ static inline uint16_t mavlink_msg_esc_info_encode_chan(uint8_t system_id, uint8 return mavlink_msg_esc_info_pack_chan(system_id, component_id, chan, msg, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature); } +/** + * @brief Encode a esc_info struct with provided status structure + * + * @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 esc_info C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_esc_info_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_info_t* esc_info) +{ + return mavlink_msg_esc_info_pack_status(system_id, component_id, _status, msg, esc_info->index, esc_info->time_usec, esc_info->counter, esc_info->count, esc_info->connection_type, esc_info->info, esc_info->failure_flags, esc_info->error_count, esc_info->temperature); +} + /** * @brief Send a esc_info message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_esc_status.h b/common/mavlink_msg_esc_status.h index 4254cb72..a793889f 100644 --- a/common/mavlink_msg_esc_status.h +++ b/common/mavlink_msg_esc_status.h @@ -87,6 +87,49 @@ static inline uint16_t mavlink_msg_esc_status_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESC_STATUS_LEN, MAVLINK_MSG_ID_ESC_STATUS_CRC); } +/** + * @brief Pack a esc_status 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 index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number. + * @param rpm [rpm] Reported motor RPM from each ESC (negative for reverse rotation). + * @param voltage [V] Voltage measured from each ESC. + * @param current [A] Current measured from each ESC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_esc_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t index, uint64_t time_usec, const int32_t *rpm, const float *voltage, const float *current) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESC_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 56, index); + _mav_put_int32_t_array(buf, 8, rpm, 4); + _mav_put_float_array(buf, 24, voltage, 4); + _mav_put_float_array(buf, 40, current, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESC_STATUS_LEN); +#else + mavlink_esc_status_t packet; + packet.time_usec = time_usec; + packet.index = index; + mav_array_memcpy(packet.rpm, rpm, sizeof(int32_t)*4); + mav_array_memcpy(packet.voltage, voltage, sizeof(float)*4); + mav_array_memcpy(packet.current, current, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESC_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESC_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESC_STATUS_LEN, MAVLINK_MSG_ID_ESC_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESC_STATUS_LEN); +#endif +} + /** * @brief Pack a esc_status message on a channel * @param system_id ID of this system @@ -153,6 +196,20 @@ static inline uint16_t mavlink_msg_esc_status_encode_chan(uint8_t system_id, uin return mavlink_msg_esc_status_pack_chan(system_id, component_id, chan, msg, esc_status->index, esc_status->time_usec, esc_status->rpm, esc_status->voltage, esc_status->current); } +/** + * @brief Encode a esc_status struct with provided status structure + * + * @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 esc_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_esc_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_esc_status_t* esc_status) +{ + return mavlink_msg_esc_status_pack_status(system_id, component_id, _status, msg, esc_status->index, esc_status->time_usec, esc_status->rpm, esc_status->voltage, esc_status->current); +} + /** * @brief Send a esc_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_estimator_status.h b/common/mavlink_msg_estimator_status.h index 21ef9a67..5654a78f 100644 --- a/common/mavlink_msg_estimator_status.h +++ b/common/mavlink_msg_estimator_status.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_estimator_status_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ESTIMATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN, MAVLINK_MSG_ID_ESTIMATOR_STATUS_CRC); } +/** + * @brief Pack a estimator_status 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param flags Bitmap indicating which EKF outputs are valid. + * @param vel_ratio Velocity innovation test ratio + * @param pos_horiz_ratio Horizontal position innovation test ratio + * @param pos_vert_ratio Vertical position innovation test ratio + * @param mag_ratio Magnetometer innovation test ratio + * @param hagl_ratio Height above terrain innovation test ratio + * @param tas_ratio True airspeed innovation test ratio + * @param pos_horiz_accuracy [m] Horizontal position 1-STD accuracy relative to the EKF local origin + * @param pos_vert_accuracy [m] Vertical position 1-STD accuracy relative to the EKF local origin + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_estimator_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint16_t flags, float vel_ratio, float pos_horiz_ratio, float pos_vert_ratio, float mag_ratio, float hagl_ratio, float tas_ratio, float pos_horiz_accuracy, float pos_vert_accuracy) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, vel_ratio); + _mav_put_float(buf, 12, pos_horiz_ratio); + _mav_put_float(buf, 16, pos_vert_ratio); + _mav_put_float(buf, 20, mag_ratio); + _mav_put_float(buf, 24, hagl_ratio); + _mav_put_float(buf, 28, tas_ratio); + _mav_put_float(buf, 32, pos_horiz_accuracy); + _mav_put_float(buf, 36, pos_vert_accuracy); + _mav_put_uint16_t(buf, 40, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN); +#else + mavlink_estimator_status_t packet; + packet.time_usec = time_usec; + packet.vel_ratio = vel_ratio; + packet.pos_horiz_ratio = pos_horiz_ratio; + packet.pos_vert_ratio = pos_vert_ratio; + packet.mag_ratio = mag_ratio; + packet.hagl_ratio = hagl_ratio; + packet.tas_ratio = tas_ratio; + packet.pos_horiz_accuracy = pos_horiz_accuracy; + packet.pos_vert_accuracy = pos_vert_accuracy; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ESTIMATOR_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESTIMATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN, MAVLINK_MSG_ID_ESTIMATOR_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ESTIMATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_ESTIMATOR_STATUS_LEN); +#endif +} + /** * @brief Pack a estimator_status message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_estimator_status_encode_chan(uint8_t system_i return mavlink_msg_estimator_status_pack_chan(system_id, component_id, chan, msg, estimator_status->time_usec, estimator_status->flags, estimator_status->vel_ratio, estimator_status->pos_horiz_ratio, estimator_status->pos_vert_ratio, estimator_status->mag_ratio, estimator_status->hagl_ratio, estimator_status->tas_ratio, estimator_status->pos_horiz_accuracy, estimator_status->pos_vert_accuracy); } +/** + * @brief Encode a estimator_status struct with provided status structure + * + * @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 estimator_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_estimator_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_estimator_status_t* estimator_status) +{ + return mavlink_msg_estimator_status_pack_status(system_id, component_id, _status, msg, estimator_status->time_usec, estimator_status->flags, estimator_status->vel_ratio, estimator_status->pos_horiz_ratio, estimator_status->pos_vert_ratio, estimator_status->mag_ratio, estimator_status->hagl_ratio, estimator_status->tas_ratio, estimator_status->pos_horiz_accuracy, estimator_status->pos_vert_accuracy); +} + /** * @brief Send a estimator_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_event.h b/common/mavlink_msg_event.h index 7c419849..100739b8 100644 --- a/common/mavlink_msg_event.h +++ b/common/mavlink_msg_event.h @@ -97,6 +97,55 @@ static inline uint16_t mavlink_msg_event_pack(uint8_t system_id, uint8_t compone return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_EVENT_MIN_LEN, MAVLINK_MSG_ID_EVENT_LEN, MAVLINK_MSG_ID_EVENT_CRC); } +/** + * @brief Pack a event 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 destination_component Component ID + * @param destination_system System ID + * @param id Event ID (as defined in the component metadata) + * @param event_time_boot_ms [ms] Timestamp (time since system boot when the event happened). + * @param sequence Sequence number. + * @param log_levels Log levels: 4 bits MSB: internal (for logging purposes), 4 bits LSB: external. Levels: Emergency = 0, Alert = 1, Critical = 2, Error = 3, Warning = 4, Notice = 5, Info = 6, Debug = 7, Protocol = 8, Disabled = 9 + * @param arguments Arguments (depend on event ID). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_event_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t destination_component, uint8_t destination_system, uint32_t id, uint32_t event_time_boot_ms, uint16_t sequence, uint8_t log_levels, const uint8_t *arguments) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_EVENT_LEN]; + _mav_put_uint32_t(buf, 0, id); + _mav_put_uint32_t(buf, 4, event_time_boot_ms); + _mav_put_uint16_t(buf, 8, sequence); + _mav_put_uint8_t(buf, 10, destination_component); + _mav_put_uint8_t(buf, 11, destination_system); + _mav_put_uint8_t(buf, 12, log_levels); + _mav_put_uint8_t_array(buf, 13, arguments, 40); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_EVENT_LEN); +#else + mavlink_event_t packet; + packet.id = id; + packet.event_time_boot_ms = event_time_boot_ms; + packet.sequence = sequence; + packet.destination_component = destination_component; + packet.destination_system = destination_system; + packet.log_levels = log_levels; + mav_array_memcpy(packet.arguments, arguments, sizeof(uint8_t)*40); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_EVENT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_EVENT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EVENT_MIN_LEN, MAVLINK_MSG_ID_EVENT_LEN, MAVLINK_MSG_ID_EVENT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EVENT_MIN_LEN, MAVLINK_MSG_ID_EVENT_LEN); +#endif +} + /** * @brief Pack a event message on a channel * @param system_id ID of this system @@ -169,6 +218,20 @@ static inline uint16_t mavlink_msg_event_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_event_pack_chan(system_id, component_id, chan, msg, event->destination_component, event->destination_system, event->id, event->event_time_boot_ms, event->sequence, event->log_levels, event->arguments); } +/** + * @brief Encode a event struct with provided status structure + * + * @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 event C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_event_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_event_t* event) +{ + return mavlink_msg_event_pack_status(system_id, component_id, _status, msg, event->destination_component, event->destination_system, event->id, event->event_time_boot_ms, event->sequence, event->log_levels, event->arguments); +} + /** * @brief Send a event message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_extended_sys_state.h b/common/mavlink_msg_extended_sys_state.h index e9bc9418..5da29716 100644 --- a/common/mavlink_msg_extended_sys_state.h +++ b/common/mavlink_msg_extended_sys_state.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_extended_sys_state_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_MIN_LEN, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_CRC); } +/** + * @brief Pack a extended_sys_state 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 vtol_state The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. + * @param landed_state The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_extended_sys_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t vtol_state, uint8_t landed_state) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN]; + _mav_put_uint8_t(buf, 0, vtol_state); + _mav_put_uint8_t(buf, 1, landed_state); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN); +#else + mavlink_extended_sys_state_t packet; + packet.vtol_state = vtol_state; + packet.landed_state = landed_state; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_EXTENDED_SYS_STATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_MIN_LEN, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_MIN_LEN, MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN); +#endif +} + /** * @brief Pack a extended_sys_state message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_extended_sys_state_encode_chan(uint8_t system return mavlink_msg_extended_sys_state_pack_chan(system_id, component_id, chan, msg, extended_sys_state->vtol_state, extended_sys_state->landed_state); } +/** + * @brief Encode a extended_sys_state struct with provided status structure + * + * @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 extended_sys_state C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_extended_sys_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_extended_sys_state_t* extended_sys_state) +{ + return mavlink_msg_extended_sys_state_pack_status(system_id, component_id, _status, msg, extended_sys_state->vtol_state, extended_sys_state->landed_state); +} + /** * @brief Send a extended_sys_state message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_fence_status.h b/common/mavlink_msg_fence_status.h index 98b442aa..c8858f96 100644 --- a/common/mavlink_msg_fence_status.h +++ b/common/mavlink_msg_fence_status.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_fence_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC); } +/** + * @brief Pack a fence_status 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 breach_status Breach status (0 if currently inside fence, 1 if outside). + * @param breach_count Number of fence breaches. + * @param breach_type Last breach type. + * @param breach_time [ms] Time (since boot) of last breach. + * @param breach_mitigation Active action to prevent fence breach + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_fence_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t breach_status, uint16_t breach_count, uint8_t breach_type, uint32_t breach_time, uint8_t breach_mitigation) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FENCE_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, breach_time); + _mav_put_uint16_t(buf, 4, breach_count); + _mav_put_uint8_t(buf, 6, breach_status); + _mav_put_uint8_t(buf, 7, breach_type); + _mav_put_uint8_t(buf, 8, breach_mitigation); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_STATUS_LEN); +#else + mavlink_fence_status_t packet; + packet.breach_time = breach_time; + packet.breach_count = breach_count; + packet.breach_status = breach_status; + packet.breach_type = breach_type; + packet.breach_mitigation = breach_mitigation; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FENCE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN); +#endif +} + /** * @brief Pack a fence_status message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_fence_status_encode_chan(uint8_t system_id, u return mavlink_msg_fence_status_pack_chan(system_id, component_id, chan, msg, fence_status->breach_status, fence_status->breach_count, fence_status->breach_type, fence_status->breach_time, fence_status->breach_mitigation); } +/** + * @brief Encode a fence_status struct with provided status structure + * + * @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 fence_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_fence_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_fence_status_t* fence_status) +{ + return mavlink_msg_fence_status_pack_status(system_id, component_id, _status, msg, fence_status->breach_status, fence_status->breach_count, fence_status->breach_type, fence_status->breach_time, fence_status->breach_mitigation); +} + /** * @brief Send a fence_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_file_transfer_protocol.h b/common/mavlink_msg_file_transfer_protocol.h index 68d5a54e..adc74e56 100644 --- a/common/mavlink_msg_file_transfer_protocol.h +++ b/common/mavlink_msg_file_transfer_protocol.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_file_transfer_protocol_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC); } +/** + * @brief Pack a file_transfer_protocol 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 target_network Network ID (0 for broadcast) + * @param target_system System ID (0 for broadcast) + * @param target_component Component ID (0 for broadcast) + * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The content/format of this block is defined in https://mavlink.io/en/services/ftp.html. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_protocol_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN]; + _mav_put_uint8_t(buf, 0, target_network); + _mav_put_uint8_t(buf, 1, target_system); + _mav_put_uint8_t(buf, 2, target_component); + _mav_put_uint8_t_array(buf, 3, payload, 251); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN); +#else + mavlink_file_transfer_protocol_t packet; + packet.target_network = target_network; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN); +#endif +} + /** * @brief Pack a file_transfer_protocol message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_file_transfer_protocol_encode_chan(uint8_t sy return mavlink_msg_file_transfer_protocol_pack_chan(system_id, component_id, chan, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload); } +/** + * @brief Encode a file_transfer_protocol struct with provided status structure + * + * @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 file_transfer_protocol C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_file_transfer_protocol_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_file_transfer_protocol_t* file_transfer_protocol) +{ + return mavlink_msg_file_transfer_protocol_pack_status(system_id, component_id, _status, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload); +} + /** * @brief Send a file_transfer_protocol message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_flight_information.h b/common/mavlink_msg_flight_information.h index ec9e5827..040b5e10 100644 --- a/common/mavlink_msg_flight_information.h +++ b/common/mavlink_msg_flight_information.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_flight_information_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLIGHT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN, MAVLINK_MSG_ID_FLIGHT_INFORMATION_CRC); } +/** + * @brief Pack a flight_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param arming_time_utc [us] Timestamp at arming (since system boot). Set to 0 on boot. Set value on arming. Note, field is misnamed UTC. + * @param takeoff_time_utc [us] Timestamp at takeoff (since system boot). Set to 0 at boot and on arming. Note, field is misnamed UTC. + * @param flight_uuid Flight number. Note, field is misnamed UUID. + * @param landing_time [ms] Timestamp at landing (in ms since system boot). Set to 0 at boot and on arming. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flight_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint64_t arming_time_utc, uint64_t takeoff_time_utc, uint64_t flight_uuid, uint32_t landing_time) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN]; + _mav_put_uint64_t(buf, 0, arming_time_utc); + _mav_put_uint64_t(buf, 8, takeoff_time_utc); + _mav_put_uint64_t(buf, 16, flight_uuid); + _mav_put_uint32_t(buf, 24, time_boot_ms); + _mav_put_uint32_t(buf, 28, landing_time); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN); +#else + mavlink_flight_information_t packet; + packet.arming_time_utc = arming_time_utc; + packet.takeoff_time_utc = takeoff_time_utc; + packet.flight_uuid = flight_uuid; + packet.time_boot_ms = time_boot_ms; + packet.landing_time = landing_time; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLIGHT_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLIGHT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN, MAVLINK_MSG_ID_FLIGHT_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLIGHT_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_INFORMATION_LEN); +#endif +} + /** * @brief Pack a flight_information message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_flight_information_encode_chan(uint8_t system return mavlink_msg_flight_information_pack_chan(system_id, component_id, chan, msg, flight_information->time_boot_ms, flight_information->arming_time_utc, flight_information->takeoff_time_utc, flight_information->flight_uuid, flight_information->landing_time); } +/** + * @brief Encode a flight_information struct with provided status structure + * + * @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 flight_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flight_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flight_information_t* flight_information) +{ + return mavlink_msg_flight_information_pack_status(system_id, component_id, _status, msg, flight_information->time_boot_ms, flight_information->arming_time_utc, flight_information->takeoff_time_utc, flight_information->flight_uuid, flight_information->landing_time); +} + /** * @brief Send a flight_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_follow_target.h b/common/mavlink_msg_follow_target.h index 1c854728..5200e68c 100644 --- a/common/mavlink_msg_follow_target.h +++ b/common/mavlink_msg_follow_target.h @@ -125,6 +125,67 @@ static inline uint16_t mavlink_msg_follow_target_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC); } +/** + * @brief Pack a follow_target 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 timestamp [ms] Timestamp (time since system boot). + * @param est_capabilities bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3) + * @param lat [degE7] Latitude (WGS84) + * @param lon [degE7] Longitude (WGS84) + * @param alt [m] Altitude (MSL) + * @param vel [m/s] target velocity (0,0,0) for unknown + * @param acc [m/s/s] linear target acceleration (0,0,0) for unknown + * @param attitude_q (0 0 0 0 for unknown) + * @param rates (0 0 0 for unknown) + * @param position_cov eph epv + * @param custom_state button states or switches of a tracker device + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_follow_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t est_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *attitude_q, const float *rates, const float *position_cov, uint64_t custom_state) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FOLLOW_TARGET_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint64_t(buf, 8, custom_state); + _mav_put_int32_t(buf, 16, lat); + _mav_put_int32_t(buf, 20, lon); + _mav_put_float(buf, 24, alt); + _mav_put_uint8_t(buf, 92, est_capabilities); + _mav_put_float_array(buf, 28, vel, 3); + _mav_put_float_array(buf, 40, acc, 3); + _mav_put_float_array(buf, 52, attitude_q, 4); + _mav_put_float_array(buf, 68, rates, 3); + _mav_put_float_array(buf, 80, position_cov, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN); +#else + mavlink_follow_target_t packet; + packet.timestamp = timestamp; + packet.custom_state = custom_state; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.est_capabilities = est_capabilities; + mav_array_memcpy(packet.vel, vel, sizeof(float)*3); + mav_array_memcpy(packet.acc, acc, sizeof(float)*3); + mav_array_memcpy(packet.attitude_q, attitude_q, sizeof(float)*4); + mav_array_memcpy(packet.rates, rates, sizeof(float)*3); + mav_array_memcpy(packet.position_cov, position_cov, sizeof(float)*3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FOLLOW_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN); +#endif +} + /** * @brief Pack a follow_target message on a channel * @param system_id ID of this system @@ -209,6 +270,20 @@ static inline uint16_t mavlink_msg_follow_target_encode_chan(uint8_t system_id, return mavlink_msg_follow_target_pack_chan(system_id, component_id, chan, msg, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state); } +/** + * @brief Encode a follow_target struct with provided status structure + * + * @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 follow_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_follow_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_follow_target_t* follow_target) +{ + return mavlink_msg_follow_target_pack_status(system_id, component_id, _status, msg, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state); +} + /** * @brief Send a follow_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_generator_status.h b/common/mavlink_msg_generator_status.h index a8e1a448..d9a8ce39 100644 --- a/common/mavlink_msg_generator_status.h +++ b/common/mavlink_msg_generator_status.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_generator_status_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC); } +/** + * @brief Pack a generator_status 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 status Status flags. + * @param generator_speed [rpm] Speed of electrical generator or alternator. UINT16_MAX: field not provided. + * @param battery_current [A] Current into/out of battery. Positive for out. Negative for in. NaN: field not provided. + * @param load_current [A] Current going to the UAV. If battery current not available this is the DC current from the generator. Positive for out. Negative for in. NaN: field not provided + * @param power_generated [W] The power being generated. NaN: field not provided + * @param bus_voltage [V] Voltage of the bus seen at the generator, or battery bus if battery bus is controlled by generator and at a different voltage to main bus. + * @param rectifier_temperature [degC] The temperature of the rectifier or power converter. INT16_MAX: field not provided. + * @param bat_current_setpoint [A] The target battery current. Positive for out. Negative for in. NaN: field not provided + * @param generator_temperature [degC] The temperature of the mechanical motor, fuel cell core or generator. INT16_MAX: field not provided. + * @param runtime [s] Seconds this generator has run since it was rebooted. UINT32_MAX: field not provided. + * @param time_until_maintenance [s] Seconds until this generator requires maintenance. A negative value indicates maintenance is past-due. INT32_MAX: field not provided. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_generator_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t status, uint16_t generator_speed, float battery_current, float load_current, float power_generated, float bus_voltage, int16_t rectifier_temperature, float bat_current_setpoint, int16_t generator_temperature, uint32_t runtime, int32_t time_until_maintenance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GENERATOR_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, status); + _mav_put_float(buf, 8, battery_current); + _mav_put_float(buf, 12, load_current); + _mav_put_float(buf, 16, power_generated); + _mav_put_float(buf, 20, bus_voltage); + _mav_put_float(buf, 24, bat_current_setpoint); + _mav_put_uint32_t(buf, 28, runtime); + _mav_put_int32_t(buf, 32, time_until_maintenance); + _mav_put_uint16_t(buf, 36, generator_speed); + _mav_put_int16_t(buf, 38, rectifier_temperature); + _mav_put_int16_t(buf, 40, generator_temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN); +#else + mavlink_generator_status_t packet; + packet.status = status; + packet.battery_current = battery_current; + packet.load_current = load_current; + packet.power_generated = power_generated; + packet.bus_voltage = bus_voltage; + packet.bat_current_setpoint = bat_current_setpoint; + packet.runtime = runtime; + packet.time_until_maintenance = time_until_maintenance; + packet.generator_speed = generator_speed; + packet.rectifier_temperature = rectifier_temperature; + packet.generator_temperature = generator_temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GENERATOR_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GENERATOR_STATUS_MIN_LEN, MAVLINK_MSG_ID_GENERATOR_STATUS_LEN); +#endif +} + /** * @brief Pack a generator_status message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_generator_status_encode_chan(uint8_t system_i return mavlink_msg_generator_status_pack_chan(system_id, component_id, chan, msg, generator_status->status, generator_status->generator_speed, generator_status->battery_current, generator_status->load_current, generator_status->power_generated, generator_status->bus_voltage, generator_status->rectifier_temperature, generator_status->bat_current_setpoint, generator_status->generator_temperature, generator_status->runtime, generator_status->time_until_maintenance); } +/** + * @brief Encode a generator_status struct with provided status structure + * + * @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 generator_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_generator_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_generator_status_t* generator_status) +{ + return mavlink_msg_generator_status_pack_status(system_id, component_id, _status, msg, generator_status->status, generator_status->generator_speed, generator_status->battery_current, generator_status->load_current, generator_status->power_generated, generator_status->bus_voltage, generator_status->rectifier_temperature, generator_status->bat_current_setpoint, generator_status->generator_temperature, generator_status->runtime, generator_status->time_until_maintenance); +} + /** * @brief Send a generator_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_device_attitude_status.h b/common/mavlink_msg_gimbal_device_attitude_status.h index 12ed1eb9..bad3d96b 100644 --- a/common/mavlink_msg_gimbal_device_attitude_status.h +++ b/common/mavlink_msg_gimbal_device_attitude_status.h @@ -127,6 +127,70 @@ static inline uint16_t mavlink_msg_gimbal_device_attitude_status_pack(uint8_t sy return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_CRC); } +/** + * @brief Pack a gimbal_device_attitude_status 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 target_system System ID + * @param target_component Component ID + * @param time_boot_ms [ms] Timestamp (time since system boot). + * @param flags Current gimbal flags set. + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation). The frame is described in the message description. + * @param angular_velocity_x [rad/s] X component of angular velocity (positive: rolling to the right). The frame is described in the message description. NaN if unknown. + * @param angular_velocity_y [rad/s] Y component of angular velocity (positive: pitching up). The frame is described in the message description. NaN if unknown. + * @param angular_velocity_z [rad/s] Z component of angular velocity (positive: yawing to the right). The frame is described in the message description. NaN if unknown. + * @param failure_flags Failure flags (0 for no failure) + * @param delta_yaw [rad] Yaw angle relating the quaternions in earth and body frames (see message description). NaN if unknown. + * @param delta_yaw_velocity [rad/s] Yaw angular velocity relating the angular velocities in earth and body frames (see message description). NaN if unknown. + * @param gimbal_device_id This field is to be used if the gimbal manager and the gimbal device are the same component and hence have the same component ID. This field is then set a number between 1-6. If the component ID is separate, this field is not required and must be set to 0. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_device_attitude_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t time_boot_ms, uint16_t flags, const float *q, float angular_velocity_x, float angular_velocity_y, float angular_velocity_z, uint32_t failure_flags, float delta_yaw, float delta_yaw_velocity, uint8_t gimbal_device_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 20, angular_velocity_x); + _mav_put_float(buf, 24, angular_velocity_y); + _mav_put_float(buf, 28, angular_velocity_z); + _mav_put_uint32_t(buf, 32, failure_flags); + _mav_put_uint16_t(buf, 36, flags); + _mav_put_uint8_t(buf, 38, target_system); + _mav_put_uint8_t(buf, 39, target_component); + _mav_put_float(buf, 40, delta_yaw); + _mav_put_float(buf, 44, delta_yaw_velocity); + _mav_put_uint8_t(buf, 48, gimbal_device_id); + _mav_put_float_array(buf, 4, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN); +#else + mavlink_gimbal_device_attitude_status_t packet; + packet.time_boot_ms = time_boot_ms; + packet.angular_velocity_x = angular_velocity_x; + packet.angular_velocity_y = angular_velocity_y; + packet.angular_velocity_z = angular_velocity_z; + packet.failure_flags = failure_flags; + packet.flags = flags; + packet.target_system = target_system; + packet.target_component = target_component; + packet.delta_yaw = delta_yaw; + packet.delta_yaw_velocity = delta_yaw_velocity; + packet.gimbal_device_id = gimbal_device_id; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_ATTITUDE_STATUS_LEN); +#endif +} + /** * @brief Pack a gimbal_device_attitude_status message on a channel * @param system_id ID of this system @@ -214,6 +278,20 @@ static inline uint16_t mavlink_msg_gimbal_device_attitude_status_encode_chan(uin return mavlink_msg_gimbal_device_attitude_status_pack_chan(system_id, component_id, chan, msg, gimbal_device_attitude_status->target_system, gimbal_device_attitude_status->target_component, gimbal_device_attitude_status->time_boot_ms, gimbal_device_attitude_status->flags, gimbal_device_attitude_status->q, gimbal_device_attitude_status->angular_velocity_x, gimbal_device_attitude_status->angular_velocity_y, gimbal_device_attitude_status->angular_velocity_z, gimbal_device_attitude_status->failure_flags, gimbal_device_attitude_status->delta_yaw, gimbal_device_attitude_status->delta_yaw_velocity, gimbal_device_attitude_status->gimbal_device_id); } +/** + * @brief Encode a gimbal_device_attitude_status struct with provided status structure + * + * @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 gimbal_device_attitude_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_device_attitude_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_device_attitude_status_t* gimbal_device_attitude_status) +{ + return mavlink_msg_gimbal_device_attitude_status_pack_status(system_id, component_id, _status, msg, gimbal_device_attitude_status->target_system, gimbal_device_attitude_status->target_component, gimbal_device_attitude_status->time_boot_ms, gimbal_device_attitude_status->flags, gimbal_device_attitude_status->q, gimbal_device_attitude_status->angular_velocity_x, gimbal_device_attitude_status->angular_velocity_y, gimbal_device_attitude_status->angular_velocity_z, gimbal_device_attitude_status->failure_flags, gimbal_device_attitude_status->delta_yaw, gimbal_device_attitude_status->delta_yaw_velocity, gimbal_device_attitude_status->gimbal_device_id); +} + /** * @brief Send a gimbal_device_attitude_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_device_information.h b/common/mavlink_msg_gimbal_device_information.h index 4969bfa6..e6d7b068 100644 --- a/common/mavlink_msg_gimbal_device_information.h +++ b/common/mavlink_msg_gimbal_device_information.h @@ -153,6 +153,82 @@ static inline uint16_t mavlink_msg_gimbal_device_information_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_CRC); } +/** + * @brief Pack a gimbal_device_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param vendor_name Name of the gimbal vendor. + * @param model_name Name of the gimbal model. + * @param custom_name Custom name of the gimbal given to it by the user. + * @param firmware_version Version of the gimbal firmware, encoded as: (Dev & 0xff) << 24 | (Patch & 0xff) << 16 | (Minor & 0xff) << 8 | (Major & 0xff). + * @param hardware_version Version of the gimbal hardware, encoded as: (Dev & 0xff) << 24 | (Patch & 0xff) << 16 | (Minor & 0xff) << 8 | (Major & 0xff). + * @param uid UID of gimbal hardware (0 if unknown). + * @param cap_flags Bitmap of gimbal capability flags. + * @param custom_cap_flags Bitmap for use for gimbal-specific capability flags. + * @param roll_min [rad] Minimum hardware roll angle (positive: rolling to the right, negative: rolling to the left). NAN if unknown. + * @param roll_max [rad] Maximum hardware roll angle (positive: rolling to the right, negative: rolling to the left). NAN if unknown. + * @param pitch_min [rad] Minimum hardware pitch angle (positive: up, negative: down). NAN if unknown. + * @param pitch_max [rad] Maximum hardware pitch angle (positive: up, negative: down). NAN if unknown. + * @param yaw_min [rad] Minimum hardware yaw angle (positive: to the right, negative: to the left). NAN if unknown. + * @param yaw_max [rad] Maximum hardware yaw angle (positive: to the right, negative: to the left). NAN if unknown. + * @param gimbal_device_id This field is to be used if the gimbal manager and the gimbal device are the same component and hence have the same component ID. This field is then set to a number between 1-6. If the component ID is separate, this field is not required and must be set to 0. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_device_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, const char *vendor_name, const char *model_name, const char *custom_name, uint32_t firmware_version, uint32_t hardware_version, uint64_t uid, uint16_t cap_flags, uint16_t custom_cap_flags, float roll_min, float roll_max, float pitch_min, float pitch_max, float yaw_min, float yaw_max, uint8_t gimbal_device_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN]; + _mav_put_uint64_t(buf, 0, uid); + _mav_put_uint32_t(buf, 8, time_boot_ms); + _mav_put_uint32_t(buf, 12, firmware_version); + _mav_put_uint32_t(buf, 16, hardware_version); + _mav_put_float(buf, 20, roll_min); + _mav_put_float(buf, 24, roll_max); + _mav_put_float(buf, 28, pitch_min); + _mav_put_float(buf, 32, pitch_max); + _mav_put_float(buf, 36, yaw_min); + _mav_put_float(buf, 40, yaw_max); + _mav_put_uint16_t(buf, 44, cap_flags); + _mav_put_uint16_t(buf, 46, custom_cap_flags); + _mav_put_uint8_t(buf, 144, gimbal_device_id); + _mav_put_char_array(buf, 48, vendor_name, 32); + _mav_put_char_array(buf, 80, model_name, 32); + _mav_put_char_array(buf, 112, custom_name, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN); +#else + mavlink_gimbal_device_information_t packet; + packet.uid = uid; + packet.time_boot_ms = time_boot_ms; + packet.firmware_version = firmware_version; + packet.hardware_version = hardware_version; + packet.roll_min = roll_min; + packet.roll_max = roll_max; + packet.pitch_min = pitch_min; + packet.pitch_max = pitch_max; + packet.yaw_min = yaw_min; + packet.yaw_max = yaw_max; + packet.cap_flags = cap_flags; + packet.custom_cap_flags = custom_cap_flags; + packet.gimbal_device_id = gimbal_device_id; + mav_array_memcpy(packet.vendor_name, vendor_name, sizeof(char)*32); + mav_array_memcpy(packet.model_name, model_name, sizeof(char)*32); + mav_array_memcpy(packet.custom_name, custom_name, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_INFORMATION_LEN); +#endif +} + /** * @brief Pack a gimbal_device_information message on a channel * @param system_id ID of this system @@ -252,6 +328,20 @@ static inline uint16_t mavlink_msg_gimbal_device_information_encode_chan(uint8_t return mavlink_msg_gimbal_device_information_pack_chan(system_id, component_id, chan, msg, gimbal_device_information->time_boot_ms, gimbal_device_information->vendor_name, gimbal_device_information->model_name, gimbal_device_information->custom_name, gimbal_device_information->firmware_version, gimbal_device_information->hardware_version, gimbal_device_information->uid, gimbal_device_information->cap_flags, gimbal_device_information->custom_cap_flags, gimbal_device_information->roll_min, gimbal_device_information->roll_max, gimbal_device_information->pitch_min, gimbal_device_information->pitch_max, gimbal_device_information->yaw_min, gimbal_device_information->yaw_max, gimbal_device_information->gimbal_device_id); } +/** + * @brief Encode a gimbal_device_information struct with provided status structure + * + * @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 gimbal_device_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_device_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_device_information_t* gimbal_device_information) +{ + return mavlink_msg_gimbal_device_information_pack_status(system_id, component_id, _status, msg, gimbal_device_information->time_boot_ms, gimbal_device_information->vendor_name, gimbal_device_information->model_name, gimbal_device_information->custom_name, gimbal_device_information->firmware_version, gimbal_device_information->hardware_version, gimbal_device_information->uid, gimbal_device_information->cap_flags, gimbal_device_information->custom_cap_flags, gimbal_device_information->roll_min, gimbal_device_information->roll_max, gimbal_device_information->pitch_min, gimbal_device_information->pitch_max, gimbal_device_information->yaw_min, gimbal_device_information->yaw_max, gimbal_device_information->gimbal_device_id); +} + /** * @brief Send a gimbal_device_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_device_set_attitude.h b/common/mavlink_msg_gimbal_device_set_attitude.h index 8685be65..01afa481 100644 --- a/common/mavlink_msg_gimbal_device_set_attitude.h +++ b/common/mavlink_msg_gimbal_device_set_attitude.h @@ -97,6 +97,55 @@ static inline uint16_t mavlink_msg_gimbal_device_set_attitude_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_CRC); } +/** + * @brief Pack a gimbal_device_set_attitude 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 target_system System ID + * @param target_component Component ID + * @param flags Low level gimbal flags. + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation). The frame is described in the message description. Set fields to NaN to be ignored. + * @param angular_velocity_x [rad/s] X component of angular velocity (positive: rolling to the right). The frame is described in the message description. NaN to be ignored. + * @param angular_velocity_y [rad/s] Y component of angular velocity (positive: pitching up). The frame is described in the message description. NaN to be ignored. + * @param angular_velocity_z [rad/s] Z component of angular velocity (positive: yawing to the right). The frame is described in the message description. NaN to be ignored. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_device_set_attitude_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t flags, const float *q, float angular_velocity_x, float angular_velocity_y, float angular_velocity_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN]; + _mav_put_float(buf, 16, angular_velocity_x); + _mav_put_float(buf, 20, angular_velocity_y); + _mav_put_float(buf, 24, angular_velocity_z); + _mav_put_uint16_t(buf, 28, flags); + _mav_put_uint8_t(buf, 30, target_system); + _mav_put_uint8_t(buf, 31, target_component); + _mav_put_float_array(buf, 0, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN); +#else + mavlink_gimbal_device_set_attitude_t packet; + packet.angular_velocity_x = angular_velocity_x; + packet.angular_velocity_y = angular_velocity_y; + packet.angular_velocity_z = angular_velocity_z; + packet.flags = flags; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_DEVICE_SET_ATTITUDE_LEN); +#endif +} + /** * @brief Pack a gimbal_device_set_attitude message on a channel * @param system_id ID of this system @@ -169,6 +218,20 @@ static inline uint16_t mavlink_msg_gimbal_device_set_attitude_encode_chan(uint8_ return mavlink_msg_gimbal_device_set_attitude_pack_chan(system_id, component_id, chan, msg, gimbal_device_set_attitude->target_system, gimbal_device_set_attitude->target_component, gimbal_device_set_attitude->flags, gimbal_device_set_attitude->q, gimbal_device_set_attitude->angular_velocity_x, gimbal_device_set_attitude->angular_velocity_y, gimbal_device_set_attitude->angular_velocity_z); } +/** + * @brief Encode a gimbal_device_set_attitude struct with provided status structure + * + * @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 gimbal_device_set_attitude C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_device_set_attitude_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_device_set_attitude_t* gimbal_device_set_attitude) +{ + return mavlink_msg_gimbal_device_set_attitude_pack_status(system_id, component_id, _status, msg, gimbal_device_set_attitude->target_system, gimbal_device_set_attitude->target_component, gimbal_device_set_attitude->flags, gimbal_device_set_attitude->q, gimbal_device_set_attitude->angular_velocity_x, gimbal_device_set_attitude->angular_velocity_y, gimbal_device_set_attitude->angular_velocity_z); +} + /** * @brief Send a gimbal_device_set_attitude message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_manager_information.h b/common/mavlink_msg_gimbal_manager_information.h index f0d403ca..2fa1b311 100644 --- a/common/mavlink_msg_gimbal_manager_information.h +++ b/common/mavlink_msg_gimbal_manager_information.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_gimbal_manager_information_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_CRC); } +/** + * @brief Pack a gimbal_manager_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param cap_flags Bitmap of gimbal capability flags. + * @param gimbal_device_id Gimbal device ID that this gimbal manager is responsible for. Component ID of gimbal device (or 1-6 for non-MAVLink gimbal). + * @param roll_min [rad] Minimum hardware roll angle (positive: rolling to the right, negative: rolling to the left) + * @param roll_max [rad] Maximum hardware roll angle (positive: rolling to the right, negative: rolling to the left) + * @param pitch_min [rad] Minimum pitch angle (positive: up, negative: down) + * @param pitch_max [rad] Maximum pitch angle (positive: up, negative: down) + * @param yaw_min [rad] Minimum yaw angle (positive: to the right, negative: to the left) + * @param yaw_max [rad] Maximum yaw angle (positive: to the right, negative: to the left) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_manager_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t cap_flags, uint8_t gimbal_device_id, float roll_min, float roll_max, float pitch_min, float pitch_max, float yaw_min, float yaw_max) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, cap_flags); + _mav_put_float(buf, 8, roll_min); + _mav_put_float(buf, 12, roll_max); + _mav_put_float(buf, 16, pitch_min); + _mav_put_float(buf, 20, pitch_max); + _mav_put_float(buf, 24, yaw_min); + _mav_put_float(buf, 28, yaw_max); + _mav_put_uint8_t(buf, 32, gimbal_device_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN); +#else + mavlink_gimbal_manager_information_t packet; + packet.time_boot_ms = time_boot_ms; + packet.cap_flags = cap_flags; + packet.roll_min = roll_min; + packet.roll_max = roll_max; + packet.pitch_min = pitch_min; + packet.pitch_max = pitch_max; + packet.yaw_min = yaw_min; + packet.yaw_max = yaw_max; + packet.gimbal_device_id = gimbal_device_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_INFORMATION_LEN); +#endif +} + /** * @brief Pack a gimbal_manager_information message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_gimbal_manager_information_encode_chan(uint8_ return mavlink_msg_gimbal_manager_information_pack_chan(system_id, component_id, chan, msg, gimbal_manager_information->time_boot_ms, gimbal_manager_information->cap_flags, gimbal_manager_information->gimbal_device_id, gimbal_manager_information->roll_min, gimbal_manager_information->roll_max, gimbal_manager_information->pitch_min, gimbal_manager_information->pitch_max, gimbal_manager_information->yaw_min, gimbal_manager_information->yaw_max); } +/** + * @brief Encode a gimbal_manager_information struct with provided status structure + * + * @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 gimbal_manager_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_manager_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_manager_information_t* gimbal_manager_information) +{ + return mavlink_msg_gimbal_manager_information_pack_status(system_id, component_id, _status, msg, gimbal_manager_information->time_boot_ms, gimbal_manager_information->cap_flags, gimbal_manager_information->gimbal_device_id, gimbal_manager_information->roll_min, gimbal_manager_information->roll_max, gimbal_manager_information->pitch_min, gimbal_manager_information->pitch_max, gimbal_manager_information->yaw_min, gimbal_manager_information->yaw_max); +} + /** * @brief Send a gimbal_manager_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_manager_set_attitude.h b/common/mavlink_msg_gimbal_manager_set_attitude.h index 8ae53b27..3086de29 100644 --- a/common/mavlink_msg_gimbal_manager_set_attitude.h +++ b/common/mavlink_msg_gimbal_manager_set_attitude.h @@ -103,6 +103,58 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_attitude_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_CRC); } +/** + * @brief Pack a gimbal_manager_set_attitude 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 target_system System ID + * @param target_component Component ID + * @param flags High level gimbal manager flags to use. + * @param gimbal_device_id Component ID of gimbal device to address (or 1-6 for non-MAVLink gimbal), 0 for all gimbal device components. Send command multiple times for more than one gimbal (but not all gimbals). + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation, the frame is depends on whether the flag GIMBAL_MANAGER_FLAGS_YAW_LOCK is set) + * @param angular_velocity_x [rad/s] X component of angular velocity, positive is rolling to the right, NaN to be ignored. + * @param angular_velocity_y [rad/s] Y component of angular velocity, positive is pitching up, NaN to be ignored. + * @param angular_velocity_z [rad/s] Z component of angular velocity, positive is yawing to the right, NaN to be ignored. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_attitude_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t flags, uint8_t gimbal_device_id, const float *q, float angular_velocity_x, float angular_velocity_y, float angular_velocity_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN]; + _mav_put_uint32_t(buf, 0, flags); + _mav_put_float(buf, 20, angular_velocity_x); + _mav_put_float(buf, 24, angular_velocity_y); + _mav_put_float(buf, 28, angular_velocity_z); + _mav_put_uint8_t(buf, 32, target_system); + _mav_put_uint8_t(buf, 33, target_component); + _mav_put_uint8_t(buf, 34, gimbal_device_id); + _mav_put_float_array(buf, 4, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN); +#else + mavlink_gimbal_manager_set_attitude_t packet; + packet.flags = flags; + packet.angular_velocity_x = angular_velocity_x; + packet.angular_velocity_y = angular_velocity_y; + packet.angular_velocity_z = angular_velocity_z; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_device_id = gimbal_device_id; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_ATTITUDE_LEN); +#endif +} + /** * @brief Pack a gimbal_manager_set_attitude message on a channel * @param system_id ID of this system @@ -178,6 +230,20 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_attitude_encode_chan(uint8 return mavlink_msg_gimbal_manager_set_attitude_pack_chan(system_id, component_id, chan, msg, gimbal_manager_set_attitude->target_system, gimbal_manager_set_attitude->target_component, gimbal_manager_set_attitude->flags, gimbal_manager_set_attitude->gimbal_device_id, gimbal_manager_set_attitude->q, gimbal_manager_set_attitude->angular_velocity_x, gimbal_manager_set_attitude->angular_velocity_y, gimbal_manager_set_attitude->angular_velocity_z); } +/** + * @brief Encode a gimbal_manager_set_attitude struct with provided status structure + * + * @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 gimbal_manager_set_attitude C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_attitude_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_manager_set_attitude_t* gimbal_manager_set_attitude) +{ + return mavlink_msg_gimbal_manager_set_attitude_pack_status(system_id, component_id, _status, msg, gimbal_manager_set_attitude->target_system, gimbal_manager_set_attitude->target_component, gimbal_manager_set_attitude->flags, gimbal_manager_set_attitude->gimbal_device_id, gimbal_manager_set_attitude->q, gimbal_manager_set_attitude->angular_velocity_x, gimbal_manager_set_attitude->angular_velocity_y, gimbal_manager_set_attitude->angular_velocity_z); +} + /** * @brief Send a gimbal_manager_set_attitude message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_manager_set_manual_control.h b/common/mavlink_msg_gimbal_manager_set_manual_control.h index bf4ac348..11150a7a 100644 --- a/common/mavlink_msg_gimbal_manager_set_manual_control.h +++ b/common/mavlink_msg_gimbal_manager_set_manual_control.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_manual_control_pack(uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_CRC); } +/** + * @brief Pack a gimbal_manager_set_manual_control 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 target_system System ID + * @param target_component Component ID + * @param flags High level gimbal manager flags. + * @param gimbal_device_id Component ID of gimbal device to address (or 1-6 for non-MAVLink gimbal), 0 for all gimbal device components. Send command multiple times for more than one gimbal (but not all gimbals). + * @param pitch Pitch angle unitless (-1..1, positive: up, negative: down, NaN to be ignored). + * @param yaw Yaw angle unitless (-1..1, positive: to the right, negative: to the left, NaN to be ignored). + * @param pitch_rate Pitch angular rate unitless (-1..1, positive: up, negative: down, NaN to be ignored). + * @param yaw_rate Yaw angular rate unitless (-1..1, positive: to the right, negative: to the left, NaN to be ignored). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_manual_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t flags, uint8_t gimbal_device_id, float pitch, float yaw, float pitch_rate, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN]; + _mav_put_uint32_t(buf, 0, flags); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, pitch_rate); + _mav_put_float(buf, 16, yaw_rate); + _mav_put_uint8_t(buf, 20, target_system); + _mav_put_uint8_t(buf, 21, target_component); + _mav_put_uint8_t(buf, 22, gimbal_device_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN); +#else + mavlink_gimbal_manager_set_manual_control_t packet; + packet.flags = flags; + packet.pitch = pitch; + packet.yaw = yaw; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_device_id = gimbal_device_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_MANUAL_CONTROL_LEN); +#endif +} + /** * @brief Pack a gimbal_manager_set_manual_control message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_manual_control_encode_chan return mavlink_msg_gimbal_manager_set_manual_control_pack_chan(system_id, component_id, chan, msg, gimbal_manager_set_manual_control->target_system, gimbal_manager_set_manual_control->target_component, gimbal_manager_set_manual_control->flags, gimbal_manager_set_manual_control->gimbal_device_id, gimbal_manager_set_manual_control->pitch, gimbal_manager_set_manual_control->yaw, gimbal_manager_set_manual_control->pitch_rate, gimbal_manager_set_manual_control->yaw_rate); } +/** + * @brief Encode a gimbal_manager_set_manual_control struct with provided status structure + * + * @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 gimbal_manager_set_manual_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_manual_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_manager_set_manual_control_t* gimbal_manager_set_manual_control) +{ + return mavlink_msg_gimbal_manager_set_manual_control_pack_status(system_id, component_id, _status, msg, gimbal_manager_set_manual_control->target_system, gimbal_manager_set_manual_control->target_component, gimbal_manager_set_manual_control->flags, gimbal_manager_set_manual_control->gimbal_device_id, gimbal_manager_set_manual_control->pitch, gimbal_manager_set_manual_control->yaw, gimbal_manager_set_manual_control->pitch_rate, gimbal_manager_set_manual_control->yaw_rate); +} + /** * @brief Send a gimbal_manager_set_manual_control message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_manager_set_pitchyaw.h b/common/mavlink_msg_gimbal_manager_set_pitchyaw.h index 5972e913..b33060e7 100644 --- a/common/mavlink_msg_gimbal_manager_set_pitchyaw.h +++ b/common/mavlink_msg_gimbal_manager_set_pitchyaw.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_pitchyaw_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_CRC); } +/** + * @brief Pack a gimbal_manager_set_pitchyaw 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 target_system System ID + * @param target_component Component ID + * @param flags High level gimbal manager flags to use. + * @param gimbal_device_id Component ID of gimbal device to address (or 1-6 for non-MAVLink gimbal), 0 for all gimbal device components. Send command multiple times for more than one gimbal (but not all gimbals). + * @param pitch [rad] Pitch angle (positive: up, negative: down, NaN to be ignored). + * @param yaw [rad] Yaw angle (positive: to the right, negative: to the left, NaN to be ignored). + * @param pitch_rate [rad/s] Pitch angular rate (positive: up, negative: down, NaN to be ignored). + * @param yaw_rate [rad/s] Yaw angular rate (positive: to the right, negative: to the left, NaN to be ignored). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_pitchyaw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t flags, uint8_t gimbal_device_id, float pitch, float yaw, float pitch_rate, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN]; + _mav_put_uint32_t(buf, 0, flags); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, pitch_rate); + _mav_put_float(buf, 16, yaw_rate); + _mav_put_uint8_t(buf, 20, target_system); + _mav_put_uint8_t(buf, 21, target_component); + _mav_put_uint8_t(buf, 22, gimbal_device_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN); +#else + mavlink_gimbal_manager_set_pitchyaw_t packet; + packet.flags = flags; + packet.pitch = pitch; + packet.yaw = yaw; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_device_id = gimbal_device_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_SET_PITCHYAW_LEN); +#endif +} + /** * @brief Pack a gimbal_manager_set_pitchyaw message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_gimbal_manager_set_pitchyaw_encode_chan(uint8 return mavlink_msg_gimbal_manager_set_pitchyaw_pack_chan(system_id, component_id, chan, msg, gimbal_manager_set_pitchyaw->target_system, gimbal_manager_set_pitchyaw->target_component, gimbal_manager_set_pitchyaw->flags, gimbal_manager_set_pitchyaw->gimbal_device_id, gimbal_manager_set_pitchyaw->pitch, gimbal_manager_set_pitchyaw->yaw, gimbal_manager_set_pitchyaw->pitch_rate, gimbal_manager_set_pitchyaw->yaw_rate); } +/** + * @brief Encode a gimbal_manager_set_pitchyaw struct with provided status structure + * + * @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 gimbal_manager_set_pitchyaw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_manager_set_pitchyaw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_manager_set_pitchyaw_t* gimbal_manager_set_pitchyaw) +{ + return mavlink_msg_gimbal_manager_set_pitchyaw_pack_status(system_id, component_id, _status, msg, gimbal_manager_set_pitchyaw->target_system, gimbal_manager_set_pitchyaw->target_component, gimbal_manager_set_pitchyaw->flags, gimbal_manager_set_pitchyaw->gimbal_device_id, gimbal_manager_set_pitchyaw->pitch, gimbal_manager_set_pitchyaw->yaw, gimbal_manager_set_pitchyaw->pitch_rate, gimbal_manager_set_pitchyaw->yaw_rate); +} + /** * @brief Send a gimbal_manager_set_pitchyaw message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gimbal_manager_status.h b/common/mavlink_msg_gimbal_manager_status.h index 484d2ab5..1f4d5a22 100644 --- a/common/mavlink_msg_gimbal_manager_status.h +++ b/common/mavlink_msg_gimbal_manager_status.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_gimbal_manager_status_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_CRC); } +/** + * @brief Pack a gimbal_manager_status 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param flags High level gimbal manager flags currently applied. + * @param gimbal_device_id Gimbal device ID that this gimbal manager is responsible for. Component ID of gimbal device (or 1-6 for non-MAVLink gimbal). + * @param primary_control_sysid System ID of MAVLink component with primary control, 0 for none. + * @param primary_control_compid Component ID of MAVLink component with primary control, 0 for none. + * @param secondary_control_sysid System ID of MAVLink component with secondary control, 0 for none. + * @param secondary_control_compid Component ID of MAVLink component with secondary control, 0 for none. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gimbal_manager_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint32_t flags, uint8_t gimbal_device_id, uint8_t primary_control_sysid, uint8_t primary_control_compid, uint8_t secondary_control_sysid, uint8_t secondary_control_compid) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint32_t(buf, 4, flags); + _mav_put_uint8_t(buf, 8, gimbal_device_id); + _mav_put_uint8_t(buf, 9, primary_control_sysid); + _mav_put_uint8_t(buf, 10, primary_control_compid); + _mav_put_uint8_t(buf, 11, secondary_control_sysid); + _mav_put_uint8_t(buf, 12, secondary_control_compid); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN); +#else + mavlink_gimbal_manager_status_t packet; + packet.time_boot_ms = time_boot_ms; + packet.flags = flags; + packet.gimbal_device_id = gimbal_device_id; + packet.primary_control_sysid = primary_control_sysid; + packet.primary_control_compid = primary_control_compid; + packet.secondary_control_sysid = secondary_control_sysid; + packet.secondary_control_compid = secondary_control_compid; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_GIMBAL_MANAGER_STATUS_LEN); +#endif +} + /** * @brief Pack a gimbal_manager_status message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_gimbal_manager_status_encode_chan(uint8_t sys return mavlink_msg_gimbal_manager_status_pack_chan(system_id, component_id, chan, msg, gimbal_manager_status->time_boot_ms, gimbal_manager_status->flags, gimbal_manager_status->gimbal_device_id, gimbal_manager_status->primary_control_sysid, gimbal_manager_status->primary_control_compid, gimbal_manager_status->secondary_control_sysid, gimbal_manager_status->secondary_control_compid); } +/** + * @brief Encode a gimbal_manager_status struct with provided status structure + * + * @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 gimbal_manager_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gimbal_manager_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gimbal_manager_status_t* gimbal_manager_status) +{ + return mavlink_msg_gimbal_manager_status_pack_status(system_id, component_id, _status, msg, gimbal_manager_status->time_boot_ms, gimbal_manager_status->flags, gimbal_manager_status->gimbal_device_id, gimbal_manager_status->primary_control_sysid, gimbal_manager_status->primary_control_compid, gimbal_manager_status->secondary_control_sysid, gimbal_manager_status->secondary_control_compid); +} + /** * @brief Send a gimbal_manager_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_global_position_int.h b/common/mavlink_msg_global_position_int.h index e30d87dc..545e5e53 100644 --- a/common/mavlink_msg_global_position_int.h +++ b/common/mavlink_msg_global_position_int.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_CRC); } +/** + * @brief Pack a global_position_int 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param lat [degE7] Latitude, expressed + * @param lon [degE7] Longitude, expressed + * @param alt [mm] Altitude (MSL). Note that virtually all GPS modules provide both WGS84 and MSL. + * @param relative_alt [mm] Altitude above ground + * @param vx [cm/s] Ground X Speed (Latitude, positive north) + * @param vy [cm/s] Ground Y Speed (Longitude, positive east) + * @param vz [cm/s] Ground Z Speed (Altitude, positive down) + * @param hdg [cdeg] Vehicle heading (yaw angle), 0.0..359.99 degrees. If unknown, set to: UINT16_MAX + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_global_position_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t hdg) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat); + _mav_put_int32_t(buf, 8, lon); + _mav_put_int32_t(buf, 12, alt); + _mav_put_int32_t(buf, 16, relative_alt); + _mav_put_int16_t(buf, 20, vx); + _mav_put_int16_t(buf, 22, vy); + _mav_put_int16_t(buf, 24, vz); + _mav_put_uint16_t(buf, 26, hdg); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN); +#else + mavlink_global_position_int_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.relative_alt = relative_alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.hdg = hdg; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_LEN); +#endif +} + /** * @brief Pack a global_position_int message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_global_position_int_encode_chan(uint8_t syste return mavlink_msg_global_position_int_pack_chan(system_id, component_id, chan, msg, global_position_int->time_boot_ms, global_position_int->lat, global_position_int->lon, global_position_int->alt, global_position_int->relative_alt, global_position_int->vx, global_position_int->vy, global_position_int->vz, global_position_int->hdg); } +/** + * @brief Encode a global_position_int struct with provided status structure + * + * @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 global_position_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_global_position_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_global_position_int_t* global_position_int) +{ + return mavlink_msg_global_position_int_pack_status(system_id, component_id, _status, msg, global_position_int->time_boot_ms, global_position_int->lat, global_position_int->lon, global_position_int->alt, global_position_int->relative_alt, global_position_int->vx, global_position_int->vy, global_position_int->vz, global_position_int->hdg); +} + /** * @brief Send a global_position_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_global_position_int_cov.h b/common/mavlink_msg_global_position_int_cov.h index 89f4c646..98b32530 100644 --- a/common/mavlink_msg_global_position_int_cov.h +++ b/common/mavlink_msg_global_position_int_cov.h @@ -115,6 +115,64 @@ static inline uint16_t mavlink_msg_global_position_int_cov_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_CRC); } +/** + * @brief Pack a global_position_int_cov 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param estimator_type Class id of the estimator this estimate originated from. + * @param lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param alt [mm] Altitude in meters above MSL + * @param relative_alt [mm] Altitude above ground + * @param vx [m/s] Ground X Speed (Latitude) + * @param vy [m/s] Ground Y Speed (Longitude) + * @param vz [m/s] Ground Z Speed (Altitude) + * @param covariance Row-major representation of a 6x6 position and velocity 6x6 cross-covariance matrix (states: lat, lon, alt, vx, vy, vz; first six entries are the first ROW, next six entries are the second row, etc.). If unknown, assign NaN value to first element in the array. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_global_position_int_cov_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t estimator_type, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, float vx, float vy, float vz, const float *covariance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_int32_t(buf, 16, alt); + _mav_put_int32_t(buf, 20, relative_alt); + _mav_put_float(buf, 24, vx); + _mav_put_float(buf, 28, vy); + _mav_put_float(buf, 32, vz); + _mav_put_uint8_t(buf, 180, estimator_type); + _mav_put_float_array(buf, 36, covariance, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN); +#else + mavlink_global_position_int_cov_t packet; + packet.time_usec = time_usec; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.relative_alt = relative_alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.estimator_type = estimator_type; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV_LEN); +#endif +} + /** * @brief Pack a global_position_int_cov message on a channel * @param system_id ID of this system @@ -196,6 +254,20 @@ static inline uint16_t mavlink_msg_global_position_int_cov_encode_chan(uint8_t s return mavlink_msg_global_position_int_cov_pack_chan(system_id, component_id, chan, msg, global_position_int_cov->time_usec, global_position_int_cov->estimator_type, global_position_int_cov->lat, global_position_int_cov->lon, global_position_int_cov->alt, global_position_int_cov->relative_alt, global_position_int_cov->vx, global_position_int_cov->vy, global_position_int_cov->vz, global_position_int_cov->covariance); } +/** + * @brief Encode a global_position_int_cov struct with provided status structure + * + * @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 global_position_int_cov C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_global_position_int_cov_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_global_position_int_cov_t* global_position_int_cov) +{ + return mavlink_msg_global_position_int_cov_pack_status(system_id, component_id, _status, msg, global_position_int_cov->time_usec, global_position_int_cov->estimator_type, global_position_int_cov->lat, global_position_int_cov->lon, global_position_int_cov->alt, global_position_int_cov->relative_alt, global_position_int_cov->vx, global_position_int_cov->vy, global_position_int_cov->vz, global_position_int_cov->covariance); +} + /** * @brief Send a global_position_int_cov message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_global_vision_position_estimate.h b/common/mavlink_msg_global_vision_position_estimate.h index b2dee2ec..1bd6614d 100644 --- a/common/mavlink_msg_global_vision_position_estimate.h +++ b/common/mavlink_msg_global_vision_position_estimate.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack(uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_CRC); } +/** + * @brief Pack a global_vision_position_estimate 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 usec [us] Timestamp (UNIX time or since system boot) + * @param x [m] Global X position + * @param y [m] Global Y position + * @param z [m] Global Z position + * @param roll [rad] Roll angle + * @param pitch [rad] Pitch angle + * @param yaw [rad] Yaw angle + * @param covariance Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states: x_global, y_global, z_global, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_global_vision_position_estimate_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw, const float *covariance, uint8_t reset_counter) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN]; + _mav_put_uint64_t(buf, 0, usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 20, roll); + _mav_put_float(buf, 24, pitch); + _mav_put_float(buf, 28, yaw); + _mav_put_uint8_t(buf, 116, reset_counter); + _mav_put_float_array(buf, 32, covariance, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN); +#else + mavlink_global_vision_position_estimate_t packet; + packet.usec = usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.reset_counter = reset_counter; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE_LEN); +#endif +} + /** * @brief Pack a global_vision_position_estimate message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_encode_chan(u return mavlink_msg_global_vision_position_estimate_pack_chan(system_id, component_id, chan, msg, global_vision_position_estimate->usec, global_vision_position_estimate->x, global_vision_position_estimate->y, global_vision_position_estimate->z, global_vision_position_estimate->roll, global_vision_position_estimate->pitch, global_vision_position_estimate->yaw, global_vision_position_estimate->covariance, global_vision_position_estimate->reset_counter); } +/** + * @brief Encode a global_vision_position_estimate struct with provided status structure + * + * @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 global_vision_position_estimate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_global_vision_position_estimate_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_global_vision_position_estimate_t* global_vision_position_estimate) +{ + return mavlink_msg_global_vision_position_estimate_pack_status(system_id, component_id, _status, msg, global_vision_position_estimate->usec, global_vision_position_estimate->x, global_vision_position_estimate->y, global_vision_position_estimate->z, global_vision_position_estimate->roll, global_vision_position_estimate->pitch, global_vision_position_estimate->yaw, global_vision_position_estimate->covariance, global_vision_position_estimate->reset_counter); +} + /** * @brief Send a global_vision_position_estimate message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps2_raw.h b/common/mavlink_msg_gps2_raw.h index aa7bdfa0..6583917f 100644 --- a/common/mavlink_msg_gps2_raw.h +++ b/common/mavlink_msg_gps2_raw.h @@ -165,6 +165,90 @@ static inline uint16_t mavlink_msg_gps2_raw_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS2_RAW_MIN_LEN, MAVLINK_MSG_ID_GPS2_RAW_LEN, MAVLINK_MSG_ID_GPS2_RAW_CRC); } +/** + * @brief Pack a gps2_raw 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param fix_type GPS fix type. + * @param lat [degE7] Latitude (WGS84) + * @param lon [degE7] Longitude (WGS84) + * @param alt [mm] Altitude (MSL). Positive for up. + * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX + * @param cog [cdeg] Course over ground (NOT heading, but direction of movement): 0.0..359.99 degrees. If unknown, set to: UINT16_MAX + * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX + * @param dgps_numch Number of DGPS satellites + * @param dgps_age [ms] Age of DGPS info + * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north. + * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up. + * @param h_acc [mm] Position uncertainty. + * @param v_acc [mm] Altitude uncertainty. + * @param vel_acc [mm] Speed uncertainty. + * @param hdg_acc [degE5] Heading / track uncertainty + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps2_raw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, uint8_t dgps_numch, uint32_t dgps_age, uint16_t yaw, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS2_RAW_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_int32_t(buf, 16, alt); + _mav_put_uint32_t(buf, 20, dgps_age); + _mav_put_uint16_t(buf, 24, eph); + _mav_put_uint16_t(buf, 26, epv); + _mav_put_uint16_t(buf, 28, vel); + _mav_put_uint16_t(buf, 30, cog); + _mav_put_uint8_t(buf, 32, fix_type); + _mav_put_uint8_t(buf, 33, satellites_visible); + _mav_put_uint8_t(buf, 34, dgps_numch); + _mav_put_uint16_t(buf, 35, yaw); + _mav_put_int32_t(buf, 37, alt_ellipsoid); + _mav_put_uint32_t(buf, 41, h_acc); + _mav_put_uint32_t(buf, 45, v_acc); + _mav_put_uint32_t(buf, 49, vel_acc); + _mav_put_uint32_t(buf, 53, hdg_acc); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS2_RAW_LEN); +#else + mavlink_gps2_raw_t packet; + packet.time_usec = time_usec; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.dgps_age = dgps_age; + packet.eph = eph; + packet.epv = epv; + packet.vel = vel; + packet.cog = cog; + packet.fix_type = fix_type; + packet.satellites_visible = satellites_visible; + packet.dgps_numch = dgps_numch; + packet.yaw = yaw; + packet.alt_ellipsoid = alt_ellipsoid; + packet.h_acc = h_acc; + packet.v_acc = v_acc; + packet.vel_acc = vel_acc; + packet.hdg_acc = hdg_acc; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS2_RAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS2_RAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS2_RAW_MIN_LEN, MAVLINK_MSG_ID_GPS2_RAW_LEN, MAVLINK_MSG_ID_GPS2_RAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS2_RAW_MIN_LEN, MAVLINK_MSG_ID_GPS2_RAW_LEN); +#endif +} + /** * @brief Pack a gps2_raw message on a channel * @param system_id ID of this system @@ -272,6 +356,20 @@ static inline uint16_t mavlink_msg_gps2_raw_encode_chan(uint8_t system_id, uint8 return mavlink_msg_gps2_raw_pack_chan(system_id, component_id, chan, msg, gps2_raw->time_usec, gps2_raw->fix_type, gps2_raw->lat, gps2_raw->lon, gps2_raw->alt, gps2_raw->eph, gps2_raw->epv, gps2_raw->vel, gps2_raw->cog, gps2_raw->satellites_visible, gps2_raw->dgps_numch, gps2_raw->dgps_age, gps2_raw->yaw, gps2_raw->alt_ellipsoid, gps2_raw->h_acc, gps2_raw->v_acc, gps2_raw->vel_acc, gps2_raw->hdg_acc); } +/** + * @brief Encode a gps2_raw struct with provided status structure + * + * @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 gps2_raw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps2_raw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps2_raw_t* gps2_raw) +{ + return mavlink_msg_gps2_raw_pack_status(system_id, component_id, _status, msg, gps2_raw->time_usec, gps2_raw->fix_type, gps2_raw->lat, gps2_raw->lon, gps2_raw->alt, gps2_raw->eph, gps2_raw->epv, gps2_raw->vel, gps2_raw->cog, gps2_raw->satellites_visible, gps2_raw->dgps_numch, gps2_raw->dgps_age, gps2_raw->yaw, gps2_raw->alt_ellipsoid, gps2_raw->h_acc, gps2_raw->v_acc, gps2_raw->vel_acc, gps2_raw->hdg_acc); +} + /** * @brief Send a gps2_raw message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps2_rtk.h b/common/mavlink_msg_gps2_rtk.h index e546c70e..5ff07bda 100644 --- a/common/mavlink_msg_gps2_rtk.h +++ b/common/mavlink_msg_gps2_rtk.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_gps2_rtk_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS2_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS2_RTK_LEN, MAVLINK_MSG_ID_GPS2_RTK_CRC); } +/** + * @brief Pack a gps2_rtk 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 time_last_baseline_ms [ms] Time since boot of last baseline message received. + * @param rtk_receiver_id Identification of connected RTK receiver. + * @param wn GPS Week Number of last baseline + * @param tow [ms] GPS Time of Week of last baseline + * @param rtk_health GPS-specific health report for RTK data. + * @param rtk_rate [Hz] Rate of baseline messages being received by GPS + * @param nsats Current number of sats used for RTK calculation. + * @param baseline_coords_type Coordinate system of baseline + * @param baseline_a_mm [mm] Current baseline in ECEF x or NED north component. + * @param baseline_b_mm [mm] Current baseline in ECEF y or NED east component. + * @param baseline_c_mm [mm] Current baseline in ECEF z or NED down component. + * @param accuracy Current estimate of baseline accuracy. + * @param iar_num_hypotheses Current number of integer ambiguity hypotheses. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps2_rtk_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS2_RTK_LEN]; + _mav_put_uint32_t(buf, 0, time_last_baseline_ms); + _mav_put_uint32_t(buf, 4, tow); + _mav_put_int32_t(buf, 8, baseline_a_mm); + _mav_put_int32_t(buf, 12, baseline_b_mm); + _mav_put_int32_t(buf, 16, baseline_c_mm); + _mav_put_uint32_t(buf, 20, accuracy); + _mav_put_int32_t(buf, 24, iar_num_hypotheses); + _mav_put_uint16_t(buf, 28, wn); + _mav_put_uint8_t(buf, 30, rtk_receiver_id); + _mav_put_uint8_t(buf, 31, rtk_health); + _mav_put_uint8_t(buf, 32, rtk_rate); + _mav_put_uint8_t(buf, 33, nsats); + _mav_put_uint8_t(buf, 34, baseline_coords_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS2_RTK_LEN); +#else + mavlink_gps2_rtk_t packet; + packet.time_last_baseline_ms = time_last_baseline_ms; + packet.tow = tow; + packet.baseline_a_mm = baseline_a_mm; + packet.baseline_b_mm = baseline_b_mm; + packet.baseline_c_mm = baseline_c_mm; + packet.accuracy = accuracy; + packet.iar_num_hypotheses = iar_num_hypotheses; + packet.wn = wn; + packet.rtk_receiver_id = rtk_receiver_id; + packet.rtk_health = rtk_health; + packet.rtk_rate = rtk_rate; + packet.nsats = nsats; + packet.baseline_coords_type = baseline_coords_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS2_RTK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS2_RTK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS2_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS2_RTK_LEN, MAVLINK_MSG_ID_GPS2_RTK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS2_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS2_RTK_LEN); +#endif +} + /** * @brief Pack a gps2_rtk message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_gps2_rtk_encode_chan(uint8_t system_id, uint8 return mavlink_msg_gps2_rtk_pack_chan(system_id, component_id, chan, msg, gps2_rtk->time_last_baseline_ms, gps2_rtk->rtk_receiver_id, gps2_rtk->wn, gps2_rtk->tow, gps2_rtk->rtk_health, gps2_rtk->rtk_rate, gps2_rtk->nsats, gps2_rtk->baseline_coords_type, gps2_rtk->baseline_a_mm, gps2_rtk->baseline_b_mm, gps2_rtk->baseline_c_mm, gps2_rtk->accuracy, gps2_rtk->iar_num_hypotheses); } +/** + * @brief Encode a gps2_rtk struct with provided status structure + * + * @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 gps2_rtk C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps2_rtk_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps2_rtk_t* gps2_rtk) +{ + return mavlink_msg_gps2_rtk_pack_status(system_id, component_id, _status, msg, gps2_rtk->time_last_baseline_ms, gps2_rtk->rtk_receiver_id, gps2_rtk->wn, gps2_rtk->tow, gps2_rtk->rtk_health, gps2_rtk->rtk_rate, gps2_rtk->nsats, gps2_rtk->baseline_coords_type, gps2_rtk->baseline_a_mm, gps2_rtk->baseline_b_mm, gps2_rtk->baseline_c_mm, gps2_rtk->accuracy, gps2_rtk->iar_num_hypotheses); +} + /** * @brief Send a gps2_rtk message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_global_origin.h b/common/mavlink_msg_gps_global_origin.h index c9a67774..9ed7968f 100644 --- a/common/mavlink_msg_gps_global_origin.h +++ b/common/mavlink_msg_gps_global_origin.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_gps_global_origin_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_CRC); } +/** + * @brief Pack a gps_global_origin 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 latitude [degE7] Latitude (WGS84) + * @param longitude [degE7] Longitude (WGS84) + * @param altitude [mm] Altitude (MSL). Positive for up. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_global_origin_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t latitude, int32_t longitude, int32_t altitude, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN]; + _mav_put_int32_t(buf, 0, latitude); + _mav_put_int32_t(buf, 4, longitude); + _mav_put_int32_t(buf, 8, altitude); + _mav_put_uint64_t(buf, 12, time_usec); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN); +#else + mavlink_gps_global_origin_t packet; + packet.latitude = latitude; + packet.longitude = longitude; + packet.altitude = altitude; + packet.time_usec = time_usec; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN); +#endif +} + /** * @brief Pack a gps_global_origin message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_gps_global_origin_encode_chan(uint8_t system_ return mavlink_msg_gps_global_origin_pack_chan(system_id, component_id, chan, msg, gps_global_origin->latitude, gps_global_origin->longitude, gps_global_origin->altitude, gps_global_origin->time_usec); } +/** + * @brief Encode a gps_global_origin struct with provided status structure + * + * @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 gps_global_origin C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_global_origin_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_global_origin_t* gps_global_origin) +{ + return mavlink_msg_gps_global_origin_pack_status(system_id, component_id, _status, msg, gps_global_origin->latitude, gps_global_origin->longitude, gps_global_origin->altitude, gps_global_origin->time_usec); +} + /** * @brief Send a gps_global_origin message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_inject_data.h b/common/mavlink_msg_gps_inject_data.h index 9b224267..2fed22a7 100644 --- a/common/mavlink_msg_gps_inject_data.h +++ b/common/mavlink_msg_gps_inject_data.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_gps_inject_data_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_INJECT_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN, MAVLINK_MSG_ID_GPS_INJECT_DATA_CRC); } +/** + * @brief Pack a gps_inject_data 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 target_system System ID + * @param target_component Component ID + * @param len [bytes] Data length + * @param data Raw data (110 is enough for 12 satellites of RTCMv2) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_inject_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, len); + _mav_put_uint8_t_array(buf, 3, data, 110); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN); +#else + mavlink_gps_inject_data_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*110); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_INJECT_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_INJECT_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN, MAVLINK_MSG_ID_GPS_INJECT_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_INJECT_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_INJECT_DATA_LEN); +#endif +} + /** * @brief Pack a gps_inject_data message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_gps_inject_data_encode_chan(uint8_t system_id return mavlink_msg_gps_inject_data_pack_chan(system_id, component_id, chan, msg, gps_inject_data->target_system, gps_inject_data->target_component, gps_inject_data->len, gps_inject_data->data); } +/** + * @brief Encode a gps_inject_data struct with provided status structure + * + * @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 gps_inject_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_inject_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_inject_data_t* gps_inject_data) +{ + return mavlink_msg_gps_inject_data_pack_status(system_id, component_id, _status, msg, gps_inject_data->target_system, gps_inject_data->target_component, gps_inject_data->len, gps_inject_data->data); +} + /** * @brief Send a gps_inject_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_input.h b/common/mavlink_msg_gps_input.h index 6e920f21..de72c7f0 100644 --- a/common/mavlink_msg_gps_input.h +++ b/common/mavlink_msg_gps_input.h @@ -171,6 +171,93 @@ static inline uint16_t mavlink_msg_gps_input_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_INPUT_MIN_LEN, MAVLINK_MSG_ID_GPS_INPUT_LEN, MAVLINK_MSG_ID_GPS_INPUT_CRC); } +/** + * @brief Pack a gps_input 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param gps_id ID of the GPS for multiple GPS inputs + * @param ignore_flags Bitmap indicating which GPS input flags fields to ignore. All other fields must be provided. + * @param time_week_ms [ms] GPS time (from start of GPS week) + * @param time_week GPS week number + * @param fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK + * @param lat [degE7] Latitude (WGS84) + * @param lon [degE7] Longitude (WGS84) + * @param alt [m] Altitude (MSL). Positive for up. + * @param hdop GPS HDOP horizontal dilution of position (unitless). If unknown, set to: UINT16_MAX + * @param vdop GPS VDOP vertical dilution of position (unitless). If unknown, set to: UINT16_MAX + * @param vn [m/s] GPS velocity in north direction in earth-fixed NED frame + * @param ve [m/s] GPS velocity in east direction in earth-fixed NED frame + * @param vd [m/s] GPS velocity in down direction in earth-fixed NED frame + * @param speed_accuracy [m/s] GPS speed accuracy + * @param horiz_accuracy [m] GPS horizontal accuracy + * @param vert_accuracy [m] GPS vertical accuracy + * @param satellites_visible Number of satellites visible. + * @param yaw [cdeg] Yaw of vehicle relative to Earth's North, zero means not available, use 36000 for north + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_input_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t gps_id, uint16_t ignore_flags, uint32_t time_week_ms, uint16_t time_week, uint8_t fix_type, int32_t lat, int32_t lon, float alt, float hdop, float vdop, float vn, float ve, float vd, float speed_accuracy, float horiz_accuracy, float vert_accuracy, uint8_t satellites_visible, uint16_t yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_INPUT_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, time_week_ms); + _mav_put_int32_t(buf, 12, lat); + _mav_put_int32_t(buf, 16, lon); + _mav_put_float(buf, 20, alt); + _mav_put_float(buf, 24, hdop); + _mav_put_float(buf, 28, vdop); + _mav_put_float(buf, 32, vn); + _mav_put_float(buf, 36, ve); + _mav_put_float(buf, 40, vd); + _mav_put_float(buf, 44, speed_accuracy); + _mav_put_float(buf, 48, horiz_accuracy); + _mav_put_float(buf, 52, vert_accuracy); + _mav_put_uint16_t(buf, 56, ignore_flags); + _mav_put_uint16_t(buf, 58, time_week); + _mav_put_uint8_t(buf, 60, gps_id); + _mav_put_uint8_t(buf, 61, fix_type); + _mav_put_uint8_t(buf, 62, satellites_visible); + _mav_put_uint16_t(buf, 63, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_INPUT_LEN); +#else + mavlink_gps_input_t packet; + packet.time_usec = time_usec; + packet.time_week_ms = time_week_ms; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.hdop = hdop; + packet.vdop = vdop; + packet.vn = vn; + packet.ve = ve; + packet.vd = vd; + packet.speed_accuracy = speed_accuracy; + packet.horiz_accuracy = horiz_accuracy; + packet.vert_accuracy = vert_accuracy; + packet.ignore_flags = ignore_flags; + packet.time_week = time_week; + packet.gps_id = gps_id; + packet.fix_type = fix_type; + packet.satellites_visible = satellites_visible; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_INPUT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_INPUT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_INPUT_MIN_LEN, MAVLINK_MSG_ID_GPS_INPUT_LEN, MAVLINK_MSG_ID_GPS_INPUT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_INPUT_MIN_LEN, MAVLINK_MSG_ID_GPS_INPUT_LEN); +#endif +} + /** * @brief Pack a gps_input message on a channel * @param system_id ID of this system @@ -281,6 +368,20 @@ static inline uint16_t mavlink_msg_gps_input_encode_chan(uint8_t system_id, uint return mavlink_msg_gps_input_pack_chan(system_id, component_id, chan, msg, gps_input->time_usec, gps_input->gps_id, gps_input->ignore_flags, gps_input->time_week_ms, gps_input->time_week, gps_input->fix_type, gps_input->lat, gps_input->lon, gps_input->alt, gps_input->hdop, gps_input->vdop, gps_input->vn, gps_input->ve, gps_input->vd, gps_input->speed_accuracy, gps_input->horiz_accuracy, gps_input->vert_accuracy, gps_input->satellites_visible, gps_input->yaw); } +/** + * @brief Encode a gps_input struct with provided status structure + * + * @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 gps_input C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_input_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_input_t* gps_input) +{ + return mavlink_msg_gps_input_pack_status(system_id, component_id, _status, msg, gps_input->time_usec, gps_input->gps_id, gps_input->ignore_flags, gps_input->time_week_ms, gps_input->time_week, gps_input->fix_type, gps_input->lat, gps_input->lon, gps_input->alt, gps_input->hdop, gps_input->vdop, gps_input->vn, gps_input->ve, gps_input->vd, gps_input->speed_accuracy, gps_input->horiz_accuracy, gps_input->vert_accuracy, gps_input->satellites_visible, gps_input->yaw); +} + /** * @brief Send a gps_input message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_raw_int.h b/common/mavlink_msg_gps_raw_int.h index 5fdbef07..427044e5 100644 --- a/common/mavlink_msg_gps_raw_int.h +++ b/common/mavlink_msg_gps_raw_int.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_gps_raw_int_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC); } +/** + * @brief Pack a gps_raw_int 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param fix_type GPS fix type. + * @param lat [degE7] Latitude (WGS84, EGM96 ellipsoid) + * @param lon [degE7] Longitude (WGS84, EGM96 ellipsoid) + * @param alt [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude. + * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX + * @param cog [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX + * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX + * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up. + * @param h_acc [mm] Position uncertainty. + * @param v_acc [mm] Altitude uncertainty. + * @param vel_acc [mm] Speed uncertainty. + * @param hdg_acc [degE5] Heading / track uncertainty + * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_raw_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc, uint16_t yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_RAW_INT_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_int32_t(buf, 16, alt); + _mav_put_uint16_t(buf, 20, eph); + _mav_put_uint16_t(buf, 22, epv); + _mav_put_uint16_t(buf, 24, vel); + _mav_put_uint16_t(buf, 26, cog); + _mav_put_uint8_t(buf, 28, fix_type); + _mav_put_uint8_t(buf, 29, satellites_visible); + _mav_put_int32_t(buf, 30, alt_ellipsoid); + _mav_put_uint32_t(buf, 34, h_acc); + _mav_put_uint32_t(buf, 38, v_acc); + _mav_put_uint32_t(buf, 42, vel_acc); + _mav_put_uint32_t(buf, 46, hdg_acc); + _mav_put_uint16_t(buf, 50, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RAW_INT_LEN); +#else + mavlink_gps_raw_int_t packet; + packet.time_usec = time_usec; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.eph = eph; + packet.epv = epv; + packet.vel = vel; + packet.cog = cog; + packet.fix_type = fix_type; + packet.satellites_visible = satellites_visible; + packet.alt_ellipsoid = alt_ellipsoid; + packet.h_acc = h_acc; + packet.v_acc = v_acc; + packet.vel_acc = vel_acc; + packet.hdg_acc = hdg_acc; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RAW_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN); +#endif +} + /** * @brief Pack a gps_raw_int message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_gps_raw_int_encode_chan(uint8_t system_id, ui return mavlink_msg_gps_raw_int_pack_chan(system_id, component_id, chan, msg, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw); } +/** + * @brief Encode a gps_raw_int struct with provided status structure + * + * @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 gps_raw_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_raw_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_raw_int_t* gps_raw_int) +{ + return mavlink_msg_gps_raw_int_pack_status(system_id, component_id, _status, msg, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw); +} + /** * @brief Send a gps_raw_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_rtcm_data.h b/common/mavlink_msg_gps_rtcm_data.h index a6f861ee..ec8e0325 100644 --- a/common/mavlink_msg_gps_rtcm_data.h +++ b/common/mavlink_msg_gps_rtcm_data.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_gps_rtcm_data_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); } +/** + * @brief Pack a gps_rtcm_data 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 flags LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order. + * @param len [bytes] data length + * @param data RTCM message (may be fragmented) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_rtcm_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t flags, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN]; + _mav_put_uint8_t(buf, 0, flags); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 180); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); +#else + mavlink_gps_rtcm_data_t packet; + packet.flags = flags; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_RTCM_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN); +#endif +} + /** * @brief Pack a gps_rtcm_data message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_gps_rtcm_data_encode_chan(uint8_t system_id, return mavlink_msg_gps_rtcm_data_pack_chan(system_id, component_id, chan, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data); } +/** + * @brief Encode a gps_rtcm_data struct with provided status structure + * + * @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 gps_rtcm_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_rtcm_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_rtcm_data_t* gps_rtcm_data) +{ + return mavlink_msg_gps_rtcm_data_pack_status(system_id, component_id, _status, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data); +} + /** * @brief Send a gps_rtcm_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_rtk.h b/common/mavlink_msg_gps_rtk.h index 538b0db9..66579018 100644 --- a/common/mavlink_msg_gps_rtk.h +++ b/common/mavlink_msg_gps_rtk.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_gps_rtk_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC); } +/** + * @brief Pack a gps_rtk 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 time_last_baseline_ms [ms] Time since boot of last baseline message received. + * @param rtk_receiver_id Identification of connected RTK receiver. + * @param wn GPS Week Number of last baseline + * @param tow [ms] GPS Time of Week of last baseline + * @param rtk_health GPS-specific health report for RTK data. + * @param rtk_rate [Hz] Rate of baseline messages being received by GPS + * @param nsats Current number of sats used for RTK calculation. + * @param baseline_coords_type Coordinate system of baseline + * @param baseline_a_mm [mm] Current baseline in ECEF x or NED north component. + * @param baseline_b_mm [mm] Current baseline in ECEF y or NED east component. + * @param baseline_c_mm [mm] Current baseline in ECEF z or NED down component. + * @param accuracy Current estimate of baseline accuracy. + * @param iar_num_hypotheses Current number of integer ambiguity hypotheses. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_rtk_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_RTK_LEN]; + _mav_put_uint32_t(buf, 0, time_last_baseline_ms); + _mav_put_uint32_t(buf, 4, tow); + _mav_put_int32_t(buf, 8, baseline_a_mm); + _mav_put_int32_t(buf, 12, baseline_b_mm); + _mav_put_int32_t(buf, 16, baseline_c_mm); + _mav_put_uint32_t(buf, 20, accuracy); + _mav_put_int32_t(buf, 24, iar_num_hypotheses); + _mav_put_uint16_t(buf, 28, wn); + _mav_put_uint8_t(buf, 30, rtk_receiver_id); + _mav_put_uint8_t(buf, 31, rtk_health); + _mav_put_uint8_t(buf, 32, rtk_rate); + _mav_put_uint8_t(buf, 33, nsats); + _mav_put_uint8_t(buf, 34, baseline_coords_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTK_LEN); +#else + mavlink_gps_rtk_t packet; + packet.time_last_baseline_ms = time_last_baseline_ms; + packet.tow = tow; + packet.baseline_a_mm = baseline_a_mm; + packet.baseline_b_mm = baseline_b_mm; + packet.baseline_c_mm = baseline_c_mm; + packet.accuracy = accuracy; + packet.iar_num_hypotheses = iar_num_hypotheses; + packet.wn = wn; + packet.rtk_receiver_id = rtk_receiver_id; + packet.rtk_health = rtk_health; + packet.rtk_rate = rtk_rate; + packet.nsats = nsats; + packet.baseline_coords_type = baseline_coords_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_RTK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN); +#endif +} + /** * @brief Pack a gps_rtk message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_gps_rtk_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_gps_rtk_pack_chan(system_id, component_id, chan, msg, gps_rtk->time_last_baseline_ms, gps_rtk->rtk_receiver_id, gps_rtk->wn, gps_rtk->tow, gps_rtk->rtk_health, gps_rtk->rtk_rate, gps_rtk->nsats, gps_rtk->baseline_coords_type, gps_rtk->baseline_a_mm, gps_rtk->baseline_b_mm, gps_rtk->baseline_c_mm, gps_rtk->accuracy, gps_rtk->iar_num_hypotheses); } +/** + * @brief Encode a gps_rtk struct with provided status structure + * + * @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 gps_rtk C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_rtk_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_rtk_t* gps_rtk) +{ + return mavlink_msg_gps_rtk_pack_status(system_id, component_id, _status, msg, gps_rtk->time_last_baseline_ms, gps_rtk->rtk_receiver_id, gps_rtk->wn, gps_rtk->tow, gps_rtk->rtk_health, gps_rtk->rtk_rate, gps_rtk->nsats, gps_rtk->baseline_coords_type, gps_rtk->baseline_a_mm, gps_rtk->baseline_b_mm, gps_rtk->baseline_c_mm, gps_rtk->accuracy, gps_rtk->iar_num_hypotheses); +} + /** * @brief Send a gps_rtk message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_gps_status.h b/common/mavlink_msg_gps_status.h index 65273a5c..299789d6 100644 --- a/common/mavlink_msg_gps_status.h +++ b/common/mavlink_msg_gps_status.h @@ -95,6 +95,52 @@ static inline uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC); } +/** + * @brief Pack a gps_status 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 satellites_visible Number of satellites visible + * @param satellite_prn Global satellite ID + * @param satellite_used 0: Satellite not used, 1: used for localization + * @param satellite_elevation [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite + * @param satellite_azimuth [deg] Direction of satellite, 0: 0 deg, 255: 360 deg. + * @param satellite_snr [dB] Signal to noise ratio of satellite + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_gps_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GPS_STATUS_LEN]; + _mav_put_uint8_t(buf, 0, satellites_visible); + _mav_put_uint8_t_array(buf, 1, satellite_prn, 20); + _mav_put_uint8_t_array(buf, 21, satellite_used, 20); + _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20); + _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20); + _mav_put_uint8_t_array(buf, 81, satellite_snr, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_STATUS_LEN); +#else + mavlink_gps_status_t packet; + packet.satellites_visible = satellites_visible; + mav_array_memcpy(packet.satellite_prn, satellite_prn, sizeof(uint8_t)*20); + mav_array_memcpy(packet.satellite_used, satellite_used, sizeof(uint8_t)*20); + mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20); + mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20); + mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GPS_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN); +#endif +} + /** * @brief Pack a gps_status message on a channel * @param system_id ID of this system @@ -164,6 +210,20 @@ static inline uint16_t mavlink_msg_gps_status_encode_chan(uint8_t system_id, uin return mavlink_msg_gps_status_pack_chan(system_id, component_id, chan, msg, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr); } +/** + * @brief Encode a gps_status struct with provided status structure + * + * @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 gps_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_gps_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status) +{ + return mavlink_msg_gps_status_pack_status(system_id, component_id, _status, msg, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr); +} + /** * @brief Send a gps_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_high_latency.h b/common/mavlink_msg_high_latency.h index 29ae264d..35a6fe02 100644 --- a/common/mavlink_msg_high_latency.h +++ b/common/mavlink_msg_high_latency.h @@ -201,6 +201,108 @@ static inline uint16_t mavlink_msg_high_latency_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIGH_LATENCY_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY_LEN, MAVLINK_MSG_ID_HIGH_LATENCY_CRC); } +/** + * @brief Pack a high_latency 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 base_mode Bitmap of enabled system modes. + * @param custom_mode A bitfield for use for autopilot-specific flags. + * @param landed_state The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknown. + * @param roll [cdeg] roll + * @param pitch [cdeg] pitch + * @param heading [cdeg] heading + * @param throttle [%] throttle (percentage) + * @param heading_sp [cdeg] heading setpoint + * @param latitude [degE7] Latitude + * @param longitude [degE7] Longitude + * @param altitude_amsl [m] Altitude above mean sea level + * @param altitude_sp [m] Altitude setpoint relative to the home position + * @param airspeed [m/s] airspeed + * @param airspeed_sp [m/s] airspeed setpoint + * @param groundspeed [m/s] groundspeed + * @param climb_rate [m/s] climb rate + * @param gps_nsat Number of satellites visible. If unknown, set to UINT8_MAX + * @param gps_fix_type GPS Fix type. + * @param battery_remaining [%] Remaining battery (percentage) + * @param temperature [degC] Autopilot temperature (degrees C) + * @param temperature_air [degC] Air temperature (degrees C) from airspeed sensor + * @param failsafe failsafe (each bit represents a failsafe where 0=ok, 1=failsafe active (bit0:RC, bit1:batt, bit2:GPS, bit3:GCS, bit4:fence) + * @param wp_num current waypoint number + * @param wp_distance [m] distance to target + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_high_latency_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t base_mode, uint32_t custom_mode, uint8_t landed_state, int16_t roll, int16_t pitch, uint16_t heading, int8_t throttle, int16_t heading_sp, int32_t latitude, int32_t longitude, int16_t altitude_amsl, int16_t altitude_sp, uint8_t airspeed, uint8_t airspeed_sp, uint8_t groundspeed, int8_t climb_rate, uint8_t gps_nsat, uint8_t gps_fix_type, uint8_t battery_remaining, int8_t temperature, int8_t temperature_air, uint8_t failsafe, uint8_t wp_num, uint16_t wp_distance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIGH_LATENCY_LEN]; + _mav_put_uint32_t(buf, 0, custom_mode); + _mav_put_int32_t(buf, 4, latitude); + _mav_put_int32_t(buf, 8, longitude); + _mav_put_int16_t(buf, 12, roll); + _mav_put_int16_t(buf, 14, pitch); + _mav_put_uint16_t(buf, 16, heading); + _mav_put_int16_t(buf, 18, heading_sp); + _mav_put_int16_t(buf, 20, altitude_amsl); + _mav_put_int16_t(buf, 22, altitude_sp); + _mav_put_uint16_t(buf, 24, wp_distance); + _mav_put_uint8_t(buf, 26, base_mode); + _mav_put_uint8_t(buf, 27, landed_state); + _mav_put_int8_t(buf, 28, throttle); + _mav_put_uint8_t(buf, 29, airspeed); + _mav_put_uint8_t(buf, 30, airspeed_sp); + _mav_put_uint8_t(buf, 31, groundspeed); + _mav_put_int8_t(buf, 32, climb_rate); + _mav_put_uint8_t(buf, 33, gps_nsat); + _mav_put_uint8_t(buf, 34, gps_fix_type); + _mav_put_uint8_t(buf, 35, battery_remaining); + _mav_put_int8_t(buf, 36, temperature); + _mav_put_int8_t(buf, 37, temperature_air); + _mav_put_uint8_t(buf, 38, failsafe); + _mav_put_uint8_t(buf, 39, wp_num); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGH_LATENCY_LEN); +#else + mavlink_high_latency_t packet; + packet.custom_mode = custom_mode; + packet.latitude = latitude; + packet.longitude = longitude; + packet.roll = roll; + packet.pitch = pitch; + packet.heading = heading; + packet.heading_sp = heading_sp; + packet.altitude_amsl = altitude_amsl; + packet.altitude_sp = altitude_sp; + packet.wp_distance = wp_distance; + packet.base_mode = base_mode; + packet.landed_state = landed_state; + packet.throttle = throttle; + packet.airspeed = airspeed; + packet.airspeed_sp = airspeed_sp; + packet.groundspeed = groundspeed; + packet.climb_rate = climb_rate; + packet.gps_nsat = gps_nsat; + packet.gps_fix_type = gps_fix_type; + packet.battery_remaining = battery_remaining; + packet.temperature = temperature; + packet.temperature_air = temperature_air; + packet.failsafe = failsafe; + packet.wp_num = wp_num; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGH_LATENCY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIGH_LATENCY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGH_LATENCY_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY_LEN, MAVLINK_MSG_ID_HIGH_LATENCY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGH_LATENCY_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY_LEN); +#endif +} + /** * @brief Pack a high_latency message on a channel * @param system_id ID of this system @@ -326,6 +428,20 @@ static inline uint16_t mavlink_msg_high_latency_encode_chan(uint8_t system_id, u return mavlink_msg_high_latency_pack_chan(system_id, component_id, chan, msg, high_latency->base_mode, high_latency->custom_mode, high_latency->landed_state, high_latency->roll, high_latency->pitch, high_latency->heading, high_latency->throttle, high_latency->heading_sp, high_latency->latitude, high_latency->longitude, high_latency->altitude_amsl, high_latency->altitude_sp, high_latency->airspeed, high_latency->airspeed_sp, high_latency->groundspeed, high_latency->climb_rate, high_latency->gps_nsat, high_latency->gps_fix_type, high_latency->battery_remaining, high_latency->temperature, high_latency->temperature_air, high_latency->failsafe, high_latency->wp_num, high_latency->wp_distance); } +/** + * @brief Encode a high_latency struct with provided status structure + * + * @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 high_latency C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_high_latency_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_high_latency_t* high_latency) +{ + return mavlink_msg_high_latency_pack_status(system_id, component_id, _status, msg, high_latency->base_mode, high_latency->custom_mode, high_latency->landed_state, high_latency->roll, high_latency->pitch, high_latency->heading, high_latency->throttle, high_latency->heading_sp, high_latency->latitude, high_latency->longitude, high_latency->altitude_amsl, high_latency->altitude_sp, high_latency->airspeed, high_latency->airspeed_sp, high_latency->groundspeed, high_latency->climb_rate, high_latency->gps_nsat, high_latency->gps_fix_type, high_latency->battery_remaining, high_latency->temperature, high_latency->temperature_air, high_latency->failsafe, high_latency->wp_num, high_latency->wp_distance); +} + /** * @brief Send a high_latency message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_high_latency2.h b/common/mavlink_msg_high_latency2.h index 39d24306..e096a849 100644 --- a/common/mavlink_msg_high_latency2.h +++ b/common/mavlink_msg_high_latency2.h @@ -219,6 +219,117 @@ static inline uint16_t mavlink_msg_high_latency2_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIGH_LATENCY2_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY2_LEN, MAVLINK_MSG_ID_HIGH_LATENCY2_CRC); } +/** + * @brief Pack a high_latency2 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 timestamp [ms] Timestamp (milliseconds since boot or Unix epoch) + * @param type Type of the MAV (quadrotor, helicopter, etc.) + * @param autopilot Autopilot type / class. Use MAV_AUTOPILOT_INVALID for components that are not flight controllers. + * @param custom_mode A bitfield for use for autopilot-specific flags (2 byte version). + * @param latitude [degE7] Latitude + * @param longitude [degE7] Longitude + * @param altitude [m] Altitude above mean sea level + * @param target_altitude [m] Altitude setpoint + * @param heading [deg/2] Heading + * @param target_heading [deg/2] Heading setpoint + * @param target_distance [dam] Distance to target waypoint or position + * @param throttle [%] Throttle + * @param airspeed [m/s*5] Airspeed + * @param airspeed_sp [m/s*5] Airspeed setpoint + * @param groundspeed [m/s*5] Groundspeed + * @param windspeed [m/s*5] Windspeed + * @param wind_heading [deg/2] Wind heading + * @param eph [dm] Maximum error horizontal position since last message + * @param epv [dm] Maximum error vertical position since last message + * @param temperature_air [degC] Air temperature from airspeed sensor + * @param climb_rate [dm/s] Maximum climb rate magnitude since last message + * @param battery [%] Battery level (-1 if field not provided). + * @param wp_num Current waypoint number + * @param failure_flags Bitmap of failure flags. + * @param custom0 Field for custom payload. + * @param custom1 Field for custom payload. + * @param custom2 Field for custom payload. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_high_latency2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t timestamp, uint8_t type, uint8_t autopilot, uint16_t custom_mode, int32_t latitude, int32_t longitude, int16_t altitude, int16_t target_altitude, uint8_t heading, uint8_t target_heading, uint16_t target_distance, uint8_t throttle, uint8_t airspeed, uint8_t airspeed_sp, uint8_t groundspeed, uint8_t windspeed, uint8_t wind_heading, uint8_t eph, uint8_t epv, int8_t temperature_air, int8_t climb_rate, int8_t battery, uint16_t wp_num, uint16_t failure_flags, int8_t custom0, int8_t custom1, int8_t custom2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIGH_LATENCY2_LEN]; + _mav_put_uint32_t(buf, 0, timestamp); + _mav_put_int32_t(buf, 4, latitude); + _mav_put_int32_t(buf, 8, longitude); + _mav_put_uint16_t(buf, 12, custom_mode); + _mav_put_int16_t(buf, 14, altitude); + _mav_put_int16_t(buf, 16, target_altitude); + _mav_put_uint16_t(buf, 18, target_distance); + _mav_put_uint16_t(buf, 20, wp_num); + _mav_put_uint16_t(buf, 22, failure_flags); + _mav_put_uint8_t(buf, 24, type); + _mav_put_uint8_t(buf, 25, autopilot); + _mav_put_uint8_t(buf, 26, heading); + _mav_put_uint8_t(buf, 27, target_heading); + _mav_put_uint8_t(buf, 28, throttle); + _mav_put_uint8_t(buf, 29, airspeed); + _mav_put_uint8_t(buf, 30, airspeed_sp); + _mav_put_uint8_t(buf, 31, groundspeed); + _mav_put_uint8_t(buf, 32, windspeed); + _mav_put_uint8_t(buf, 33, wind_heading); + _mav_put_uint8_t(buf, 34, eph); + _mav_put_uint8_t(buf, 35, epv); + _mav_put_int8_t(buf, 36, temperature_air); + _mav_put_int8_t(buf, 37, climb_rate); + _mav_put_int8_t(buf, 38, battery); + _mav_put_int8_t(buf, 39, custom0); + _mav_put_int8_t(buf, 40, custom1); + _mav_put_int8_t(buf, 41, custom2); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGH_LATENCY2_LEN); +#else + mavlink_high_latency2_t packet; + packet.timestamp = timestamp; + packet.latitude = latitude; + packet.longitude = longitude; + packet.custom_mode = custom_mode; + packet.altitude = altitude; + packet.target_altitude = target_altitude; + packet.target_distance = target_distance; + packet.wp_num = wp_num; + packet.failure_flags = failure_flags; + packet.type = type; + packet.autopilot = autopilot; + packet.heading = heading; + packet.target_heading = target_heading; + packet.throttle = throttle; + packet.airspeed = airspeed; + packet.airspeed_sp = airspeed_sp; + packet.groundspeed = groundspeed; + packet.windspeed = windspeed; + packet.wind_heading = wind_heading; + packet.eph = eph; + packet.epv = epv; + packet.temperature_air = temperature_air; + packet.climb_rate = climb_rate; + packet.battery = battery; + packet.custom0 = custom0; + packet.custom1 = custom1; + packet.custom2 = custom2; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGH_LATENCY2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIGH_LATENCY2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGH_LATENCY2_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY2_LEN, MAVLINK_MSG_ID_HIGH_LATENCY2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGH_LATENCY2_MIN_LEN, MAVLINK_MSG_ID_HIGH_LATENCY2_LEN); +#endif +} + /** * @brief Pack a high_latency2 message on a channel * @param system_id ID of this system @@ -353,6 +464,20 @@ static inline uint16_t mavlink_msg_high_latency2_encode_chan(uint8_t system_id, return mavlink_msg_high_latency2_pack_chan(system_id, component_id, chan, msg, high_latency2->timestamp, high_latency2->type, high_latency2->autopilot, high_latency2->custom_mode, high_latency2->latitude, high_latency2->longitude, high_latency2->altitude, high_latency2->target_altitude, high_latency2->heading, high_latency2->target_heading, high_latency2->target_distance, high_latency2->throttle, high_latency2->airspeed, high_latency2->airspeed_sp, high_latency2->groundspeed, high_latency2->windspeed, high_latency2->wind_heading, high_latency2->eph, high_latency2->epv, high_latency2->temperature_air, high_latency2->climb_rate, high_latency2->battery, high_latency2->wp_num, high_latency2->failure_flags, high_latency2->custom0, high_latency2->custom1, high_latency2->custom2); } +/** + * @brief Encode a high_latency2 struct with provided status structure + * + * @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 high_latency2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_high_latency2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_high_latency2_t* high_latency2) +{ + return mavlink_msg_high_latency2_pack_status(system_id, component_id, _status, msg, high_latency2->timestamp, high_latency2->type, high_latency2->autopilot, high_latency2->custom_mode, high_latency2->latitude, high_latency2->longitude, high_latency2->altitude, high_latency2->target_altitude, high_latency2->heading, high_latency2->target_heading, high_latency2->target_distance, high_latency2->throttle, high_latency2->airspeed, high_latency2->airspeed_sp, high_latency2->groundspeed, high_latency2->windspeed, high_latency2->wind_heading, high_latency2->eph, high_latency2->epv, high_latency2->temperature_air, high_latency2->climb_rate, high_latency2->battery, high_latency2->wp_num, high_latency2->failure_flags, high_latency2->custom0, high_latency2->custom1, high_latency2->custom2); +} + /** * @brief Send a high_latency2 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_highres_imu.h b/common/mavlink_msg_highres_imu.h index 0e34c9be..49fecc70 100644 --- a/common/mavlink_msg_highres_imu.h +++ b/common/mavlink_msg_highres_imu.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_highres_imu_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC); } +/** + * @brief Pack a highres_imu 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param xacc [m/s/s] X acceleration + * @param yacc [m/s/s] Y acceleration + * @param zacc [m/s/s] Z acceleration + * @param xgyro [rad/s] Angular speed around X axis + * @param ygyro [rad/s] Angular speed around Y axis + * @param zgyro [rad/s] Angular speed around Z axis + * @param xmag [gauss] X Magnetic field + * @param ymag [gauss] Y Magnetic field + * @param zmag [gauss] Z Magnetic field + * @param abs_pressure [hPa] Absolute pressure + * @param diff_pressure [hPa] Differential pressure + * @param pressure_alt Altitude calculated from pressure + * @param temperature [degC] Temperature + * @param fields_updated Bitmap for fields that have updated since last message + * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_highres_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated, uint8_t id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIGHRES_IMU_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, xacc); + _mav_put_float(buf, 12, yacc); + _mav_put_float(buf, 16, zacc); + _mav_put_float(buf, 20, xgyro); + _mav_put_float(buf, 24, ygyro); + _mav_put_float(buf, 28, zgyro); + _mav_put_float(buf, 32, xmag); + _mav_put_float(buf, 36, ymag); + _mav_put_float(buf, 40, zmag); + _mav_put_float(buf, 44, abs_pressure); + _mav_put_float(buf, 48, diff_pressure); + _mav_put_float(buf, 52, pressure_alt); + _mav_put_float(buf, 56, temperature); + _mav_put_uint16_t(buf, 60, fields_updated); + _mav_put_uint8_t(buf, 62, id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGHRES_IMU_LEN); +#else + mavlink_highres_imu_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.abs_pressure = abs_pressure; + packet.diff_pressure = diff_pressure; + packet.pressure_alt = pressure_alt; + packet.temperature = temperature; + packet.fields_updated = fields_updated; + packet.id = id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGHRES_IMU_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN); +#endif +} + /** * @brief Pack a highres_imu message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_highres_imu_encode_chan(uint8_t system_id, ui return mavlink_msg_highres_imu_pack_chan(system_id, component_id, chan, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id); } +/** + * @brief Encode a highres_imu struct with provided status structure + * + * @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 highres_imu C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_highres_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_highres_imu_t* highres_imu) +{ + return mavlink_msg_highres_imu_pack_status(system_id, component_id, _status, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id); +} + /** * @brief Send a highres_imu message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_actuator_controls.h b/common/mavlink_msg_hil_actuator_controls.h index 65f55821..314873cc 100644 --- a/common/mavlink_msg_hil_actuator_controls.h +++ b/common/mavlink_msg_hil_actuator_controls.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_hil_actuator_controls_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC); } +/** + * @brief Pack a hil_actuator_controls 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param controls Control outputs -1 .. 1. Channel assignment depends on the simulated hardware. + * @param mode System mode. Includes arming state. + * @param flags Flags as bitfield, 1: indicate simulation using lockstep. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_actuator_controls_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, const float *controls, uint8_t mode, uint64_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint64_t(buf, 8, flags); + _mav_put_uint8_t(buf, 80, mode); + _mav_put_float_array(buf, 16, controls, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN); +#else + mavlink_hil_actuator_controls_t packet; + packet.time_usec = time_usec; + packet.flags = flags; + packet.mode = mode; + mav_array_memcpy(packet.controls, controls, sizeof(float)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS_LEN); +#endif +} + /** * @brief Pack a hil_actuator_controls message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_hil_actuator_controls_encode_chan(uint8_t sys return mavlink_msg_hil_actuator_controls_pack_chan(system_id, component_id, chan, msg, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags); } +/** + * @brief Encode a hil_actuator_controls struct with provided status structure + * + * @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 hil_actuator_controls C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_actuator_controls_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_actuator_controls_t* hil_actuator_controls) +{ + return mavlink_msg_hil_actuator_controls_pack_status(system_id, component_id, _status, msg, hil_actuator_controls->time_usec, hil_actuator_controls->controls, hil_actuator_controls->mode, hil_actuator_controls->flags); +} + /** * @brief Send a hil_actuator_controls message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_controls.h b/common/mavlink_msg_hil_controls.h index 8fc1c411..1a863782 100644 --- a/common/mavlink_msg_hil_controls.h +++ b/common/mavlink_msg_hil_controls.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC); } +/** + * @brief Pack a hil_controls 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param roll_ailerons Control output -1 .. 1 + * @param pitch_elevator Control output -1 .. 1 + * @param yaw_rudder Control output -1 .. 1 + * @param throttle Throttle 0 .. 1 + * @param aux1 Aux 1, -1 .. 1 + * @param aux2 Aux 2, -1 .. 1 + * @param aux3 Aux 3, -1 .. 1 + * @param aux4 Aux 4, -1 .. 1 + * @param mode System mode. + * @param nav_mode Navigation mode (MAV_NAV_MODE) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_controls_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_CONTROLS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, roll_ailerons); + _mav_put_float(buf, 12, pitch_elevator); + _mav_put_float(buf, 16, yaw_rudder); + _mav_put_float(buf, 20, throttle); + _mav_put_float(buf, 24, aux1); + _mav_put_float(buf, 28, aux2); + _mav_put_float(buf, 32, aux3); + _mav_put_float(buf, 36, aux4); + _mav_put_uint8_t(buf, 40, mode); + _mav_put_uint8_t(buf, 41, nav_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_CONTROLS_LEN); +#else + mavlink_hil_controls_t packet; + packet.time_usec = time_usec; + packet.roll_ailerons = roll_ailerons; + packet.pitch_elevator = pitch_elevator; + packet.yaw_rudder = yaw_rudder; + packet.throttle = throttle; + packet.aux1 = aux1; + packet.aux2 = aux2; + packet.aux3 = aux3; + packet.aux4 = aux4; + packet.mode = mode; + packet.nav_mode = nav_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_CONTROLS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_CONTROLS_MIN_LEN, MAVLINK_MSG_ID_HIL_CONTROLS_LEN); +#endif +} + /** * @brief Pack a hil_controls message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_hil_controls_encode_chan(uint8_t system_id, u return mavlink_msg_hil_controls_pack_chan(system_id, component_id, chan, msg, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode); } +/** + * @brief Encode a hil_controls struct with provided status structure + * + * @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 hil_controls C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_controls_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_controls_t* hil_controls) +{ + return mavlink_msg_hil_controls_pack_status(system_id, component_id, _status, msg, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode); +} + /** * @brief Send a hil_controls message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_gps.h b/common/mavlink_msg_hil_gps.h index aa198380..da4367ea 100644 --- a/common/mavlink_msg_hil_gps.h +++ b/common/mavlink_msg_hil_gps.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_hil_gps_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC); } +/** + * @brief Pack a hil_gps 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix. + * @param lat [degE7] Latitude (WGS84) + * @param lon [degE7] Longitude (WGS84) + * @param alt [mm] Altitude (MSL). Positive for up. + * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX + * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX + * @param vn [cm/s] GPS velocity in north direction in earth-fixed NED frame + * @param ve [cm/s] GPS velocity in east direction in earth-fixed NED frame + * @param vd [cm/s] GPS velocity in down direction in earth-fixed NED frame + * @param cog [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: UINT16_MAX + * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX + * @param id GPS ID (zero indexed). Used for multiple GPS inputs + * @param yaw [cdeg] Yaw of vehicle relative to Earth's North, zero means not available, use 36000 for north + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_gps_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, int16_t vn, int16_t ve, int16_t vd, uint16_t cog, uint8_t satellites_visible, uint8_t id, uint16_t yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_GPS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_int32_t(buf, 16, alt); + _mav_put_uint16_t(buf, 20, eph); + _mav_put_uint16_t(buf, 22, epv); + _mav_put_uint16_t(buf, 24, vel); + _mav_put_int16_t(buf, 26, vn); + _mav_put_int16_t(buf, 28, ve); + _mav_put_int16_t(buf, 30, vd); + _mav_put_uint16_t(buf, 32, cog); + _mav_put_uint8_t(buf, 34, fix_type); + _mav_put_uint8_t(buf, 35, satellites_visible); + _mav_put_uint8_t(buf, 36, id); + _mav_put_uint16_t(buf, 37, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_GPS_LEN); +#else + mavlink_hil_gps_t packet; + packet.time_usec = time_usec; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.eph = eph; + packet.epv = epv; + packet.vel = vel; + packet.vn = vn; + packet.ve = ve; + packet.vd = vd; + packet.cog = cog; + packet.fix_type = fix_type; + packet.satellites_visible = satellites_visible; + packet.id = id; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_GPS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_GPS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN); +#endif +} + /** * @brief Pack a hil_gps message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_hil_gps_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_hil_gps_pack_chan(system_id, component_id, chan, msg, hil_gps->time_usec, hil_gps->fix_type, hil_gps->lat, hil_gps->lon, hil_gps->alt, hil_gps->eph, hil_gps->epv, hil_gps->vel, hil_gps->vn, hil_gps->ve, hil_gps->vd, hil_gps->cog, hil_gps->satellites_visible, hil_gps->id, hil_gps->yaw); } +/** + * @brief Encode a hil_gps struct with provided status structure + * + * @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 hil_gps C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_gps_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_gps_t* hil_gps) +{ + return mavlink_msg_hil_gps_pack_status(system_id, component_id, _status, msg, hil_gps->time_usec, hil_gps->fix_type, hil_gps->lat, hil_gps->lon, hil_gps->alt, hil_gps->eph, hil_gps->epv, hil_gps->vel, hil_gps->vn, hil_gps->ve, hil_gps->vd, hil_gps->cog, hil_gps->satellites_visible, hil_gps->id, hil_gps->yaw); +} + /** * @brief Send a hil_gps message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_optical_flow.h b/common/mavlink_msg_hil_optical_flow.h index de0ec247..68becc7d 100644 --- a/common/mavlink_msg_hil_optical_flow.h +++ b/common/mavlink_msg_hil_optical_flow.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_hil_optical_flow_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC); } +/** + * @brief Pack a hil_optical_flow 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param sensor_id Sensor ID + * @param integration_time_us [us] Integration time. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the. + * @param integrated_x [rad] Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.) + * @param integrated_y [rad] Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.) + * @param integrated_xgyro [rad] RH rotation around X axis + * @param integrated_ygyro [rad] RH rotation around Y axis + * @param integrated_zgyro [rad] RH rotation around Z axis + * @param temperature [cdegC] Temperature + * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality + * @param time_delta_distance_us [us] Time since the distance was sampled. + * @param distance [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_optical_flow_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t sensor_id, uint32_t integration_time_us, float integrated_x, float integrated_y, float integrated_xgyro, float integrated_ygyro, float integrated_zgyro, int16_t temperature, uint8_t quality, uint32_t time_delta_distance_us, float distance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, integration_time_us); + _mav_put_float(buf, 12, integrated_x); + _mav_put_float(buf, 16, integrated_y); + _mav_put_float(buf, 20, integrated_xgyro); + _mav_put_float(buf, 24, integrated_ygyro); + _mav_put_float(buf, 28, integrated_zgyro); + _mav_put_uint32_t(buf, 32, time_delta_distance_us); + _mav_put_float(buf, 36, distance); + _mav_put_int16_t(buf, 40, temperature); + _mav_put_uint8_t(buf, 42, sensor_id); + _mav_put_uint8_t(buf, 43, quality); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN); +#else + mavlink_hil_optical_flow_t packet; + packet.time_usec = time_usec; + packet.integration_time_us = integration_time_us; + packet.integrated_x = integrated_x; + packet.integrated_y = integrated_y; + packet.integrated_xgyro = integrated_xgyro; + packet.integrated_ygyro = integrated_ygyro; + packet.integrated_zgyro = integrated_zgyro; + packet.time_delta_distance_us = time_delta_distance_us; + packet.distance = distance; + packet.temperature = temperature; + packet.sensor_id = sensor_id; + packet.quality = quality; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN); +#endif +} + /** * @brief Pack a hil_optical_flow message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_hil_optical_flow_encode_chan(uint8_t system_i return mavlink_msg_hil_optical_flow_pack_chan(system_id, component_id, chan, msg, hil_optical_flow->time_usec, hil_optical_flow->sensor_id, hil_optical_flow->integration_time_us, hil_optical_flow->integrated_x, hil_optical_flow->integrated_y, hil_optical_flow->integrated_xgyro, hil_optical_flow->integrated_ygyro, hil_optical_flow->integrated_zgyro, hil_optical_flow->temperature, hil_optical_flow->quality, hil_optical_flow->time_delta_distance_us, hil_optical_flow->distance); } +/** + * @brief Encode a hil_optical_flow struct with provided status structure + * + * @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 hil_optical_flow C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_optical_flow_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_optical_flow_t* hil_optical_flow) +{ + return mavlink_msg_hil_optical_flow_pack_status(system_id, component_id, _status, msg, hil_optical_flow->time_usec, hil_optical_flow->sensor_id, hil_optical_flow->integration_time_us, hil_optical_flow->integrated_x, hil_optical_flow->integrated_y, hil_optical_flow->integrated_xgyro, hil_optical_flow->integrated_ygyro, hil_optical_flow->integrated_zgyro, hil_optical_flow->temperature, hil_optical_flow->quality, hil_optical_flow->time_delta_distance_us, hil_optical_flow->distance); +} + /** * @brief Send a hil_optical_flow message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_rc_inputs_raw.h b/common/mavlink_msg_hil_rc_inputs_raw.h index 78cad3fd..2c571c02 100644 --- a/common/mavlink_msg_hil_rc_inputs_raw.h +++ b/common/mavlink_msg_hil_rc_inputs_raw.h @@ -141,6 +141,78 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_MIN_LEN, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_CRC); } +/** + * @brief Pack a hil_rc_inputs_raw 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param chan1_raw [us] RC channel 1 value + * @param chan2_raw [us] RC channel 2 value + * @param chan3_raw [us] RC channel 3 value + * @param chan4_raw [us] RC channel 4 value + * @param chan5_raw [us] RC channel 5 value + * @param chan6_raw [us] RC channel 6 value + * @param chan7_raw [us] RC channel 7 value + * @param chan8_raw [us] RC channel 8 value + * @param chan9_raw [us] RC channel 9 value + * @param chan10_raw [us] RC channel 10 value + * @param chan11_raw [us] RC channel 11 value + * @param chan12_raw [us] RC channel 12 value + * @param rssi Receive signal strength indicator in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint16_t chan9_raw, uint16_t chan10_raw, uint16_t chan11_raw, uint16_t chan12_raw, uint8_t rssi) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint16_t(buf, 8, chan1_raw); + _mav_put_uint16_t(buf, 10, chan2_raw); + _mav_put_uint16_t(buf, 12, chan3_raw); + _mav_put_uint16_t(buf, 14, chan4_raw); + _mav_put_uint16_t(buf, 16, chan5_raw); + _mav_put_uint16_t(buf, 18, chan6_raw); + _mav_put_uint16_t(buf, 20, chan7_raw); + _mav_put_uint16_t(buf, 22, chan8_raw); + _mav_put_uint16_t(buf, 24, chan9_raw); + _mav_put_uint16_t(buf, 26, chan10_raw); + _mav_put_uint16_t(buf, 28, chan11_raw); + _mav_put_uint16_t(buf, 30, chan12_raw); + _mav_put_uint8_t(buf, 32, rssi); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN); +#else + mavlink_hil_rc_inputs_raw_t packet; + packet.time_usec = time_usec; + packet.chan1_raw = chan1_raw; + packet.chan2_raw = chan2_raw; + packet.chan3_raw = chan3_raw; + packet.chan4_raw = chan4_raw; + packet.chan5_raw = chan5_raw; + packet.chan6_raw = chan6_raw; + packet.chan7_raw = chan7_raw; + packet.chan8_raw = chan8_raw; + packet.chan9_raw = chan9_raw; + packet.chan10_raw = chan10_raw; + packet.chan11_raw = chan11_raw; + packet.chan12_raw = chan12_raw; + packet.rssi = rssi; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_MIN_LEN, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_MIN_LEN, MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW_LEN); +#endif +} + /** * @brief Pack a hil_rc_inputs_raw message on a channel * @param system_id ID of this system @@ -236,6 +308,20 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_encode_chan(uint8_t system_ return mavlink_msg_hil_rc_inputs_raw_pack_chan(system_id, component_id, chan, msg, hil_rc_inputs_raw->time_usec, hil_rc_inputs_raw->chan1_raw, hil_rc_inputs_raw->chan2_raw, hil_rc_inputs_raw->chan3_raw, hil_rc_inputs_raw->chan4_raw, hil_rc_inputs_raw->chan5_raw, hil_rc_inputs_raw->chan6_raw, hil_rc_inputs_raw->chan7_raw, hil_rc_inputs_raw->chan8_raw, hil_rc_inputs_raw->chan9_raw, hil_rc_inputs_raw->chan10_raw, hil_rc_inputs_raw->chan11_raw, hil_rc_inputs_raw->chan12_raw, hil_rc_inputs_raw->rssi); } +/** + * @brief Encode a hil_rc_inputs_raw struct with provided status structure + * + * @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 hil_rc_inputs_raw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_rc_inputs_raw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_rc_inputs_raw_t* hil_rc_inputs_raw) +{ + return mavlink_msg_hil_rc_inputs_raw_pack_status(system_id, component_id, _status, msg, hil_rc_inputs_raw->time_usec, hil_rc_inputs_raw->chan1_raw, hil_rc_inputs_raw->chan2_raw, hil_rc_inputs_raw->chan3_raw, hil_rc_inputs_raw->chan4_raw, hil_rc_inputs_raw->chan5_raw, hil_rc_inputs_raw->chan6_raw, hil_rc_inputs_raw->chan7_raw, hil_rc_inputs_raw->chan8_raw, hil_rc_inputs_raw->chan9_raw, hil_rc_inputs_raw->chan10_raw, hil_rc_inputs_raw->chan11_raw, hil_rc_inputs_raw->chan12_raw, hil_rc_inputs_raw->rssi); +} + /** * @brief Send a hil_rc_inputs_raw message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_sensor.h b/common/mavlink_msg_hil_sensor.h index 28c10c7e..d56243aa 100644 --- a/common/mavlink_msg_hil_sensor.h +++ b/common/mavlink_msg_hil_sensor.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_hil_sensor_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC); } +/** + * @brief Pack a hil_sensor 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param xacc [m/s/s] X acceleration + * @param yacc [m/s/s] Y acceleration + * @param zacc [m/s/s] Z acceleration + * @param xgyro [rad/s] Angular speed around X axis in body frame + * @param ygyro [rad/s] Angular speed around Y axis in body frame + * @param zgyro [rad/s] Angular speed around Z axis in body frame + * @param xmag [gauss] X Magnetic field + * @param ymag [gauss] Y Magnetic field + * @param zmag [gauss] Z Magnetic field + * @param abs_pressure [hPa] Absolute pressure + * @param diff_pressure [hPa] Differential pressure (airspeed) + * @param pressure_alt Altitude calculated from pressure + * @param temperature [degC] Temperature + * @param fields_updated Bitmap for fields that have updated since last message + * @param id Sensor ID (zero indexed). Used for multiple sensor inputs + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_sensor_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint32_t fields_updated, uint8_t id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, xacc); + _mav_put_float(buf, 12, yacc); + _mav_put_float(buf, 16, zacc); + _mav_put_float(buf, 20, xgyro); + _mav_put_float(buf, 24, ygyro); + _mav_put_float(buf, 28, zgyro); + _mav_put_float(buf, 32, xmag); + _mav_put_float(buf, 36, ymag); + _mav_put_float(buf, 40, zmag); + _mav_put_float(buf, 44, abs_pressure); + _mav_put_float(buf, 48, diff_pressure); + _mav_put_float(buf, 52, pressure_alt); + _mav_put_float(buf, 56, temperature); + _mav_put_uint32_t(buf, 60, fields_updated); + _mav_put_uint8_t(buf, 64, id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN); +#else + mavlink_hil_sensor_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.abs_pressure = abs_pressure; + packet.diff_pressure = diff_pressure; + packet.pressure_alt = pressure_alt; + packet.temperature = temperature; + packet.fields_updated = fields_updated; + packet.id = id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN); +#endif +} + /** * @brief Pack a hil_sensor message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_hil_sensor_encode_chan(uint8_t system_id, uin return mavlink_msg_hil_sensor_pack_chan(system_id, component_id, chan, msg, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id); } +/** + * @brief Encode a hil_sensor struct with provided status structure + * + * @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 hil_sensor C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_sensor_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_sensor_t* hil_sensor) +{ + return mavlink_msg_hil_sensor_pack_status(system_id, component_id, _status, msg, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id); +} + /** * @brief Send a hil_sensor message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_state.h b/common/mavlink_msg_hil_state.h index 4766c920..67035718 100644 --- a/common/mavlink_msg_hil_state.h +++ b/common/mavlink_msg_hil_state.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC); } +/** + * @brief Pack a hil_state 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param roll [rad] Roll angle + * @param pitch [rad] Pitch angle + * @param yaw [rad] Yaw angle + * @param rollspeed [rad/s] Body frame roll / phi angular speed + * @param pitchspeed [rad/s] Body frame pitch / theta angular speed + * @param yawspeed [rad/s] Body frame yaw / psi angular speed + * @param lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param alt [mm] Altitude + * @param vx [cm/s] Ground X Speed (Latitude) + * @param vy [cm/s] Ground Y Speed (Longitude) + * @param vz [cm/s] Ground Z Speed (Altitude) + * @param xacc [mG] X acceleration + * @param yacc [mG] Y acceleration + * @param zacc [mG] Z acceleration + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_STATE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, roll); + _mav_put_float(buf, 12, pitch); + _mav_put_float(buf, 16, yaw); + _mav_put_float(buf, 20, rollspeed); + _mav_put_float(buf, 24, pitchspeed); + _mav_put_float(buf, 28, yawspeed); + _mav_put_int32_t(buf, 32, lat); + _mav_put_int32_t(buf, 36, lon); + _mav_put_int32_t(buf, 40, alt); + _mav_put_int16_t(buf, 44, vx); + _mav_put_int16_t(buf, 46, vy); + _mav_put_int16_t(buf, 48, vz); + _mav_put_int16_t(buf, 50, xacc); + _mav_put_int16_t(buf, 52, yacc); + _mav_put_int16_t(buf, 54, zacc); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN); +#else + mavlink_hil_state_t packet; + packet.time_usec = time_usec; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_STATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN); +#endif +} + /** * @brief Pack a hil_state message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_hil_state_encode_chan(uint8_t system_id, uint return mavlink_msg_hil_state_pack_chan(system_id, component_id, chan, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc); } +/** + * @brief Encode a hil_state struct with provided status structure + * + * @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 hil_state C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state) +{ + return mavlink_msg_hil_state_pack_status(system_id, component_id, _status, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc); +} + /** * @brief Send a hil_state message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hil_state_quaternion.h b/common/mavlink_msg_hil_state_quaternion.h index 856603c5..ac8daa6f 100644 --- a/common/mavlink_msg_hil_state_quaternion.h +++ b/common/mavlink_msg_hil_state_quaternion.h @@ -151,6 +151,82 @@ static inline uint16_t mavlink_msg_hil_state_quaternion_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_CRC); } +/** + * @brief Pack a hil_state_quaternion 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param attitude_quaternion Vehicle attitude expressed as normalized quaternion in w, x, y, z order (with 1 0 0 0 being the null-rotation) + * @param rollspeed [rad/s] Body frame roll / phi angular speed + * @param pitchspeed [rad/s] Body frame pitch / theta angular speed + * @param yawspeed [rad/s] Body frame yaw / psi angular speed + * @param lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param alt [mm] Altitude + * @param vx [cm/s] Ground X Speed (Latitude) + * @param vy [cm/s] Ground Y Speed (Longitude) + * @param vz [cm/s] Ground Z Speed (Altitude) + * @param ind_airspeed [cm/s] Indicated airspeed + * @param true_airspeed [cm/s] True airspeed + * @param xacc [mG] X acceleration + * @param yacc [mG] Y acceleration + * @param zacc [mG] Z acceleration + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hil_state_quaternion_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, const float *attitude_quaternion, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, uint16_t ind_airspeed, uint16_t true_airspeed, int16_t xacc, int16_t yacc, int16_t zacc) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 24, rollspeed); + _mav_put_float(buf, 28, pitchspeed); + _mav_put_float(buf, 32, yawspeed); + _mav_put_int32_t(buf, 36, lat); + _mav_put_int32_t(buf, 40, lon); + _mav_put_int32_t(buf, 44, alt); + _mav_put_int16_t(buf, 48, vx); + _mav_put_int16_t(buf, 50, vy); + _mav_put_int16_t(buf, 52, vz); + _mav_put_uint16_t(buf, 54, ind_airspeed); + _mav_put_uint16_t(buf, 56, true_airspeed); + _mav_put_int16_t(buf, 58, xacc); + _mav_put_int16_t(buf, 60, yacc); + _mav_put_int16_t(buf, 62, zacc); + _mav_put_float_array(buf, 8, attitude_quaternion, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN); +#else + mavlink_hil_state_quaternion_t packet; + packet.time_usec = time_usec; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.ind_airspeed = ind_airspeed; + packet.true_airspeed = true_airspeed; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + mav_array_memcpy(packet.attitude_quaternion, attitude_quaternion, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIL_STATE_QUATERNION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_QUATERNION_LEN); +#endif +} + /** * @brief Pack a hil_state_quaternion message on a channel * @param system_id ID of this system @@ -250,6 +326,20 @@ static inline uint16_t mavlink_msg_hil_state_quaternion_encode_chan(uint8_t syst return mavlink_msg_hil_state_quaternion_pack_chan(system_id, component_id, chan, msg, hil_state_quaternion->time_usec, hil_state_quaternion->attitude_quaternion, hil_state_quaternion->rollspeed, hil_state_quaternion->pitchspeed, hil_state_quaternion->yawspeed, hil_state_quaternion->lat, hil_state_quaternion->lon, hil_state_quaternion->alt, hil_state_quaternion->vx, hil_state_quaternion->vy, hil_state_quaternion->vz, hil_state_quaternion->ind_airspeed, hil_state_quaternion->true_airspeed, hil_state_quaternion->xacc, hil_state_quaternion->yacc, hil_state_quaternion->zacc); } +/** + * @brief Encode a hil_state_quaternion struct with provided status structure + * + * @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 hil_state_quaternion C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hil_state_quaternion_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_state_quaternion_t* hil_state_quaternion) +{ + return mavlink_msg_hil_state_quaternion_pack_status(system_id, component_id, _status, msg, hil_state_quaternion->time_usec, hil_state_quaternion->attitude_quaternion, hil_state_quaternion->rollspeed, hil_state_quaternion->pitchspeed, hil_state_quaternion->yawspeed, hil_state_quaternion->lat, hil_state_quaternion->lon, hil_state_quaternion->alt, hil_state_quaternion->vx, hil_state_quaternion->vy, hil_state_quaternion->vz, hil_state_quaternion->ind_airspeed, hil_state_quaternion->true_airspeed, hil_state_quaternion->xacc, hil_state_quaternion->yacc, hil_state_quaternion->zacc); +} + /** * @brief Send a hil_state_quaternion message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_home_position.h b/common/mavlink_msg_home_position.h index 7041396e..b220664b 100644 --- a/common/mavlink_msg_home_position.h +++ b/common/mavlink_msg_home_position.h @@ -129,6 +129,71 @@ static inline uint16_t mavlink_msg_home_position_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC); } +/** + * @brief Pack a home_position 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 latitude [degE7] Latitude (WGS84) + * @param longitude [degE7] Longitude (WGS84) + * @param altitude [mm] Altitude (MSL). Positive for up. + * @param x [m] Local X position of this position in the local coordinate frame (NED) + * @param y [m] Local Y position of this position in the local coordinate frame (NED) + * @param z [m] Local Z position of this position in the local coordinate frame (NED: positive "down") + * @param q + Quaternion indicating world-to-surface-normal and heading transformation of the takeoff position. + Used to indicate the heading and slope of the ground. + All fields should be set to NaN if an accurate quaternion for both heading and surface slope cannot be supplied. + + * @param approach_x [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param approach_y [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param approach_z [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_home_position_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t latitude, int32_t longitude, int32_t altitude, float x, float y, float z, const float *q, float approach_x, float approach_y, float approach_z, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HOME_POSITION_LEN]; + _mav_put_int32_t(buf, 0, latitude); + _mav_put_int32_t(buf, 4, longitude); + _mav_put_int32_t(buf, 8, altitude); + _mav_put_float(buf, 12, x); + _mav_put_float(buf, 16, y); + _mav_put_float(buf, 20, z); + _mav_put_float(buf, 40, approach_x); + _mav_put_float(buf, 44, approach_y); + _mav_put_float(buf, 48, approach_z); + _mav_put_uint64_t(buf, 52, time_usec); + _mav_put_float_array(buf, 24, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HOME_POSITION_LEN); +#else + mavlink_home_position_t packet; + packet.latitude = latitude; + packet.longitude = longitude; + packet.altitude = altitude; + packet.x = x; + packet.y = y; + packet.z = z; + packet.approach_x = approach_x; + packet.approach_y = approach_y; + packet.approach_z = approach_z; + packet.time_usec = time_usec; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HOME_POSITION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HOME_POSITION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN, MAVLINK_MSG_ID_HOME_POSITION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_HOME_POSITION_LEN); +#endif +} + /** * @brief Pack a home_position message on a channel * @param system_id ID of this system @@ -217,6 +282,20 @@ static inline uint16_t mavlink_msg_home_position_encode_chan(uint8_t system_id, return mavlink_msg_home_position_pack_chan(system_id, component_id, chan, msg, home_position->latitude, home_position->longitude, home_position->altitude, home_position->x, home_position->y, home_position->z, home_position->q, home_position->approach_x, home_position->approach_y, home_position->approach_z, home_position->time_usec); } +/** + * @brief Encode a home_position struct with provided status structure + * + * @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 home_position C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_home_position_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_home_position_t* home_position) +{ + return mavlink_msg_home_position_pack_status(system_id, component_id, _status, msg, home_position->latitude, home_position->longitude, home_position->altitude, home_position->x, home_position->y, home_position->z, home_position->q, home_position->approach_x, home_position->approach_y, home_position->approach_z, home_position->time_usec); +} + /** * @brief Send a home_position message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_hygrometer_sensor.h b/common/mavlink_msg_hygrometer_sensor.h index 0ae784ff..a9d027b2 100644 --- a/common/mavlink_msg_hygrometer_sensor.h +++ b/common/mavlink_msg_hygrometer_sensor.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_hygrometer_sensor_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HYGROMETER_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN, MAVLINK_MSG_ID_HYGROMETER_SENSOR_CRC); } +/** + * @brief Pack a hygrometer_sensor 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 id Hygrometer ID + * @param temperature [cdegC] Temperature + * @param humidity [c%] Humidity + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hygrometer_sensor_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, int16_t temperature, uint16_t humidity) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN]; + _mav_put_int16_t(buf, 0, temperature); + _mav_put_uint16_t(buf, 2, humidity); + _mav_put_uint8_t(buf, 4, id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN); +#else + mavlink_hygrometer_sensor_t packet; + packet.temperature = temperature; + packet.humidity = humidity; + packet.id = id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HYGROMETER_SENSOR; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HYGROMETER_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN, MAVLINK_MSG_ID_HYGROMETER_SENSOR_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HYGROMETER_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HYGROMETER_SENSOR_LEN); +#endif +} + /** * @brief Pack a hygrometer_sensor message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_hygrometer_sensor_encode_chan(uint8_t system_ return mavlink_msg_hygrometer_sensor_pack_chan(system_id, component_id, chan, msg, hygrometer_sensor->id, hygrometer_sensor->temperature, hygrometer_sensor->humidity); } +/** + * @brief Encode a hygrometer_sensor struct with provided status structure + * + * @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 hygrometer_sensor C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hygrometer_sensor_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hygrometer_sensor_t* hygrometer_sensor) +{ + return mavlink_msg_hygrometer_sensor_pack_status(system_id, component_id, _status, msg, hygrometer_sensor->id, hygrometer_sensor->temperature, hygrometer_sensor->humidity); +} + /** * @brief Send a hygrometer_sensor message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_isbd_link_status.h b/common/mavlink_msg_isbd_link_status.h index 7273e11a..893a8377 100644 --- a/common/mavlink_msg_isbd_link_status.h +++ b/common/mavlink_msg_isbd_link_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_isbd_link_status_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ISBD_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN, MAVLINK_MSG_ID_ISBD_LINK_STATUS_CRC); } +/** + * @brief Pack a isbd_link_status 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 timestamp [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param last_heartbeat [us] Timestamp of the last successful sbd session. The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param failed_sessions Number of failed SBD sessions. + * @param successful_sessions Number of successful SBD sessions. + * @param signal_quality Signal quality equal to the number of bars displayed on the ISU signal strength indicator. Range is 0 to 5, where 0 indicates no signal and 5 indicates maximum signal strength. + * @param ring_pending 1: Ring call pending, 0: No call pending. + * @param tx_session_pending 1: Transmission session pending, 0: No transmission session pending. + * @param rx_session_pending 1: Receiving session pending, 0: No receiving session pending. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_isbd_link_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint64_t last_heartbeat, uint16_t failed_sessions, uint16_t successful_sessions, uint8_t signal_quality, uint8_t ring_pending, uint8_t tx_session_pending, uint8_t rx_session_pending) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint64_t(buf, 8, last_heartbeat); + _mav_put_uint16_t(buf, 16, failed_sessions); + _mav_put_uint16_t(buf, 18, successful_sessions); + _mav_put_uint8_t(buf, 20, signal_quality); + _mav_put_uint8_t(buf, 21, ring_pending); + _mav_put_uint8_t(buf, 22, tx_session_pending); + _mav_put_uint8_t(buf, 23, rx_session_pending); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN); +#else + mavlink_isbd_link_status_t packet; + packet.timestamp = timestamp; + packet.last_heartbeat = last_heartbeat; + packet.failed_sessions = failed_sessions; + packet.successful_sessions = successful_sessions; + packet.signal_quality = signal_quality; + packet.ring_pending = ring_pending; + packet.tx_session_pending = tx_session_pending; + packet.rx_session_pending = rx_session_pending; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ISBD_LINK_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ISBD_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN, MAVLINK_MSG_ID_ISBD_LINK_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ISBD_LINK_STATUS_MIN_LEN, MAVLINK_MSG_ID_ISBD_LINK_STATUS_LEN); +#endif +} + /** * @brief Pack a isbd_link_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_isbd_link_status_encode_chan(uint8_t system_i return mavlink_msg_isbd_link_status_pack_chan(system_id, component_id, chan, msg, isbd_link_status->timestamp, isbd_link_status->last_heartbeat, isbd_link_status->failed_sessions, isbd_link_status->successful_sessions, isbd_link_status->signal_quality, isbd_link_status->ring_pending, isbd_link_status->tx_session_pending, isbd_link_status->rx_session_pending); } +/** + * @brief Encode a isbd_link_status struct with provided status structure + * + * @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 isbd_link_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_isbd_link_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_isbd_link_status_t* isbd_link_status) +{ + return mavlink_msg_isbd_link_status_pack_status(system_id, component_id, _status, msg, isbd_link_status->timestamp, isbd_link_status->last_heartbeat, isbd_link_status->failed_sessions, isbd_link_status->successful_sessions, isbd_link_status->signal_quality, isbd_link_status->ring_pending, isbd_link_status->tx_session_pending, isbd_link_status->rx_session_pending); +} + /** * @brief Send a isbd_link_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_landing_target.h b/common/mavlink_msg_landing_target.h index 1de2d9ef..0e480b85 100644 --- a/common/mavlink_msg_landing_target.h +++ b/common/mavlink_msg_landing_target.h @@ -139,6 +139,76 @@ static inline uint16_t mavlink_msg_landing_target_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC); } +/** + * @brief Pack a landing_target 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param target_num The ID of the target if multiple targets are present + * @param frame Coordinate frame used for following fields. + * @param angle_x [rad] X-axis angular offset of the target from the center of the image + * @param angle_y [rad] Y-axis angular offset of the target from the center of the image + * @param distance [m] Distance to the target from the vehicle + * @param size_x [rad] Size of target along x-axis + * @param size_y [rad] Size of target along y-axis + * @param x [m] X Position of the landing target in MAV_FRAME + * @param y [m] Y Position of the landing target in MAV_FRAME + * @param z [m] Z Position of the landing target in MAV_FRAME + * @param q Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param type Type of landing target + * @param position_valid Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_landing_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y, float x, float y, float z, const float *q, uint8_t type, uint8_t position_valid) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, angle_x); + _mav_put_float(buf, 12, angle_y); + _mav_put_float(buf, 16, distance); + _mav_put_float(buf, 20, size_x); + _mav_put_float(buf, 24, size_y); + _mav_put_uint8_t(buf, 28, target_num); + _mav_put_uint8_t(buf, 29, frame); + _mav_put_float(buf, 30, x); + _mav_put_float(buf, 34, y); + _mav_put_float(buf, 38, z); + _mav_put_uint8_t(buf, 58, type); + _mav_put_uint8_t(buf, 59, position_valid); + _mav_put_float_array(buf, 42, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN); +#else + mavlink_landing_target_t packet; + packet.time_usec = time_usec; + packet.angle_x = angle_x; + packet.angle_y = angle_y; + packet.distance = distance; + packet.size_x = size_x; + packet.size_y = size_y; + packet.target_num = target_num; + packet.frame = frame; + packet.x = x; + packet.y = y; + packet.z = z; + packet.type = type; + packet.position_valid = position_valid; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN); +#endif +} + /** * @brief Pack a landing_target message on a channel * @param system_id ID of this system @@ -232,6 +302,20 @@ static inline uint16_t mavlink_msg_landing_target_encode_chan(uint8_t system_id, return mavlink_msg_landing_target_pack_chan(system_id, component_id, chan, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid); } +/** + * @brief Encode a landing_target struct with provided status structure + * + * @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 landing_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_landing_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target) +{ + return mavlink_msg_landing_target_pack_status(system_id, component_id, _status, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid); +} + /** * @brief Send a landing_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_link_node_status.h b/common/mavlink_msg_link_node_status.h index 927118f8..ee21a165 100644 --- a/common/mavlink_msg_link_node_status.h +++ b/common/mavlink_msg_link_node_status.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_link_node_status_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LINK_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN, MAVLINK_MSG_ID_LINK_NODE_STATUS_CRC); } +/** + * @brief Pack a link_node_status 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 timestamp [ms] Timestamp (time since system boot). + * @param tx_buf [%] Remaining free transmit buffer space + * @param rx_buf [%] Remaining free receive buffer space + * @param tx_rate [bytes/s] Transmit rate + * @param rx_rate [bytes/s] Receive rate + * @param rx_parse_err [bytes] Number of bytes that could not be parsed correctly. + * @param tx_overflows [bytes] Transmit buffer overflows. This number wraps around as it reaches UINT16_MAX + * @param rx_overflows [bytes] Receive buffer overflows. This number wraps around as it reaches UINT16_MAX + * @param messages_sent Messages sent + * @param messages_received Messages received (estimated from counting seq) + * @param messages_lost Messages lost (estimated from counting seq) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_link_node_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t tx_buf, uint8_t rx_buf, uint32_t tx_rate, uint32_t rx_rate, uint16_t rx_parse_err, uint16_t tx_overflows, uint16_t rx_overflows, uint32_t messages_sent, uint32_t messages_received, uint32_t messages_lost) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_uint32_t(buf, 8, tx_rate); + _mav_put_uint32_t(buf, 12, rx_rate); + _mav_put_uint32_t(buf, 16, messages_sent); + _mav_put_uint32_t(buf, 20, messages_received); + _mav_put_uint32_t(buf, 24, messages_lost); + _mav_put_uint16_t(buf, 28, rx_parse_err); + _mav_put_uint16_t(buf, 30, tx_overflows); + _mav_put_uint16_t(buf, 32, rx_overflows); + _mav_put_uint8_t(buf, 34, tx_buf); + _mav_put_uint8_t(buf, 35, rx_buf); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN); +#else + mavlink_link_node_status_t packet; + packet.timestamp = timestamp; + packet.tx_rate = tx_rate; + packet.rx_rate = rx_rate; + packet.messages_sent = messages_sent; + packet.messages_received = messages_received; + packet.messages_lost = messages_lost; + packet.rx_parse_err = rx_parse_err; + packet.tx_overflows = tx_overflows; + packet.rx_overflows = rx_overflows; + packet.tx_buf = tx_buf; + packet.rx_buf = rx_buf; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LINK_NODE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LINK_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN, MAVLINK_MSG_ID_LINK_NODE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LINK_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_LINK_NODE_STATUS_LEN); +#endif +} + /** * @brief Pack a link_node_status message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_link_node_status_encode_chan(uint8_t system_i return mavlink_msg_link_node_status_pack_chan(system_id, component_id, chan, msg, link_node_status->timestamp, link_node_status->tx_buf, link_node_status->rx_buf, link_node_status->tx_rate, link_node_status->rx_rate, link_node_status->rx_parse_err, link_node_status->tx_overflows, link_node_status->rx_overflows, link_node_status->messages_sent, link_node_status->messages_received, link_node_status->messages_lost); } +/** + * @brief Encode a link_node_status struct with provided status structure + * + * @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 link_node_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_link_node_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_link_node_status_t* link_node_status) +{ + return mavlink_msg_link_node_status_pack_status(system_id, component_id, _status, msg, link_node_status->timestamp, link_node_status->tx_buf, link_node_status->rx_buf, link_node_status->tx_rate, link_node_status->rx_rate, link_node_status->rx_parse_err, link_node_status->tx_overflows, link_node_status->rx_overflows, link_node_status->messages_sent, link_node_status->messages_received, link_node_status->messages_lost); +} + /** * @brief Send a link_node_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_local_position_ned.h b/common/mavlink_msg_local_position_ned.h index a84fca84..4ecb9947 100644 --- a/common/mavlink_msg_local_position_ned.h +++ b/common/mavlink_msg_local_position_ned.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_local_position_ned_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC); } +/** + * @brief Pack a local_position_ned 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param x [m] X Position + * @param y [m] Y Position + * @param z [m] Z Position + * @param vx [m/s] X Speed + * @param vy [m/s] Y Speed + * @param vz [m/s] Z Speed + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_local_position_ned_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, vx); + _mav_put_float(buf, 20, vy); + _mav_put_float(buf, 24, vz); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN); +#else + mavlink_local_position_ned_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN); +#endif +} + /** * @brief Pack a local_position_ned message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_local_position_ned_encode_chan(uint8_t system return mavlink_msg_local_position_ned_pack_chan(system_id, component_id, chan, msg, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz); } +/** + * @brief Encode a local_position_ned struct with provided status structure + * + * @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 local_position_ned C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_local_position_ned_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_local_position_ned_t* local_position_ned) +{ + return mavlink_msg_local_position_ned_pack_status(system_id, component_id, _status, msg, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz); +} + /** * @brief Send a local_position_ned message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_local_position_ned_cov.h b/common/mavlink_msg_local_position_ned_cov.h index b7eeba49..d4d76f7d 100644 --- a/common/mavlink_msg_local_position_ned_cov.h +++ b/common/mavlink_msg_local_position_ned_cov.h @@ -127,6 +127,70 @@ static inline uint16_t mavlink_msg_local_position_ned_cov_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_CRC); } +/** + * @brief Pack a local_position_ned_cov 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param estimator_type Class id of the estimator this estimate originated from. + * @param x [m] X Position + * @param y [m] Y Position + * @param z [m] Z Position + * @param vx [m/s] X Speed + * @param vy [m/s] Y Speed + * @param vz [m/s] Z Speed + * @param ax [m/s/s] X Acceleration + * @param ay [m/s/s] Y Acceleration + * @param az [m/s/s] Z Acceleration + * @param covariance Row-major representation of position, velocity and acceleration 9x9 cross-covariance matrix upper right triangle (states: x, y, z, vx, vy, vz, ax, ay, az; first nine entries are the first ROW, next eight entries are the second row, etc.). If unknown, assign NaN value to first element in the array. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_local_position_ned_cov_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t estimator_type, float x, float y, float z, float vx, float vy, float vz, float ax, float ay, float az, const float *covariance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 20, vx); + _mav_put_float(buf, 24, vy); + _mav_put_float(buf, 28, vz); + _mav_put_float(buf, 32, ax); + _mav_put_float(buf, 36, ay); + _mav_put_float(buf, 40, az); + _mav_put_uint8_t(buf, 224, estimator_type); + _mav_put_float_array(buf, 44, covariance, 45); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN); +#else + mavlink_local_position_ned_cov_t packet; + packet.time_usec = time_usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.ax = ax; + packet.ay = ay; + packet.az = az; + packet.estimator_type = estimator_type; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*45); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV_LEN); +#endif +} + /** * @brief Pack a local_position_ned_cov message on a channel * @param system_id ID of this system @@ -214,6 +278,20 @@ static inline uint16_t mavlink_msg_local_position_ned_cov_encode_chan(uint8_t sy return mavlink_msg_local_position_ned_cov_pack_chan(system_id, component_id, chan, msg, local_position_ned_cov->time_usec, local_position_ned_cov->estimator_type, local_position_ned_cov->x, local_position_ned_cov->y, local_position_ned_cov->z, local_position_ned_cov->vx, local_position_ned_cov->vy, local_position_ned_cov->vz, local_position_ned_cov->ax, local_position_ned_cov->ay, local_position_ned_cov->az, local_position_ned_cov->covariance); } +/** + * @brief Encode a local_position_ned_cov struct with provided status structure + * + * @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 local_position_ned_cov C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_local_position_ned_cov_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_local_position_ned_cov_t* local_position_ned_cov) +{ + return mavlink_msg_local_position_ned_cov_pack_status(system_id, component_id, _status, msg, local_position_ned_cov->time_usec, local_position_ned_cov->estimator_type, local_position_ned_cov->x, local_position_ned_cov->y, local_position_ned_cov->z, local_position_ned_cov->vx, local_position_ned_cov->vy, local_position_ned_cov->vz, local_position_ned_cov->ax, local_position_ned_cov->ay, local_position_ned_cov->az, local_position_ned_cov->covariance); +} + /** * @brief Send a local_position_ned_cov message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_local_position_ned_system_global_offset.h b/common/mavlink_msg_local_position_ned_system_global_offset.h index 30fbab19..bb1ef6c2 100644 --- a/common/mavlink_msg_local_position_ned_system_global_offset.h +++ b/common/mavlink_msg_local_position_ned_system_global_offset.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_pack( return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_CRC); } +/** + * @brief Pack a local_position_ned_system_global_offset 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param x [m] X Position + * @param y [m] Y Position + * @param z [m] Z Position + * @param roll [rad] Roll + * @param pitch [rad] Pitch + * @param yaw [rad] Yaw + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float x, float y, float z, float roll, float pitch, float yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN); +#else + mavlink_local_position_ned_system_global_offset_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN); +#endif +} + /** * @brief Pack a local_position_ned_system_global_offset message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_encod return mavlink_msg_local_position_ned_system_global_offset_pack_chan(system_id, component_id, chan, msg, local_position_ned_system_global_offset->time_boot_ms, local_position_ned_system_global_offset->x, local_position_ned_system_global_offset->y, local_position_ned_system_global_offset->z, local_position_ned_system_global_offset->roll, local_position_ned_system_global_offset->pitch, local_position_ned_system_global_offset->yaw); } +/** + * @brief Encode a local_position_ned_system_global_offset struct with provided status structure + * + * @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 local_position_ned_system_global_offset C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_local_position_ned_system_global_offset_t* local_position_ned_system_global_offset) +{ + return mavlink_msg_local_position_ned_system_global_offset_pack_status(system_id, component_id, _status, msg, local_position_ned_system_global_offset->time_boot_ms, local_position_ned_system_global_offset->x, local_position_ned_system_global_offset->y, local_position_ned_system_global_offset->z, local_position_ned_system_global_offset->roll, local_position_ned_system_global_offset->pitch, local_position_ned_system_global_offset->yaw); +} + /** * @brief Send a local_position_ned_system_global_offset message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_data.h b/common/mavlink_msg_log_data.h index 6f879cd2..ef54a674 100644 --- a/common/mavlink_msg_log_data.h +++ b/common/mavlink_msg_log_data.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_log_data_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC); } +/** + * @brief Pack a log_data 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 id Log id (from LOG_ENTRY reply) + * @param ofs Offset into the log + * @param count [bytes] Number of bytes (zero for end of log) + * @param data log data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t id, uint32_t ofs, uint8_t count, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_DATA_LEN]; + _mav_put_uint32_t(buf, 0, ofs); + _mav_put_uint16_t(buf, 4, id); + _mav_put_uint8_t(buf, 6, count); + _mav_put_uint8_t_array(buf, 7, data, 90); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_DATA_LEN); +#else + mavlink_log_data_t packet; + packet.ofs = ofs; + packet.id = id; + packet.count = count; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN); +#endif +} + /** * @brief Pack a log_data message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_log_data_encode_chan(uint8_t system_id, uint8 return mavlink_msg_log_data_pack_chan(system_id, component_id, chan, msg, log_data->id, log_data->ofs, log_data->count, log_data->data); } +/** + * @brief Encode a log_data struct with provided status structure + * + * @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 log_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_data_t* log_data) +{ + return mavlink_msg_log_data_pack_status(system_id, component_id, _status, msg, log_data->id, log_data->ofs, log_data->count, log_data->data); +} + /** * @brief Send a log_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_entry.h b/common/mavlink_msg_log_entry.h index 6fb0048a..01fd64e6 100644 --- a/common/mavlink_msg_log_entry.h +++ b/common/mavlink_msg_log_entry.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_log_entry_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC); } +/** + * @brief Pack a log_entry 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 id Log id + * @param num_logs Total number of logs + * @param last_log_num High log number + * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available + * @param size [bytes] Size of the log (may be approximate) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_entry_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t id, uint16_t num_logs, uint16_t last_log_num, uint32_t time_utc, uint32_t size) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN]; + _mav_put_uint32_t(buf, 0, time_utc); + _mav_put_uint32_t(buf, 4, size); + _mav_put_uint16_t(buf, 8, id); + _mav_put_uint16_t(buf, 10, num_logs); + _mav_put_uint16_t(buf, 12, last_log_num); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ENTRY_LEN); +#else + mavlink_log_entry_t packet; + packet.time_utc = time_utc; + packet.size = size; + packet.id = id; + packet.num_logs = num_logs; + packet.last_log_num = last_log_num; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ENTRY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_ENTRY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN); +#endif +} + /** * @brief Pack a log_entry message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_log_entry_encode_chan(uint8_t system_id, uint return mavlink_msg_log_entry_pack_chan(system_id, component_id, chan, msg, log_entry->id, log_entry->num_logs, log_entry->last_log_num, log_entry->time_utc, log_entry->size); } +/** + * @brief Encode a log_entry struct with provided status structure + * + * @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 log_entry C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_entry_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_entry_t* log_entry) +{ + return mavlink_msg_log_entry_pack_status(system_id, component_id, _status, msg, log_entry->id, log_entry->num_logs, log_entry->last_log_num, log_entry->time_utc, log_entry->size); +} + /** * @brief Send a log_entry message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_erase.h b/common/mavlink_msg_log_erase.h index 1dec9e29..2627ec66 100644 --- a/common/mavlink_msg_log_erase.h +++ b/common/mavlink_msg_log_erase.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_log_erase_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); } +/** + * @brief Pack a log_erase 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_erase_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ERASE_LEN); +#else + mavlink_log_erase_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ERASE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_ERASE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN); +#endif +} + /** * @brief Pack a log_erase message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_log_erase_encode_chan(uint8_t system_id, uint return mavlink_msg_log_erase_pack_chan(system_id, component_id, chan, msg, log_erase->target_system, log_erase->target_component); } +/** + * @brief Encode a log_erase struct with provided status structure + * + * @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 log_erase C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_erase_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_erase_t* log_erase) +{ + return mavlink_msg_log_erase_pack_status(system_id, component_id, _status, msg, log_erase->target_system, log_erase->target_component); +} + /** * @brief Send a log_erase message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_request_data.h b/common/mavlink_msg_log_request_data.h index 6cc0cfb7..46802c50 100644 --- a/common/mavlink_msg_log_request_data.h +++ b/common/mavlink_msg_log_request_data.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_log_request_data_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_REQUEST_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN, MAVLINK_MSG_ID_LOG_REQUEST_DATA_CRC); } +/** + * @brief Pack a log_request_data 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 target_system System ID + * @param target_component Component ID + * @param id Log id (from LOG_ENTRY reply) + * @param ofs Offset into the log + * @param count [bytes] Number of bytes + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_request_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t id, uint32_t ofs, uint32_t count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN]; + _mav_put_uint32_t(buf, 0, ofs); + _mav_put_uint32_t(buf, 4, count); + _mav_put_uint16_t(buf, 8, id); + _mav_put_uint8_t(buf, 10, target_system); + _mav_put_uint8_t(buf, 11, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN); +#else + mavlink_log_request_data_t packet; + packet.ofs = ofs; + packet.count = count; + packet.id = id; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN, MAVLINK_MSG_ID_LOG_REQUEST_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_DATA_LEN); +#endif +} + /** * @brief Pack a log_request_data message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_log_request_data_encode_chan(uint8_t system_i return mavlink_msg_log_request_data_pack_chan(system_id, component_id, chan, msg, log_request_data->target_system, log_request_data->target_component, log_request_data->id, log_request_data->ofs, log_request_data->count); } +/** + * @brief Encode a log_request_data struct with provided status structure + * + * @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 log_request_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_request_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_request_data_t* log_request_data) +{ + return mavlink_msg_log_request_data_pack_status(system_id, component_id, _status, msg, log_request_data->target_system, log_request_data->target_component, log_request_data->id, log_request_data->ofs, log_request_data->count); +} + /** * @brief Send a log_request_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_request_end.h b/common/mavlink_msg_log_request_end.h index 387a7c09..1db8103a 100644 --- a/common/mavlink_msg_log_request_end.h +++ b/common/mavlink_msg_log_request_end.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_log_request_end_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); } +/** + * @brief Pack a log_request_end 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_request_end_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); +#else + mavlink_log_request_end_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_END; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); +#endif +} + /** * @brief Pack a log_request_end message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_log_request_end_encode_chan(uint8_t system_id return mavlink_msg_log_request_end_pack_chan(system_id, component_id, chan, msg, log_request_end->target_system, log_request_end->target_component); } +/** + * @brief Encode a log_request_end struct with provided status structure + * + * @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 log_request_end C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_request_end_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_request_end_t* log_request_end) +{ + return mavlink_msg_log_request_end_pack_status(system_id, component_id, _status, msg, log_request_end->target_system, log_request_end->target_component); +} + /** * @brief Send a log_request_end message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_log_request_list.h b/common/mavlink_msg_log_request_list.h index de193356..f25cd56c 100644 --- a/common/mavlink_msg_log_request_list.h +++ b/common/mavlink_msg_log_request_list.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_log_request_list_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN, MAVLINK_MSG_ID_LOG_REQUEST_LIST_CRC); } +/** + * @brief Pack a log_request_list 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 target_system System ID + * @param target_component Component ID + * @param start First log id (0 for first available) + * @param end Last log id (0xffff for last available) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_log_request_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t start, uint16_t end) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN]; + _mav_put_uint16_t(buf, 0, start); + _mav_put_uint16_t(buf, 2, end); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN); +#else + mavlink_log_request_list_t packet; + packet.start = start; + packet.end = end; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN, MAVLINK_MSG_ID_LOG_REQUEST_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOG_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_LIST_LEN); +#endif +} + /** * @brief Pack a log_request_list message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_log_request_list_encode_chan(uint8_t system_i return mavlink_msg_log_request_list_pack_chan(system_id, component_id, chan, msg, log_request_list->target_system, log_request_list->target_component, log_request_list->start, log_request_list->end); } +/** + * @brief Encode a log_request_list struct with provided status structure + * + * @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 log_request_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_log_request_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_log_request_list_t* log_request_list) +{ + return mavlink_msg_log_request_list_pack_status(system_id, component_id, _status, msg, log_request_list->target_system, log_request_list->target_component, log_request_list->start, log_request_list->end); +} + /** * @brief Send a log_request_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_logging_ack.h b/common/mavlink_msg_logging_ack.h index 66471061..b1fae2af 100644 --- a/common/mavlink_msg_logging_ack.h +++ b/common/mavlink_msg_logging_ack.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_logging_ack_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOGGING_ACK_MIN_LEN, MAVLINK_MSG_ID_LOGGING_ACK_LEN, MAVLINK_MSG_ID_LOGGING_ACK_CRC); } +/** + * @brief Pack a logging_ack 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 target_system system ID of the target + * @param target_component component ID of the target + * @param sequence sequence number (must match the one in LOGGING_DATA_ACKED) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_logging_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t sequence) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOGGING_ACK_LEN]; + _mav_put_uint16_t(buf, 0, sequence); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_ACK_LEN); +#else + mavlink_logging_ack_t packet; + packet.sequence = sequence; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOGGING_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_ACK_MIN_LEN, MAVLINK_MSG_ID_LOGGING_ACK_LEN, MAVLINK_MSG_ID_LOGGING_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_ACK_MIN_LEN, MAVLINK_MSG_ID_LOGGING_ACK_LEN); +#endif +} + /** * @brief Pack a logging_ack message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_logging_ack_encode_chan(uint8_t system_id, ui return mavlink_msg_logging_ack_pack_chan(system_id, component_id, chan, msg, logging_ack->target_system, logging_ack->target_component, logging_ack->sequence); } +/** + * @brief Encode a logging_ack struct with provided status structure + * + * @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 logging_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_logging_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_logging_ack_t* logging_ack) +{ + return mavlink_msg_logging_ack_pack_status(system_id, component_id, _status, msg, logging_ack->target_system, logging_ack->target_component, logging_ack->sequence); +} + /** * @brief Send a logging_ack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_logging_data.h b/common/mavlink_msg_logging_data.h index fa2fa235..bd680ee7 100644 --- a/common/mavlink_msg_logging_data.h +++ b/common/mavlink_msg_logging_data.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_logging_data_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC); } +/** + * @brief Pack a logging_data 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 target_system system ID of the target + * @param target_component component ID of the target + * @param sequence sequence number (can wrap) + * @param length [bytes] data length + * @param first_message_offset [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to UINT8_MAX if no start exists). + * @param data logged data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_logging_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN]; + _mav_put_uint16_t(buf, 0, sequence); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, length); + _mav_put_uint8_t(buf, 5, first_message_offset); + _mav_put_uint8_t_array(buf, 6, data, 249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_LEN); +#else + mavlink_logging_data_t packet; + packet.sequence = sequence; + packet.target_system = target_system; + packet.target_component = target_component; + packet.length = length; + packet.first_message_offset = first_message_offset; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN); +#endif +} + /** * @brief Pack a logging_data message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_logging_data_encode_chan(uint8_t system_id, u return mavlink_msg_logging_data_pack_chan(system_id, component_id, chan, msg, logging_data->target_system, logging_data->target_component, logging_data->sequence, logging_data->length, logging_data->first_message_offset, logging_data->data); } +/** + * @brief Encode a logging_data struct with provided status structure + * + * @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 logging_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_logging_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_logging_data_t* logging_data) +{ + return mavlink_msg_logging_data_pack_status(system_id, component_id, _status, msg, logging_data->target_system, logging_data->target_component, logging_data->sequence, logging_data->length, logging_data->first_message_offset, logging_data->data); +} + /** * @brief Send a logging_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_logging_data_acked.h b/common/mavlink_msg_logging_data_acked.h index 15618d5b..c277a579 100644 --- a/common/mavlink_msg_logging_data_acked.h +++ b/common/mavlink_msg_logging_data_acked.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_logging_data_acked_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_CRC); } +/** + * @brief Pack a logging_data_acked 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 target_system system ID of the target + * @param target_component component ID of the target + * @param sequence sequence number (can wrap) + * @param length [bytes] data length + * @param first_message_offset [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to UINT8_MAX if no start exists). + * @param data logged data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_logging_data_acked_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN]; + _mav_put_uint16_t(buf, 0, sequence); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, length); + _mav_put_uint8_t(buf, 5, first_message_offset); + _mav_put_uint8_t_array(buf, 6, data, 249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN); +#else + mavlink_logging_data_acked_t packet; + packet.sequence = sequence; + packet.target_system = target_system; + packet.target_component = target_component; + packet.length = length; + packet.first_message_offset = first_message_offset; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA_ACKED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_ACKED_LEN); +#endif +} + /** * @brief Pack a logging_data_acked message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_logging_data_acked_encode_chan(uint8_t system return mavlink_msg_logging_data_acked_pack_chan(system_id, component_id, chan, msg, logging_data_acked->target_system, logging_data_acked->target_component, logging_data_acked->sequence, logging_data_acked->length, logging_data_acked->first_message_offset, logging_data_acked->data); } +/** + * @brief Encode a logging_data_acked struct with provided status structure + * + * @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 logging_data_acked C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_logging_data_acked_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_logging_data_acked_t* logging_data_acked) +{ + return mavlink_msg_logging_data_acked_pack_status(system_id, component_id, _status, msg, logging_data_acked->target_system, logging_data_acked->target_component, logging_data_acked->sequence, logging_data_acked->length, logging_data_acked->first_message_offset, logging_data_acked->data); +} + /** * @brief Send a logging_data_acked message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mag_cal_report.h b/common/mavlink_msg_mag_cal_report.h index 43e0a750..750d1e91 100644 --- a/common/mavlink_msg_mag_cal_report.h +++ b/common/mavlink_msg_mag_cal_report.h @@ -165,6 +165,90 @@ static inline uint16_t mavlink_msg_mag_cal_report_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC); } +/** + * @brief Pack a mag_cal_report 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 compass_id Compass being calibrated. + * @param cal_mask Bitmask of compasses being calibrated. + * @param cal_status Calibration Status. + * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters. + * @param fitness [mgauss] RMS milligauss residuals. + * @param ofs_x X offset. + * @param ofs_y Y offset. + * @param ofs_z Z offset. + * @param diag_x X diagonal (matrix 11). + * @param diag_y Y diagonal (matrix 22). + * @param diag_z Z diagonal (matrix 33). + * @param offdiag_x X off-diagonal (matrix 12 and 21). + * @param offdiag_y Y off-diagonal (matrix 13 and 31). + * @param offdiag_z Z off-diagonal (matrix 32 and 23). + * @param orientation_confidence Confidence in orientation (higher is better). + * @param old_orientation orientation before calibration. + * @param new_orientation orientation after calibration. + * @param scale_factor field radius correction factor + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mag_cal_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN]; + _mav_put_float(buf, 0, fitness); + _mav_put_float(buf, 4, ofs_x); + _mav_put_float(buf, 8, ofs_y); + _mav_put_float(buf, 12, ofs_z); + _mav_put_float(buf, 16, diag_x); + _mav_put_float(buf, 20, diag_y); + _mav_put_float(buf, 24, diag_z); + _mav_put_float(buf, 28, offdiag_x); + _mav_put_float(buf, 32, offdiag_y); + _mav_put_float(buf, 36, offdiag_z); + _mav_put_uint8_t(buf, 40, compass_id); + _mav_put_uint8_t(buf, 41, cal_mask); + _mav_put_uint8_t(buf, 42, cal_status); + _mav_put_uint8_t(buf, 43, autosaved); + _mav_put_float(buf, 44, orientation_confidence); + _mav_put_uint8_t(buf, 48, old_orientation); + _mav_put_uint8_t(buf, 49, new_orientation); + _mav_put_float(buf, 50, scale_factor); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN); +#else + mavlink_mag_cal_report_t packet; + packet.fitness = fitness; + packet.ofs_x = ofs_x; + packet.ofs_y = ofs_y; + packet.ofs_z = ofs_z; + packet.diag_x = diag_x; + packet.diag_y = diag_y; + packet.diag_z = diag_z; + packet.offdiag_x = offdiag_x; + packet.offdiag_y = offdiag_y; + packet.offdiag_z = offdiag_z; + packet.compass_id = compass_id; + packet.cal_mask = cal_mask; + packet.cal_status = cal_status; + packet.autosaved = autosaved; + packet.orientation_confidence = orientation_confidence; + packet.old_orientation = old_orientation; + packet.new_orientation = new_orientation; + packet.scale_factor = scale_factor; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MAG_CAL_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN); +#endif +} + /** * @brief Pack a mag_cal_report message on a channel * @param system_id ID of this system @@ -272,6 +356,20 @@ static inline uint16_t mavlink_msg_mag_cal_report_encode_chan(uint8_t system_id, return mavlink_msg_mag_cal_report_pack_chan(system_id, component_id, chan, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor); } +/** + * @brief Encode a mag_cal_report struct with provided status structure + * + * @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 mag_cal_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mag_cal_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report) +{ + return mavlink_msg_mag_cal_report_pack_status(system_id, component_id, _status, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor); +} + /** * @brief Send a mag_cal_report message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_manual_control.h b/common/mavlink_msg_manual_control.h index 0ef34414..d2b1e38b 100644 --- a/common/mavlink_msg_manual_control.h +++ b/common/mavlink_msg_manual_control.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC); } +/** + * @brief Pack a manual_control 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 target The system to be controlled. + * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust. + * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + * @param buttons A bitfield corresponding to the joystick buttons' 0-15 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. + * @param buttons2 A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16. + * @param enabled_extensions Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6 + * @param s Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid. + * @param t Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid. + * @param aux1 Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset. + * @param aux2 Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset. + * @param aux3 Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset. + * @param aux4 Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset. + * @param aux5 Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset. + * @param aux6 Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_manual_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons, uint16_t buttons2, uint8_t enabled_extensions, int16_t s, int16_t t, int16_t aux1, int16_t aux2, int16_t aux3, int16_t aux4, int16_t aux5, int16_t aux6) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN]; + _mav_put_int16_t(buf, 0, x); + _mav_put_int16_t(buf, 2, y); + _mav_put_int16_t(buf, 4, z); + _mav_put_int16_t(buf, 6, r); + _mav_put_uint16_t(buf, 8, buttons); + _mav_put_uint8_t(buf, 10, target); + _mav_put_uint16_t(buf, 11, buttons2); + _mav_put_uint8_t(buf, 13, enabled_extensions); + _mav_put_int16_t(buf, 14, s); + _mav_put_int16_t(buf, 16, t); + _mav_put_int16_t(buf, 18, aux1); + _mav_put_int16_t(buf, 20, aux2); + _mav_put_int16_t(buf, 22, aux3); + _mav_put_int16_t(buf, 24, aux4); + _mav_put_int16_t(buf, 26, aux5); + _mav_put_int16_t(buf, 28, aux6); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN); +#else + mavlink_manual_control_t packet; + packet.x = x; + packet.y = y; + packet.z = z; + packet.r = r; + packet.buttons = buttons; + packet.target = target; + packet.buttons2 = buttons2; + packet.enabled_extensions = enabled_extensions; + packet.s = s; + packet.t = t; + packet.aux1 = aux1; + packet.aux2 = aux2; + packet.aux3 = aux3; + packet.aux4 = aux4; + packet.aux5 = aux5; + packet.aux6 = aux6; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN); +#endif +} + /** * @brief Pack a manual_control message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_manual_control_encode_chan(uint8_t system_id, return mavlink_msg_manual_control_pack_chan(system_id, component_id, chan, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons, manual_control->buttons2, manual_control->enabled_extensions, manual_control->s, manual_control->t, manual_control->aux1, manual_control->aux2, manual_control->aux3, manual_control->aux4, manual_control->aux5, manual_control->aux6); } +/** + * @brief Encode a manual_control struct with provided status structure + * + * @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 manual_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_manual_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control) +{ + return mavlink_msg_manual_control_pack_status(system_id, component_id, _status, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons, manual_control->buttons2, manual_control->enabled_extensions, manual_control->s, manual_control->t, manual_control->aux1, manual_control->aux2, manual_control->aux3, manual_control->aux4, manual_control->aux5, manual_control->aux6); +} + /** * @brief Send a manual_control message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_manual_setpoint.h b/common/mavlink_msg_manual_setpoint.h index 09e5041c..7ec60201 100644 --- a/common/mavlink_msg_manual_setpoint.h +++ b/common/mavlink_msg_manual_setpoint.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_manual_setpoint_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC); } +/** + * @brief Pack a manual_setpoint 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param roll [rad/s] Desired roll rate + * @param pitch [rad/s] Desired pitch rate + * @param yaw [rad/s] Desired yaw rate + * @param thrust Collective thrust, normalized to 0 .. 1 + * @param mode_switch Flight mode switch position, 0.. 255 + * @param manual_override_switch Override mode switch position, 0.. 255 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_manual_setpoint_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, thrust); + _mav_put_uint8_t(buf, 20, mode_switch); + _mav_put_uint8_t(buf, 21, manual_override_switch); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN); +#else + mavlink_manual_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.thrust = thrust; + packet.mode_switch = mode_switch; + packet.manual_override_switch = manual_override_switch; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MANUAL_SETPOINT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MANUAL_SETPOINT_MIN_LEN, MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN); +#endif +} + /** * @brief Pack a manual_setpoint message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_manual_setpoint_encode_chan(uint8_t system_id return mavlink_msg_manual_setpoint_pack_chan(system_id, component_id, chan, msg, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch); } +/** + * @brief Encode a manual_setpoint struct with provided status structure + * + * @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 manual_setpoint C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_manual_setpoint_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_manual_setpoint_t* manual_setpoint) +{ + return mavlink_msg_manual_setpoint_pack_status(system_id, component_id, _status, msg, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch); +} + /** * @brief Send a manual_setpoint message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_memory_vect.h b/common/mavlink_msg_memory_vect.h index 61a73862..c3ef3e5d 100644 --- a/common/mavlink_msg_memory_vect.h +++ b/common/mavlink_msg_memory_vect.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_memory_vect_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC); } +/** + * @brief Pack a memory_vect 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 address Starting address of the debug variables + * @param ver Version code of the type variable. 0=unknown, type ignored and assumed int16_t. 1=as below + * @param type Type code of the memory variables. for ver = 1: 0=16 x int16_t, 1=16 x uint16_t, 2=16 x Q15, 3=16 x 1Q14 + * @param value Memory contents at specified address + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_memory_vect_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t address, uint8_t ver, uint8_t type, const int8_t *value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MEMORY_VECT_LEN]; + _mav_put_uint16_t(buf, 0, address); + _mav_put_uint8_t(buf, 2, ver); + _mav_put_uint8_t(buf, 3, type); + _mav_put_int8_t_array(buf, 4, value, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MEMORY_VECT_LEN); +#else + mavlink_memory_vect_t packet; + packet.address = address; + packet.ver = ver; + packet.type = type; + mav_array_memcpy(packet.value, value, sizeof(int8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MEMORY_VECT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN, MAVLINK_MSG_ID_MEMORY_VECT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MEMORY_VECT_MIN_LEN, MAVLINK_MSG_ID_MEMORY_VECT_LEN); +#endif +} + /** * @brief Pack a memory_vect message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_memory_vect_encode_chan(uint8_t system_id, ui return mavlink_msg_memory_vect_pack_chan(system_id, component_id, chan, msg, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value); } +/** + * @brief Encode a memory_vect struct with provided status structure + * + * @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 memory_vect C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_memory_vect_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_memory_vect_t* memory_vect) +{ + return mavlink_msg_memory_vect_pack_status(system_id, component_id, _status, msg, memory_vect->address, memory_vect->ver, memory_vect->type, memory_vect->value); +} + /** * @brief Send a memory_vect message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_message_interval.h b/common/mavlink_msg_message_interval.h index 5a94a182..2e14cfdd 100644 --- a/common/mavlink_msg_message_interval.h +++ b/common/mavlink_msg_message_interval.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_message_interval_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC); } +/** + * @brief Pack a message_interval 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 message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages. + * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_message_interval_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t message_id, int32_t interval_us) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN]; + _mav_put_int32_t(buf, 0, interval_us); + _mav_put_uint16_t(buf, 4, message_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN); +#else + mavlink_message_interval_t packet; + packet.interval_us = interval_us; + packet.message_id = message_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MESSAGE_INTERVAL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN); +#endif +} + /** * @brief Pack a message_interval message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_message_interval_encode_chan(uint8_t system_i return mavlink_msg_message_interval_pack_chan(system_id, component_id, chan, msg, message_interval->message_id, message_interval->interval_us); } +/** + * @brief Encode a message_interval struct with provided status structure + * + * @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 message_interval C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_message_interval_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval) +{ + return mavlink_msg_message_interval_pack_status(system_id, component_id, _status, msg, message_interval->message_id, message_interval->interval_us); +} + /** * @brief Send a message_interval message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_ack.h b/common/mavlink_msg_mission_ack.h index 2294c3bb..62def0a3 100644 --- a/common/mavlink_msg_mission_ack.h +++ b/common/mavlink_msg_mission_ack.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); } +/** + * @brief Pack a mission_ack 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 target_system System ID + * @param target_component Component ID + * @param type Mission result. + * @param mission_type Mission type. + * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle). + The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS. + The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique). + 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT). + 0 if plan ids are not supported. + The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded. + + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, type); + _mav_put_uint8_t(buf, 3, mission_type); + _mav_put_uint32_t(buf, 4, opaque_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN); +#else + mavlink_mission_ack_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.type = type; + packet.mission_type = mission_type; + packet.opaque_id = opaque_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN); +#endif +} + /** * @brief Pack a mission_ack message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_mission_ack_encode_chan(uint8_t system_id, ui return mavlink_msg_mission_ack_pack_chan(system_id, component_id, chan, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id); } +/** + * @brief Encode a mission_ack struct with provided status structure + * + * @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 mission_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack) +{ + return mavlink_msg_mission_ack_pack_status(system_id, component_id, _status, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id); +} + /** * @brief Send a mission_ack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_clear_all.h b/common/mavlink_msg_mission_clear_all.h index 724ea126..8d359c7d 100644 --- a/common/mavlink_msg_mission_clear_all.h +++ b/common/mavlink_msg_mission_clear_all.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_mission_clear_all_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); } +/** + * @brief Pack a mission_clear_all 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 target_system System ID + * @param target_component Component ID + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_clear_all_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); +#else + mavlink_mission_clear_all_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_CLEAR_ALL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_MIN_LEN, MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN); +#endif +} + /** * @brief Pack a mission_clear_all message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_mission_clear_all_encode_chan(uint8_t system_ return mavlink_msg_mission_clear_all_pack_chan(system_id, component_id, chan, msg, mission_clear_all->target_system, mission_clear_all->target_component, mission_clear_all->mission_type); } +/** + * @brief Encode a mission_clear_all struct with provided status structure + * + * @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 mission_clear_all C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_clear_all_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_clear_all_t* mission_clear_all) +{ + return mavlink_msg_mission_clear_all_pack_status(system_id, component_id, _status, msg, mission_clear_all->target_system, mission_clear_all->target_component, mission_clear_all->mission_type); +} + /** * @brief Send a mission_clear_all message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_count.h b/common/mavlink_msg_mission_count.h index 3c3e2d9a..635fc314 100644 --- a/common/mavlink_msg_mission_count.h +++ b/common/mavlink_msg_mission_count.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_mission_count_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC); } +/** + * @brief Pack a mission_count 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 target_system System ID + * @param target_component Component ID + * @param count Number of mission items in the sequence + * @param mission_type Mission type. + * @param opaque_id Id of current on-vehicle mission, fence, or rally point plan (on download from vehicle). + This field is used when downloading a plan from a vehicle to a GCS. + 0 on upload to the vehicle from GCS. + 0 if plan ids are not supported. + The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded. + The ids are recalculated by the vehicle when any part of the on-vehicle plan changes (when a new plan is uploaded, the vehicle returns the new id to the GCS in MISSION_ACK). + + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_count_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t count, uint8_t mission_type, uint32_t opaque_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_COUNT_LEN]; + _mav_put_uint16_t(buf, 0, count); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, mission_type); + _mav_put_uint32_t(buf, 5, opaque_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_COUNT_LEN); +#else + mavlink_mission_count_t packet; + packet.count = count; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + packet.opaque_id = opaque_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_COUNT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_COUNT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN, MAVLINK_MSG_ID_MISSION_COUNT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_COUNT_MIN_LEN, MAVLINK_MSG_ID_MISSION_COUNT_LEN); +#endif +} + /** * @brief Pack a mission_count message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_mission_count_encode_chan(uint8_t system_id, return mavlink_msg_mission_count_pack_chan(system_id, component_id, chan, msg, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id); } +/** + * @brief Encode a mission_count struct with provided status structure + * + * @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 mission_count C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_count_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_count_t* mission_count) +{ + return mavlink_msg_mission_count_pack_status(system_id, component_id, _status, msg, mission_count->target_system, mission_count->target_component, mission_count->count, mission_count->mission_type, mission_count->opaque_id); +} + /** * @brief Send a mission_count message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_current.h b/common/mavlink_msg_mission_current.h index 60537415..bbb2dfcd 100644 --- a/common/mavlink_msg_mission_current.h +++ b/common/mavlink_msg_mission_current.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_mission_current_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); } +/** + * @brief Pack a mission_current 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 seq Sequence + * @param total Total number of mission items on vehicle (on last item, sequence == total). If the autopilot stores its home location as part of the mission this will be excluded from the total. 0: Not supported, UINT16_MAX if no mission is present on the vehicle. + * @param mission_state Mission state machine state. MISSION_STATE_UNKNOWN if state reporting not supported. + * @param mission_mode Vehicle is in a mode that can execute mission items or suspended. 0: Unknown, 1: In mission mode, 2: Suspended (not in mission mode). + * @param mission_id Id of current on-vehicle mission plan, or 0 if IDs are not supported or there is no mission loaded. GCS can use this to track changes to the mission plan type. The same value is returned on mission upload (in the MISSION_ACK). + * @param fence_id Id of current on-vehicle fence plan, or 0 if IDs are not supported or there is no fence loaded. GCS can use this to track changes to the fence plan type. The same value is returned on fence upload (in the MISSION_ACK). + * @param rally_points_id Id of current on-vehicle rally point plan, or 0 if IDs are not supported or there are no rally points loaded. GCS can use this to track changes to the rally point plan type. The same value is returned on rally point upload (in the MISSION_ACK). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_current_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t seq, uint16_t total, uint8_t mission_state, uint8_t mission_mode, uint32_t mission_id, uint32_t fence_id, uint32_t rally_points_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_CURRENT_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint16_t(buf, 2, total); + _mav_put_uint8_t(buf, 4, mission_state); + _mav_put_uint8_t(buf, 5, mission_mode); + _mav_put_uint32_t(buf, 6, mission_id); + _mav_put_uint32_t(buf, 10, fence_id); + _mav_put_uint32_t(buf, 14, rally_points_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); +#else + mavlink_mission_current_t packet; + packet.seq = seq; + packet.total = total; + packet.mission_state = mission_state; + packet.mission_mode = mission_mode; + packet.mission_id = mission_id; + packet.fence_id = fence_id; + packet.rally_points_id = rally_points_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_CURRENT_LEN); +#endif +} + /** * @brief Pack a mission_current message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_mission_current_encode_chan(uint8_t system_id return mavlink_msg_mission_current_pack_chan(system_id, component_id, chan, msg, mission_current->seq, mission_current->total, mission_current->mission_state, mission_current->mission_mode, mission_current->mission_id, mission_current->fence_id, mission_current->rally_points_id); } +/** + * @brief Encode a mission_current struct with provided status structure + * + * @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 mission_current C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_current_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_current_t* mission_current) +{ + return mavlink_msg_mission_current_pack_status(system_id, component_id, _status, msg, mission_current->seq, mission_current->total, mission_current->mission_state, mission_current->mission_mode, mission_current->mission_id, mission_current->fence_id, mission_current->rally_points_id); +} + /** * @brief Send a mission_current message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_item.h b/common/mavlink_msg_mission_item.h index 1394f866..1ffac4e2 100644 --- a/common/mavlink_msg_mission_item.h +++ b/common/mavlink_msg_mission_item.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_mission_item_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC); } +/** + * @brief Pack a mission_item 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @param frame The coordinate system of the waypoint. + * @param command The scheduled action for the waypoint. + * @param current false:0, true:1 + * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes. + * @param param1 PARAM1, see MAV_CMD enum + * @param param2 PARAM2, see MAV_CMD enum + * @param param3 PARAM3, see MAV_CMD enum + * @param param4 PARAM4, see MAV_CMD enum + * @param x PARAM5 / local: X coordinate, global: latitude + * @param y PARAM6 / local: Y coordinate, global: longitude + * @param z PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame). + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_item_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, float x, float y, float z, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_ITEM_LEN]; + _mav_put_float(buf, 0, param1); + _mav_put_float(buf, 4, param2); + _mav_put_float(buf, 8, param3); + _mav_put_float(buf, 12, param4); + _mav_put_float(buf, 16, x); + _mav_put_float(buf, 20, y); + _mav_put_float(buf, 24, z); + _mav_put_uint16_t(buf, 28, seq); + _mav_put_uint16_t(buf, 30, command); + _mav_put_uint8_t(buf, 32, target_system); + _mav_put_uint8_t(buf, 33, target_component); + _mav_put_uint8_t(buf, 34, frame); + _mav_put_uint8_t(buf, 35, current); + _mav_put_uint8_t(buf, 36, autocontinue); + _mav_put_uint8_t(buf, 37, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_LEN); +#else + mavlink_mission_item_t packet; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.x = x; + packet.y = y; + packet.z = z; + packet.seq = seq; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.frame = frame; + packet.current = current; + packet.autocontinue = autocontinue; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN); +#endif +} + /** * @brief Pack a mission_item message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_mission_item_encode_chan(uint8_t system_id, u return mavlink_msg_mission_item_pack_chan(system_id, component_id, chan, msg, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type); } +/** + * @brief Encode a mission_item struct with provided status structure + * + * @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 mission_item C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_item_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_item_t* mission_item) +{ + return mavlink_msg_mission_item_pack_status(system_id, component_id, _status, msg, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type); +} + /** * @brief Send a mission_item message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_item_int.h b/common/mavlink_msg_mission_item_int.h index 88e6f5e5..47ca0de2 100644 --- a/common/mavlink_msg_mission_item_int.h +++ b/common/mavlink_msg_mission_item_int.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_mission_item_int_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ITEM_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN, MAVLINK_MSG_ID_MISSION_ITEM_INT_CRC); } +/** + * @brief Pack a mission_item_int 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 target_system System ID + * @param target_component Component ID + * @param seq Waypoint ID (sequence number). Starts at zero. Increases monotonically for each waypoint, no gaps in the sequence (0,1,2,3,4). + * @param frame The coordinate system of the waypoint. + * @param command The scheduled action for the waypoint. + * @param current false:0, true:1 + * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes. + * @param param1 PARAM1, see MAV_CMD enum + * @param param2 PARAM2, see MAV_CMD enum + * @param param3 PARAM3, see MAV_CMD enum + * @param param4 PARAM4, see MAV_CMD enum + * @param x PARAM5 / local: x position in meters * 1e4, global: latitude in degrees * 10^7 + * @param y PARAM6 / y position: local: x position in meters * 1e4, global: longitude in degrees *10^7 + * @param z PARAM7 / z position: global: altitude in meters (relative or absolute, depending on frame. + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_item_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, int32_t x, int32_t y, float z, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN]; + _mav_put_float(buf, 0, param1); + _mav_put_float(buf, 4, param2); + _mav_put_float(buf, 8, param3); + _mav_put_float(buf, 12, param4); + _mav_put_int32_t(buf, 16, x); + _mav_put_int32_t(buf, 20, y); + _mav_put_float(buf, 24, z); + _mav_put_uint16_t(buf, 28, seq); + _mav_put_uint16_t(buf, 30, command); + _mav_put_uint8_t(buf, 32, target_system); + _mav_put_uint8_t(buf, 33, target_component); + _mav_put_uint8_t(buf, 34, frame); + _mav_put_uint8_t(buf, 35, current); + _mav_put_uint8_t(buf, 36, autocontinue); + _mav_put_uint8_t(buf, 37, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN); +#else + mavlink_mission_item_int_t packet; + packet.param1 = param1; + packet.param2 = param2; + packet.param3 = param3; + packet.param4 = param4; + packet.x = x; + packet.y = y; + packet.z = z; + packet.seq = seq; + packet.command = command; + packet.target_system = target_system; + packet.target_component = target_component; + packet.frame = frame; + packet.current = current; + packet.autocontinue = autocontinue; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN, MAVLINK_MSG_ID_MISSION_ITEM_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_INT_LEN); +#endif +} + /** * @brief Pack a mission_item_int message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_mission_item_int_encode_chan(uint8_t system_i return mavlink_msg_mission_item_int_pack_chan(system_id, component_id, chan, msg, mission_item_int->target_system, mission_item_int->target_component, mission_item_int->seq, mission_item_int->frame, mission_item_int->command, mission_item_int->current, mission_item_int->autocontinue, mission_item_int->param1, mission_item_int->param2, mission_item_int->param3, mission_item_int->param4, mission_item_int->x, mission_item_int->y, mission_item_int->z, mission_item_int->mission_type); } +/** + * @brief Encode a mission_item_int struct with provided status structure + * + * @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 mission_item_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_item_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_item_int_t* mission_item_int) +{ + return mavlink_msg_mission_item_int_pack_status(system_id, component_id, _status, msg, mission_item_int->target_system, mission_item_int->target_component, mission_item_int->seq, mission_item_int->frame, mission_item_int->command, mission_item_int->current, mission_item_int->autocontinue, mission_item_int->param1, mission_item_int->param2, mission_item_int->param3, mission_item_int->param4, mission_item_int->x, mission_item_int->y, mission_item_int->z, mission_item_int->mission_type); +} + /** * @brief Send a mission_item_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_item_reached.h b/common/mavlink_msg_mission_item_reached.h index fbc195db..2760cb06 100644 --- a/common/mavlink_msg_mission_item_reached.h +++ b/common/mavlink_msg_mission_item_reached.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_mission_item_reached_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); } +/** + * @brief Pack a mission_item_reached 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 seq Sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_item_reached_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; + _mav_put_uint16_t(buf, 0, seq); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); +#else + mavlink_mission_item_reached_t packet; + packet.seq = seq; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); +#endif +} + /** * @brief Pack a mission_item_reached message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_mission_item_reached_encode_chan(uint8_t syst return mavlink_msg_mission_item_reached_pack_chan(system_id, component_id, chan, msg, mission_item_reached->seq); } +/** + * @brief Encode a mission_item_reached struct with provided status structure + * + * @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 mission_item_reached C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_item_reached_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_item_reached_t* mission_item_reached) +{ + return mavlink_msg_mission_item_reached_pack_status(system_id, component_id, _status, msg, mission_item_reached->seq); +} + /** * @brief Send a mission_item_reached message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_request.h b/common/mavlink_msg_mission_request.h index a2770a1e..55239ef9 100644 --- a/common/mavlink_msg_mission_request.h +++ b/common/mavlink_msg_mission_request.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_mission_request_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_CRC); } +/** + * @brief Pack a mission_request 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_REQUEST_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_LEN); +#else + mavlink_mission_request_t packet; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LEN); +#endif +} + /** * @brief Pack a mission_request message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_mission_request_encode_chan(uint8_t system_id return mavlink_msg_mission_request_pack_chan(system_id, component_id, chan, msg, mission_request->target_system, mission_request->target_component, mission_request->seq, mission_request->mission_type); } +/** + * @brief Encode a mission_request struct with provided status structure + * + * @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 mission_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_request_t* mission_request) +{ + return mavlink_msg_mission_request_pack_status(system_id, component_id, _status, msg, mission_request->target_system, mission_request->target_component, mission_request->seq, mission_request->mission_type); +} + /** * @brief Send a mission_request message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_request_int.h b/common/mavlink_msg_mission_request_int.h index a81e3196..590c89ff 100644 --- a/common/mavlink_msg_mission_request_int.h +++ b/common/mavlink_msg_mission_request_int.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_mission_request_int_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_REQUEST_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_INT_CRC); } +/** + * @brief Pack a mission_request_int 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_request_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN); +#else + mavlink_mission_request_int_t packet; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_INT_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_INT_LEN); +#endif +} + /** * @brief Pack a mission_request_int message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_mission_request_int_encode_chan(uint8_t syste return mavlink_msg_mission_request_int_pack_chan(system_id, component_id, chan, msg, mission_request_int->target_system, mission_request_int->target_component, mission_request_int->seq, mission_request_int->mission_type); } +/** + * @brief Encode a mission_request_int struct with provided status structure + * + * @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 mission_request_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_request_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_request_int_t* mission_request_int) +{ + return mavlink_msg_mission_request_int_pack_status(system_id, component_id, _status, msg, mission_request_int->target_system, mission_request_int->target_component, mission_request_int->seq, mission_request_int->mission_type); +} + /** * @brief Send a mission_request_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_request_list.h b/common/mavlink_msg_mission_request_list.h index 2e70c224..d13fe504 100644 --- a/common/mavlink_msg_mission_request_list.h +++ b/common/mavlink_msg_mission_request_list.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_mission_request_list_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); } +/** + * @brief Pack a mission_request_list 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 target_system System ID + * @param target_component Component ID + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_request_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); +#else + mavlink_mission_request_list_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN); +#endif +} + /** * @brief Pack a mission_request_list message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_mission_request_list_encode_chan(uint8_t syst return mavlink_msg_mission_request_list_pack_chan(system_id, component_id, chan, msg, mission_request_list->target_system, mission_request_list->target_component, mission_request_list->mission_type); } +/** + * @brief Encode a mission_request_list struct with provided status structure + * + * @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 mission_request_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_request_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_request_list_t* mission_request_list) +{ + return mavlink_msg_mission_request_list_pack_status(system_id, component_id, _status, msg, mission_request_list->target_system, mission_request_list->target_component, mission_request_list->mission_type); +} + /** * @brief Send a mission_request_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_request_partial_list.h b/common/mavlink_msg_mission_request_partial_list.h index 8612b956..fce899d1 100644 --- a/common/mavlink_msg_mission_request_partial_list.h +++ b/common/mavlink_msg_mission_request_partial_list.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_pack(uint8_t sys return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_CRC); } +/** + * @brief Pack a mission_request_partial_list 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 target_system System ID + * @param target_component Component ID + * @param start_index Start index + * @param end_index End index, -1 by default (-1: send list to end). Else a valid index of the list + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_request_partial_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int16_t start_index, int16_t end_index, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN]; + _mav_put_int16_t(buf, 0, start_index); + _mav_put_int16_t(buf, 2, end_index); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN); +#else + mavlink_mission_request_partial_list_t packet; + packet.start_index = start_index; + packet.end_index = end_index; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST_LEN); +#endif +} + /** * @brief Pack a mission_request_partial_list message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_encode_chan(uint return mavlink_msg_mission_request_partial_list_pack_chan(system_id, component_id, chan, msg, mission_request_partial_list->target_system, mission_request_partial_list->target_component, mission_request_partial_list->start_index, mission_request_partial_list->end_index, mission_request_partial_list->mission_type); } +/** + * @brief Encode a mission_request_partial_list struct with provided status structure + * + * @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 mission_request_partial_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_request_partial_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_request_partial_list_t* mission_request_partial_list) +{ + return mavlink_msg_mission_request_partial_list_pack_status(system_id, component_id, _status, msg, mission_request_partial_list->target_system, mission_request_partial_list->target_component, mission_request_partial_list->start_index, mission_request_partial_list->end_index, mission_request_partial_list->mission_type); +} + /** * @brief Send a mission_request_partial_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_set_current.h b/common/mavlink_msg_mission_set_current.h index 225fd2d9..4a2de71b 100644 --- a/common/mavlink_msg_mission_set_current.h +++ b/common/mavlink_msg_mission_set_current.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_mission_set_current_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_SET_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_SET_CURRENT_CRC); } +/** + * @brief Pack a mission_set_current 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_set_current_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN); +#else + mavlink_mission_set_current_t packet; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_SET_CURRENT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_SET_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN, MAVLINK_MSG_ID_MISSION_SET_CURRENT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_SET_CURRENT_MIN_LEN, MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN); +#endif +} + /** * @brief Pack a mission_set_current message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_mission_set_current_encode_chan(uint8_t syste return mavlink_msg_mission_set_current_pack_chan(system_id, component_id, chan, msg, mission_set_current->target_system, mission_set_current->target_component, mission_set_current->seq); } +/** + * @brief Encode a mission_set_current struct with provided status structure + * + * @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 mission_set_current C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_set_current_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_set_current_t* mission_set_current) +{ + return mavlink_msg_mission_set_current_pack_status(system_id, component_id, _status, msg, mission_set_current->target_system, mission_set_current->target_component, mission_set_current->seq); +} + /** * @brief Send a mission_set_current message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mission_write_partial_list.h b/common/mavlink_msg_mission_write_partial_list.h index e6705f60..3171a3d5 100644 --- a/common/mavlink_msg_mission_write_partial_list.h +++ b/common/mavlink_msg_mission_write_partial_list.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_CRC); } +/** + * @brief Pack a mission_write_partial_list 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 target_system System ID + * @param target_component Component ID + * @param start_index Start index. Must be smaller / equal to the largest index of the current onboard list. + * @param end_index End index, equal or greater than start index. + * @param mission_type Mission type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mission_write_partial_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int16_t start_index, int16_t end_index, uint8_t mission_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN]; + _mav_put_int16_t(buf, 0, start_index); + _mav_put_int16_t(buf, 2, end_index); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, mission_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN); +#else + mavlink_mission_write_partial_list_t packet; + packet.start_index = start_index; + packet.end_index = end_index; + packet.target_system = target_system; + packet.target_component = target_component; + packet.mission_type = mission_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_MIN_LEN, MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST_LEN); +#endif +} + /** * @brief Pack a mission_write_partial_list message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_encode_chan(uint8_ return mavlink_msg_mission_write_partial_list_pack_chan(system_id, component_id, chan, msg, mission_write_partial_list->target_system, mission_write_partial_list->target_component, mission_write_partial_list->start_index, mission_write_partial_list->end_index, mission_write_partial_list->mission_type); } +/** + * @brief Encode a mission_write_partial_list struct with provided status structure + * + * @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 mission_write_partial_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mission_write_partial_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_write_partial_list_t* mission_write_partial_list) +{ + return mavlink_msg_mission_write_partial_list_pack_status(system_id, component_id, _status, msg, mission_write_partial_list->target_system, mission_write_partial_list->target_component, mission_write_partial_list->start_index, mission_write_partial_list->end_index, mission_write_partial_list->mission_type); +} + /** * @brief Send a mission_write_partial_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_mount_orientation.h b/common/mavlink_msg_mount_orientation.h index 820f4529..dfd59510 100644 --- a/common/mavlink_msg_mount_orientation.h +++ b/common/mavlink_msg_mount_orientation.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_mount_orientation_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MOUNT_ORIENTATION_MIN_LEN, MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN, MAVLINK_MSG_ID_MOUNT_ORIENTATION_CRC); } +/** + * @brief Pack a mount_orientation 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param roll [deg] Roll in global frame (set to NaN for invalid). + * @param pitch [deg] Pitch in global frame (set to NaN for invalid). + * @param yaw [deg] Yaw relative to vehicle (set to NaN for invalid). + * @param yaw_absolute [deg] Yaw in absolute frame relative to Earth's North, north is 0 (set to NaN for invalid). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_mount_orientation_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float roll, float pitch, float yaw, float yaw_absolute) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, yaw_absolute); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN); +#else + mavlink_mount_orientation_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.yaw_absolute = yaw_absolute; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_MOUNT_ORIENTATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_ORIENTATION_MIN_LEN, MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN, MAVLINK_MSG_ID_MOUNT_ORIENTATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MOUNT_ORIENTATION_MIN_LEN, MAVLINK_MSG_ID_MOUNT_ORIENTATION_LEN); +#endif +} + /** * @brief Pack a mount_orientation message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_mount_orientation_encode_chan(uint8_t system_ return mavlink_msg_mount_orientation_pack_chan(system_id, component_id, chan, msg, mount_orientation->time_boot_ms, mount_orientation->roll, mount_orientation->pitch, mount_orientation->yaw, mount_orientation->yaw_absolute); } +/** + * @brief Encode a mount_orientation struct with provided status structure + * + * @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 mount_orientation C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_mount_orientation_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mount_orientation_t* mount_orientation) +{ + return mavlink_msg_mount_orientation_pack_status(system_id, component_id, _status, msg, mount_orientation->time_boot_ms, mount_orientation->roll, mount_orientation->pitch, mount_orientation->yaw, mount_orientation->yaw_absolute); +} + /** * @brief Send a mount_orientation message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_named_value_float.h b/common/mavlink_msg_named_value_float.h index fe75e782..11d2423f 100644 --- a/common/mavlink_msg_named_value_float.h +++ b/common/mavlink_msg_named_value_float.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_named_value_float_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); } +/** + * @brief Pack a named_value_float 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param name Name of the debug variable + * @param value Floating point value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_named_value_float_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, const char *name, float value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, value); + _mav_put_char_array(buf, 8, name, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); +#else + mavlink_named_value_float_t packet; + packet.time_boot_ms = time_boot_ms; + packet.value = value; + mav_array_memcpy(packet.name, name, sizeof(char)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_FLOAT_LEN); +#endif +} + /** * @brief Pack a named_value_float message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_named_value_float_encode_chan(uint8_t system_ return mavlink_msg_named_value_float_pack_chan(system_id, component_id, chan, msg, named_value_float->time_boot_ms, named_value_float->name, named_value_float->value); } +/** + * @brief Encode a named_value_float struct with provided status structure + * + * @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 named_value_float C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_named_value_float_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_named_value_float_t* named_value_float) +{ + return mavlink_msg_named_value_float_pack_status(system_id, component_id, _status, msg, named_value_float->time_boot_ms, named_value_float->name, named_value_float->value); +} + /** * @brief Send a named_value_float message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_named_value_int.h b/common/mavlink_msg_named_value_int.h index f33d7f4d..37f94ee0 100644 --- a/common/mavlink_msg_named_value_int.h +++ b/common/mavlink_msg_named_value_int.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_named_value_int_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC); } +/** + * @brief Pack a named_value_int 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param name Name of the debug variable + * @param value Signed integer value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_named_value_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, const char *name, int32_t value) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, value); + _mav_put_char_array(buf, 8, name, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN); +#else + mavlink_named_value_int_t packet; + packet.time_boot_ms = time_boot_ms; + packet.value = value; + mav_array_memcpy(packet.name, name, sizeof(char)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAMED_VALUE_INT_MIN_LEN, MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN); +#endif +} + /** * @brief Pack a named_value_int message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_named_value_int_encode_chan(uint8_t system_id return mavlink_msg_named_value_int_pack_chan(system_id, component_id, chan, msg, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value); } +/** + * @brief Encode a named_value_int struct with provided status structure + * + * @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 named_value_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_named_value_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_named_value_int_t* named_value_int) +{ + return mavlink_msg_named_value_int_pack_status(system_id, component_id, _status, msg, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value); +} + /** * @brief Send a named_value_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_nav_controller_output.h b/common/mavlink_msg_nav_controller_output.h index 1e29b77d..fc1dc42a 100644 --- a/common/mavlink_msg_nav_controller_output.h +++ b/common/mavlink_msg_nav_controller_output.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_nav_controller_output_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC); } +/** + * @brief Pack a nav_controller_output 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 nav_roll [deg] Current desired roll + * @param nav_pitch [deg] Current desired pitch + * @param nav_bearing [deg] Current desired heading + * @param target_bearing [deg] Bearing to current waypoint/target + * @param wp_dist [m] Distance to active waypoint + * @param alt_error [m] Current altitude error + * @param aspd_error [m/s] Current airspeed error + * @param xtrack_error [m] Current crosstrack error on x-y plane + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_nav_controller_output_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float nav_roll, float nav_pitch, int16_t nav_bearing, int16_t target_bearing, uint16_t wp_dist, float alt_error, float aspd_error, float xtrack_error) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN]; + _mav_put_float(buf, 0, nav_roll); + _mav_put_float(buf, 4, nav_pitch); + _mav_put_float(buf, 8, alt_error); + _mav_put_float(buf, 12, aspd_error); + _mav_put_float(buf, 16, xtrack_error); + _mav_put_int16_t(buf, 20, nav_bearing); + _mav_put_int16_t(buf, 22, target_bearing); + _mav_put_uint16_t(buf, 24, wp_dist); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN); +#else + mavlink_nav_controller_output_t packet; + packet.nav_roll = nav_roll; + packet.nav_pitch = nav_pitch; + packet.alt_error = alt_error; + packet.aspd_error = aspd_error; + packet.xtrack_error = xtrack_error; + packet.nav_bearing = nav_bearing; + packet.target_bearing = target_bearing; + packet.wp_dist = wp_dist; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_MIN_LEN, MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT_LEN); +#endif +} + /** * @brief Pack a nav_controller_output message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_nav_controller_output_encode_chan(uint8_t sys return mavlink_msg_nav_controller_output_pack_chan(system_id, component_id, chan, msg, nav_controller_output->nav_roll, nav_controller_output->nav_pitch, nav_controller_output->nav_bearing, nav_controller_output->target_bearing, nav_controller_output->wp_dist, nav_controller_output->alt_error, nav_controller_output->aspd_error, nav_controller_output->xtrack_error); } +/** + * @brief Encode a nav_controller_output struct with provided status structure + * + * @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 nav_controller_output C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_nav_controller_output_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_nav_controller_output_t* nav_controller_output) +{ + return mavlink_msg_nav_controller_output_pack_status(system_id, component_id, _status, msg, nav_controller_output->nav_roll, nav_controller_output->nav_pitch, nav_controller_output->nav_bearing, nav_controller_output->target_bearing, nav_controller_output->wp_dist, nav_controller_output->alt_error, nav_controller_output->aspd_error, nav_controller_output->xtrack_error); +} + /** * @brief Send a nav_controller_output message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_obstacle_distance.h b/common/mavlink_msg_obstacle_distance.h index afc25f14..94cfcc99 100644 --- a/common/mavlink_msg_obstacle_distance.h +++ b/common/mavlink_msg_obstacle_distance.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_obstacle_distance_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC); } +/** + * @brief Pack a obstacle_distance 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param sensor_type Class id of the distance sensor type. + * @param distances [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm. + * @param increment [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero. + * @param min_distance [cm] Minimum distance the sensor can measure. + * @param max_distance [cm] Maximum distance the sensor can measure. + * @param increment_f [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise. + * @param angle_offset [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise. + * @param frame Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_obstacle_distance_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t sensor_type, const uint16_t *distances, uint8_t increment, uint16_t min_distance, uint16_t max_distance, float increment_f, float angle_offset, uint8_t frame) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint16_t(buf, 152, min_distance); + _mav_put_uint16_t(buf, 154, max_distance); + _mav_put_uint8_t(buf, 156, sensor_type); + _mav_put_uint8_t(buf, 157, increment); + _mav_put_float(buf, 158, increment_f); + _mav_put_float(buf, 162, angle_offset); + _mav_put_uint8_t(buf, 166, frame); + _mav_put_uint16_t_array(buf, 8, distances, 72); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN); +#else + mavlink_obstacle_distance_t packet; + packet.time_usec = time_usec; + packet.min_distance = min_distance; + packet.max_distance = max_distance; + packet.sensor_type = sensor_type; + packet.increment = increment; + packet.increment_f = increment_f; + packet.angle_offset = angle_offset; + packet.frame = frame; + mav_array_memcpy(packet.distances, distances, sizeof(uint16_t)*72); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN); +#endif +} + /** * @brief Pack a obstacle_distance message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_obstacle_distance_encode_chan(uint8_t system_ return mavlink_msg_obstacle_distance_pack_chan(system_id, component_id, chan, msg, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame); } +/** + * @brief Encode a obstacle_distance struct with provided status structure + * + * @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 obstacle_distance C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_obstacle_distance_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_obstacle_distance_t* obstacle_distance) +{ + return mavlink_msg_obstacle_distance_pack_status(system_id, component_id, _status, msg, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame); +} + /** * @brief Send a obstacle_distance message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_odometry.h b/common/mavlink_msg_odometry.h index df2b74a6..b0064065 100644 --- a/common/mavlink_msg_odometry.h +++ b/common/mavlink_msg_odometry.h @@ -165,6 +165,88 @@ static inline uint16_t mavlink_msg_odometry_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC); } +/** + * @brief Pack a odometry 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param frame_id Coordinate frame of reference for the pose data. + * @param child_frame_id Coordinate frame of reference for the velocity in free space (twist) data. + * @param x [m] X Position + * @param y [m] Y Position + * @param z [m] Z Position + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation) + * @param vx [m/s] X linear speed + * @param vy [m/s] Y linear speed + * @param vz [m/s] Z linear speed + * @param rollspeed [rad/s] Roll angular speed + * @param pitchspeed [rad/s] Pitch angular speed + * @param yawspeed [rad/s] Yaw angular speed + * @param pose_covariance Row-major representation of a 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @param velocity_covariance Row-major representation of a 6x6 velocity cross-covariance matrix upper right triangle (states: vx, vy, vz, rollspeed, pitchspeed, yawspeed; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps. + * @param estimator_type Type of estimator that is providing the odometry. + * @param quality [%] Optional odometry quality metric as a percentage. -1 = odometry has failed, 0 = unknown/unset quality, 1 = worst quality, 100 = best quality + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_odometry_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t frame_id, uint8_t child_frame_id, float x, float y, float z, const float *q, float vx, float vy, float vz, float rollspeed, float pitchspeed, float yawspeed, const float *pose_covariance, const float *velocity_covariance, uint8_t reset_counter, uint8_t estimator_type, int8_t quality) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ODOMETRY_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 36, vx); + _mav_put_float(buf, 40, vy); + _mav_put_float(buf, 44, vz); + _mav_put_float(buf, 48, rollspeed); + _mav_put_float(buf, 52, pitchspeed); + _mav_put_float(buf, 56, yawspeed); + _mav_put_uint8_t(buf, 228, frame_id); + _mav_put_uint8_t(buf, 229, child_frame_id); + _mav_put_uint8_t(buf, 230, reset_counter); + _mav_put_uint8_t(buf, 231, estimator_type); + _mav_put_int8_t(buf, 232, quality); + _mav_put_float_array(buf, 20, q, 4); + _mav_put_float_array(buf, 60, pose_covariance, 21); + _mav_put_float_array(buf, 144, velocity_covariance, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ODOMETRY_LEN); +#else + mavlink_odometry_t packet; + packet.time_usec = time_usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.rollspeed = rollspeed; + packet.pitchspeed = pitchspeed; + packet.yawspeed = yawspeed; + packet.frame_id = frame_id; + packet.child_frame_id = child_frame_id; + packet.reset_counter = reset_counter; + packet.estimator_type = estimator_type; + packet.quality = quality; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + mav_array_memcpy(packet.pose_covariance, pose_covariance, sizeof(float)*21); + mav_array_memcpy(packet.velocity_covariance, velocity_covariance, sizeof(float)*21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ODOMETRY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ODOMETRY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN, MAVLINK_MSG_ID_ODOMETRY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ODOMETRY_MIN_LEN, MAVLINK_MSG_ID_ODOMETRY_LEN); +#endif +} + /** * @brief Pack a odometry message on a channel * @param system_id ID of this system @@ -270,6 +352,20 @@ static inline uint16_t mavlink_msg_odometry_encode_chan(uint8_t system_id, uint8 return mavlink_msg_odometry_pack_chan(system_id, component_id, chan, msg, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality); } +/** + * @brief Encode a odometry struct with provided status structure + * + * @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 odometry C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_odometry_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_odometry_t* odometry) +{ + return mavlink_msg_odometry_pack_status(system_id, component_id, _status, msg, odometry->time_usec, odometry->frame_id, odometry->child_frame_id, odometry->x, odometry->y, odometry->z, odometry->q, odometry->vx, odometry->vy, odometry->vz, odometry->rollspeed, odometry->pitchspeed, odometry->yawspeed, odometry->pose_covariance, odometry->velocity_covariance, odometry->reset_counter, odometry->estimator_type, odometry->quality); +} + /** * @brief Send a odometry message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_onboard_computer_status.h b/common/mavlink_msg_onboard_computer_status.h index 55bb396f..b251972c 100644 --- a/common/mavlink_msg_onboard_computer_status.h +++ b/common/mavlink_msg_onboard_computer_status.h @@ -188,6 +188,94 @@ static inline uint16_t mavlink_msg_onboard_computer_status_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_MIN_LEN, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_CRC); } +/** + * @brief Pack a onboard_computer_status 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param uptime [ms] Time since system boot. + * @param type Type of the onboard computer: 0: Mission computer primary, 1: Mission computer backup 1, 2: Mission computer backup 2, 3: Compute node, 4-5: Compute spares, 6-9: Payload computers. + * @param cpu_cores CPU usage on the component in percent (100 - idle). A value of UINT8_MAX implies the field is unused. + * @param cpu_combined Combined CPU usage as the last 10 slices of 100 MS (a histogram). This allows to identify spikes in load that max out the system, but only for a short amount of time. A value of UINT8_MAX implies the field is unused. + * @param gpu_cores GPU usage on the component in percent (100 - idle). A value of UINT8_MAX implies the field is unused. + * @param gpu_combined Combined GPU usage as the last 10 slices of 100 MS (a histogram). This allows to identify spikes in load that max out the system, but only for a short amount of time. A value of UINT8_MAX implies the field is unused. + * @param temperature_board [degC] Temperature of the board. A value of INT8_MAX implies the field is unused. + * @param temperature_core [degC] Temperature of the CPU core. A value of INT8_MAX implies the field is unused. + * @param fan_speed [rpm] Fan speeds. A value of INT16_MAX implies the field is unused. + * @param ram_usage [MiB] Amount of used RAM on the component system. A value of UINT32_MAX implies the field is unused. + * @param ram_total [MiB] Total amount of RAM on the component system. A value of UINT32_MAX implies the field is unused. + * @param storage_type Storage type: 0: HDD, 1: SSD, 2: EMMC, 3: SD card (non-removable), 4: SD card (removable). A value of UINT32_MAX implies the field is unused. + * @param storage_usage [MiB] Amount of used storage space on the component system. A value of UINT32_MAX implies the field is unused. + * @param storage_total [MiB] Total amount of storage space on the component system. A value of UINT32_MAX implies the field is unused. + * @param link_type Link type: 0-9: UART, 10-19: Wired network, 20-29: Wifi, 30-39: Point-to-point proprietary, 40-49: Mesh proprietary + * @param link_tx_rate [KiB/s] Network traffic from the component system. A value of UINT32_MAX implies the field is unused. + * @param link_rx_rate [KiB/s] Network traffic to the component system. A value of UINT32_MAX implies the field is unused. + * @param link_tx_max [KiB/s] Network capacity from the component system. A value of UINT32_MAX implies the field is unused. + * @param link_rx_max [KiB/s] Network capacity to the component system. A value of UINT32_MAX implies the field is unused. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_onboard_computer_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t uptime, uint8_t type, const uint8_t *cpu_cores, const uint8_t *cpu_combined, const uint8_t *gpu_cores, const uint8_t *gpu_combined, int8_t temperature_board, const int8_t *temperature_core, const int16_t *fan_speed, uint32_t ram_usage, uint32_t ram_total, const uint32_t *storage_type, const uint32_t *storage_usage, const uint32_t *storage_total, const uint32_t *link_type, const uint32_t *link_tx_rate, const uint32_t *link_rx_rate, const uint32_t *link_tx_max, const uint32_t *link_rx_max) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, uptime); + _mav_put_uint32_t(buf, 12, ram_usage); + _mav_put_uint32_t(buf, 16, ram_total); + _mav_put_uint8_t(buf, 196, type); + _mav_put_int8_t(buf, 229, temperature_board); + _mav_put_uint32_t_array(buf, 20, storage_type, 4); + _mav_put_uint32_t_array(buf, 36, storage_usage, 4); + _mav_put_uint32_t_array(buf, 52, storage_total, 4); + _mav_put_uint32_t_array(buf, 68, link_type, 6); + _mav_put_uint32_t_array(buf, 92, link_tx_rate, 6); + _mav_put_uint32_t_array(buf, 116, link_rx_rate, 6); + _mav_put_uint32_t_array(buf, 140, link_tx_max, 6); + _mav_put_uint32_t_array(buf, 164, link_rx_max, 6); + _mav_put_int16_t_array(buf, 188, fan_speed, 4); + _mav_put_uint8_t_array(buf, 197, cpu_cores, 8); + _mav_put_uint8_t_array(buf, 205, cpu_combined, 10); + _mav_put_uint8_t_array(buf, 215, gpu_cores, 4); + _mav_put_uint8_t_array(buf, 219, gpu_combined, 10); + _mav_put_int8_t_array(buf, 230, temperature_core, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN); +#else + mavlink_onboard_computer_status_t packet; + packet.time_usec = time_usec; + packet.uptime = uptime; + packet.ram_usage = ram_usage; + packet.ram_total = ram_total; + packet.type = type; + packet.temperature_board = temperature_board; + mav_array_memcpy(packet.storage_type, storage_type, sizeof(uint32_t)*4); + mav_array_memcpy(packet.storage_usage, storage_usage, sizeof(uint32_t)*4); + mav_array_memcpy(packet.storage_total, storage_total, sizeof(uint32_t)*4); + mav_array_memcpy(packet.link_type, link_type, sizeof(uint32_t)*6); + mav_array_memcpy(packet.link_tx_rate, link_tx_rate, sizeof(uint32_t)*6); + mav_array_memcpy(packet.link_rx_rate, link_rx_rate, sizeof(uint32_t)*6); + mav_array_memcpy(packet.link_tx_max, link_tx_max, sizeof(uint32_t)*6); + mav_array_memcpy(packet.link_rx_max, link_rx_max, sizeof(uint32_t)*6); + mav_array_memcpy(packet.fan_speed, fan_speed, sizeof(int16_t)*4); + mav_array_memcpy(packet.cpu_cores, cpu_cores, sizeof(uint8_t)*8); + mav_array_memcpy(packet.cpu_combined, cpu_combined, sizeof(uint8_t)*10); + mav_array_memcpy(packet.gpu_cores, gpu_cores, sizeof(uint8_t)*4); + mav_array_memcpy(packet.gpu_combined, gpu_combined, sizeof(uint8_t)*10); + mav_array_memcpy(packet.temperature_core, temperature_core, sizeof(int8_t)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_MIN_LEN, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_MIN_LEN, MAVLINK_MSG_ID_ONBOARD_COMPUTER_STATUS_LEN); +#endif +} + /** * @brief Pack a onboard_computer_status message on a channel * @param system_id ID of this system @@ -299,6 +387,20 @@ static inline uint16_t mavlink_msg_onboard_computer_status_encode_chan(uint8_t s return mavlink_msg_onboard_computer_status_pack_chan(system_id, component_id, chan, msg, onboard_computer_status->time_usec, onboard_computer_status->uptime, onboard_computer_status->type, onboard_computer_status->cpu_cores, onboard_computer_status->cpu_combined, onboard_computer_status->gpu_cores, onboard_computer_status->gpu_combined, onboard_computer_status->temperature_board, onboard_computer_status->temperature_core, onboard_computer_status->fan_speed, onboard_computer_status->ram_usage, onboard_computer_status->ram_total, onboard_computer_status->storage_type, onboard_computer_status->storage_usage, onboard_computer_status->storage_total, onboard_computer_status->link_type, onboard_computer_status->link_tx_rate, onboard_computer_status->link_rx_rate, onboard_computer_status->link_tx_max, onboard_computer_status->link_rx_max); } +/** + * @brief Encode a onboard_computer_status struct with provided status structure + * + * @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 onboard_computer_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_onboard_computer_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_onboard_computer_status_t* onboard_computer_status) +{ + return mavlink_msg_onboard_computer_status_pack_status(system_id, component_id, _status, msg, onboard_computer_status->time_usec, onboard_computer_status->uptime, onboard_computer_status->type, onboard_computer_status->cpu_cores, onboard_computer_status->cpu_combined, onboard_computer_status->gpu_cores, onboard_computer_status->gpu_combined, onboard_computer_status->temperature_board, onboard_computer_status->temperature_core, onboard_computer_status->fan_speed, onboard_computer_status->ram_usage, onboard_computer_status->ram_total, onboard_computer_status->storage_type, onboard_computer_status->storage_usage, onboard_computer_status->storage_total, onboard_computer_status->link_type, onboard_computer_status->link_tx_rate, onboard_computer_status->link_rx_rate, onboard_computer_status->link_tx_max, onboard_computer_status->link_rx_max); +} + /** * @brief Send a onboard_computer_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_arm_status.h b/common/mavlink_msg_open_drone_id_arm_status.h index d715499f..8cbcf8fb 100644 --- a/common/mavlink_msg_open_drone_id_arm_status.h +++ b/common/mavlink_msg_open_drone_id_arm_status.h @@ -67,6 +67,40 @@ static inline uint16_t mavlink_msg_open_drone_id_arm_status_pack(uint8_t system_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_CRC); } +/** + * @brief Pack a open_drone_id_arm_status 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 status Status level indicating if arming is allowed. + * @param error Text error message, should be empty if status is good to arm. Fill with nulls in unused portion. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_arm_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t status, const char *error) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN]; + _mav_put_uint8_t(buf, 0, status); + _mav_put_char_array(buf, 1, error, 50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN); +#else + mavlink_open_drone_id_arm_status_t packet; + packet.status = status; + mav_array_memcpy(packet.error, error, sizeof(char)*50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_ARM_STATUS_LEN); +#endif +} + /** * @brief Pack a open_drone_id_arm_status message on a channel * @param system_id ID of this system @@ -124,6 +158,20 @@ static inline uint16_t mavlink_msg_open_drone_id_arm_status_encode_chan(uint8_t return mavlink_msg_open_drone_id_arm_status_pack_chan(system_id, component_id, chan, msg, open_drone_id_arm_status->status, open_drone_id_arm_status->error); } +/** + * @brief Encode a open_drone_id_arm_status struct with provided status structure + * + * @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 open_drone_id_arm_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_arm_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_arm_status_t* open_drone_id_arm_status) +{ + return mavlink_msg_open_drone_id_arm_status_pack_status(system_id, component_id, _status, msg, open_drone_id_arm_status->status, open_drone_id_arm_status->error); +} + /** * @brief Send a open_drone_id_arm_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_authentication.h b/common/mavlink_msg_open_drone_id_authentication.h index 4c5fc3a0..0aa43172 100644 --- a/common/mavlink_msg_open_drone_id_authentication.h +++ b/common/mavlink_msg_open_drone_id_authentication.h @@ -110,6 +110,61 @@ static inline uint16_t mavlink_msg_open_drone_id_authentication_pack(uint8_t sys return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_CRC); } +/** + * @brief Pack a open_drone_id_authentication 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param authentication_type Indicates the type of authentication. + * @param data_page Allowed range is 0 - 15. + * @param last_page_index This field is only present for page 0. Allowed range is 0 - 15. See the description of struct ODID_Auth_data at https://github.com/opendroneid/opendroneid-core-c/blob/master/libopendroneid/opendroneid.h. + * @param length [bytes] This field is only present for page 0. Total bytes of authentication_data from all data pages. See the description of struct ODID_Auth_data at https://github.com/opendroneid/opendroneid-core-c/blob/master/libopendroneid/opendroneid.h. + * @param timestamp [s] This field is only present for page 0. 32 bit Unix Timestamp in seconds since 00:00:00 01/01/2019. + * @param authentication_data Opaque authentication data. For page 0, the size is only 17 bytes. For other pages, the size is 23 bytes. Shall be filled with nulls in the unused portion of the field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_authentication_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t authentication_type, uint8_t data_page, uint8_t last_page_index, uint8_t length, uint32_t timestamp, const uint8_t *authentication_data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN]; + _mav_put_uint32_t(buf, 0, timestamp); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 26, authentication_type); + _mav_put_uint8_t(buf, 27, data_page); + _mav_put_uint8_t(buf, 28, last_page_index); + _mav_put_uint8_t(buf, 29, length); + _mav_put_uint8_t_array(buf, 6, id_or_mac, 20); + _mav_put_uint8_t_array(buf, 30, authentication_data, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN); +#else + mavlink_open_drone_id_authentication_t packet; + packet.timestamp = timestamp; + packet.target_system = target_system; + packet.target_component = target_component; + packet.authentication_type = authentication_type; + packet.data_page = data_page; + packet.last_page_index = last_page_index; + packet.length = length; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + mav_array_memcpy(packet.authentication_data, authentication_data, sizeof(uint8_t)*23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_AUTHENTICATION_LEN); +#endif +} + /** * @brief Pack a open_drone_id_authentication message on a channel * @param system_id ID of this system @@ -188,6 +243,20 @@ static inline uint16_t mavlink_msg_open_drone_id_authentication_encode_chan(uint return mavlink_msg_open_drone_id_authentication_pack_chan(system_id, component_id, chan, msg, open_drone_id_authentication->target_system, open_drone_id_authentication->target_component, open_drone_id_authentication->id_or_mac, open_drone_id_authentication->authentication_type, open_drone_id_authentication->data_page, open_drone_id_authentication->last_page_index, open_drone_id_authentication->length, open_drone_id_authentication->timestamp, open_drone_id_authentication->authentication_data); } +/** + * @brief Encode a open_drone_id_authentication struct with provided status structure + * + * @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 open_drone_id_authentication C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_authentication_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_authentication_t* open_drone_id_authentication) +{ + return mavlink_msg_open_drone_id_authentication_pack_status(system_id, component_id, _status, msg, open_drone_id_authentication->target_system, open_drone_id_authentication->target_component, open_drone_id_authentication->id_or_mac, open_drone_id_authentication->authentication_type, open_drone_id_authentication->data_page, open_drone_id_authentication->last_page_index, open_drone_id_authentication->length, open_drone_id_authentication->timestamp, open_drone_id_authentication->authentication_data); +} + /** * @brief Send a open_drone_id_authentication message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_basic_id.h b/common/mavlink_msg_open_drone_id_basic_id.h index e2231451..72e295eb 100644 --- a/common/mavlink_msg_open_drone_id_basic_id.h +++ b/common/mavlink_msg_open_drone_id_basic_id.h @@ -92,6 +92,52 @@ static inline uint16_t mavlink_msg_open_drone_id_basic_id_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_CRC); } +/** + * @brief Pack a open_drone_id_basic_id 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param id_type Indicates the format for the uas_id field of this message. + * @param ua_type Indicates the type of UA (Unmanned Aircraft). + * @param uas_id UAS (Unmanned Aircraft System) ID following the format specified by id_type. Shall be filled with nulls in the unused portion of the field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_basic_id_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t id_type, uint8_t ua_type, const uint8_t *uas_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 22, id_type); + _mav_put_uint8_t(buf, 23, ua_type); + _mav_put_uint8_t_array(buf, 2, id_or_mac, 20); + _mav_put_uint8_t_array(buf, 24, uas_id, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN); +#else + mavlink_open_drone_id_basic_id_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.id_type = id_type; + packet.ua_type = ua_type; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + mav_array_memcpy(packet.uas_id, uas_id, sizeof(uint8_t)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_BASIC_ID_LEN); +#endif +} + /** * @brief Pack a open_drone_id_basic_id message on a channel * @param system_id ID of this system @@ -161,6 +207,20 @@ static inline uint16_t mavlink_msg_open_drone_id_basic_id_encode_chan(uint8_t sy return mavlink_msg_open_drone_id_basic_id_pack_chan(system_id, component_id, chan, msg, open_drone_id_basic_id->target_system, open_drone_id_basic_id->target_component, open_drone_id_basic_id->id_or_mac, open_drone_id_basic_id->id_type, open_drone_id_basic_id->ua_type, open_drone_id_basic_id->uas_id); } +/** + * @brief Encode a open_drone_id_basic_id struct with provided status structure + * + * @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 open_drone_id_basic_id C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_basic_id_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_basic_id_t* open_drone_id_basic_id) +{ + return mavlink_msg_open_drone_id_basic_id_pack_status(system_id, component_id, _status, msg, open_drone_id_basic_id->target_system, open_drone_id_basic_id->target_component, open_drone_id_basic_id->id_or_mac, open_drone_id_basic_id->id_type, open_drone_id_basic_id->ua_type, open_drone_id_basic_id->uas_id); +} + /** * @brief Send a open_drone_id_basic_id message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_location.h b/common/mavlink_msg_open_drone_id_location.h index c0fd46cf..752246fd 100644 --- a/common/mavlink_msg_open_drone_id_location.h +++ b/common/mavlink_msg_open_drone_id_location.h @@ -169,6 +169,91 @@ static inline uint16_t mavlink_msg_open_drone_id_location_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_CRC); } +/** + * @brief Pack a open_drone_id_location 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param status Indicates whether the unmanned aircraft is on the ground or in the air. + * @param direction [cdeg] Direction over ground (not heading, but direction of movement) measured clockwise from true North: 0 - 35999 centi-degrees. If unknown: 36100 centi-degrees. + * @param speed_horizontal [cm/s] Ground speed. Positive only. If unknown: 25500 cm/s. If speed is larger than 25425 cm/s, use 25425 cm/s. + * @param speed_vertical [cm/s] The vertical speed. Up is positive. If unknown: 6300 cm/s. If speed is larger than 6200 cm/s, use 6200 cm/s. If lower than -6200 cm/s, use -6200 cm/s. + * @param latitude [degE7] Current latitude of the unmanned aircraft. If unknown: 0 (both Lat/Lon). + * @param longitude [degE7] Current longitude of the unmanned aircraft. If unknown: 0 (both Lat/Lon). + * @param altitude_barometric [m] The altitude calculated from the barometric pressue. Reference is against 29.92inHg or 1013.2mb. If unknown: -1000 m. + * @param altitude_geodetic [m] The geodetic altitude as defined by WGS84. If unknown: -1000 m. + * @param height_reference Indicates the reference point for the height field. + * @param height [m] The current height of the unmanned aircraft above the take-off location or the ground as indicated by height_reference. If unknown: -1000 m. + * @param horizontal_accuracy The accuracy of the horizontal position. + * @param vertical_accuracy The accuracy of the vertical position. + * @param barometer_accuracy The accuracy of the barometric altitude. + * @param speed_accuracy The accuracy of the horizontal and vertical speed. + * @param timestamp [s] Seconds after the full hour with reference to UTC time. Typically the GPS outputs a time-of-week value in milliseconds. First convert that to UTC and then convert for this field using ((float) (time_week_ms % (60*60*1000))) / 1000. If unknown: 0xFFFF. + * @param timestamp_accuracy The accuracy of the timestamps. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_location_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t status, uint16_t direction, uint16_t speed_horizontal, int16_t speed_vertical, int32_t latitude, int32_t longitude, float altitude_barometric, float altitude_geodetic, uint8_t height_reference, float height, uint8_t horizontal_accuracy, uint8_t vertical_accuracy, uint8_t barometer_accuracy, uint8_t speed_accuracy, float timestamp, uint8_t timestamp_accuracy) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN]; + _mav_put_int32_t(buf, 0, latitude); + _mav_put_int32_t(buf, 4, longitude); + _mav_put_float(buf, 8, altitude_barometric); + _mav_put_float(buf, 12, altitude_geodetic); + _mav_put_float(buf, 16, height); + _mav_put_float(buf, 20, timestamp); + _mav_put_uint16_t(buf, 24, direction); + _mav_put_uint16_t(buf, 26, speed_horizontal); + _mav_put_int16_t(buf, 28, speed_vertical); + _mav_put_uint8_t(buf, 30, target_system); + _mav_put_uint8_t(buf, 31, target_component); + _mav_put_uint8_t(buf, 52, status); + _mav_put_uint8_t(buf, 53, height_reference); + _mav_put_uint8_t(buf, 54, horizontal_accuracy); + _mav_put_uint8_t(buf, 55, vertical_accuracy); + _mav_put_uint8_t(buf, 56, barometer_accuracy); + _mav_put_uint8_t(buf, 57, speed_accuracy); + _mav_put_uint8_t(buf, 58, timestamp_accuracy); + _mav_put_uint8_t_array(buf, 32, id_or_mac, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN); +#else + mavlink_open_drone_id_location_t packet; + packet.latitude = latitude; + packet.longitude = longitude; + packet.altitude_barometric = altitude_barometric; + packet.altitude_geodetic = altitude_geodetic; + packet.height = height; + packet.timestamp = timestamp; + packet.direction = direction; + packet.speed_horizontal = speed_horizontal; + packet.speed_vertical = speed_vertical; + packet.target_system = target_system; + packet.target_component = target_component; + packet.status = status; + packet.height_reference = height_reference; + packet.horizontal_accuracy = horizontal_accuracy; + packet.vertical_accuracy = vertical_accuracy; + packet.barometer_accuracy = barometer_accuracy; + packet.speed_accuracy = speed_accuracy; + packet.timestamp_accuracy = timestamp_accuracy; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION_LEN); +#endif +} + /** * @brief Pack a open_drone_id_location message on a channel * @param system_id ID of this system @@ -277,6 +362,20 @@ static inline uint16_t mavlink_msg_open_drone_id_location_encode_chan(uint8_t sy return mavlink_msg_open_drone_id_location_pack_chan(system_id, component_id, chan, msg, open_drone_id_location->target_system, open_drone_id_location->target_component, open_drone_id_location->id_or_mac, open_drone_id_location->status, open_drone_id_location->direction, open_drone_id_location->speed_horizontal, open_drone_id_location->speed_vertical, open_drone_id_location->latitude, open_drone_id_location->longitude, open_drone_id_location->altitude_barometric, open_drone_id_location->altitude_geodetic, open_drone_id_location->height_reference, open_drone_id_location->height, open_drone_id_location->horizontal_accuracy, open_drone_id_location->vertical_accuracy, open_drone_id_location->barometer_accuracy, open_drone_id_location->speed_accuracy, open_drone_id_location->timestamp, open_drone_id_location->timestamp_accuracy); } +/** + * @brief Encode a open_drone_id_location struct with provided status structure + * + * @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 open_drone_id_location C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_location_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_location_t* open_drone_id_location) +{ + return mavlink_msg_open_drone_id_location_pack_status(system_id, component_id, _status, msg, open_drone_id_location->target_system, open_drone_id_location->target_component, open_drone_id_location->id_or_mac, open_drone_id_location->status, open_drone_id_location->direction, open_drone_id_location->speed_horizontal, open_drone_id_location->speed_vertical, open_drone_id_location->latitude, open_drone_id_location->longitude, open_drone_id_location->altitude_barometric, open_drone_id_location->altitude_geodetic, open_drone_id_location->height_reference, open_drone_id_location->height, open_drone_id_location->horizontal_accuracy, open_drone_id_location->vertical_accuracy, open_drone_id_location->barometer_accuracy, open_drone_id_location->speed_accuracy, open_drone_id_location->timestamp, open_drone_id_location->timestamp_accuracy); +} + /** * @brief Send a open_drone_id_location message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_message_pack.h b/common/mavlink_msg_open_drone_id_message_pack.h index 506e3e79..52dfcfdd 100644 --- a/common/mavlink_msg_open_drone_id_message_pack.h +++ b/common/mavlink_msg_open_drone_id_message_pack.h @@ -92,6 +92,52 @@ static inline uint16_t mavlink_msg_open_drone_id_message_pack_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_CRC); } +/** + * @brief Pack a open_drone_id_message_pack 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param single_message_size [bytes] This field must currently always be equal to 25 (bytes), since all encoded OpenDroneID messages are specified to have this length. + * @param msg_pack_size Number of encoded messages in the pack (not the number of bytes). Allowed range is 1 - 9. + * @param messages Concatenation of encoded OpenDroneID messages. Shall be filled with nulls in the unused portion of the field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_message_pack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t single_message_size, uint8_t msg_pack_size, const uint8_t *messages) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 22, single_message_size); + _mav_put_uint8_t(buf, 23, msg_pack_size); + _mav_put_uint8_t_array(buf, 2, id_or_mac, 20); + _mav_put_uint8_t_array(buf, 24, messages, 225); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN); +#else + mavlink_open_drone_id_message_pack_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.single_message_size = single_message_size; + packet.msg_pack_size = msg_pack_size; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + mav_array_memcpy(packet.messages, messages, sizeof(uint8_t)*225); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_MESSAGE_PACK_LEN); +#endif +} + /** * @brief Pack a open_drone_id_message_pack message on a channel * @param system_id ID of this system @@ -161,6 +207,20 @@ static inline uint16_t mavlink_msg_open_drone_id_message_pack_encode_chan(uint8_ return mavlink_msg_open_drone_id_message_pack_pack_chan(system_id, component_id, chan, msg, open_drone_id_message_pack->target_system, open_drone_id_message_pack->target_component, open_drone_id_message_pack->id_or_mac, open_drone_id_message_pack->single_message_size, open_drone_id_message_pack->msg_pack_size, open_drone_id_message_pack->messages); } +/** + * @brief Encode a open_drone_id_message_pack struct with provided status structure + * + * @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 open_drone_id_message_pack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_message_pack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_message_pack_t* open_drone_id_message_pack) +{ + return mavlink_msg_open_drone_id_message_pack_pack_status(system_id, component_id, _status, msg, open_drone_id_message_pack->target_system, open_drone_id_message_pack->target_component, open_drone_id_message_pack->id_or_mac, open_drone_id_message_pack->single_message_size, open_drone_id_message_pack->msg_pack_size, open_drone_id_message_pack->messages); +} + /** * @brief Send a open_drone_id_message_pack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_operator_id.h b/common/mavlink_msg_open_drone_id_operator_id.h index ba72d2b0..827ff350 100644 --- a/common/mavlink_msg_open_drone_id_operator_id.h +++ b/common/mavlink_msg_open_drone_id_operator_id.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_open_drone_id_operator_id_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_CRC); } +/** + * @brief Pack a open_drone_id_operator_id 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param operator_id_type Indicates the type of the operator_id field. + * @param operator_id Text description or numeric value expressed as ASCII characters. Shall be filled with nulls in the unused portion of the field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_operator_id_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t operator_id_type, const char *operator_id) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 22, operator_id_type); + _mav_put_uint8_t_array(buf, 2, id_or_mac, 20); + _mav_put_char_array(buf, 23, operator_id, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN); +#else + mavlink_open_drone_id_operator_id_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.operator_id_type = operator_id_type; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + mav_array_memcpy(packet.operator_id, operator_id, sizeof(char)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_OPERATOR_ID_LEN); +#endif +} + /** * @brief Pack a open_drone_id_operator_id message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_open_drone_id_operator_id_encode_chan(uint8_t return mavlink_msg_open_drone_id_operator_id_pack_chan(system_id, component_id, chan, msg, open_drone_id_operator_id->target_system, open_drone_id_operator_id->target_component, open_drone_id_operator_id->id_or_mac, open_drone_id_operator_id->operator_id_type, open_drone_id_operator_id->operator_id); } +/** + * @brief Encode a open_drone_id_operator_id struct with provided status structure + * + * @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 open_drone_id_operator_id C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_operator_id_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_operator_id_t* open_drone_id_operator_id) +{ + return mavlink_msg_open_drone_id_operator_id_pack_status(system_id, component_id, _status, msg, open_drone_id_operator_id->target_system, open_drone_id_operator_id->target_component, open_drone_id_operator_id->id_or_mac, open_drone_id_operator_id->operator_id_type, open_drone_id_operator_id->operator_id); +} + /** * @brief Send a open_drone_id_operator_id message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_self_id.h b/common/mavlink_msg_open_drone_id_self_id.h index fbc787a0..652d9d58 100644 --- a/common/mavlink_msg_open_drone_id_self_id.h +++ b/common/mavlink_msg_open_drone_id_self_id.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_open_drone_id_self_id_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_CRC); } +/** + * @brief Pack a open_drone_id_self_id 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param description_type Indicates the type of the description field. + * @param description Text description or numeric value expressed as ASCII characters. Shall be filled with nulls in the unused portion of the field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_self_id_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t description_type, const char *description) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 22, description_type); + _mav_put_uint8_t_array(buf, 2, id_or_mac, 20); + _mav_put_char_array(buf, 23, description, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN); +#else + mavlink_open_drone_id_self_id_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.description_type = description_type; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + mav_array_memcpy(packet.description, description, sizeof(char)*23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SELF_ID_LEN); +#endif +} + /** * @brief Pack a open_drone_id_self_id message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_open_drone_id_self_id_encode_chan(uint8_t sys return mavlink_msg_open_drone_id_self_id_pack_chan(system_id, component_id, chan, msg, open_drone_id_self_id->target_system, open_drone_id_self_id->target_component, open_drone_id_self_id->id_or_mac, open_drone_id_self_id->description_type, open_drone_id_self_id->description); } +/** + * @brief Encode a open_drone_id_self_id struct with provided status structure + * + * @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 open_drone_id_self_id C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_self_id_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_self_id_t* open_drone_id_self_id) +{ + return mavlink_msg_open_drone_id_self_id_pack_status(system_id, component_id, _status, msg, open_drone_id_self_id->target_system, open_drone_id_self_id->target_component, open_drone_id_self_id->id_or_mac, open_drone_id_self_id->description_type, open_drone_id_self_id->description); +} + /** * @brief Send a open_drone_id_self_id message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_system.h b/common/mavlink_msg_open_drone_id_system.h index 876c0595..0dfba418 100644 --- a/common/mavlink_msg_open_drone_id_system.h +++ b/common/mavlink_msg_open_drone_id_system.h @@ -145,6 +145,79 @@ static inline uint16_t mavlink_msg_open_drone_id_system_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_CRC); } +/** + * @brief Pack a open_drone_id_system 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param id_or_mac Only used for drone ID data received from other UAs. See detailed description at https://mavlink.io/en/services/opendroneid.html. + * @param operator_location_type Specifies the operator location type. + * @param classification_type Specifies the classification type of the UA. + * @param operator_latitude [degE7] Latitude of the operator. If unknown: 0 (both Lat/Lon). + * @param operator_longitude [degE7] Longitude of the operator. If unknown: 0 (both Lat/Lon). + * @param area_count Number of aircraft in the area, group or formation (default 1). Used only for swarms/multiple UA. + * @param area_radius [m] Radius of the cylindrical area of the group or formation (default 0). Used only for swarms/multiple UA. + * @param area_ceiling [m] Area Operations Ceiling relative to WGS84. If unknown: -1000 m. Used only for swarms/multiple UA. + * @param area_floor [m] Area Operations Floor relative to WGS84. If unknown: -1000 m. Used only for swarms/multiple UA. + * @param category_eu When classification_type is MAV_ODID_CLASSIFICATION_TYPE_EU, specifies the category of the UA. + * @param class_eu When classification_type is MAV_ODID_CLASSIFICATION_TYPE_EU, specifies the class of the UA. + * @param operator_altitude_geo [m] Geodetic altitude of the operator relative to WGS84. If unknown: -1000 m. + * @param timestamp [s] 32 bit Unix Timestamp in seconds since 00:00:00 01/01/2019. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_system_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *id_or_mac, uint8_t operator_location_type, uint8_t classification_type, int32_t operator_latitude, int32_t operator_longitude, uint16_t area_count, uint16_t area_radius, float area_ceiling, float area_floor, uint8_t category_eu, uint8_t class_eu, float operator_altitude_geo, uint32_t timestamp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN]; + _mav_put_int32_t(buf, 0, operator_latitude); + _mav_put_int32_t(buf, 4, operator_longitude); + _mav_put_float(buf, 8, area_ceiling); + _mav_put_float(buf, 12, area_floor); + _mav_put_float(buf, 16, operator_altitude_geo); + _mav_put_uint32_t(buf, 20, timestamp); + _mav_put_uint16_t(buf, 24, area_count); + _mav_put_uint16_t(buf, 26, area_radius); + _mav_put_uint8_t(buf, 28, target_system); + _mav_put_uint8_t(buf, 29, target_component); + _mav_put_uint8_t(buf, 50, operator_location_type); + _mav_put_uint8_t(buf, 51, classification_type); + _mav_put_uint8_t(buf, 52, category_eu); + _mav_put_uint8_t(buf, 53, class_eu); + _mav_put_uint8_t_array(buf, 30, id_or_mac, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN); +#else + mavlink_open_drone_id_system_t packet; + packet.operator_latitude = operator_latitude; + packet.operator_longitude = operator_longitude; + packet.area_ceiling = area_ceiling; + packet.area_floor = area_floor; + packet.operator_altitude_geo = operator_altitude_geo; + packet.timestamp = timestamp; + packet.area_count = area_count; + packet.area_radius = area_radius; + packet.target_system = target_system; + packet.target_component = target_component; + packet.operator_location_type = operator_location_type; + packet.classification_type = classification_type; + packet.category_eu = category_eu; + packet.class_eu = class_eu; + mav_array_memcpy(packet.id_or_mac, id_or_mac, sizeof(uint8_t)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_LEN); +#endif +} + /** * @brief Pack a open_drone_id_system message on a channel * @param system_id ID of this system @@ -241,6 +314,20 @@ static inline uint16_t mavlink_msg_open_drone_id_system_encode_chan(uint8_t syst return mavlink_msg_open_drone_id_system_pack_chan(system_id, component_id, chan, msg, open_drone_id_system->target_system, open_drone_id_system->target_component, open_drone_id_system->id_or_mac, open_drone_id_system->operator_location_type, open_drone_id_system->classification_type, open_drone_id_system->operator_latitude, open_drone_id_system->operator_longitude, open_drone_id_system->area_count, open_drone_id_system->area_radius, open_drone_id_system->area_ceiling, open_drone_id_system->area_floor, open_drone_id_system->category_eu, open_drone_id_system->class_eu, open_drone_id_system->operator_altitude_geo, open_drone_id_system->timestamp); } +/** + * @brief Encode a open_drone_id_system struct with provided status structure + * + * @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 open_drone_id_system C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_system_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_system_t* open_drone_id_system) +{ + return mavlink_msg_open_drone_id_system_pack_status(system_id, component_id, _status, msg, open_drone_id_system->target_system, open_drone_id_system->target_component, open_drone_id_system->id_or_mac, open_drone_id_system->operator_location_type, open_drone_id_system->classification_type, open_drone_id_system->operator_latitude, open_drone_id_system->operator_longitude, open_drone_id_system->area_count, open_drone_id_system->area_radius, open_drone_id_system->area_ceiling, open_drone_id_system->area_floor, open_drone_id_system->category_eu, open_drone_id_system->class_eu, open_drone_id_system->operator_altitude_geo, open_drone_id_system->timestamp); +} + /** * @brief Send a open_drone_id_system message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_open_drone_id_system_update.h b/common/mavlink_msg_open_drone_id_system_update.h index 8549cc90..89687d70 100644 --- a/common/mavlink_msg_open_drone_id_system_update.h +++ b/common/mavlink_msg_open_drone_id_system_update.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_open_drone_id_system_update_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_CRC); } +/** + * @brief Pack a open_drone_id_system_update 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param operator_latitude [degE7] Latitude of the operator. If unknown: 0 (both Lat/Lon). + * @param operator_longitude [degE7] Longitude of the operator. If unknown: 0 (both Lat/Lon). + * @param operator_altitude_geo [m] Geodetic altitude of the operator relative to WGS84. If unknown: -1000 m. + * @param timestamp [s] 32 bit Unix Timestamp in seconds since 00:00:00 01/01/2019. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_open_drone_id_system_update_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int32_t operator_latitude, int32_t operator_longitude, float operator_altitude_geo, uint32_t timestamp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN]; + _mav_put_int32_t(buf, 0, operator_latitude); + _mav_put_int32_t(buf, 4, operator_longitude); + _mav_put_float(buf, 8, operator_altitude_geo); + _mav_put_uint32_t(buf, 12, timestamp); + _mav_put_uint8_t(buf, 16, target_system); + _mav_put_uint8_t(buf, 17, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN); +#else + mavlink_open_drone_id_system_update_t packet; + packet.operator_latitude = operator_latitude; + packet.operator_longitude = operator_longitude; + packet.operator_altitude_geo = operator_altitude_geo; + packet.timestamp = timestamp; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_MIN_LEN, MAVLINK_MSG_ID_OPEN_DRONE_ID_SYSTEM_UPDATE_LEN); +#endif +} + /** * @brief Pack a open_drone_id_system_update message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_open_drone_id_system_update_encode_chan(uint8 return mavlink_msg_open_drone_id_system_update_pack_chan(system_id, component_id, chan, msg, open_drone_id_system_update->target_system, open_drone_id_system_update->target_component, open_drone_id_system_update->operator_latitude, open_drone_id_system_update->operator_longitude, open_drone_id_system_update->operator_altitude_geo, open_drone_id_system_update->timestamp); } +/** + * @brief Encode a open_drone_id_system_update struct with provided status structure + * + * @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 open_drone_id_system_update C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_open_drone_id_system_update_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_open_drone_id_system_update_t* open_drone_id_system_update) +{ + return mavlink_msg_open_drone_id_system_update_pack_status(system_id, component_id, _status, msg, open_drone_id_system_update->target_system, open_drone_id_system_update->target_component, open_drone_id_system_update->operator_latitude, open_drone_id_system_update->operator_longitude, open_drone_id_system_update->operator_altitude_geo, open_drone_id_system_update->timestamp); +} + /** * @brief Send a open_drone_id_system_update message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_optical_flow.h b/common/mavlink_msg_optical_flow.h index 0c414a84..45f648d9 100644 --- a/common/mavlink_msg_optical_flow.h +++ b/common/mavlink_msg_optical_flow.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC); } +/** + * @brief Pack a optical_flow 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param sensor_id Sensor ID + * @param flow_x [dpix] Flow in x-sensor direction + * @param flow_y [dpix] Flow in y-sensor direction + * @param flow_comp_m_x [m/s] Flow in x-sensor direction, angular-speed compensated + * @param flow_comp_m_y [m/s] Flow in y-sensor direction, angular-speed compensated + * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality + * @param ground_distance [m] Ground distance. Positive value: distance known. Negative value: Unknown distance + * @param flow_rate_x [rad/s] Flow rate about X axis + * @param flow_rate_y [rad/s] Flow rate about Y axis + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_optical_flow_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance, float flow_rate_x, float flow_rate_y) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, flow_comp_m_x); + _mav_put_float(buf, 12, flow_comp_m_y); + _mav_put_float(buf, 16, ground_distance); + _mav_put_int16_t(buf, 20, flow_x); + _mav_put_int16_t(buf, 22, flow_y); + _mav_put_uint8_t(buf, 24, sensor_id); + _mav_put_uint8_t(buf, 25, quality); + _mav_put_float(buf, 26, flow_rate_x); + _mav_put_float(buf, 30, flow_rate_y); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN); +#else + mavlink_optical_flow_t packet; + packet.time_usec = time_usec; + packet.flow_comp_m_x = flow_comp_m_x; + packet.flow_comp_m_y = flow_comp_m_y; + packet.ground_distance = ground_distance; + packet.flow_x = flow_x; + packet.flow_y = flow_y; + packet.sensor_id = sensor_id; + packet.quality = quality; + packet.flow_rate_x = flow_rate_x; + packet.flow_rate_y = flow_rate_y; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN); +#endif +} + /** * @brief Pack a optical_flow message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_optical_flow_encode_chan(uint8_t system_id, u return mavlink_msg_optical_flow_pack_chan(system_id, component_id, chan, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y); } +/** + * @brief Encode a optical_flow struct with provided status structure + * + * @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 optical_flow C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_optical_flow_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow) +{ + return mavlink_msg_optical_flow_pack_status(system_id, component_id, _status, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y); +} + /** * @brief Send a optical_flow message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_optical_flow_rad.h b/common/mavlink_msg_optical_flow_rad.h index a8065dce..df26d625 100644 --- a/common/mavlink_msg_optical_flow_rad.h +++ b/common/mavlink_msg_optical_flow_rad.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_optical_flow_rad_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_CRC); } +/** + * @brief Pack a optical_flow_rad 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param sensor_id Sensor ID + * @param integration_time_us [us] Integration time. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the. + * @param integrated_x [rad] Flow around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.) + * @param integrated_y [rad] Flow around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.) + * @param integrated_xgyro [rad] RH rotation around X axis + * @param integrated_ygyro [rad] RH rotation around Y axis + * @param integrated_zgyro [rad] RH rotation around Z axis + * @param temperature [cdegC] Temperature + * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality + * @param time_delta_distance_us [us] Time since the distance was sampled. + * @param distance [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_optical_flow_rad_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t sensor_id, uint32_t integration_time_us, float integrated_x, float integrated_y, float integrated_xgyro, float integrated_ygyro, float integrated_zgyro, int16_t temperature, uint8_t quality, uint32_t time_delta_distance_us, float distance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, integration_time_us); + _mav_put_float(buf, 12, integrated_x); + _mav_put_float(buf, 16, integrated_y); + _mav_put_float(buf, 20, integrated_xgyro); + _mav_put_float(buf, 24, integrated_ygyro); + _mav_put_float(buf, 28, integrated_zgyro); + _mav_put_uint32_t(buf, 32, time_delta_distance_us); + _mav_put_float(buf, 36, distance); + _mav_put_int16_t(buf, 40, temperature); + _mav_put_uint8_t(buf, 42, sensor_id); + _mav_put_uint8_t(buf, 43, quality); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN); +#else + mavlink_optical_flow_rad_t packet; + packet.time_usec = time_usec; + packet.integration_time_us = integration_time_us; + packet.integrated_x = integrated_x; + packet.integrated_y = integrated_y; + packet.integrated_xgyro = integrated_xgyro; + packet.integrated_ygyro = integrated_ygyro; + packet.integrated_zgyro = integrated_zgyro; + packet.time_delta_distance_us = time_delta_distance_us; + packet.distance = distance; + packet.temperature = temperature; + packet.sensor_id = sensor_id; + packet.quality = quality; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW_RAD; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_RAD_LEN); +#endif +} + /** * @brief Pack a optical_flow_rad message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_optical_flow_rad_encode_chan(uint8_t system_i return mavlink_msg_optical_flow_rad_pack_chan(system_id, component_id, chan, msg, optical_flow_rad->time_usec, optical_flow_rad->sensor_id, optical_flow_rad->integration_time_us, optical_flow_rad->integrated_x, optical_flow_rad->integrated_y, optical_flow_rad->integrated_xgyro, optical_flow_rad->integrated_ygyro, optical_flow_rad->integrated_zgyro, optical_flow_rad->temperature, optical_flow_rad->quality, optical_flow_rad->time_delta_distance_us, optical_flow_rad->distance); } +/** + * @brief Encode a optical_flow_rad struct with provided status structure + * + * @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 optical_flow_rad C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_optical_flow_rad_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_optical_flow_rad_t* optical_flow_rad) +{ + return mavlink_msg_optical_flow_rad_pack_status(system_id, component_id, _status, msg, optical_flow_rad->time_usec, optical_flow_rad->sensor_id, optical_flow_rad->integration_time_us, optical_flow_rad->integrated_x, optical_flow_rad->integrated_y, optical_flow_rad->integrated_xgyro, optical_flow_rad->integrated_ygyro, optical_flow_rad->integrated_zgyro, optical_flow_rad->temperature, optical_flow_rad->quality, optical_flow_rad->time_delta_distance_us, optical_flow_rad->distance); +} + /** * @brief Send a optical_flow_rad message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_orbit_execution_status.h b/common/mavlink_msg_orbit_execution_status.h index d5d9f3b1..2a38cb66 100644 --- a/common/mavlink_msg_orbit_execution_status.h +++ b/common/mavlink_msg_orbit_execution_status.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_orbit_execution_status_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_CRC); } +/** + * @brief Pack a orbit_execution_status 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param radius [m] Radius of the orbit circle. Positive values orbit clockwise, negative values orbit counter-clockwise. + * @param frame The coordinate system of the fields: x, y, z. + * @param x X coordinate of center point. Coordinate system depends on frame field: local = x position in meters * 1e4, global = latitude in degrees * 1e7. + * @param y Y coordinate of center point. Coordinate system depends on frame field: local = x position in meters * 1e4, global = latitude in degrees * 1e7. + * @param z [m] Altitude of center point. Coordinate system depends on frame field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_orbit_execution_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float radius, uint8_t frame, int32_t x, int32_t y, float z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, radius); + _mav_put_int32_t(buf, 12, x); + _mav_put_int32_t(buf, 16, y); + _mav_put_float(buf, 20, z); + _mav_put_uint8_t(buf, 24, frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN); +#else + mavlink_orbit_execution_status_t packet; + packet.time_usec = time_usec; + packet.radius = radius; + packet.x = x; + packet.y = y; + packet.z = z; + packet.frame = frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS_LEN); +#endif +} + /** * @brief Pack a orbit_execution_status message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_orbit_execution_status_encode_chan(uint8_t sy return mavlink_msg_orbit_execution_status_pack_chan(system_id, component_id, chan, msg, orbit_execution_status->time_usec, orbit_execution_status->radius, orbit_execution_status->frame, orbit_execution_status->x, orbit_execution_status->y, orbit_execution_status->z); } +/** + * @brief Encode a orbit_execution_status struct with provided status structure + * + * @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 orbit_execution_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_orbit_execution_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_orbit_execution_status_t* orbit_execution_status) +{ + return mavlink_msg_orbit_execution_status_pack_status(system_id, component_id, _status, msg, orbit_execution_status->time_usec, orbit_execution_status->radius, orbit_execution_status->frame, orbit_execution_status->x, orbit_execution_status->y, orbit_execution_status->z); +} + /** * @brief Send a orbit_execution_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_ext_ack.h b/common/mavlink_msg_param_ext_ack.h index e3da02b5..b5ef9f62 100644 --- a/common/mavlink_msg_param_ext_ack.h +++ b/common/mavlink_msg_param_ext_ack.h @@ -80,6 +80,46 @@ static inline uint16_t mavlink_msg_param_ext_ack_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_ACK_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN, MAVLINK_MSG_ID_PARAM_EXT_ACK_CRC); } +/** + * @brief Pack a param_ext_ack 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 param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Parameter value (new value if PARAM_ACK_ACCEPTED, current value otherwise) + * @param param_type Parameter type. + * @param param_result Result code. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ext_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *param_id, const char *param_value, uint8_t param_type, uint8_t param_result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN]; + _mav_put_uint8_t(buf, 144, param_type); + _mav_put_uint8_t(buf, 145, param_result); + _mav_put_char_array(buf, 0, param_id, 16); + _mav_put_char_array(buf, 16, param_value, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN); +#else + mavlink_param_ext_ack_t packet; + packet.param_type = param_type; + packet.param_result = param_result; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_ACK_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN, MAVLINK_MSG_ID_PARAM_EXT_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_ACK_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_ACK_LEN); +#endif +} + /** * @brief Pack a param_ext_ack message on a channel * @param system_id ID of this system @@ -143,6 +183,20 @@ static inline uint16_t mavlink_msg_param_ext_ack_encode_chan(uint8_t system_id, return mavlink_msg_param_ext_ack_pack_chan(system_id, component_id, chan, msg, param_ext_ack->param_id, param_ext_ack->param_value, param_ext_ack->param_type, param_ext_ack->param_result); } +/** + * @brief Encode a param_ext_ack struct with provided status structure + * + * @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 param_ext_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ext_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_ack_t* param_ext_ack) +{ + return mavlink_msg_param_ext_ack_pack_status(system_id, component_id, _status, msg, param_ext_ack->param_id, param_ext_ack->param_value, param_ext_ack->param_type, param_ext_ack->param_result); +} + /** * @brief Send a param_ext_ack message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_ext_request_list.h b/common/mavlink_msg_param_ext_request_list.h index 945fd0c3..ece81afd 100644 --- a/common/mavlink_msg_param_ext_request_list.h +++ b/common/mavlink_msg_param_ext_request_list.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_param_ext_request_list_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); } +/** + * @brief Pack a param_ext_request_list 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ext_request_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN); +#else + mavlink_param_ext_request_list_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN); +#endif +} + /** * @brief Pack a param_ext_request_list message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_param_ext_request_list_encode_chan(uint8_t sy return mavlink_msg_param_ext_request_list_pack_chan(system_id, component_id, chan, msg, param_ext_request_list->target_system, param_ext_request_list->target_component); } +/** + * @brief Encode a param_ext_request_list struct with provided status structure + * + * @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 param_ext_request_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ext_request_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_request_list_t* param_ext_request_list) +{ + return mavlink_msg_param_ext_request_list_pack_status(system_id, component_id, _status, msg, param_ext_request_list->target_system, param_ext_request_list->target_component); +} + /** * @brief Send a param_ext_request_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_ext_request_read.h b/common/mavlink_msg_param_ext_request_read.h index 3c18f63d..f5589d92 100644 --- a/common/mavlink_msg_param_ext_request_read.h +++ b/common/mavlink_msg_param_ext_request_read.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_param_ext_request_read_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_CRC); } +/** + * @brief Pack a param_ext_request_read 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 target_system System ID + * @param target_component Component ID + * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Set to -1 to use the Parameter ID field as identifier (else param_id will be ignored) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ext_request_read_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN]; + _mav_put_int16_t(buf, 0, param_index); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_char_array(buf, 4, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN); +#else + mavlink_param_ext_request_read_t packet; + packet.param_index = param_index; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_READ_LEN); +#endif +} + /** * @brief Pack a param_ext_request_read message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_param_ext_request_read_encode_chan(uint8_t sy return mavlink_msg_param_ext_request_read_pack_chan(system_id, component_id, chan, msg, param_ext_request_read->target_system, param_ext_request_read->target_component, param_ext_request_read->param_id, param_ext_request_read->param_index); } +/** + * @brief Encode a param_ext_request_read struct with provided status structure + * + * @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 param_ext_request_read C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ext_request_read_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_request_read_t* param_ext_request_read) +{ + return mavlink_msg_param_ext_request_read_pack_status(system_id, component_id, _status, msg, param_ext_request_read->target_system, param_ext_request_read->target_component, param_ext_request_read->param_id, param_ext_request_read->param_index); +} + /** * @brief Send a param_ext_request_read message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_ext_set.h b/common/mavlink_msg_param_ext_set.h index c17e0a32..44023def 100644 --- a/common/mavlink_msg_param_ext_set.h +++ b/common/mavlink_msg_param_ext_set.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_param_ext_set_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_SET_LEN, MAVLINK_MSG_ID_PARAM_EXT_SET_CRC); } +/** + * @brief Pack a param_ext_set 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 target_system System ID + * @param target_component Component ID + * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Parameter value + * @param param_type Parameter type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ext_set_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, const char *param_value, uint8_t param_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_EXT_SET_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 146, param_type); + _mav_put_char_array(buf, 2, param_id, 16); + _mav_put_char_array(buf, 18, param_value, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_SET_LEN); +#else + mavlink_param_ext_set_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.param_type = param_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_SET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_SET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_SET_LEN, MAVLINK_MSG_ID_PARAM_EXT_SET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_SET_LEN); +#endif +} + /** * @brief Pack a param_ext_set message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_param_ext_set_encode_chan(uint8_t system_id, return mavlink_msg_param_ext_set_pack_chan(system_id, component_id, chan, msg, param_ext_set->target_system, param_ext_set->target_component, param_ext_set->param_id, param_ext_set->param_value, param_ext_set->param_type); } +/** + * @brief Encode a param_ext_set struct with provided status structure + * + * @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 param_ext_set C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ext_set_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_set_t* param_ext_set) +{ + return mavlink_msg_param_ext_set_pack_status(system_id, component_id, _status, msg, param_ext_set->target_system, param_ext_set->target_component, param_ext_set->param_id, param_ext_set->param_value, param_ext_set->param_type); +} + /** * @brief Send a param_ext_set message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_ext_value.h b/common/mavlink_msg_param_ext_value.h index e9384f0b..efc7298b 100644 --- a/common/mavlink_msg_param_ext_value.h +++ b/common/mavlink_msg_param_ext_value.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_param_ext_value_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC); } +/** + * @brief Pack a param_ext_value 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 param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Parameter value + * @param param_type Parameter type. + * @param param_count Total number of parameters + * @param param_index Index of this parameter + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ext_value_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *param_id, const char *param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN]; + _mav_put_uint16_t(buf, 0, param_count); + _mav_put_uint16_t(buf, 2, param_index); + _mav_put_uint8_t(buf, 148, param_type); + _mav_put_char_array(buf, 4, param_id, 16); + _mav_put_char_array(buf, 20, param_value, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN); +#else + mavlink_param_ext_value_t packet; + packet.param_count = param_count; + packet.param_index = param_index; + packet.param_type = param_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_VALUE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN); +#endif +} + /** * @brief Pack a param_ext_value message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_param_ext_value_encode_chan(uint8_t system_id return mavlink_msg_param_ext_value_pack_chan(system_id, component_id, chan, msg, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index); } +/** + * @brief Encode a param_ext_value struct with provided status structure + * + * @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 param_ext_value C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ext_value_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_value_t* param_ext_value) +{ + return mavlink_msg_param_ext_value_pack_status(system_id, component_id, _status, msg, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index); +} + /** * @brief Send a param_ext_value message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_map_rc.h b/common/mavlink_msg_param_map_rc.h index 46fcaa19..71595534 100644 --- a/common/mavlink_msg_param_map_rc.h +++ b/common/mavlink_msg_param_map_rc.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_param_map_rc_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_MAP_RC_MIN_LEN, MAVLINK_MSG_ID_PARAM_MAP_RC_LEN, MAVLINK_MSG_ID_PARAM_MAP_RC_CRC); } +/** + * @brief Pack a param_map_rc 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 target_system System ID + * @param target_component Component ID + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored), send -2 to disable any existing map for this rc_channel_index. + * @param parameter_rc_channel_index Index of parameter RC channel. Not equal to the RC channel id. Typically corresponds to a potentiometer-knob on the RC. + * @param param_value0 Initial parameter value + * @param scale Scale, maps the RC range [-1, 1] to a parameter value + * @param param_value_min Minimum param value. The protocol does not define if this overwrites an onboard minimum value. (Depends on implementation) + * @param param_value_max Maximum param value. The protocol does not define if this overwrites an onboard maximum value. (Depends on implementation) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_map_rc_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index, uint8_t parameter_rc_channel_index, float param_value0, float scale, float param_value_min, float param_value_max) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_MAP_RC_LEN]; + _mav_put_float(buf, 0, param_value0); + _mav_put_float(buf, 4, scale); + _mav_put_float(buf, 8, param_value_min); + _mav_put_float(buf, 12, param_value_max); + _mav_put_int16_t(buf, 16, param_index); + _mav_put_uint8_t(buf, 18, target_system); + _mav_put_uint8_t(buf, 19, target_component); + _mav_put_uint8_t(buf, 36, parameter_rc_channel_index); + _mav_put_char_array(buf, 20, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_MAP_RC_LEN); +#else + mavlink_param_map_rc_t packet; + packet.param_value0 = param_value0; + packet.scale = scale; + packet.param_value_min = param_value_min; + packet.param_value_max = param_value_max; + packet.param_index = param_index; + packet.target_system = target_system; + packet.target_component = target_component; + packet.parameter_rc_channel_index = parameter_rc_channel_index; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_MAP_RC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_MAP_RC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_MAP_RC_MIN_LEN, MAVLINK_MSG_ID_PARAM_MAP_RC_LEN, MAVLINK_MSG_ID_PARAM_MAP_RC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_MAP_RC_MIN_LEN, MAVLINK_MSG_ID_PARAM_MAP_RC_LEN); +#endif +} + /** * @brief Pack a param_map_rc message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_param_map_rc_encode_chan(uint8_t system_id, u return mavlink_msg_param_map_rc_pack_chan(system_id, component_id, chan, msg, param_map_rc->target_system, param_map_rc->target_component, param_map_rc->param_id, param_map_rc->param_index, param_map_rc->parameter_rc_channel_index, param_map_rc->param_value0, param_map_rc->scale, param_map_rc->param_value_min, param_map_rc->param_value_max); } +/** + * @brief Encode a param_map_rc struct with provided status structure + * + * @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 param_map_rc C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_map_rc_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_map_rc_t* param_map_rc) +{ + return mavlink_msg_param_map_rc_pack_status(system_id, component_id, _status, msg, param_map_rc->target_system, param_map_rc->target_component, param_map_rc->param_id, param_map_rc->param_index, param_map_rc->parameter_rc_channel_index, param_map_rc->param_value0, param_map_rc->scale, param_map_rc->param_value_min, param_map_rc->param_value_max); +} + /** * @brief Send a param_map_rc message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_request_list.h b/common/mavlink_msg_param_request_list.h index 7ccfc87b..d569e9fb 100644 --- a/common/mavlink_msg_param_request_list.h +++ b/common/mavlink_msg_param_request_list.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_param_request_list_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); } +/** + * @brief Pack a param_request_list 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_request_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); +#else + mavlink_param_request_list_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); +#endif +} + /** * @brief Pack a param_request_list message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_param_request_list_encode_chan(uint8_t system return mavlink_msg_param_request_list_pack_chan(system_id, component_id, chan, msg, param_request_list->target_system, param_request_list->target_component); } +/** + * @brief Encode a param_request_list struct with provided status structure + * + * @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 param_request_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_request_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_request_list_t* param_request_list) +{ + return mavlink_msg_param_request_list_pack_status(system_id, component_id, _status, msg, param_request_list->target_system, param_request_list->target_component); +} + /** * @brief Send a param_request_list message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_request_read.h b/common/mavlink_msg_param_request_read.h index fa71a491..276924e3 100644 --- a/common/mavlink_msg_param_request_read.h +++ b/common/mavlink_msg_param_request_read.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_param_request_read_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC); } +/** + * @brief Pack a param_request_read 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 target_system System ID + * @param target_component Component ID + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_request_read_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN]; + _mav_put_int16_t(buf, 0, param_index); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_char_array(buf, 4, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN); +#else + mavlink_param_request_read_t packet; + packet.param_index = param_index; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_READ; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN); +#endif +} + /** * @brief Pack a param_request_read message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_param_request_read_encode_chan(uint8_t system return mavlink_msg_param_request_read_pack_chan(system_id, component_id, chan, msg, param_request_read->target_system, param_request_read->target_component, param_request_read->param_id, param_request_read->param_index); } +/** + * @brief Encode a param_request_read struct with provided status structure + * + * @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 param_request_read C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_request_read_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_request_read_t* param_request_read) +{ + return mavlink_msg_param_request_read_pack_status(system_id, component_id, _status, msg, param_request_read->target_system, param_request_read->target_component, param_request_read->param_id, param_request_read->param_index); +} + /** * @brief Send a param_request_read message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_set.h b/common/mavlink_msg_param_set.h index 36a2bd43..26956811 100644 --- a/common/mavlink_msg_param_set.h +++ b/common/mavlink_msg_param_set.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_SET_LEN, MAVLINK_MSG_ID_PARAM_SET_CRC); } +/** + * @brief Pack a param_set 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 target_system System ID + * @param target_component Component ID + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Onboard parameter value + * @param param_type Onboard parameter type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_set_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, float param_value, uint8_t param_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_SET_LEN]; + _mav_put_float(buf, 0, param_value); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 22, param_type); + _mav_put_char_array(buf, 6, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_SET_LEN); +#else + mavlink_param_set_t packet; + packet.param_value = param_value; + packet.target_system = target_system; + packet.target_component = target_component; + packet.param_type = param_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_SET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_SET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_SET_LEN, MAVLINK_MSG_ID_PARAM_SET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_SET_MIN_LEN, MAVLINK_MSG_ID_PARAM_SET_LEN); +#endif +} + /** * @brief Pack a param_set message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_param_set_encode_chan(uint8_t system_id, uint return mavlink_msg_param_set_pack_chan(system_id, component_id, chan, msg, param_set->target_system, param_set->target_component, param_set->param_id, param_set->param_value, param_set->param_type); } +/** + * @brief Encode a param_set struct with provided status structure + * + * @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 param_set C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_set_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_set_t* param_set) +{ + return mavlink_msg_param_set_pack_status(system_id, component_id, _status, msg, param_set->target_system, param_set->target_component, param_set->param_id, param_set->param_value, param_set->param_type); +} + /** * @brief Send a param_set message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_param_value.h b/common/mavlink_msg_param_value.h index 58bf4c53..b32e9a50 100644 --- a/common/mavlink_msg_param_value.h +++ b/common/mavlink_msg_param_value.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_LEN, MAVLINK_MSG_ID_PARAM_VALUE_CRC); } +/** + * @brief Pack a param_value 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 param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Onboard parameter value + * @param param_type Onboard parameter type. + * @param param_count Total number of onboard parameters + * @param param_index Index of this onboard parameter + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_value_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *param_id, float param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_VALUE_LEN]; + _mav_put_float(buf, 0, param_value); + _mav_put_uint16_t(buf, 4, param_count); + _mav_put_uint16_t(buf, 6, param_index); + _mav_put_uint8_t(buf, 24, param_type); + _mav_put_char_array(buf, 8, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_VALUE_LEN); +#else + mavlink_param_value_t packet; + packet.param_value = param_value; + packet.param_count = param_count; + packet.param_index = param_index; + packet.param_type = param_type; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_VALUE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_LEN, MAVLINK_MSG_ID_PARAM_VALUE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_LEN); +#endif +} + /** * @brief Pack a param_value message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_param_value_encode_chan(uint8_t system_id, ui return mavlink_msg_param_value_pack_chan(system_id, component_id, chan, msg, param_value->param_id, param_value->param_value, param_value->param_type, param_value->param_count, param_value->param_index); } +/** + * @brief Encode a param_value struct with provided status structure + * + * @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 param_value C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_value_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_value_t* param_value) +{ + return mavlink_msg_param_value_pack_status(system_id, component_id, _status, msg, param_value->param_id, param_value->param_value, param_value->param_type, param_value->param_count, param_value->param_index); +} + /** * @brief Send a param_value message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_ping.h b/common/mavlink_msg_ping.h index e91a9b29..a7d03541 100644 --- a/common/mavlink_msg_ping.h +++ b/common/mavlink_msg_ping.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_ping_pack(uint8_t system_id, uint8_t componen return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PING_MIN_LEN, MAVLINK_MSG_ID_PING_LEN, MAVLINK_MSG_ID_PING_CRC); } +/** + * @brief Pack a ping 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param seq PING sequence + * @param target_system 0: request ping from all receiving systems. If greater than 0: message is a ping response and number is the system id of the requesting system + * @param target_component 0: request ping from all receiving components. If greater than 0: message is a ping response and number is the component id of the requesting component. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ping_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t seq, uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PING_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, seq); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint8_t(buf, 13, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PING_LEN); +#else + mavlink_ping_t packet; + packet.time_usec = time_usec; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PING_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PING; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PING_MIN_LEN, MAVLINK_MSG_ID_PING_LEN, MAVLINK_MSG_ID_PING_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PING_MIN_LEN, MAVLINK_MSG_ID_PING_LEN); +#endif +} + /** * @brief Pack a ping message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_ping_encode_chan(uint8_t system_id, uint8_t c return mavlink_msg_ping_pack_chan(system_id, component_id, chan, msg, ping->time_usec, ping->seq, ping->target_system, ping->target_component); } +/** + * @brief Encode a ping struct with provided status structure + * + * @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 ping C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ping_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ping_t* ping) +{ + return mavlink_msg_ping_pack_status(system_id, component_id, _status, msg, ping->time_usec, ping->seq, ping->target_system, ping->target_component); +} + /** * @brief Send a ping message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_play_tune.h b/common/mavlink_msg_play_tune.h index dac305ec..502f2f6f 100644 --- a/common/mavlink_msg_play_tune.h +++ b/common/mavlink_msg_play_tune.h @@ -80,6 +80,46 @@ static inline uint16_t mavlink_msg_play_tune_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC); } +/** + * @brief Pack a play_tune 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 target_system System ID + * @param target_component Component ID + * @param tune tune in board specific format + * @param tune2 tune extension (appended to tune) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_play_tune_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *tune, const char *tune2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PLAY_TUNE_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_char_array(buf, 2, tune, 30); + _mav_put_char_array(buf, 32, tune2, 200); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_LEN); +#else + mavlink_play_tune_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.tune, tune, sizeof(char)*30); + mav_array_memcpy(packet.tune2, tune2, sizeof(char)*200); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN); +#endif +} + /** * @brief Pack a play_tune message on a channel * @param system_id ID of this system @@ -143,6 +183,20 @@ static inline uint16_t mavlink_msg_play_tune_encode_chan(uint8_t system_id, uint return mavlink_msg_play_tune_pack_chan(system_id, component_id, chan, msg, play_tune->target_system, play_tune->target_component, play_tune->tune, play_tune->tune2); } +/** + * @brief Encode a play_tune struct with provided status structure + * + * @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 play_tune C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_play_tune_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_play_tune_t* play_tune) +{ + return mavlink_msg_play_tune_pack_status(system_id, component_id, _status, msg, play_tune->target_system, play_tune->target_component, play_tune->tune, play_tune->tune2); +} + /** * @brief Send a play_tune message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_play_tune_v2.h b/common/mavlink_msg_play_tune_v2.h index f71da0aa..2985f429 100644 --- a/common/mavlink_msg_play_tune_v2.h +++ b/common/mavlink_msg_play_tune_v2.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_play_tune_v2_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC); } +/** + * @brief Pack a play_tune_v2 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 target_system System ID + * @param target_component Component ID + * @param format Tune format + * @param tune Tune definition as a NULL-terminated string. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_play_tune_v2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t format, const char *tune) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN]; + _mav_put_uint32_t(buf, 0, format); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_char_array(buf, 6, tune, 248); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN); +#else + mavlink_play_tune_v2_t packet; + packet.format = format; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.tune, tune, sizeof(char)*248); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE_V2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN); +#endif +} + /** * @brief Pack a play_tune_v2 message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_play_tune_v2_encode_chan(uint8_t system_id, u return mavlink_msg_play_tune_v2_pack_chan(system_id, component_id, chan, msg, play_tune_v2->target_system, play_tune_v2->target_component, play_tune_v2->format, play_tune_v2->tune); } +/** + * @brief Encode a play_tune_v2 struct with provided status structure + * + * @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 play_tune_v2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_play_tune_v2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_play_tune_v2_t* play_tune_v2) +{ + return mavlink_msg_play_tune_v2_pack_status(system_id, component_id, _status, msg, play_tune_v2->target_system, play_tune_v2->target_component, play_tune_v2->format, play_tune_v2->tune); +} + /** * @brief Send a play_tune_v2 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_position_target_global_int.h b/common/mavlink_msg_position_target_global_int.h index bb619b50..2ad7a998 100644 --- a/common/mavlink_msg_position_target_global_int.h +++ b/common/mavlink_msg_position_target_global_int.h @@ -141,6 +141,78 @@ static inline uint16_t mavlink_msg_position_target_global_int_pack(uint8_t syste return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_CRC); } +/** + * @brief Pack a position_target_global_int 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 time_boot_ms [ms] Timestamp (time since system boot). The rationale for the timestamp in the setpoint is to allow the system to compensate for the transport delay of the setpoint. This allows the system to compensate processing latency. + * @param coordinate_frame Valid options are: MAV_FRAME_GLOBAL_INT = 5, MAV_FRAME_GLOBAL_RELATIVE_ALT_INT = 6, MAV_FRAME_GLOBAL_TERRAIN_ALT_INT = 11 + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param lat_int [degE7] X Position in WGS84 frame + * @param lon_int [degE7] Y Position in WGS84 frame + * @param alt [m] Altitude (MSL, AGL or relative to home altitude, depending on frame) + * @param vx [m/s] X velocity in NED frame + * @param vy [m/s] Y velocity in NED frame + * @param vz [m/s] Z velocity in NED frame + * @param afx [m/s/s] X acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afy [m/s/s] Y acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afz [m/s/s] Z acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param yaw [rad] yaw setpoint + * @param yaw_rate [rad/s] yaw rate setpoint + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_position_target_global_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t coordinate_frame, uint16_t type_mask, int32_t lat_int, int32_t lon_int, float alt, float vx, float vy, float vz, float afx, float afy, float afz, float yaw, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat_int); + _mav_put_int32_t(buf, 8, lon_int); + _mav_put_float(buf, 12, alt); + _mav_put_float(buf, 16, vx); + _mav_put_float(buf, 20, vy); + _mav_put_float(buf, 24, vz); + _mav_put_float(buf, 28, afx); + _mav_put_float(buf, 32, afy); + _mav_put_float(buf, 36, afz); + _mav_put_float(buf, 40, yaw); + _mav_put_float(buf, 44, yaw_rate); + _mav_put_uint16_t(buf, 48, type_mask); + _mav_put_uint8_t(buf, 50, coordinate_frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN); +#else + mavlink_position_target_global_int_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat_int = lat_int; + packet.lon_int = lon_int; + packet.alt = alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.afx = afx; + packet.afy = afy; + packet.afz = afz; + packet.yaw = yaw; + packet.yaw_rate = yaw_rate; + packet.type_mask = type_mask; + packet.coordinate_frame = coordinate_frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT_LEN); +#endif +} + /** * @brief Pack a position_target_global_int message on a channel * @param system_id ID of this system @@ -236,6 +308,20 @@ static inline uint16_t mavlink_msg_position_target_global_int_encode_chan(uint8_ return mavlink_msg_position_target_global_int_pack_chan(system_id, component_id, chan, msg, position_target_global_int->time_boot_ms, position_target_global_int->coordinate_frame, position_target_global_int->type_mask, position_target_global_int->lat_int, position_target_global_int->lon_int, position_target_global_int->alt, position_target_global_int->vx, position_target_global_int->vy, position_target_global_int->vz, position_target_global_int->afx, position_target_global_int->afy, position_target_global_int->afz, position_target_global_int->yaw, position_target_global_int->yaw_rate); } +/** + * @brief Encode a position_target_global_int struct with provided status structure + * + * @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 position_target_global_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_position_target_global_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_position_target_global_int_t* position_target_global_int) +{ + return mavlink_msg_position_target_global_int_pack_status(system_id, component_id, _status, msg, position_target_global_int->time_boot_ms, position_target_global_int->coordinate_frame, position_target_global_int->type_mask, position_target_global_int->lat_int, position_target_global_int->lon_int, position_target_global_int->alt, position_target_global_int->vx, position_target_global_int->vy, position_target_global_int->vz, position_target_global_int->afx, position_target_global_int->afy, position_target_global_int->afz, position_target_global_int->yaw, position_target_global_int->yaw_rate); +} + /** * @brief Send a position_target_global_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_position_target_local_ned.h b/common/mavlink_msg_position_target_local_ned.h index 6aa98aee..975652af 100644 --- a/common/mavlink_msg_position_target_local_ned.h +++ b/common/mavlink_msg_position_target_local_ned.h @@ -141,6 +141,78 @@ static inline uint16_t mavlink_msg_position_target_local_ned_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_CRC); } +/** + * @brief Pack a position_target_local_ned 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param coordinate_frame Valid options are: MAV_FRAME_LOCAL_NED = 1, MAV_FRAME_LOCAL_OFFSET_NED = 7, MAV_FRAME_BODY_NED = 8, MAV_FRAME_BODY_OFFSET_NED = 9 + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param x [m] X Position in NED frame + * @param y [m] Y Position in NED frame + * @param z [m] Z Position in NED frame (note, altitude is negative in NED) + * @param vx [m/s] X velocity in NED frame + * @param vy [m/s] Y velocity in NED frame + * @param vz [m/s] Z velocity in NED frame + * @param afx [m/s/s] X acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afy [m/s/s] Y acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afz [m/s/s] Z acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param yaw [rad] yaw setpoint + * @param yaw_rate [rad/s] yaw rate setpoint + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_position_target_local_ned_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t coordinate_frame, uint16_t type_mask, float x, float y, float z, float vx, float vy, float vz, float afx, float afy, float afz, float yaw, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, vx); + _mav_put_float(buf, 20, vy); + _mav_put_float(buf, 24, vz); + _mav_put_float(buf, 28, afx); + _mav_put_float(buf, 32, afy); + _mav_put_float(buf, 36, afz); + _mav_put_float(buf, 40, yaw); + _mav_put_float(buf, 44, yaw_rate); + _mav_put_uint16_t(buf, 48, type_mask); + _mav_put_uint8_t(buf, 50, coordinate_frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN); +#else + mavlink_position_target_local_ned_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.afx = afx; + packet.afy = afy; + packet.afz = afz; + packet.yaw = yaw; + packet.yaw_rate = yaw_rate; + packet.type_mask = type_mask; + packet.coordinate_frame = coordinate_frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED_LEN); +#endif +} + /** * @brief Pack a position_target_local_ned message on a channel * @param system_id ID of this system @@ -236,6 +308,20 @@ static inline uint16_t mavlink_msg_position_target_local_ned_encode_chan(uint8_t return mavlink_msg_position_target_local_ned_pack_chan(system_id, component_id, chan, msg, position_target_local_ned->time_boot_ms, position_target_local_ned->coordinate_frame, position_target_local_ned->type_mask, position_target_local_ned->x, position_target_local_ned->y, position_target_local_ned->z, position_target_local_ned->vx, position_target_local_ned->vy, position_target_local_ned->vz, position_target_local_ned->afx, position_target_local_ned->afy, position_target_local_ned->afz, position_target_local_ned->yaw, position_target_local_ned->yaw_rate); } +/** + * @brief Encode a position_target_local_ned struct with provided status structure + * + * @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 position_target_local_ned C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_position_target_local_ned_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_position_target_local_ned_t* position_target_local_ned) +{ + return mavlink_msg_position_target_local_ned_pack_status(system_id, component_id, _status, msg, position_target_local_ned->time_boot_ms, position_target_local_ned->coordinate_frame, position_target_local_ned->type_mask, position_target_local_ned->x, position_target_local_ned->y, position_target_local_ned->z, position_target_local_ned->vx, position_target_local_ned->vy, position_target_local_ned->vz, position_target_local_ned->afx, position_target_local_ned->afy, position_target_local_ned->afz, position_target_local_ned->yaw, position_target_local_ned->yaw_rate); +} + /** * @brief Send a position_target_local_ned message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_power_status.h b/common/mavlink_msg_power_status.h index a3cd2fe6..1343156d 100644 --- a/common/mavlink_msg_power_status.h +++ b/common/mavlink_msg_power_status.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_power_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); } +/** + * @brief Pack a power_status 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 Vcc [mV] 5V rail voltage. + * @param Vservo [mV] Servo rail voltage. + * @param flags Bitmap of power supply status flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_power_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t Vcc, uint16_t Vservo, uint16_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; + _mav_put_uint16_t(buf, 0, Vcc); + _mav_put_uint16_t(buf, 2, Vservo); + _mav_put_uint16_t(buf, 4, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POWER_STATUS_LEN); +#else + mavlink_power_status_t packet; + packet.Vcc = Vcc; + packet.Vservo = Vservo; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POWER_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_POWER_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN); +#endif +} + /** * @brief Pack a power_status message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_power_status_encode_chan(uint8_t system_id, u return mavlink_msg_power_status_pack_chan(system_id, component_id, chan, msg, power_status->Vcc, power_status->Vservo, power_status->flags); } +/** + * @brief Encode a power_status struct with provided status structure + * + * @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 power_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_power_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_power_status_t* power_status) +{ + return mavlink_msg_power_status_pack_status(system_id, component_id, _status, msg, power_status->Vcc, power_status->Vservo, power_status->flags); +} + /** * @brief Send a power_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_radio_status.h b/common/mavlink_msg_radio_status.h index baadd0b1..8a6c5591 100644 --- a/common/mavlink_msg_radio_status.h +++ b/common/mavlink_msg_radio_status.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_radio_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC); } +/** + * @brief Pack a radio_status 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 rssi Local (message sender) received signal strength indication in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @param remrssi Remote (message receiver) signal strength indication in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @param txbuf [%] Remaining free transmitter buffer space. + * @param noise Local background noise level. These are device dependent RSSI values (scale as approx 2x dB on SiK radios). Values: [0-254], UINT8_MAX: invalid/unknown. + * @param remnoise Remote background noise level. These are device dependent RSSI values (scale as approx 2x dB on SiK radios). Values: [0-254], UINT8_MAX: invalid/unknown. + * @param rxerrors Count of radio packet receive errors (since boot). + * @param fixed Count of error corrected radio packets (since boot). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RADIO_STATUS_LEN]; + _mav_put_uint16_t(buf, 0, rxerrors); + _mav_put_uint16_t(buf, 2, fixed); + _mav_put_uint8_t(buf, 4, rssi); + _mav_put_uint8_t(buf, 5, remrssi); + _mav_put_uint8_t(buf, 6, txbuf); + _mav_put_uint8_t(buf, 7, noise); + _mav_put_uint8_t(buf, 8, remnoise); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_STATUS_LEN); +#else + mavlink_radio_status_t packet; + packet.rxerrors = rxerrors; + packet.fixed = fixed; + packet.rssi = rssi; + packet.remrssi = remrssi; + packet.txbuf = txbuf; + packet.noise = noise; + packet.remnoise = remnoise; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN); +#endif +} + /** * @brief Pack a radio_status message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_radio_status_encode_chan(uint8_t system_id, u return mavlink_msg_radio_status_pack_chan(system_id, component_id, chan, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed); } +/** + * @brief Encode a radio_status struct with provided status structure + * + * @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 radio_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_radio_status_t* radio_status) +{ + return mavlink_msg_radio_status_pack_status(system_id, component_id, _status, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed); +} + /** * @brief Send a radio_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_raw_imu.h b/common/mavlink_msg_raw_imu.h index f80b8012..168359d8 100644 --- a/common/mavlink_msg_raw_imu.h +++ b/common/mavlink_msg_raw_imu.h @@ -129,6 +129,72 @@ static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC); } +/** + * @brief Pack a raw_imu 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param xacc X acceleration (raw) + * @param yacc Y acceleration (raw) + * @param zacc Z acceleration (raw) + * @param xgyro Angular speed around X axis (raw) + * @param ygyro Angular speed around Y axis (raw) + * @param zgyro Angular speed around Z axis (raw) + * @param xmag X Magnetic field (raw) + * @param ymag Y Magnetic field (raw) + * @param zmag Z Magnetic field (raw) + * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0) + * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_raw_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, 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, uint8_t id, int16_t temperature) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RAW_IMU_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int16_t(buf, 8, xacc); + _mav_put_int16_t(buf, 10, yacc); + _mav_put_int16_t(buf, 12, zacc); + _mav_put_int16_t(buf, 14, xgyro); + _mav_put_int16_t(buf, 16, ygyro); + _mav_put_int16_t(buf, 18, zgyro); + _mav_put_int16_t(buf, 20, xmag); + _mav_put_int16_t(buf, 22, ymag); + _mav_put_int16_t(buf, 24, zmag); + _mav_put_uint8_t(buf, 26, id); + _mav_put_int16_t(buf, 27, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN); +#else + mavlink_raw_imu_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.id = id; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RAW_IMU; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN); +#endif +} + /** * @brief Pack a raw_imu message on a channel * @param system_id ID of this system @@ -218,6 +284,20 @@ static inline uint16_t mavlink_msg_raw_imu_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_raw_imu_pack_chan(system_id, component_id, chan, msg, raw_imu->time_usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag, raw_imu->id, raw_imu->temperature); } +/** + * @brief Encode a raw_imu struct with provided status structure + * + * @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 raw_imu C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_raw_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_raw_imu_t* raw_imu) +{ + return mavlink_msg_raw_imu_pack_status(system_id, component_id, _status, msg, raw_imu->time_usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag, raw_imu->id, raw_imu->temperature); +} + /** * @brief Send a raw_imu message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_raw_pressure.h b/common/mavlink_msg_raw_pressure.h index b0f49dc9..ededbf7b 100644 --- a/common/mavlink_msg_raw_pressure.h +++ b/common/mavlink_msg_raw_pressure.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC); } +/** + * @brief Pack a raw_pressure 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param press_abs Absolute pressure (raw) + * @param press_diff1 Differential pressure 1 (raw, 0 if nonexistent) + * @param press_diff2 Differential pressure 2 (raw, 0 if nonexistent) + * @param temperature Raw Temperature measurement (raw) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_raw_pressure_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, int16_t press_abs, int16_t press_diff1, int16_t press_diff2, int16_t temperature) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RAW_PRESSURE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_int16_t(buf, 8, press_abs); + _mav_put_int16_t(buf, 10, press_diff1); + _mav_put_int16_t(buf, 12, press_diff2); + _mav_put_int16_t(buf, 14, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_PRESSURE_LEN); +#else + mavlink_raw_pressure_t packet; + packet.time_usec = time_usec; + packet.press_abs = press_abs; + packet.press_diff1 = press_diff1; + packet.press_diff2 = press_diff2; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_PRESSURE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_RAW_PRESSURE_LEN); +#endif +} + /** * @brief Pack a raw_pressure message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_raw_pressure_encode_chan(uint8_t system_id, u return mavlink_msg_raw_pressure_pack_chan(system_id, component_id, chan, msg, raw_pressure->time_usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature); } +/** + * @brief Encode a raw_pressure struct with provided status structure + * + * @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 raw_pressure C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_raw_pressure_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_raw_pressure_t* raw_pressure) +{ + return mavlink_msg_raw_pressure_pack_status(system_id, component_id, _status, msg, raw_pressure->time_usec, raw_pressure->press_abs, raw_pressure->press_diff1, raw_pressure->press_diff2, raw_pressure->temperature); +} + /** * @brief Send a raw_pressure message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_raw_rpm.h b/common/mavlink_msg_raw_rpm.h index e34cdbf7..cb599ed7 100644 --- a/common/mavlink_msg_raw_rpm.h +++ b/common/mavlink_msg_raw_rpm.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_raw_rpm_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); } +/** + * @brief Pack a raw_rpm 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 index Index of this RPM sensor (0-indexed) + * @param frequency [rpm] Indicated rate + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_raw_rpm_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t index, float frequency) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RAW_RPM_LEN]; + _mav_put_float(buf, 0, frequency); + _mav_put_uint8_t(buf, 4, index); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_RPM_LEN); +#else + mavlink_raw_rpm_t packet; + packet.frequency = frequency; + packet.index = index; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_RPM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RAW_RPM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN); +#endif +} + /** * @brief Pack a raw_rpm message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_raw_rpm_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_raw_rpm_pack_chan(system_id, component_id, chan, msg, raw_rpm->index, raw_rpm->frequency); } +/** + * @brief Encode a raw_rpm struct with provided status structure + * + * @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 raw_rpm C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_raw_rpm_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_raw_rpm_t* raw_rpm) +{ + return mavlink_msg_raw_rpm_pack_status(system_id, component_id, _status, msg, raw_rpm->index, raw_rpm->frequency); +} + /** * @brief Send a raw_rpm message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_rc_channels.h b/common/mavlink_msg_rc_channels.h index 721bc65e..8a3af544 100644 --- a/common/mavlink_msg_rc_channels.h +++ b/common/mavlink_msg_rc_channels.h @@ -183,6 +183,99 @@ static inline uint16_t mavlink_msg_rc_channels_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_LEN, MAVLINK_MSG_ID_RC_CHANNELS_CRC); } +/** + * @brief Pack a rc_channels 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param chancount Total number of RC channels being received. This can be larger than 18, indicating that more channels are available but not given in this message. This value should be 0 when no RC channels are available. + * @param chan1_raw [us] RC channel 1 value. + * @param chan2_raw [us] RC channel 2 value. + * @param chan3_raw [us] RC channel 3 value. + * @param chan4_raw [us] RC channel 4 value. + * @param chan5_raw [us] RC channel 5 value. + * @param chan6_raw [us] RC channel 6 value. + * @param chan7_raw [us] RC channel 7 value. + * @param chan8_raw [us] RC channel 8 value. + * @param chan9_raw [us] RC channel 9 value. + * @param chan10_raw [us] RC channel 10 value. + * @param chan11_raw [us] RC channel 11 value. + * @param chan12_raw [us] RC channel 12 value. + * @param chan13_raw [us] RC channel 13 value. + * @param chan14_raw [us] RC channel 14 value. + * @param chan15_raw [us] RC channel 15 value. + * @param chan16_raw [us] RC channel 16 value. + * @param chan17_raw [us] RC channel 17 value. + * @param chan18_raw [us] RC channel 18 value. + * @param rssi Receive signal strength indicator in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rc_channels_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t chancount, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint16_t chan9_raw, uint16_t chan10_raw, uint16_t chan11_raw, uint16_t chan12_raw, uint16_t chan13_raw, uint16_t chan14_raw, uint16_t chan15_raw, uint16_t chan16_raw, uint16_t chan17_raw, uint16_t chan18_raw, uint8_t rssi) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RC_CHANNELS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint16_t(buf, 4, chan1_raw); + _mav_put_uint16_t(buf, 6, chan2_raw); + _mav_put_uint16_t(buf, 8, chan3_raw); + _mav_put_uint16_t(buf, 10, chan4_raw); + _mav_put_uint16_t(buf, 12, chan5_raw); + _mav_put_uint16_t(buf, 14, chan6_raw); + _mav_put_uint16_t(buf, 16, chan7_raw); + _mav_put_uint16_t(buf, 18, chan8_raw); + _mav_put_uint16_t(buf, 20, chan9_raw); + _mav_put_uint16_t(buf, 22, chan10_raw); + _mav_put_uint16_t(buf, 24, chan11_raw); + _mav_put_uint16_t(buf, 26, chan12_raw); + _mav_put_uint16_t(buf, 28, chan13_raw); + _mav_put_uint16_t(buf, 30, chan14_raw); + _mav_put_uint16_t(buf, 32, chan15_raw); + _mav_put_uint16_t(buf, 34, chan16_raw); + _mav_put_uint16_t(buf, 36, chan17_raw); + _mav_put_uint16_t(buf, 38, chan18_raw); + _mav_put_uint8_t(buf, 40, chancount); + _mav_put_uint8_t(buf, 41, rssi); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RC_CHANNELS_LEN); +#else + mavlink_rc_channels_t packet; + packet.time_boot_ms = time_boot_ms; + packet.chan1_raw = chan1_raw; + packet.chan2_raw = chan2_raw; + packet.chan3_raw = chan3_raw; + packet.chan4_raw = chan4_raw; + packet.chan5_raw = chan5_raw; + packet.chan6_raw = chan6_raw; + packet.chan7_raw = chan7_raw; + packet.chan8_raw = chan8_raw; + packet.chan9_raw = chan9_raw; + packet.chan10_raw = chan10_raw; + packet.chan11_raw = chan11_raw; + packet.chan12_raw = chan12_raw; + packet.chan13_raw = chan13_raw; + packet.chan14_raw = chan14_raw; + packet.chan15_raw = chan15_raw; + packet.chan16_raw = chan16_raw; + packet.chan17_raw = chan17_raw; + packet.chan18_raw = chan18_raw; + packet.chancount = chancount; + packet.rssi = rssi; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RC_CHANNELS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_LEN, MAVLINK_MSG_ID_RC_CHANNELS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_LEN); +#endif +} + /** * @brief Pack a rc_channels message on a channel * @param system_id ID of this system @@ -299,6 +392,20 @@ static inline uint16_t mavlink_msg_rc_channels_encode_chan(uint8_t system_id, ui return mavlink_msg_rc_channels_pack_chan(system_id, component_id, chan, msg, rc_channels->time_boot_ms, rc_channels->chancount, rc_channels->chan1_raw, rc_channels->chan2_raw, rc_channels->chan3_raw, rc_channels->chan4_raw, rc_channels->chan5_raw, rc_channels->chan6_raw, rc_channels->chan7_raw, rc_channels->chan8_raw, rc_channels->chan9_raw, rc_channels->chan10_raw, rc_channels->chan11_raw, rc_channels->chan12_raw, rc_channels->chan13_raw, rc_channels->chan14_raw, rc_channels->chan15_raw, rc_channels->chan16_raw, rc_channels->chan17_raw, rc_channels->chan18_raw, rc_channels->rssi); } +/** + * @brief Encode a rc_channels struct with provided status structure + * + * @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 rc_channels C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rc_channels_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rc_channels_t* rc_channels) +{ + return mavlink_msg_rc_channels_pack_status(system_id, component_id, _status, msg, rc_channels->time_boot_ms, rc_channels->chancount, rc_channels->chan1_raw, rc_channels->chan2_raw, rc_channels->chan3_raw, rc_channels->chan4_raw, rc_channels->chan5_raw, rc_channels->chan6_raw, rc_channels->chan7_raw, rc_channels->chan8_raw, rc_channels->chan9_raw, rc_channels->chan10_raw, rc_channels->chan11_raw, rc_channels->chan12_raw, rc_channels->chan13_raw, rc_channels->chan14_raw, rc_channels->chan15_raw, rc_channels->chan16_raw, rc_channels->chan17_raw, rc_channels->chan18_raw, rc_channels->rssi); +} + /** * @brief Send a rc_channels message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_rc_channels_override.h b/common/mavlink_msg_rc_channels_override.h index bc973c91..74b6b07f 100644 --- a/common/mavlink_msg_rc_channels_override.h +++ b/common/mavlink_msg_rc_channels_override.h @@ -177,6 +177,96 @@ static inline uint16_t mavlink_msg_rc_channels_override_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_CRC); } +/** + * @brief Pack a rc_channels_override 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 target_system System ID + * @param target_component Component ID + * @param chan1_raw [us] RC channel 1 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan2_raw [us] RC channel 2 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan3_raw [us] RC channel 3 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan4_raw [us] RC channel 4 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan5_raw [us] RC channel 5 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan6_raw [us] RC channel 6 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan7_raw [us] RC channel 7 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan8_raw [us] RC channel 8 value. A value of UINT16_MAX means to ignore this field. A value of 0 means to release this channel back to the RC radio. + * @param chan9_raw [us] RC channel 9 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan10_raw [us] RC channel 10 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan11_raw [us] RC channel 11 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan12_raw [us] RC channel 12 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan13_raw [us] RC channel 13 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan14_raw [us] RC channel 14 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan15_raw [us] RC channel 15 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan16_raw [us] RC channel 16 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan17_raw [us] RC channel 17 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @param chan18_raw [us] RC channel 18 value. A value of 0 or UINT16_MAX means to ignore this field. A value of UINT16_MAX-1 means to release this channel back to the RC radio. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rc_channels_override_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint16_t chan9_raw, uint16_t chan10_raw, uint16_t chan11_raw, uint16_t chan12_raw, uint16_t chan13_raw, uint16_t chan14_raw, uint16_t chan15_raw, uint16_t chan16_raw, uint16_t chan17_raw, uint16_t chan18_raw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN]; + _mav_put_uint16_t(buf, 0, chan1_raw); + _mav_put_uint16_t(buf, 2, chan2_raw); + _mav_put_uint16_t(buf, 4, chan3_raw); + _mav_put_uint16_t(buf, 6, chan4_raw); + _mav_put_uint16_t(buf, 8, chan5_raw); + _mav_put_uint16_t(buf, 10, chan6_raw); + _mav_put_uint16_t(buf, 12, chan7_raw); + _mav_put_uint16_t(buf, 14, chan8_raw); + _mav_put_uint8_t(buf, 16, target_system); + _mav_put_uint8_t(buf, 17, target_component); + _mav_put_uint16_t(buf, 18, chan9_raw); + _mav_put_uint16_t(buf, 20, chan10_raw); + _mav_put_uint16_t(buf, 22, chan11_raw); + _mav_put_uint16_t(buf, 24, chan12_raw); + _mav_put_uint16_t(buf, 26, chan13_raw); + _mav_put_uint16_t(buf, 28, chan14_raw); + _mav_put_uint16_t(buf, 30, chan15_raw); + _mav_put_uint16_t(buf, 32, chan16_raw); + _mav_put_uint16_t(buf, 34, chan17_raw); + _mav_put_uint16_t(buf, 36, chan18_raw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN); +#else + mavlink_rc_channels_override_t packet; + packet.chan1_raw = chan1_raw; + packet.chan2_raw = chan2_raw; + packet.chan3_raw = chan3_raw; + packet.chan4_raw = chan4_raw; + packet.chan5_raw = chan5_raw; + packet.chan6_raw = chan6_raw; + packet.chan7_raw = chan7_raw; + packet.chan8_raw = chan8_raw; + packet.target_system = target_system; + packet.target_component = target_component; + packet.chan9_raw = chan9_raw; + packet.chan10_raw = chan10_raw; + packet.chan11_raw = chan11_raw; + packet.chan12_raw = chan12_raw; + packet.chan13_raw = chan13_raw; + packet.chan14_raw = chan14_raw; + packet.chan15_raw = chan15_raw; + packet.chan16_raw = chan16_raw; + packet.chan17_raw = chan17_raw; + packet.chan18_raw = chan18_raw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE_LEN); +#endif +} + /** * @brief Pack a rc_channels_override message on a channel * @param system_id ID of this system @@ -290,6 +380,20 @@ static inline uint16_t mavlink_msg_rc_channels_override_encode_chan(uint8_t syst return mavlink_msg_rc_channels_override_pack_chan(system_id, component_id, chan, msg, rc_channels_override->target_system, rc_channels_override->target_component, rc_channels_override->chan1_raw, rc_channels_override->chan2_raw, rc_channels_override->chan3_raw, rc_channels_override->chan4_raw, rc_channels_override->chan5_raw, rc_channels_override->chan6_raw, rc_channels_override->chan7_raw, rc_channels_override->chan8_raw, rc_channels_override->chan9_raw, rc_channels_override->chan10_raw, rc_channels_override->chan11_raw, rc_channels_override->chan12_raw, rc_channels_override->chan13_raw, rc_channels_override->chan14_raw, rc_channels_override->chan15_raw, rc_channels_override->chan16_raw, rc_channels_override->chan17_raw, rc_channels_override->chan18_raw); } +/** + * @brief Encode a rc_channels_override struct with provided status structure + * + * @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 rc_channels_override C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rc_channels_override_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rc_channels_override_t* rc_channels_override) +{ + return mavlink_msg_rc_channels_override_pack_status(system_id, component_id, _status, msg, rc_channels_override->target_system, rc_channels_override->target_component, rc_channels_override->chan1_raw, rc_channels_override->chan2_raw, rc_channels_override->chan3_raw, rc_channels_override->chan4_raw, rc_channels_override->chan5_raw, rc_channels_override->chan6_raw, rc_channels_override->chan7_raw, rc_channels_override->chan8_raw, rc_channels_override->chan9_raw, rc_channels_override->chan10_raw, rc_channels_override->chan11_raw, rc_channels_override->chan12_raw, rc_channels_override->chan13_raw, rc_channels_override->chan14_raw, rc_channels_override->chan15_raw, rc_channels_override->chan16_raw, rc_channels_override->chan17_raw, rc_channels_override->chan18_raw); +} + /** * @brief Send a rc_channels_override message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_rc_channels_raw.h b/common/mavlink_msg_rc_channels_raw.h index af768381..ef87f107 100644 --- a/common/mavlink_msg_rc_channels_raw.h +++ b/common/mavlink_msg_rc_channels_raw.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RC_CHANNELS_RAW_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN, MAVLINK_MSG_ID_RC_CHANNELS_RAW_CRC); } +/** + * @brief Pack a rc_channels_raw 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param port Servo output port (set of 8 outputs = 1 port). Flight stacks running on Pixhawk should use: 0 = MAIN, 1 = AUX. + * @param chan1_raw [us] RC channel 1 value. + * @param chan2_raw [us] RC channel 2 value. + * @param chan3_raw [us] RC channel 3 value. + * @param chan4_raw [us] RC channel 4 value. + * @param chan5_raw [us] RC channel 5 value. + * @param chan6_raw [us] RC channel 6 value. + * @param chan7_raw [us] RC channel 7 value. + * @param chan8_raw [us] RC channel 8 value. + * @param rssi Receive signal strength indicator in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rc_channels_raw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t port, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint8_t rssi) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint16_t(buf, 4, chan1_raw); + _mav_put_uint16_t(buf, 6, chan2_raw); + _mav_put_uint16_t(buf, 8, chan3_raw); + _mav_put_uint16_t(buf, 10, chan4_raw); + _mav_put_uint16_t(buf, 12, chan5_raw); + _mav_put_uint16_t(buf, 14, chan6_raw); + _mav_put_uint16_t(buf, 16, chan7_raw); + _mav_put_uint16_t(buf, 18, chan8_raw); + _mav_put_uint8_t(buf, 20, port); + _mav_put_uint8_t(buf, 21, rssi); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN); +#else + mavlink_rc_channels_raw_t packet; + packet.time_boot_ms = time_boot_ms; + packet.chan1_raw = chan1_raw; + packet.chan2_raw = chan2_raw; + packet.chan3_raw = chan3_raw; + packet.chan4_raw = chan4_raw; + packet.chan5_raw = chan5_raw; + packet.chan6_raw = chan6_raw; + packet.chan7_raw = chan7_raw; + packet.chan8_raw = chan8_raw; + packet.port = port; + packet.rssi = rssi; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_RAW_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN, MAVLINK_MSG_ID_RC_CHANNELS_RAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_RAW_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN); +#endif +} + /** * @brief Pack a rc_channels_raw message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_rc_channels_raw_encode_chan(uint8_t system_id return mavlink_msg_rc_channels_raw_pack_chan(system_id, component_id, chan, msg, rc_channels_raw->time_boot_ms, rc_channels_raw->port, rc_channels_raw->chan1_raw, rc_channels_raw->chan2_raw, rc_channels_raw->chan3_raw, rc_channels_raw->chan4_raw, rc_channels_raw->chan5_raw, rc_channels_raw->chan6_raw, rc_channels_raw->chan7_raw, rc_channels_raw->chan8_raw, rc_channels_raw->rssi); } +/** + * @brief Encode a rc_channels_raw struct with provided status structure + * + * @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 rc_channels_raw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rc_channels_raw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rc_channels_raw_t* rc_channels_raw) +{ + return mavlink_msg_rc_channels_raw_pack_status(system_id, component_id, _status, msg, rc_channels_raw->time_boot_ms, rc_channels_raw->port, rc_channels_raw->chan1_raw, rc_channels_raw->chan2_raw, rc_channels_raw->chan3_raw, rc_channels_raw->chan4_raw, rc_channels_raw->chan5_raw, rc_channels_raw->chan6_raw, rc_channels_raw->chan7_raw, rc_channels_raw->chan8_raw, rc_channels_raw->rssi); +} + /** * @brief Send a rc_channels_raw message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_rc_channels_scaled.h b/common/mavlink_msg_rc_channels_scaled.h index bc5dea78..509ba029 100644 --- a/common/mavlink_msg_rc_channels_scaled.h +++ b/common/mavlink_msg_rc_channels_scaled.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_CRC); } +/** + * @brief Pack a rc_channels_scaled 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param port Servo output port (set of 8 outputs = 1 port). Flight stacks running on Pixhawk should use: 0 = MAIN, 1 = AUX. + * @param chan1_scaled RC channel 1 value scaled. + * @param chan2_scaled RC channel 2 value scaled. + * @param chan3_scaled RC channel 3 value scaled. + * @param chan4_scaled RC channel 4 value scaled. + * @param chan5_scaled RC channel 5 value scaled. + * @param chan6_scaled RC channel 6 value scaled. + * @param chan7_scaled RC channel 7 value scaled. + * @param chan8_scaled RC channel 8 value scaled. + * @param rssi Receive signal strength indicator in device-dependent units/scale. Values: [0-254], UINT8_MAX: invalid/unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rc_channels_scaled_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t port, int16_t chan1_scaled, int16_t chan2_scaled, int16_t chan3_scaled, int16_t chan4_scaled, int16_t chan5_scaled, int16_t chan6_scaled, int16_t chan7_scaled, int16_t chan8_scaled, uint8_t rssi) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int16_t(buf, 4, chan1_scaled); + _mav_put_int16_t(buf, 6, chan2_scaled); + _mav_put_int16_t(buf, 8, chan3_scaled); + _mav_put_int16_t(buf, 10, chan4_scaled); + _mav_put_int16_t(buf, 12, chan5_scaled); + _mav_put_int16_t(buf, 14, chan6_scaled); + _mav_put_int16_t(buf, 16, chan7_scaled); + _mav_put_int16_t(buf, 18, chan8_scaled); + _mav_put_uint8_t(buf, 20, port); + _mav_put_uint8_t(buf, 21, rssi); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN); +#else + mavlink_rc_channels_scaled_t packet; + packet.time_boot_ms = time_boot_ms; + packet.chan1_scaled = chan1_scaled; + packet.chan2_scaled = chan2_scaled; + packet.chan3_scaled = chan3_scaled; + packet.chan4_scaled = chan4_scaled; + packet.chan5_scaled = chan5_scaled; + packet.chan6_scaled = chan6_scaled; + packet.chan7_scaled = chan7_scaled; + packet.chan8_scaled = chan8_scaled; + packet.port = port; + packet.rssi = rssi; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_SCALED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_MIN_LEN, MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN); +#endif +} + /** * @brief Pack a rc_channels_scaled message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_encode_chan(uint8_t system return mavlink_msg_rc_channels_scaled_pack_chan(system_id, component_id, chan, msg, rc_channels_scaled->time_boot_ms, rc_channels_scaled->port, rc_channels_scaled->chan1_scaled, rc_channels_scaled->chan2_scaled, rc_channels_scaled->chan3_scaled, rc_channels_scaled->chan4_scaled, rc_channels_scaled->chan5_scaled, rc_channels_scaled->chan6_scaled, rc_channels_scaled->chan7_scaled, rc_channels_scaled->chan8_scaled, rc_channels_scaled->rssi); } +/** + * @brief Encode a rc_channels_scaled struct with provided status structure + * + * @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 rc_channels_scaled C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rc_channels_scaled_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_rc_channels_scaled_t* rc_channels_scaled) +{ + return mavlink_msg_rc_channels_scaled_pack_status(system_id, component_id, _status, msg, rc_channels_scaled->time_boot_ms, rc_channels_scaled->port, rc_channels_scaled->chan1_scaled, rc_channels_scaled->chan2_scaled, rc_channels_scaled->chan3_scaled, rc_channels_scaled->chan4_scaled, rc_channels_scaled->chan5_scaled, rc_channels_scaled->chan6_scaled, rc_channels_scaled->chan7_scaled, rc_channels_scaled->chan8_scaled, rc_channels_scaled->rssi); +} + /** * @brief Send a rc_channels_scaled message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_request_data_stream.h b/common/mavlink_msg_request_data_stream.h index 617d61c6..ac417263 100644 --- a/common/mavlink_msg_request_data_stream.h +++ b/common/mavlink_msg_request_data_stream.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_request_data_stream_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC); } +/** + * @brief Pack a request_data_stream 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 target_system The target requested to send the message stream. + * @param target_component The target requested to send the message stream. + * @param req_stream_id The ID of the requested data stream + * @param req_message_rate [Hz] The requested message rate + * @param start_stop 1 to start sending, 0 to stop sending. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_request_data_stream_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN]; + _mav_put_uint16_t(buf, 0, req_message_rate); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, req_stream_id); + _mav_put_uint8_t(buf, 5, start_stop); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN); +#else + mavlink_request_data_stream_t packet; + packet.req_message_rate = req_message_rate; + packet.target_system = target_system; + packet.target_component = target_component; + packet.req_stream_id = req_stream_id; + packet.start_stop = start_stop; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_REQUEST_DATA_STREAM_LEN); +#endif +} + /** * @brief Pack a request_data_stream message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_request_data_stream_encode_chan(uint8_t syste return mavlink_msg_request_data_stream_pack_chan(system_id, component_id, chan, msg, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop); } +/** + * @brief Encode a request_data_stream struct with provided status structure + * + * @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 request_data_stream C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_request_data_stream_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_request_data_stream_t* request_data_stream) +{ + return mavlink_msg_request_data_stream_pack_status(system_id, component_id, _status, msg, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop); +} + /** * @brief Send a request_data_stream message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_request_event.h b/common/mavlink_msg_request_event.h index dcf15917..5aebfb26 100644 --- a/common/mavlink_msg_request_event.h +++ b/common/mavlink_msg_request_event.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_request_event_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_REQUEST_EVENT_MIN_LEN, MAVLINK_MSG_ID_REQUEST_EVENT_LEN, MAVLINK_MSG_ID_REQUEST_EVENT_CRC); } +/** + * @brief Pack a request_event 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 target_system System ID + * @param target_component Component ID + * @param first_sequence First sequence number of the requested event. + * @param last_sequence Last sequence number of the requested event. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_request_event_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t first_sequence, uint16_t last_sequence) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_REQUEST_EVENT_LEN]; + _mav_put_uint16_t(buf, 0, first_sequence); + _mav_put_uint16_t(buf, 2, last_sequence); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_REQUEST_EVENT_LEN); +#else + mavlink_request_event_t packet; + packet.first_sequence = first_sequence; + packet.last_sequence = last_sequence; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_REQUEST_EVENT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_REQUEST_EVENT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REQUEST_EVENT_MIN_LEN, MAVLINK_MSG_ID_REQUEST_EVENT_LEN, MAVLINK_MSG_ID_REQUEST_EVENT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_REQUEST_EVENT_MIN_LEN, MAVLINK_MSG_ID_REQUEST_EVENT_LEN); +#endif +} + /** * @brief Pack a request_event message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_request_event_encode_chan(uint8_t system_id, return mavlink_msg_request_event_pack_chan(system_id, component_id, chan, msg, request_event->target_system, request_event->target_component, request_event->first_sequence, request_event->last_sequence); } +/** + * @brief Encode a request_event struct with provided status structure + * + * @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 request_event C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_request_event_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_request_event_t* request_event) +{ + return mavlink_msg_request_event_pack_status(system_id, component_id, _status, msg, request_event->target_system, request_event->target_component, request_event->first_sequence, request_event->last_sequence); +} + /** * @brief Send a request_event message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_resource_request.h b/common/mavlink_msg_resource_request.h index 31c07f1a..e72520e6 100644 --- a/common/mavlink_msg_resource_request.h +++ b/common/mavlink_msg_resource_request.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_resource_request_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RESOURCE_REQUEST_MIN_LEN, MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN, MAVLINK_MSG_ID_RESOURCE_REQUEST_CRC); } +/** + * @brief Pack a resource_request 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 request_id Request ID. This ID should be re-used when sending back URI contents + * @param uri_type The type of requested URI. 0 = a file via URL. 1 = a UAVCAN binary + * @param uri The requested unique resource identifier (URI). It is not necessarily a straight domain name (depends on the URI type enum) + * @param transfer_type The way the autopilot wants to receive the URI. 0 = MAVLink FTP. 1 = binary stream. + * @param storage The storage path the autopilot wants the URI to be stored in. Will only be valid if the transfer_type has a storage associated (e.g. MAVLink FTP). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_resource_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t request_id, uint8_t uri_type, const uint8_t *uri, uint8_t transfer_type, const uint8_t *storage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN]; + _mav_put_uint8_t(buf, 0, request_id); + _mav_put_uint8_t(buf, 1, uri_type); + _mav_put_uint8_t(buf, 122, transfer_type); + _mav_put_uint8_t_array(buf, 2, uri, 120); + _mav_put_uint8_t_array(buf, 123, storage, 120); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN); +#else + mavlink_resource_request_t packet; + packet.request_id = request_id; + packet.uri_type = uri_type; + packet.transfer_type = transfer_type; + mav_array_memcpy(packet.uri, uri, sizeof(uint8_t)*120); + mav_array_memcpy(packet.storage, storage, sizeof(uint8_t)*120); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RESOURCE_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RESOURCE_REQUEST_MIN_LEN, MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN, MAVLINK_MSG_ID_RESOURCE_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RESOURCE_REQUEST_MIN_LEN, MAVLINK_MSG_ID_RESOURCE_REQUEST_LEN); +#endif +} + /** * @brief Pack a resource_request message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_resource_request_encode_chan(uint8_t system_i return mavlink_msg_resource_request_pack_chan(system_id, component_id, chan, msg, resource_request->request_id, resource_request->uri_type, resource_request->uri, resource_request->transfer_type, resource_request->storage); } +/** + * @brief Encode a resource_request struct with provided status structure + * + * @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 resource_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_resource_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_resource_request_t* resource_request) +{ + return mavlink_msg_resource_request_pack_status(system_id, component_id, _status, msg, resource_request->request_id, resource_request->uri_type, resource_request->uri, resource_request->transfer_type, resource_request->storage); +} + /** * @brief Send a resource_request message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_response_event_error.h b/common/mavlink_msg_response_event_error.h index 9b665a23..e0079421 100644 --- a/common/mavlink_msg_response_event_error.h +++ b/common/mavlink_msg_response_event_error.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_response_event_error_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_MIN_LEN, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_CRC); } +/** + * @brief Pack a response_event_error 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 target_system System ID + * @param target_component Component ID + * @param sequence Sequence number. + * @param sequence_oldest_available Oldest Sequence number that is still available after the sequence set in REQUEST_EVENT. + * @param reason Error reason. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_response_event_error_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t sequence, uint16_t sequence_oldest_available, uint8_t reason) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN]; + _mav_put_uint16_t(buf, 0, sequence); + _mav_put_uint16_t(buf, 2, sequence_oldest_available); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, reason); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN); +#else + mavlink_response_event_error_t packet; + packet.sequence = sequence; + packet.sequence_oldest_available = sequence_oldest_available; + packet.target_system = target_system; + packet.target_component = target_component; + packet.reason = reason; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_MIN_LEN, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_MIN_LEN, MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR_LEN); +#endif +} + /** * @brief Pack a response_event_error message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_response_event_error_encode_chan(uint8_t syst return mavlink_msg_response_event_error_pack_chan(system_id, component_id, chan, msg, response_event_error->target_system, response_event_error->target_component, response_event_error->sequence, response_event_error->sequence_oldest_available, response_event_error->reason); } +/** + * @brief Encode a response_event_error struct with provided status structure + * + * @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 response_event_error C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_response_event_error_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_response_event_error_t* response_event_error) +{ + return mavlink_msg_response_event_error_pack_status(system_id, component_id, _status, msg, response_event_error->target_system, response_event_error->target_component, response_event_error->sequence, response_event_error->sequence_oldest_available, response_event_error->reason); +} + /** * @brief Send a response_event_error message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_safety_allowed_area.h b/common/mavlink_msg_safety_allowed_area.h index 66b5c461..a51f5098 100644 --- a/common/mavlink_msg_safety_allowed_area.h +++ b/common/mavlink_msg_safety_allowed_area.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_safety_allowed_area_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_CRC); } +/** + * @brief Pack a safety_allowed_area 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 frame Coordinate frame. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down. + * @param p1x [m] x position 1 / Latitude 1 + * @param p1y [m] y position 1 / Longitude 1 + * @param p1z [m] z position 1 / Altitude 1 + * @param p2x [m] x position 2 / Latitude 2 + * @param p2y [m] y position 2 / Longitude 2 + * @param p2z [m] z position 2 / Altitude 2 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_safety_allowed_area_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t frame, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN]; + _mav_put_float(buf, 0, p1x); + _mav_put_float(buf, 4, p1y); + _mav_put_float(buf, 8, p1z); + _mav_put_float(buf, 12, p2x); + _mav_put_float(buf, 16, p2y); + _mav_put_float(buf, 20, p2z); + _mav_put_uint8_t(buf, 24, frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN); +#else + mavlink_safety_allowed_area_t packet; + packet.p1x = p1x; + packet.p1y = p1y; + packet.p1z = p1z; + packet.p2x = p2x; + packet.p2y = p2y; + packet.p2z = p2z; + packet.frame = frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA_LEN); +#endif +} + /** * @brief Pack a safety_allowed_area message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_safety_allowed_area_encode_chan(uint8_t syste return mavlink_msg_safety_allowed_area_pack_chan(system_id, component_id, chan, msg, safety_allowed_area->frame, safety_allowed_area->p1x, safety_allowed_area->p1y, safety_allowed_area->p1z, safety_allowed_area->p2x, safety_allowed_area->p2y, safety_allowed_area->p2z); } +/** + * @brief Encode a safety_allowed_area struct with provided status structure + * + * @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 safety_allowed_area C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_safety_allowed_area_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_safety_allowed_area_t* safety_allowed_area) +{ + return mavlink_msg_safety_allowed_area_pack_status(system_id, component_id, _status, msg, safety_allowed_area->frame, safety_allowed_area->p1x, safety_allowed_area->p1y, safety_allowed_area->p1z, safety_allowed_area->p2x, safety_allowed_area->p2y, safety_allowed_area->p2z); +} + /** * @brief Send a safety_allowed_area message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_safety_set_allowed_area.h b/common/mavlink_msg_safety_set_allowed_area.h index d50ac5cb..25fcb21a 100644 --- a/common/mavlink_msg_safety_set_allowed_area.h +++ b/common/mavlink_msg_safety_set_allowed_area.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_CRC); } +/** + * @brief Pack a safety_set_allowed_area 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 target_system System ID + * @param target_component Component ID + * @param frame Coordinate frame. Can be either global, GPS, right-handed with Z axis up or local, right handed, Z axis down. + * @param p1x [m] x position 1 / Latitude 1 + * @param p1y [m] y position 1 / Longitude 1 + * @param p1z [m] z position 1 / Altitude 1 + * @param p2x [m] x position 2 / Latitude 2 + * @param p2y [m] y position 2 / Longitude 2 + * @param p2z [m] z position 2 / Altitude 2 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_safety_set_allowed_area_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t frame, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN]; + _mav_put_float(buf, 0, p1x); + _mav_put_float(buf, 4, p1y); + _mav_put_float(buf, 8, p1z); + _mav_put_float(buf, 12, p2x); + _mav_put_float(buf, 16, p2y); + _mav_put_float(buf, 20, p2z); + _mav_put_uint8_t(buf, 24, target_system); + _mav_put_uint8_t(buf, 25, target_component); + _mav_put_uint8_t(buf, 26, frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN); +#else + mavlink_safety_set_allowed_area_t packet; + packet.p1x = p1x; + packet.p1y = p1y; + packet.p1z = p1z; + packet.p2x = p2x; + packet.p2y = p2y; + packet.p2z = p2z; + packet.target_system = target_system; + packet.target_component = target_component; + packet.frame = frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_MIN_LEN, MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA_LEN); +#endif +} + /** * @brief Pack a safety_set_allowed_area message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_encode_chan(uint8_t s return mavlink_msg_safety_set_allowed_area_pack_chan(system_id, component_id, chan, msg, safety_set_allowed_area->target_system, safety_set_allowed_area->target_component, safety_set_allowed_area->frame, safety_set_allowed_area->p1x, safety_set_allowed_area->p1y, safety_set_allowed_area->p1z, safety_set_allowed_area->p2x, safety_set_allowed_area->p2y, safety_set_allowed_area->p2z); } +/** + * @brief Encode a safety_set_allowed_area struct with provided status structure + * + * @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 safety_set_allowed_area C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_safety_set_allowed_area_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_safety_set_allowed_area_t* safety_set_allowed_area) +{ + return mavlink_msg_safety_set_allowed_area_pack_status(system_id, component_id, _status, msg, safety_set_allowed_area->target_system, safety_set_allowed_area->target_component, safety_set_allowed_area->frame, safety_set_allowed_area->p1x, safety_set_allowed_area->p1y, safety_set_allowed_area->p1z, safety_set_allowed_area->p2x, safety_set_allowed_area->p2y, safety_set_allowed_area->p2z); +} + /** * @brief Send a safety_set_allowed_area message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_imu.h b/common/mavlink_msg_scaled_imu.h index fac086f6..3a52e09b 100644 --- a/common/mavlink_msg_scaled_imu.h +++ b/common/mavlink_msg_scaled_imu.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_scaled_imu_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_IMU_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU_LEN, MAVLINK_MSG_ID_SCALED_IMU_CRC); } +/** + * @brief Pack a scaled_imu 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param xacc [mG] X acceleration + * @param yacc [mG] Y acceleration + * @param zacc [mG] Z acceleration + * @param xgyro [mrad/s] Angular speed around X axis + * @param ygyro [mrad/s] Angular speed around Y axis + * @param zgyro [mrad/s] Angular speed around Z axis + * @param xmag [mgauss] X Magnetic field + * @param ymag [mgauss] Y Magnetic field + * @param zmag [mgauss] Z Magnetic field + * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_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) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_IMU_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int16_t(buf, 4, xacc); + _mav_put_int16_t(buf, 6, yacc); + _mav_put_int16_t(buf, 8, zacc); + _mav_put_int16_t(buf, 10, xgyro); + _mav_put_int16_t(buf, 12, ygyro); + _mav_put_int16_t(buf, 14, zgyro); + _mav_put_int16_t(buf, 16, xmag); + _mav_put_int16_t(buf, 18, ymag); + _mav_put_int16_t(buf, 20, zmag); + _mav_put_int16_t(buf, 22, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_IMU_LEN); +#else + mavlink_scaled_imu_t packet; + packet.time_boot_ms = time_boot_ms; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_IMU_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_IMU; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU_LEN, MAVLINK_MSG_ID_SCALED_IMU_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU_LEN); +#endif +} + /** * @brief Pack a scaled_imu message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_scaled_imu_encode_chan(uint8_t system_id, uin return mavlink_msg_scaled_imu_pack_chan(system_id, component_id, chan, msg, scaled_imu->time_boot_ms, scaled_imu->xacc, scaled_imu->yacc, scaled_imu->zacc, scaled_imu->xgyro, scaled_imu->ygyro, scaled_imu->zgyro, scaled_imu->xmag, scaled_imu->ymag, scaled_imu->zmag, scaled_imu->temperature); } +/** + * @brief Encode a scaled_imu struct with provided status structure + * + * @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 scaled_imu C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_imu_t* scaled_imu) +{ + return mavlink_msg_scaled_imu_pack_status(system_id, component_id, _status, msg, scaled_imu->time_boot_ms, scaled_imu->xacc, scaled_imu->yacc, scaled_imu->zacc, scaled_imu->xgyro, scaled_imu->ygyro, scaled_imu->zgyro, scaled_imu->xmag, scaled_imu->ymag, scaled_imu->zmag, scaled_imu->temperature); +} + /** * @brief Send a scaled_imu message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_imu2.h b/common/mavlink_msg_scaled_imu2.h index 508fdff7..ba21b776 100644 --- a/common/mavlink_msg_scaled_imu2.h +++ b/common/mavlink_msg_scaled_imu2.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_scaled_imu2_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_IMU2_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU2_LEN, MAVLINK_MSG_ID_SCALED_IMU2_CRC); } +/** + * @brief Pack a scaled_imu2 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param xacc [mG] X acceleration + * @param yacc [mG] Y acceleration + * @param zacc [mG] Z acceleration + * @param xgyro [mrad/s] Angular speed around X axis + * @param ygyro [mrad/s] Angular speed around Y axis + * @param zgyro [mrad/s] Angular speed around Z axis + * @param xmag [mgauss] X Magnetic field + * @param ymag [mgauss] Y Magnetic field + * @param zmag [mgauss] Z Magnetic field + * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_imu2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_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) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_IMU2_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int16_t(buf, 4, xacc); + _mav_put_int16_t(buf, 6, yacc); + _mav_put_int16_t(buf, 8, zacc); + _mav_put_int16_t(buf, 10, xgyro); + _mav_put_int16_t(buf, 12, ygyro); + _mav_put_int16_t(buf, 14, zgyro); + _mav_put_int16_t(buf, 16, xmag); + _mav_put_int16_t(buf, 18, ymag); + _mav_put_int16_t(buf, 20, zmag); + _mav_put_int16_t(buf, 22, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_IMU2_LEN); +#else + mavlink_scaled_imu2_t packet; + packet.time_boot_ms = time_boot_ms; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_IMU2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_IMU2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU2_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU2_LEN, MAVLINK_MSG_ID_SCALED_IMU2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU2_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU2_LEN); +#endif +} + /** * @brief Pack a scaled_imu2 message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_scaled_imu2_encode_chan(uint8_t system_id, ui return mavlink_msg_scaled_imu2_pack_chan(system_id, component_id, chan, msg, scaled_imu2->time_boot_ms, scaled_imu2->xacc, scaled_imu2->yacc, scaled_imu2->zacc, scaled_imu2->xgyro, scaled_imu2->ygyro, scaled_imu2->zgyro, scaled_imu2->xmag, scaled_imu2->ymag, scaled_imu2->zmag, scaled_imu2->temperature); } +/** + * @brief Encode a scaled_imu2 struct with provided status structure + * + * @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 scaled_imu2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_imu2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_imu2_t* scaled_imu2) +{ + return mavlink_msg_scaled_imu2_pack_status(system_id, component_id, _status, msg, scaled_imu2->time_boot_ms, scaled_imu2->xacc, scaled_imu2->yacc, scaled_imu2->zacc, scaled_imu2->xgyro, scaled_imu2->ygyro, scaled_imu2->zgyro, scaled_imu2->xmag, scaled_imu2->ymag, scaled_imu2->zmag, scaled_imu2->temperature); +} + /** * @brief Send a scaled_imu2 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_imu3.h b/common/mavlink_msg_scaled_imu3.h index cbacc699..ebc68cd5 100644 --- a/common/mavlink_msg_scaled_imu3.h +++ b/common/mavlink_msg_scaled_imu3.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_scaled_imu3_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_IMU3_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU3_LEN, MAVLINK_MSG_ID_SCALED_IMU3_CRC); } +/** + * @brief Pack a scaled_imu3 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param xacc [mG] X acceleration + * @param yacc [mG] Y acceleration + * @param zacc [mG] Z acceleration + * @param xgyro [mrad/s] Angular speed around X axis + * @param ygyro [mrad/s] Angular speed around Y axis + * @param zgyro [mrad/s] Angular speed around Z axis + * @param xmag [mgauss] X Magnetic field + * @param ymag [mgauss] Y Magnetic field + * @param zmag [mgauss] Z Magnetic field + * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_imu3_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_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) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_IMU3_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int16_t(buf, 4, xacc); + _mav_put_int16_t(buf, 6, yacc); + _mav_put_int16_t(buf, 8, zacc); + _mav_put_int16_t(buf, 10, xgyro); + _mav_put_int16_t(buf, 12, ygyro); + _mav_put_int16_t(buf, 14, zgyro); + _mav_put_int16_t(buf, 16, xmag); + _mav_put_int16_t(buf, 18, ymag); + _mav_put_int16_t(buf, 20, zmag); + _mav_put_int16_t(buf, 22, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_IMU3_LEN); +#else + mavlink_scaled_imu3_t packet; + packet.time_boot_ms = time_boot_ms; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_IMU3_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_IMU3; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU3_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU3_LEN, MAVLINK_MSG_ID_SCALED_IMU3_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_IMU3_MIN_LEN, MAVLINK_MSG_ID_SCALED_IMU3_LEN); +#endif +} + /** * @brief Pack a scaled_imu3 message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_scaled_imu3_encode_chan(uint8_t system_id, ui return mavlink_msg_scaled_imu3_pack_chan(system_id, component_id, chan, msg, scaled_imu3->time_boot_ms, scaled_imu3->xacc, scaled_imu3->yacc, scaled_imu3->zacc, scaled_imu3->xgyro, scaled_imu3->ygyro, scaled_imu3->zgyro, scaled_imu3->xmag, scaled_imu3->ymag, scaled_imu3->zmag, scaled_imu3->temperature); } +/** + * @brief Encode a scaled_imu3 struct with provided status structure + * + * @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 scaled_imu3 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_imu3_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_imu3_t* scaled_imu3) +{ + return mavlink_msg_scaled_imu3_pack_status(system_id, component_id, _status, msg, scaled_imu3->time_boot_ms, scaled_imu3->xacc, scaled_imu3->yacc, scaled_imu3->zacc, scaled_imu3->xgyro, scaled_imu3->ygyro, scaled_imu3->zgyro, scaled_imu3->xmag, scaled_imu3->ymag, scaled_imu3->zmag, scaled_imu3->temperature); +} + /** * @brief Send a scaled_imu3 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_pressure.h b/common/mavlink_msg_scaled_pressure.h index fedaeed9..93d03227 100644 --- a/common/mavlink_msg_scaled_pressure.h +++ b/common/mavlink_msg_scaled_pressure.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE_CRC); } +/** + * @brief Pack a scaled_pressure 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param press_abs [hPa] Absolute pressure + * @param press_diff [hPa] Differential pressure 1 + * @param temperature [cdegC] Absolute pressure temperature + * @param temperature_press_diff [cdegC] Differential pressure temperature (0, if not available). Report values of 0 (or 1) as 1 cdegC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_pressure_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature, int16_t temperature_press_diff) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_PRESSURE_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, press_abs); + _mav_put_float(buf, 8, press_diff); + _mav_put_int16_t(buf, 12, temperature); + _mav_put_int16_t(buf, 14, temperature_press_diff); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_PRESSURE_LEN); +#else + mavlink_scaled_pressure_t packet; + packet.time_boot_ms = time_boot_ms; + packet.press_abs = press_abs; + packet.press_diff = press_diff; + packet.temperature = temperature; + packet.temperature_press_diff = temperature_press_diff; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_PRESSURE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE_LEN); +#endif +} + /** * @brief Pack a scaled_pressure message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_scaled_pressure_encode_chan(uint8_t system_id return mavlink_msg_scaled_pressure_pack_chan(system_id, component_id, chan, msg, scaled_pressure->time_boot_ms, scaled_pressure->press_abs, scaled_pressure->press_diff, scaled_pressure->temperature, scaled_pressure->temperature_press_diff); } +/** + * @brief Encode a scaled_pressure struct with provided status structure + * + * @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 scaled_pressure C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_pressure_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_pressure_t* scaled_pressure) +{ + return mavlink_msg_scaled_pressure_pack_status(system_id, component_id, _status, msg, scaled_pressure->time_boot_ms, scaled_pressure->press_abs, scaled_pressure->press_diff, scaled_pressure->temperature, scaled_pressure->temperature_press_diff); +} + /** * @brief Send a scaled_pressure message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_pressure2.h b/common/mavlink_msg_scaled_pressure2.h index 3c4a0f5a..d515ab09 100644 --- a/common/mavlink_msg_scaled_pressure2.h +++ b/common/mavlink_msg_scaled_pressure2.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_scaled_pressure2_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC); } +/** + * @brief Pack a scaled_pressure2 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param press_abs [hPa] Absolute pressure + * @param press_diff [hPa] Differential pressure + * @param temperature [cdegC] Absolute pressure temperature + * @param temperature_press_diff [cdegC] Differential pressure temperature (0, if not available). Report values of 0 (or 1) as 1 cdegC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_pressure2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature, int16_t temperature_press_diff) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, press_abs); + _mav_put_float(buf, 8, press_diff); + _mav_put_int16_t(buf, 12, temperature); + _mav_put_int16_t(buf, 14, temperature_press_diff); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN); +#else + mavlink_scaled_pressure2_t packet; + packet.time_boot_ms = time_boot_ms; + packet.press_abs = press_abs; + packet.press_diff = press_diff; + packet.temperature = temperature; + packet.temperature_press_diff = temperature_press_diff; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE2_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE2_LEN); +#endif +} + /** * @brief Pack a scaled_pressure2 message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_scaled_pressure2_encode_chan(uint8_t system_i return mavlink_msg_scaled_pressure2_pack_chan(system_id, component_id, chan, msg, scaled_pressure2->time_boot_ms, scaled_pressure2->press_abs, scaled_pressure2->press_diff, scaled_pressure2->temperature, scaled_pressure2->temperature_press_diff); } +/** + * @brief Encode a scaled_pressure2 struct with provided status structure + * + * @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 scaled_pressure2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_pressure2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_pressure2_t* scaled_pressure2) +{ + return mavlink_msg_scaled_pressure2_pack_status(system_id, component_id, _status, msg, scaled_pressure2->time_boot_ms, scaled_pressure2->press_abs, scaled_pressure2->press_diff, scaled_pressure2->temperature, scaled_pressure2->temperature_press_diff); +} + /** * @brief Send a scaled_pressure2 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_scaled_pressure3.h b/common/mavlink_msg_scaled_pressure3.h index 5c5e9737..61dbf19e 100644 --- a/common/mavlink_msg_scaled_pressure3.h +++ b/common/mavlink_msg_scaled_pressure3.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_scaled_pressure3_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCALED_PRESSURE3_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE3_CRC); } +/** + * @brief Pack a scaled_pressure3 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param press_abs [hPa] Absolute pressure + * @param press_diff [hPa] Differential pressure + * @param temperature [cdegC] Absolute pressure temperature + * @param temperature_press_diff [cdegC] Differential pressure temperature (0, if not available). Report values of 0 (or 1) as 1 cdegC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_scaled_pressure3_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, float press_abs, float press_diff, int16_t temperature, int16_t temperature_press_diff) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, press_abs); + _mav_put_float(buf, 8, press_diff); + _mav_put_int16_t(buf, 12, temperature); + _mav_put_int16_t(buf, 14, temperature_press_diff); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN); +#else + mavlink_scaled_pressure3_t packet; + packet.time_boot_ms = time_boot_ms; + packet.press_abs = press_abs; + packet.press_diff = press_diff; + packet.temperature = temperature; + packet.temperature_press_diff = temperature_press_diff; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE3; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE3_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE3_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCALED_PRESSURE3_MIN_LEN, MAVLINK_MSG_ID_SCALED_PRESSURE3_LEN); +#endif +} + /** * @brief Pack a scaled_pressure3 message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_scaled_pressure3_encode_chan(uint8_t system_i return mavlink_msg_scaled_pressure3_pack_chan(system_id, component_id, chan, msg, scaled_pressure3->time_boot_ms, scaled_pressure3->press_abs, scaled_pressure3->press_diff, scaled_pressure3->temperature, scaled_pressure3->temperature_press_diff); } +/** + * @brief Encode a scaled_pressure3 struct with provided status structure + * + * @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 scaled_pressure3 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_scaled_pressure3_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_scaled_pressure3_t* scaled_pressure3) +{ + return mavlink_msg_scaled_pressure3_pack_status(system_id, component_id, _status, msg, scaled_pressure3->time_boot_ms, scaled_pressure3->press_abs, scaled_pressure3->press_diff, scaled_pressure3->temperature, scaled_pressure3->temperature_press_diff); +} + /** * @brief Send a scaled_pressure3 message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_serial_control.h b/common/mavlink_msg_serial_control.h index 64b190af..90b53943 100644 --- a/common/mavlink_msg_serial_control.h +++ b/common/mavlink_msg_serial_control.h @@ -103,6 +103,58 @@ static inline uint16_t mavlink_msg_serial_control_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC); } +/** + * @brief Pack a serial_control 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 device Serial control device type. + * @param flags Bitmap of serial control flags. + * @param timeout [ms] Timeout for reply data + * @param baudrate [bits/s] Baudrate of transfer. Zero means no change. + * @param count [bytes] how many bytes in this transfer + * @param data serial data + * @param target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t device, uint8_t flags, uint16_t timeout, uint32_t baudrate, uint8_t count, const uint8_t *data, uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN]; + _mav_put_uint32_t(buf, 0, baudrate); + _mav_put_uint16_t(buf, 4, timeout); + _mav_put_uint8_t(buf, 6, device); + _mav_put_uint8_t(buf, 7, flags); + _mav_put_uint8_t(buf, 8, count); + _mav_put_uint8_t(buf, 79, target_system); + _mav_put_uint8_t(buf, 80, target_component); + _mav_put_uint8_t_array(buf, 9, data, 70); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN); +#else + mavlink_serial_control_t packet; + packet.baudrate = baudrate; + packet.timeout = timeout; + packet.device = device; + packet.flags = flags; + packet.count = count; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*70); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN); +#endif +} + /** * @brief Pack a serial_control message on a channel * @param system_id ID of this system @@ -178,6 +230,20 @@ static inline uint16_t mavlink_msg_serial_control_encode_chan(uint8_t system_id, return mavlink_msg_serial_control_pack_chan(system_id, component_id, chan, msg, serial_control->device, serial_control->flags, serial_control->timeout, serial_control->baudrate, serial_control->count, serial_control->data, serial_control->target_system, serial_control->target_component); } +/** + * @brief Encode a serial_control struct with provided status structure + * + * @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 serial_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_control_t* serial_control) +{ + return mavlink_msg_serial_control_pack_status(system_id, component_id, _status, msg, serial_control->device, serial_control->flags, serial_control->timeout, serial_control->baudrate, serial_control->count, serial_control->data, serial_control->target_system, serial_control->target_component); +} + /** * @brief Send a serial_control message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_servo_output_raw.h b/common/mavlink_msg_servo_output_raw.h index d1a5bb65..2b1c6b3e 100644 --- a/common/mavlink_msg_servo_output_raw.h +++ b/common/mavlink_msg_servo_output_raw.h @@ -165,6 +165,90 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_MIN_LEN, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_CRC); } +/** + * @brief Pack a servo_output_raw 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param port Servo output port (set of 8 outputs = 1 port). Flight stacks running on Pixhawk should use: 0 = MAIN, 1 = AUX. + * @param servo1_raw [us] Servo output 1 value + * @param servo2_raw [us] Servo output 2 value + * @param servo3_raw [us] Servo output 3 value + * @param servo4_raw [us] Servo output 4 value + * @param servo5_raw [us] Servo output 5 value + * @param servo6_raw [us] Servo output 6 value + * @param servo7_raw [us] Servo output 7 value + * @param servo8_raw [us] Servo output 8 value + * @param servo9_raw [us] Servo output 9 value + * @param servo10_raw [us] Servo output 10 value + * @param servo11_raw [us] Servo output 11 value + * @param servo12_raw [us] Servo output 12 value + * @param servo13_raw [us] Servo output 13 value + * @param servo14_raw [us] Servo output 14 value + * @param servo15_raw [us] Servo output 15 value + * @param servo16_raw [us] Servo output 16 value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_servo_output_raw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_usec, uint8_t port, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw, uint16_t servo9_raw, uint16_t servo10_raw, uint16_t servo11_raw, uint16_t servo12_raw, uint16_t servo13_raw, uint16_t servo14_raw, uint16_t servo15_raw, uint16_t servo16_raw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN]; + _mav_put_uint32_t(buf, 0, time_usec); + _mav_put_uint16_t(buf, 4, servo1_raw); + _mav_put_uint16_t(buf, 6, servo2_raw); + _mav_put_uint16_t(buf, 8, servo3_raw); + _mav_put_uint16_t(buf, 10, servo4_raw); + _mav_put_uint16_t(buf, 12, servo5_raw); + _mav_put_uint16_t(buf, 14, servo6_raw); + _mav_put_uint16_t(buf, 16, servo7_raw); + _mav_put_uint16_t(buf, 18, servo8_raw); + _mav_put_uint8_t(buf, 20, port); + _mav_put_uint16_t(buf, 21, servo9_raw); + _mav_put_uint16_t(buf, 23, servo10_raw); + _mav_put_uint16_t(buf, 25, servo11_raw); + _mav_put_uint16_t(buf, 27, servo12_raw); + _mav_put_uint16_t(buf, 29, servo13_raw); + _mav_put_uint16_t(buf, 31, servo14_raw); + _mav_put_uint16_t(buf, 33, servo15_raw); + _mav_put_uint16_t(buf, 35, servo16_raw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN); +#else + mavlink_servo_output_raw_t packet; + packet.time_usec = time_usec; + packet.servo1_raw = servo1_raw; + packet.servo2_raw = servo2_raw; + packet.servo3_raw = servo3_raw; + packet.servo4_raw = servo4_raw; + packet.servo5_raw = servo5_raw; + packet.servo6_raw = servo6_raw; + packet.servo7_raw = servo7_raw; + packet.servo8_raw = servo8_raw; + packet.port = port; + packet.servo9_raw = servo9_raw; + packet.servo10_raw = servo10_raw; + packet.servo11_raw = servo11_raw; + packet.servo12_raw = servo12_raw; + packet.servo13_raw = servo13_raw; + packet.servo14_raw = servo14_raw; + packet.servo15_raw = servo15_raw; + packet.servo16_raw = servo16_raw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_MIN_LEN, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_MIN_LEN, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN); +#endif +} + /** * @brief Pack a servo_output_raw message on a channel * @param system_id ID of this system @@ -272,6 +356,20 @@ static inline uint16_t mavlink_msg_servo_output_raw_encode_chan(uint8_t system_i return mavlink_msg_servo_output_raw_pack_chan(system_id, component_id, chan, msg, servo_output_raw->time_usec, servo_output_raw->port, servo_output_raw->servo1_raw, servo_output_raw->servo2_raw, servo_output_raw->servo3_raw, servo_output_raw->servo4_raw, servo_output_raw->servo5_raw, servo_output_raw->servo6_raw, servo_output_raw->servo7_raw, servo_output_raw->servo8_raw, servo_output_raw->servo9_raw, servo_output_raw->servo10_raw, servo_output_raw->servo11_raw, servo_output_raw->servo12_raw, servo_output_raw->servo13_raw, servo_output_raw->servo14_raw, servo_output_raw->servo15_raw, servo_output_raw->servo16_raw); } +/** + * @brief Encode a servo_output_raw struct with provided status structure + * + * @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 servo_output_raw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_servo_output_raw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_servo_output_raw_t* servo_output_raw) +{ + return mavlink_msg_servo_output_raw_pack_status(system_id, component_id, _status, msg, servo_output_raw->time_usec, servo_output_raw->port, servo_output_raw->servo1_raw, servo_output_raw->servo2_raw, servo_output_raw->servo3_raw, servo_output_raw->servo4_raw, servo_output_raw->servo5_raw, servo_output_raw->servo6_raw, servo_output_raw->servo7_raw, servo_output_raw->servo8_raw, servo_output_raw->servo9_raw, servo_output_raw->servo10_raw, servo_output_raw->servo11_raw, servo_output_raw->servo12_raw, servo_output_raw->servo13_raw, servo_output_raw->servo14_raw, servo_output_raw->servo15_raw, servo_output_raw->servo16_raw); +} + /** * @brief Send a servo_output_raw message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_actuator_control_target.h b/common/mavlink_msg_set_actuator_control_target.h index b9ea8fcb..8d9af8f9 100644 --- a/common/mavlink_msg_set_actuator_control_target.h +++ b/common/mavlink_msg_set_actuator_control_target.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_set_actuator_control_target_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_CRC); } +/** + * @brief Pack a set_actuator_control_target 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances. + * @param target_system System ID + * @param target_component Component ID + * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_actuator_control_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t group_mlx, uint8_t target_system, uint8_t target_component, const float *controls) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 40, group_mlx); + _mav_put_uint8_t(buf, 41, target_system); + _mav_put_uint8_t(buf, 42, target_component); + _mav_put_float_array(buf, 8, controls, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN); +#else + mavlink_set_actuator_control_target_t packet; + packet.time_usec = time_usec; + packet.group_mlx = group_mlx; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.controls, controls, sizeof(float)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET_LEN); +#endif +} + /** * @brief Pack a set_actuator_control_target message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_set_actuator_control_target_encode_chan(uint8 return mavlink_msg_set_actuator_control_target_pack_chan(system_id, component_id, chan, msg, set_actuator_control_target->time_usec, set_actuator_control_target->group_mlx, set_actuator_control_target->target_system, set_actuator_control_target->target_component, set_actuator_control_target->controls); } +/** + * @brief Encode a set_actuator_control_target struct with provided status structure + * + * @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 set_actuator_control_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_actuator_control_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_actuator_control_target_t* set_actuator_control_target) +{ + return mavlink_msg_set_actuator_control_target_pack_status(system_id, component_id, _status, msg, set_actuator_control_target->time_usec, set_actuator_control_target->group_mlx, set_actuator_control_target->target_system, set_actuator_control_target->target_component, set_actuator_control_target->controls); +} + /** * @brief Send a set_actuator_control_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_attitude_target.h b/common/mavlink_msg_set_attitude_target.h index 5196adbf..a9c7ce02 100644 --- a/common/mavlink_msg_set_attitude_target.h +++ b/common/mavlink_msg_set_attitude_target.h @@ -116,6 +116,64 @@ static inline uint16_t mavlink_msg_set_attitude_target_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC); } +/** + * @brief Pack a set_attitude_target 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param target_system System ID + * @param target_component Component ID + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD + * @param body_roll_rate [rad/s] Body roll rate + * @param body_pitch_rate [rad/s] Body pitch rate + * @param body_yaw_rate [rad/s] Body yaw rate + * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust) + * @param thrust_body 3D thrust setpoint in the body NED frame, normalized to -1 .. 1 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_attitude_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust, const float *thrust_body) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 20, body_roll_rate); + _mav_put_float(buf, 24, body_pitch_rate); + _mav_put_float(buf, 28, body_yaw_rate); + _mav_put_float(buf, 32, thrust); + _mav_put_uint8_t(buf, 36, target_system); + _mav_put_uint8_t(buf, 37, target_component); + _mav_put_uint8_t(buf, 38, type_mask); + _mav_put_float_array(buf, 4, q, 4); + _mav_put_float_array(buf, 39, thrust_body, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN); +#else + mavlink_set_attitude_target_t packet; + packet.time_boot_ms = time_boot_ms; + packet.body_roll_rate = body_roll_rate; + packet.body_pitch_rate = body_pitch_rate; + packet.body_yaw_rate = body_yaw_rate; + packet.thrust = thrust; + packet.target_system = target_system; + packet.target_component = target_component; + packet.type_mask = type_mask; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + mav_array_memcpy(packet.thrust_body, thrust_body, sizeof(float)*3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_ATTITUDE_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN); +#endif +} + /** * @brief Pack a set_attitude_target message on a channel * @param system_id ID of this system @@ -197,6 +255,20 @@ static inline uint16_t mavlink_msg_set_attitude_target_encode_chan(uint8_t syste return mavlink_msg_set_attitude_target_pack_chan(system_id, component_id, chan, msg, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body); } +/** + * @brief Encode a set_attitude_target struct with provided status structure + * + * @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 set_attitude_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_attitude_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_attitude_target_t* set_attitude_target) +{ + return mavlink_msg_set_attitude_target_pack_status(system_id, component_id, _status, msg, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body); +} + /** * @brief Send a set_attitude_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_gps_global_origin.h b/common/mavlink_msg_set_gps_global_origin.h index 88ab89b8..8147a780 100644 --- a/common/mavlink_msg_set_gps_global_origin.h +++ b/common/mavlink_msg_set_gps_global_origin.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_CRC); } +/** + * @brief Pack a set_gps_global_origin 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 target_system System ID + * @param latitude [degE7] Latitude (WGS84) + * @param longitude [degE7] Longitude (WGS84) + * @param altitude [mm] Altitude (MSL). Positive for up. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_gps_global_origin_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, int32_t latitude, int32_t longitude, int32_t altitude, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN]; + _mav_put_int32_t(buf, 0, latitude); + _mav_put_int32_t(buf, 4, longitude); + _mav_put_int32_t(buf, 8, altitude); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint64_t(buf, 13, time_usec); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN); +#else + mavlink_set_gps_global_origin_t packet; + packet.latitude = latitude; + packet.longitude = longitude; + packet.altitude = altitude; + packet.target_system = target_system; + packet.time_usec = time_usec; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_MIN_LEN, MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN_LEN); +#endif +} + /** * @brief Pack a set_gps_global_origin message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_encode_chan(uint8_t sys return mavlink_msg_set_gps_global_origin_pack_chan(system_id, component_id, chan, msg, set_gps_global_origin->target_system, set_gps_global_origin->latitude, set_gps_global_origin->longitude, set_gps_global_origin->altitude, set_gps_global_origin->time_usec); } +/** + * @brief Encode a set_gps_global_origin struct with provided status structure + * + * @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 set_gps_global_origin C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_gps_global_origin_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_gps_global_origin_t* set_gps_global_origin) +{ + return mavlink_msg_set_gps_global_origin_pack_status(system_id, component_id, _status, msg, set_gps_global_origin->target_system, set_gps_global_origin->latitude, set_gps_global_origin->longitude, set_gps_global_origin->altitude, set_gps_global_origin->time_usec); +} + /** * @brief Send a set_gps_global_origin message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_home_position.h b/common/mavlink_msg_set_home_position.h index 0bb34d7c..5d109273 100644 --- a/common/mavlink_msg_set_home_position.h +++ b/common/mavlink_msg_set_home_position.h @@ -127,6 +127,70 @@ static inline uint16_t mavlink_msg_set_home_position_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC); } +/** + * @brief Pack a set_home_position 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 target_system System ID. + * @param latitude [degE7] Latitude (WGS84) + * @param longitude [degE7] Longitude (WGS84) + * @param altitude [mm] Altitude (MSL). Positive for up. + * @param x [m] Local X position of this position in the local coordinate frame (NED) + * @param y [m] Local Y position of this position in the local coordinate frame (NED) + * @param z [m] Local Z position of this position in the local coordinate frame (NED: positive "down") + * @param q World to surface normal and heading transformation of the takeoff position. Used to indicate the heading and slope of the ground + * @param approach_x [m] Local X position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param approach_y [m] Local Y position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param approach_z [m] Local Z position of the end of the approach vector. Multicopters should set this position based on their takeoff path. Grass-landing fixed wing aircraft should set it the same way as multicopters. Runway-landing fixed wing aircraft should set it to the opposite direction of the takeoff, assuming the takeoff happened from the threshold / touchdown zone. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_home_position_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, int32_t latitude, int32_t longitude, int32_t altitude, float x, float y, float z, const float *q, float approach_x, float approach_y, float approach_z, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_HOME_POSITION_LEN]; + _mav_put_int32_t(buf, 0, latitude); + _mav_put_int32_t(buf, 4, longitude); + _mav_put_int32_t(buf, 8, altitude); + _mav_put_float(buf, 12, x); + _mav_put_float(buf, 16, y); + _mav_put_float(buf, 20, z); + _mav_put_float(buf, 40, approach_x); + _mav_put_float(buf, 44, approach_y); + _mav_put_float(buf, 48, approach_z); + _mav_put_uint8_t(buf, 52, target_system); + _mav_put_uint64_t(buf, 53, time_usec); + _mav_put_float_array(buf, 24, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN); +#else + mavlink_set_home_position_t packet; + packet.latitude = latitude; + packet.longitude = longitude; + packet.altitude = altitude; + packet.x = x; + packet.y = y; + packet.z = z; + packet.approach_x = approach_x; + packet.approach_y = approach_y; + packet.approach_z = approach_z; + packet.target_system = target_system; + packet.time_usec = time_usec; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_HOME_POSITION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_HOME_POSITION_MIN_LEN, MAVLINK_MSG_ID_SET_HOME_POSITION_LEN); +#endif +} + /** * @brief Pack a set_home_position message on a channel * @param system_id ID of this system @@ -214,6 +278,20 @@ static inline uint16_t mavlink_msg_set_home_position_encode_chan(uint8_t system_ return mavlink_msg_set_home_position_pack_chan(system_id, component_id, chan, msg, set_home_position->target_system, set_home_position->latitude, set_home_position->longitude, set_home_position->altitude, set_home_position->x, set_home_position->y, set_home_position->z, set_home_position->q, set_home_position->approach_x, set_home_position->approach_y, set_home_position->approach_z, set_home_position->time_usec); } +/** + * @brief Encode a set_home_position struct with provided status structure + * + * @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 set_home_position C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_home_position_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_home_position_t* set_home_position) +{ + return mavlink_msg_set_home_position_pack_status(system_id, component_id, _status, msg, set_home_position->target_system, set_home_position->latitude, set_home_position->longitude, set_home_position->altitude, set_home_position->x, set_home_position->y, set_home_position->z, set_home_position->q, set_home_position->approach_x, set_home_position->approach_y, set_home_position->approach_z, set_home_position->time_usec); +} + /** * @brief Send a set_home_position message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_mode.h b/common/mavlink_msg_set_mode.h index 14509122..b41d38fd 100644 --- a/common/mavlink_msg_set_mode.h +++ b/common/mavlink_msg_set_mode.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_set_mode_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); } +/** + * @brief Pack a set_mode 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 target_system The system setting the mode + * @param base_mode The new base mode. + * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_mode_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t base_mode, uint32_t custom_mode) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_MODE_LEN]; + _mav_put_uint32_t(buf, 0, custom_mode); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, base_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MODE_LEN); +#else + mavlink_set_mode_t packet; + packet.custom_mode = custom_mode; + packet.target_system = target_system; + packet.base_mode = base_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MODE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_MODE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN); +#endif +} + /** * @brief Pack a set_mode message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_set_mode_encode_chan(uint8_t system_id, uint8 return mavlink_msg_set_mode_pack_chan(system_id, component_id, chan, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode); } +/** + * @brief Encode a set_mode struct with provided status structure + * + * @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 set_mode C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_mode_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode) +{ + return mavlink_msg_set_mode_pack_status(system_id, component_id, _status, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode); +} + /** * @brief Send a set_mode message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_position_target_global_int.h b/common/mavlink_msg_set_position_target_global_int.h index 0c314cab..dd7f58f9 100644 --- a/common/mavlink_msg_set_position_target_global_int.h +++ b/common/mavlink_msg_set_position_target_global_int.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_set_position_target_global_int_pack(uint8_t s return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_CRC); } +/** + * @brief Pack a set_position_target_global_int 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 time_boot_ms [ms] Timestamp (time since system boot). The rationale for the timestamp in the setpoint is to allow the system to compensate for the transport delay of the setpoint. This allows the system to compensate processing latency. + * @param target_system System ID + * @param target_component Component ID + * @param coordinate_frame Valid options are: MAV_FRAME_GLOBAL_INT = 5, MAV_FRAME_GLOBAL_RELATIVE_ALT_INT = 6, MAV_FRAME_GLOBAL_TERRAIN_ALT_INT = 11 + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param lat_int [degE7] X Position in WGS84 frame + * @param lon_int [degE7] Y Position in WGS84 frame + * @param alt [m] Altitude (MSL, Relative to home, or AGL - depending on frame) + * @param vx [m/s] X velocity in NED frame + * @param vy [m/s] Y velocity in NED frame + * @param vz [m/s] Z velocity in NED frame + * @param afx [m/s/s] X acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afy [m/s/s] Y acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afz [m/s/s] Z acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param yaw [rad] yaw setpoint + * @param yaw_rate [rad/s] yaw rate setpoint + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_position_target_global_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t coordinate_frame, uint16_t type_mask, int32_t lat_int, int32_t lon_int, float alt, float vx, float vy, float vz, float afx, float afy, float afz, float yaw, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, lat_int); + _mav_put_int32_t(buf, 8, lon_int); + _mav_put_float(buf, 12, alt); + _mav_put_float(buf, 16, vx); + _mav_put_float(buf, 20, vy); + _mav_put_float(buf, 24, vz); + _mav_put_float(buf, 28, afx); + _mav_put_float(buf, 32, afy); + _mav_put_float(buf, 36, afz); + _mav_put_float(buf, 40, yaw); + _mav_put_float(buf, 44, yaw_rate); + _mav_put_uint16_t(buf, 48, type_mask); + _mav_put_uint8_t(buf, 50, target_system); + _mav_put_uint8_t(buf, 51, target_component); + _mav_put_uint8_t(buf, 52, coordinate_frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN); +#else + mavlink_set_position_target_global_int_t packet; + packet.time_boot_ms = time_boot_ms; + packet.lat_int = lat_int; + packet.lon_int = lon_int; + packet.alt = alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.afx = afx; + packet.afy = afy; + packet.afz = afz; + packet.yaw = yaw; + packet.yaw_rate = yaw_rate; + packet.type_mask = type_mask; + packet.target_system = target_system; + packet.target_component = target_component; + packet.coordinate_frame = coordinate_frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT_LEN); +#endif +} + /** * @brief Pack a set_position_target_global_int message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_set_position_target_global_int_encode_chan(ui return mavlink_msg_set_position_target_global_int_pack_chan(system_id, component_id, chan, msg, set_position_target_global_int->time_boot_ms, set_position_target_global_int->target_system, set_position_target_global_int->target_component, set_position_target_global_int->coordinate_frame, set_position_target_global_int->type_mask, set_position_target_global_int->lat_int, set_position_target_global_int->lon_int, set_position_target_global_int->alt, set_position_target_global_int->vx, set_position_target_global_int->vy, set_position_target_global_int->vz, set_position_target_global_int->afx, set_position_target_global_int->afy, set_position_target_global_int->afz, set_position_target_global_int->yaw, set_position_target_global_int->yaw_rate); } +/** + * @brief Encode a set_position_target_global_int struct with provided status structure + * + * @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 set_position_target_global_int C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_position_target_global_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_position_target_global_int_t* set_position_target_global_int) +{ + return mavlink_msg_set_position_target_global_int_pack_status(system_id, component_id, _status, msg, set_position_target_global_int->time_boot_ms, set_position_target_global_int->target_system, set_position_target_global_int->target_component, set_position_target_global_int->coordinate_frame, set_position_target_global_int->type_mask, set_position_target_global_int->lat_int, set_position_target_global_int->lon_int, set_position_target_global_int->alt, set_position_target_global_int->vx, set_position_target_global_int->vy, set_position_target_global_int->vz, set_position_target_global_int->afx, set_position_target_global_int->afy, set_position_target_global_int->afz, set_position_target_global_int->yaw, set_position_target_global_int->yaw_rate); +} + /** * @brief Send a set_position_target_global_int message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_set_position_target_local_ned.h b/common/mavlink_msg_set_position_target_local_ned.h index 646bda57..cf6a24b0 100644 --- a/common/mavlink_msg_set_position_target_local_ned.h +++ b/common/mavlink_msg_set_position_target_local_ned.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_set_position_target_local_ned_pack(uint8_t sy return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_CRC); } +/** + * @brief Pack a set_position_target_local_ned 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param target_system System ID + * @param target_component Component ID + * @param coordinate_frame Valid options are: MAV_FRAME_LOCAL_NED = 1, MAV_FRAME_LOCAL_OFFSET_NED = 7, MAV_FRAME_BODY_NED = 8, MAV_FRAME_BODY_OFFSET_NED = 9 + * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle. + * @param x [m] X Position in NED frame + * @param y [m] Y Position in NED frame + * @param z [m] Z Position in NED frame (note, altitude is negative in NED) + * @param vx [m/s] X velocity in NED frame + * @param vy [m/s] Y velocity in NED frame + * @param vz [m/s] Z velocity in NED frame + * @param afx [m/s/s] X acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afy [m/s/s] Y acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param afz [m/s/s] Z acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N + * @param yaw [rad] yaw setpoint + * @param yaw_rate [rad/s] yaw rate setpoint + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_position_target_local_ned_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t coordinate_frame, uint16_t type_mask, float x, float y, float z, float vx, float vy, float vz, float afx, float afy, float afz, float yaw, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, vx); + _mav_put_float(buf, 20, vy); + _mav_put_float(buf, 24, vz); + _mav_put_float(buf, 28, afx); + _mav_put_float(buf, 32, afy); + _mav_put_float(buf, 36, afz); + _mav_put_float(buf, 40, yaw); + _mav_put_float(buf, 44, yaw_rate); + _mav_put_uint16_t(buf, 48, type_mask); + _mav_put_uint8_t(buf, 50, target_system); + _mav_put_uint8_t(buf, 51, target_component); + _mav_put_uint8_t(buf, 52, coordinate_frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN); +#else + mavlink_set_position_target_local_ned_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.afx = afx; + packet.afy = afy; + packet.afz = afz; + packet.yaw = yaw; + packet.yaw_rate = yaw_rate; + packet.type_mask = type_mask; + packet.target_system = target_system; + packet.target_component = target_component; + packet.coordinate_frame = coordinate_frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_MIN_LEN, MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED_LEN); +#endif +} + /** * @brief Pack a set_position_target_local_ned message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_set_position_target_local_ned_encode_chan(uin return mavlink_msg_set_position_target_local_ned_pack_chan(system_id, component_id, chan, msg, set_position_target_local_ned->time_boot_ms, set_position_target_local_ned->target_system, set_position_target_local_ned->target_component, set_position_target_local_ned->coordinate_frame, set_position_target_local_ned->type_mask, set_position_target_local_ned->x, set_position_target_local_ned->y, set_position_target_local_ned->z, set_position_target_local_ned->vx, set_position_target_local_ned->vy, set_position_target_local_ned->vz, set_position_target_local_ned->afx, set_position_target_local_ned->afy, set_position_target_local_ned->afz, set_position_target_local_ned->yaw, set_position_target_local_ned->yaw_rate); } +/** + * @brief Encode a set_position_target_local_ned struct with provided status structure + * + * @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 set_position_target_local_ned C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_position_target_local_ned_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_position_target_local_ned_t* set_position_target_local_ned) +{ + return mavlink_msg_set_position_target_local_ned_pack_status(system_id, component_id, _status, msg, set_position_target_local_ned->time_boot_ms, set_position_target_local_ned->target_system, set_position_target_local_ned->target_component, set_position_target_local_ned->coordinate_frame, set_position_target_local_ned->type_mask, set_position_target_local_ned->x, set_position_target_local_ned->y, set_position_target_local_ned->z, set_position_target_local_ned->vx, set_position_target_local_ned->vy, set_position_target_local_ned->vz, set_position_target_local_ned->afx, set_position_target_local_ned->afy, set_position_target_local_ned->afz, set_position_target_local_ned->yaw, set_position_target_local_ned->yaw_rate); +} + /** * @brief Send a set_position_target_local_ned message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_setup_signing.h b/common/mavlink_msg_setup_signing.h index 40b2feed..ee0b5274 100644 --- a/common/mavlink_msg_setup_signing.h +++ b/common/mavlink_msg_setup_signing.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_setup_signing_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC); } +/** + * @brief Pack a setup_signing 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 target_system system id of the target + * @param target_component component ID of the target + * @param secret_key signing key + * @param initial_timestamp initial timestamp + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_setup_signing_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const uint8_t *secret_key, uint64_t initial_timestamp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SETUP_SIGNING_LEN]; + _mav_put_uint64_t(buf, 0, initial_timestamp); + _mav_put_uint8_t(buf, 8, target_system); + _mav_put_uint8_t(buf, 9, target_component); + _mav_put_uint8_t_array(buf, 10, secret_key, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SETUP_SIGNING_LEN); +#else + mavlink_setup_signing_t packet; + packet.initial_timestamp = initial_timestamp; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SETUP_SIGNING_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SETUP_SIGNING; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN); +#endif +} + /** * @brief Pack a setup_signing message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_setup_signing_encode_chan(uint8_t system_id, return mavlink_msg_setup_signing_pack_chan(system_id, component_id, chan, msg, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp); } +/** + * @brief Encode a setup_signing struct with provided status structure + * + * @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 setup_signing C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_setup_signing_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_setup_signing_t* setup_signing) +{ + return mavlink_msg_setup_signing_pack_status(system_id, component_id, _status, msg, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp); +} + /** * @brief Send a setup_signing message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_sim_state.h b/common/mavlink_msg_sim_state.h index 3442f1a0..0d7a6b82 100644 --- a/common/mavlink_msg_sim_state.h +++ b/common/mavlink_msg_sim_state.h @@ -195,6 +195,105 @@ static inline uint16_t mavlink_msg_sim_state_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC); } +/** + * @brief Pack a sim_state 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 q1 True attitude quaternion component 1, w (1 in null-rotation) + * @param q2 True attitude quaternion component 2, x (0 in null-rotation) + * @param q3 True attitude quaternion component 3, y (0 in null-rotation) + * @param q4 True attitude quaternion component 4, z (0 in null-rotation) + * @param roll Attitude roll expressed as Euler angles, not recommended except for human-readable outputs + * @param pitch Attitude pitch expressed as Euler angles, not recommended except for human-readable outputs + * @param yaw Attitude yaw expressed as Euler angles, not recommended except for human-readable outputs + * @param xacc [m/s/s] X acceleration + * @param yacc [m/s/s] Y acceleration + * @param zacc [m/s/s] Z acceleration + * @param xgyro [rad/s] Angular speed around X axis + * @param ygyro [rad/s] Angular speed around Y axis + * @param zgyro [rad/s] Angular speed around Z axis + * @param lat [deg] Latitude (lower precision). Both this and the lat_int field should be set. + * @param lon [deg] Longitude (lower precision). Both this and the lon_int field should be set. + * @param alt [m] Altitude + * @param std_dev_horz Horizontal position standard deviation + * @param std_dev_vert Vertical position standard deviation + * @param vn [m/s] True velocity in north direction in earth-fixed NED frame + * @param ve [m/s] True velocity in east direction in earth-fixed NED frame + * @param vd [m/s] True velocity in down direction in earth-fixed NED frame + * @param lat_int [degE7] Latitude (higher precision). If 0, recipients should use the lat field value (otherwise this field is preferred). + * @param lon_int [degE7] Longitude (higher precision). If 0, recipients should use the lon field value (otherwise this field is preferred). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sim_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float q1, float q2, float q3, float q4, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lon, float alt, float std_dev_horz, float std_dev_vert, float vn, float ve, float vd, int32_t lat_int, int32_t lon_int) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SIM_STATE_LEN]; + _mav_put_float(buf, 0, q1); + _mav_put_float(buf, 4, q2); + _mav_put_float(buf, 8, q3); + _mav_put_float(buf, 12, q4); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + _mav_put_float(buf, 28, xacc); + _mav_put_float(buf, 32, yacc); + _mav_put_float(buf, 36, zacc); + _mav_put_float(buf, 40, xgyro); + _mav_put_float(buf, 44, ygyro); + _mav_put_float(buf, 48, zgyro); + _mav_put_float(buf, 52, lat); + _mav_put_float(buf, 56, lon); + _mav_put_float(buf, 60, alt); + _mav_put_float(buf, 64, std_dev_horz); + _mav_put_float(buf, 68, std_dev_vert); + _mav_put_float(buf, 72, vn); + _mav_put_float(buf, 76, ve); + _mav_put_float(buf, 80, vd); + _mav_put_int32_t(buf, 84, lat_int); + _mav_put_int32_t(buf, 88, lon_int); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIM_STATE_LEN); +#else + mavlink_sim_state_t packet; + packet.q1 = q1; + packet.q2 = q2; + packet.q3 = q3; + packet.q4 = q4; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.std_dev_horz = std_dev_horz; + packet.std_dev_vert = std_dev_vert; + packet.vn = vn; + packet.ve = ve; + packet.vd = vd; + packet.lat_int = lat_int; + packet.lon_int = lon_int; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIM_STATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SIM_STATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN, MAVLINK_MSG_ID_SIM_STATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SIM_STATE_MIN_LEN, MAVLINK_MSG_ID_SIM_STATE_LEN); +#endif +} + /** * @brief Pack a sim_state message on a channel * @param system_id ID of this system @@ -317,6 +416,20 @@ static inline uint16_t mavlink_msg_sim_state_encode_chan(uint8_t system_id, uint return mavlink_msg_sim_state_pack_chan(system_id, component_id, chan, msg, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int); } +/** + * @brief Encode a sim_state struct with provided status structure + * + * @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 sim_state C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sim_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sim_state_t* sim_state) +{ + return mavlink_msg_sim_state_pack_status(system_id, component_id, _status, msg, sim_state->q1, sim_state->q2, sim_state->q3, sim_state->q4, sim_state->roll, sim_state->pitch, sim_state->yaw, sim_state->xacc, sim_state->yacc, sim_state->zacc, sim_state->xgyro, sim_state->ygyro, sim_state->zgyro, sim_state->lat, sim_state->lon, sim_state->alt, sim_state->std_dev_horz, sim_state->std_dev_vert, sim_state->vn, sim_state->ve, sim_state->vd, sim_state->lat_int, sim_state->lon_int); +} + /** * @brief Send a sim_state message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_statustext.h b/common/mavlink_msg_statustext.h index 78db7c60..e0be2f74 100644 --- a/common/mavlink_msg_statustext.h +++ b/common/mavlink_msg_statustext.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); } +/** + * @brief Pack a statustext 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 severity Severity of status. Relies on the definitions within RFC-5424. + * @param text Status text message, without null termination character + * @param id Unique (opaque) identifier for this statustext message. May be used to reassemble a logical long-statustext message from a sequence of chunks. A value of zero indicates this is the only chunk in the sequence and the message can be emitted immediately. + * @param chunk_seq This chunk's sequence number; indexing is from zero. Any null character in the text field is taken to mean this was the last chunk. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_statustext_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t severity, const char *text, uint16_t id, uint8_t chunk_seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STATUSTEXT_LEN]; + _mav_put_uint8_t(buf, 0, severity); + _mav_put_uint16_t(buf, 51, id); + _mav_put_uint8_t(buf, 53, chunk_seq); + _mav_put_char_array(buf, 1, text, 50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUSTEXT_LEN); +#else + mavlink_statustext_t packet; + packet.severity = severity; + packet.id = id; + packet.chunk_seq = chunk_seq; + mav_array_memcpy(packet.text, text, sizeof(char)*50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUSTEXT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN, MAVLINK_MSG_ID_STATUSTEXT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STATUSTEXT_MIN_LEN, MAVLINK_MSG_ID_STATUSTEXT_LEN); +#endif +} + /** * @brief Pack a statustext message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_statustext_encode_chan(uint8_t system_id, uin return mavlink_msg_statustext_pack_chan(system_id, component_id, chan, msg, statustext->severity, statustext->text, statustext->id, statustext->chunk_seq); } +/** + * @brief Encode a statustext struct with provided status structure + * + * @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 statustext C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_statustext_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_statustext_t* statustext) +{ + return mavlink_msg_statustext_pack_status(system_id, component_id, _status, msg, statustext->severity, statustext->text, statustext->id, statustext->chunk_seq); +} + /** * @brief Send a statustext message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_storage_information.h b/common/mavlink_msg_storage_information.h index 94317f41..9ff61bd8 100644 --- a/common/mavlink_msg_storage_information.h +++ b/common/mavlink_msg_storage_information.h @@ -133,6 +133,73 @@ static inline uint16_t mavlink_msg_storage_information_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC); } +/** + * @brief Pack a storage_information 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param storage_id Storage ID (1 for first, 2 for second, etc.) + * @param storage_count Number of storage devices + * @param status Status of storage + * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. + * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. + * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored. + * @param read_speed [MiB/s] Read speed. + * @param write_speed [MiB/s] Write speed. + * @param type Type of storage + * @param name Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user. + * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc. + Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported). + This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE. + If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storage_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed, uint8_t type, const char *name, uint8_t storage_usage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, total_capacity); + _mav_put_float(buf, 8, used_capacity); + _mav_put_float(buf, 12, available_capacity); + _mav_put_float(buf, 16, read_speed); + _mav_put_float(buf, 20, write_speed); + _mav_put_uint8_t(buf, 24, storage_id); + _mav_put_uint8_t(buf, 25, storage_count); + _mav_put_uint8_t(buf, 26, status); + _mav_put_uint8_t(buf, 27, type); + _mav_put_uint8_t(buf, 60, storage_usage); + _mav_put_char_array(buf, 28, name, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN); +#else + mavlink_storage_information_t packet; + packet.time_boot_ms = time_boot_ms; + packet.total_capacity = total_capacity; + packet.used_capacity = used_capacity; + packet.available_capacity = available_capacity; + packet.read_speed = read_speed; + packet.write_speed = write_speed; + packet.storage_id = storage_id; + packet.storage_count = storage_count; + packet.status = status; + packet.type = type; + packet.storage_usage = storage_usage; + mav_array_memcpy(packet.name, name, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN); +#endif +} + /** * @brief Pack a storage_information message on a channel * @param system_id ID of this system @@ -223,6 +290,20 @@ static inline uint16_t mavlink_msg_storage_information_encode_chan(uint8_t syste return mavlink_msg_storage_information_pack_chan(system_id, component_id, chan, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed, storage_information->type, storage_information->name, storage_information->storage_usage); } +/** + * @brief Encode a storage_information struct with provided status structure + * + * @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 storage_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storage_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information) +{ + return mavlink_msg_storage_information_pack_status(system_id, component_id, _status, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed, storage_information->type, storage_information->name, storage_information->storage_usage); +} + /** * @brief Send a storage_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_supported_tunes.h b/common/mavlink_msg_supported_tunes.h index 65862c2e..8bba0f51 100644 --- a/common/mavlink_msg_supported_tunes.h +++ b/common/mavlink_msg_supported_tunes.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_supported_tunes_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SUPPORTED_TUNES_MIN_LEN, MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN, MAVLINK_MSG_ID_SUPPORTED_TUNES_CRC); } +/** + * @brief Pack a supported_tunes 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 target_system System ID + * @param target_component Component ID + * @param format Bitfield of supported tune formats. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_supported_tunes_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t format) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN]; + _mav_put_uint32_t(buf, 0, format); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN); +#else + mavlink_supported_tunes_t packet; + packet.format = format; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SUPPORTED_TUNES; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SUPPORTED_TUNES_MIN_LEN, MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN, MAVLINK_MSG_ID_SUPPORTED_TUNES_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SUPPORTED_TUNES_MIN_LEN, MAVLINK_MSG_ID_SUPPORTED_TUNES_LEN); +#endif +} + /** * @brief Pack a supported_tunes message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_supported_tunes_encode_chan(uint8_t system_id return mavlink_msg_supported_tunes_pack_chan(system_id, component_id, chan, msg, supported_tunes->target_system, supported_tunes->target_component, supported_tunes->format); } +/** + * @brief Encode a supported_tunes struct with provided status structure + * + * @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 supported_tunes C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_supported_tunes_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_supported_tunes_t* supported_tunes) +{ + return mavlink_msg_supported_tunes_pack_status(system_id, component_id, _status, msg, supported_tunes->target_system, supported_tunes->target_component, supported_tunes->format); +} + /** * @brief Send a supported_tunes message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_sys_status.h b/common/mavlink_msg_sys_status.h index fb589236..86b0a27b 100644 --- a/common/mavlink_msg_sys_status.h +++ b/common/mavlink_msg_sys_status.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC); } +/** + * @brief Pack a sys_status 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 onboard_control_sensors_present Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. + * @param onboard_control_sensors_enabled Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. + * @param onboard_control_sensors_health Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy. + * @param load [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000 + * @param voltage_battery [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot + * @param current_battery [cA] Battery current, -1: Current not sent by autopilot + * @param battery_remaining [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot + * @param drop_rate_comm [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV) + * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV) + * @param errors_count1 Autopilot-specific errors + * @param errors_count2 Autopilot-specific errors + * @param errors_count3 Autopilot-specific errors + * @param errors_count4 Autopilot-specific errors + * @param onboard_control_sensors_present_extended Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. + * @param onboard_control_sensors_enabled_extended Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. + * @param onboard_control_sensors_health_extended Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_sys_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4, uint32_t onboard_control_sensors_present_extended, uint32_t onboard_control_sensors_enabled_extended, uint32_t onboard_control_sensors_health_extended) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN]; + _mav_put_uint32_t(buf, 0, onboard_control_sensors_present); + _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled); + _mav_put_uint32_t(buf, 8, onboard_control_sensors_health); + _mav_put_uint16_t(buf, 12, load); + _mav_put_uint16_t(buf, 14, voltage_battery); + _mav_put_int16_t(buf, 16, current_battery); + _mav_put_uint16_t(buf, 18, drop_rate_comm); + _mav_put_uint16_t(buf, 20, errors_comm); + _mav_put_uint16_t(buf, 22, errors_count1); + _mav_put_uint16_t(buf, 24, errors_count2); + _mav_put_uint16_t(buf, 26, errors_count3); + _mav_put_uint16_t(buf, 28, errors_count4); + _mav_put_int8_t(buf, 30, battery_remaining); + _mav_put_uint32_t(buf, 31, onboard_control_sensors_present_extended); + _mav_put_uint32_t(buf, 35, onboard_control_sensors_enabled_extended); + _mav_put_uint32_t(buf, 39, onboard_control_sensors_health_extended); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN); +#else + mavlink_sys_status_t packet; + packet.onboard_control_sensors_present = onboard_control_sensors_present; + packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled; + packet.onboard_control_sensors_health = onboard_control_sensors_health; + packet.load = load; + packet.voltage_battery = voltage_battery; + packet.current_battery = current_battery; + packet.drop_rate_comm = drop_rate_comm; + packet.errors_comm = errors_comm; + packet.errors_count1 = errors_count1; + packet.errors_count2 = errors_count2; + packet.errors_count3 = errors_count3; + packet.errors_count4 = errors_count4; + packet.battery_remaining = battery_remaining; + packet.onboard_control_sensors_present_extended = onboard_control_sensors_present_extended; + packet.onboard_control_sensors_enabled_extended = onboard_control_sensors_enabled_extended; + packet.onboard_control_sensors_health_extended = onboard_control_sensors_health_extended; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SYS_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN); +#endif +} + /** * @brief Pack a sys_status message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_sys_status_encode_chan(uint8_t system_id, uin return mavlink_msg_sys_status_pack_chan(system_id, component_id, chan, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4, sys_status->onboard_control_sensors_present_extended, sys_status->onboard_control_sensors_enabled_extended, sys_status->onboard_control_sensors_health_extended); } +/** + * @brief Encode a sys_status struct with provided status structure + * + * @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 sys_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_sys_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_sys_status_t* sys_status) +{ + return mavlink_msg_sys_status_pack_status(system_id, component_id, _status, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4, sys_status->onboard_control_sensors_present_extended, sys_status->onboard_control_sensors_enabled_extended, sys_status->onboard_control_sensors_health_extended); +} + /** * @brief Send a sys_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_system_time.h b/common/mavlink_msg_system_time.h index 0b043636..78b9afa4 100644 --- a/common/mavlink_msg_system_time.h +++ b/common/mavlink_msg_system_time.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); } +/** + * @brief Pack a system_time 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 time_unix_usec [us] Timestamp (UNIX epoch time). + * @param time_boot_ms [ms] Timestamp (time since system boot). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_system_time_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_unix_usec, uint32_t time_boot_ms) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; + _mav_put_uint64_t(buf, 0, time_unix_usec); + _mav_put_uint32_t(buf, 8, time_boot_ms); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); +#else + mavlink_system_time_t packet; + packet.time_unix_usec = time_unix_usec; + packet.time_boot_ms = time_boot_ms; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); +#endif +} + /** * @brief Pack a system_time message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_system_time_encode_chan(uint8_t system_id, ui return mavlink_msg_system_time_pack_chan(system_id, component_id, chan, msg, system_time->time_unix_usec, system_time->time_boot_ms); } +/** + * @brief Encode a system_time struct with provided status structure + * + * @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 system_time C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_system_time_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_system_time_t* system_time) +{ + return mavlink_msg_system_time_pack_status(system_id, component_id, _status, msg, system_time->time_unix_usec, system_time->time_boot_ms); +} + /** * @brief Send a system_time message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_terrain_check.h b/common/mavlink_msg_terrain_check.h index eaadfa15..f220721c 100644 --- a/common/mavlink_msg_terrain_check.h +++ b/common/mavlink_msg_terrain_check.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_terrain_check_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); } +/** + * @brief Pack a terrain_check 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 lat [degE7] Latitude + * @param lon [degE7] Longitude + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_terrain_check_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t lat, int32_t lon) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; + _mav_put_int32_t(buf, 0, lat); + _mav_put_int32_t(buf, 4, lon); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); +#else + mavlink_terrain_check_t packet; + packet.lat = lat; + packet.lon = lon; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TERRAIN_CHECK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); +#endif +} + /** * @brief Pack a terrain_check message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_terrain_check_encode_chan(uint8_t system_id, return mavlink_msg_terrain_check_pack_chan(system_id, component_id, chan, msg, terrain_check->lat, terrain_check->lon); } +/** + * @brief Encode a terrain_check struct with provided status structure + * + * @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 terrain_check C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_terrain_check_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_terrain_check_t* terrain_check) +{ + return mavlink_msg_terrain_check_pack_status(system_id, component_id, _status, msg, terrain_check->lat, terrain_check->lon); +} + /** * @brief Send a terrain_check message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_terrain_data.h b/common/mavlink_msg_terrain_data.h index ca674511..aea98d58 100644 --- a/common/mavlink_msg_terrain_data.h +++ b/common/mavlink_msg_terrain_data.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_terrain_data_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC); } +/** + * @brief Pack a terrain_data 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 lat [degE7] Latitude of SW corner of first grid + * @param lon [degE7] Longitude of SW corner of first grid + * @param grid_spacing [m] Grid spacing + * @param gridbit bit within the terrain request mask + * @param data [m] Terrain data MSL + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_terrain_data_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN]; + _mav_put_int32_t(buf, 0, lat); + _mav_put_int32_t(buf, 4, lon); + _mav_put_uint16_t(buf, 8, grid_spacing); + _mav_put_uint8_t(buf, 42, gridbit); + _mav_put_int16_t_array(buf, 10, data, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN); +#else + mavlink_terrain_data_t packet; + packet.lat = lat; + packet.lon = lon; + packet.grid_spacing = grid_spacing; + packet.gridbit = gridbit; + mav_array_memcpy(packet.data, data, sizeof(int16_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN); +#endif +} + /** * @brief Pack a terrain_data message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_terrain_data_encode_chan(uint8_t system_id, u return mavlink_msg_terrain_data_pack_chan(system_id, component_id, chan, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data); } +/** + * @brief Encode a terrain_data struct with provided status structure + * + * @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 terrain_data C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_terrain_data_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data) +{ + return mavlink_msg_terrain_data_pack_status(system_id, component_id, _status, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data); +} + /** * @brief Send a terrain_data message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_terrain_report.h b/common/mavlink_msg_terrain_report.h index 92d57a4a..02803b64 100644 --- a/common/mavlink_msg_terrain_report.h +++ b/common/mavlink_msg_terrain_report.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_terrain_report_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC); } +/** + * @brief Pack a terrain_report 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 lat [degE7] Latitude + * @param lon [degE7] Longitude + * @param spacing grid spacing (zero if terrain at this location unavailable) + * @param terrain_height [m] Terrain height MSL + * @param current_height [m] Current vehicle height above lat/lon terrain height + * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk + * @param loaded Number of 4x4 terrain blocks in memory + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_terrain_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN]; + _mav_put_int32_t(buf, 0, lat); + _mav_put_int32_t(buf, 4, lon); + _mav_put_float(buf, 8, terrain_height); + _mav_put_float(buf, 12, current_height); + _mav_put_uint16_t(buf, 16, spacing); + _mav_put_uint16_t(buf, 18, pending); + _mav_put_uint16_t(buf, 20, loaded); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN); +#else + mavlink_terrain_report_t packet; + packet.lat = lat; + packet.lon = lon; + packet.terrain_height = terrain_height; + packet.current_height = current_height; + packet.spacing = spacing; + packet.pending = pending; + packet.loaded = loaded; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN); +#endif +} + /** * @brief Pack a terrain_report message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_terrain_report_encode_chan(uint8_t system_id, return mavlink_msg_terrain_report_pack_chan(system_id, component_id, chan, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded); } +/** + * @brief Encode a terrain_report struct with provided status structure + * + * @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 terrain_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_terrain_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report) +{ + return mavlink_msg_terrain_report_pack_status(system_id, component_id, _status, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded); +} + /** * @brief Send a terrain_report message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_terrain_request.h b/common/mavlink_msg_terrain_request.h index a76cfdd3..39feff95 100644 --- a/common/mavlink_msg_terrain_request.h +++ b/common/mavlink_msg_terrain_request.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_terrain_request_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REQUEST_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN, MAVLINK_MSG_ID_TERRAIN_REQUEST_CRC); } +/** + * @brief Pack a terrain_request 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 lat [degE7] Latitude of SW corner of first grid + * @param lon [degE7] Longitude of SW corner of first grid + * @param grid_spacing [m] Grid spacing + * @param mask Bitmask of requested 4x4 grids (row major 8x7 array of grids, 56 bits) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_terrain_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t lat, int32_t lon, uint16_t grid_spacing, uint64_t mask) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN]; + _mav_put_uint64_t(buf, 0, mask); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_uint16_t(buf, 16, grid_spacing); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN); +#else + mavlink_terrain_request_t packet; + packet.mask = mask; + packet.lat = lat; + packet.lon = lon; + packet.grid_spacing = grid_spacing; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TERRAIN_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REQUEST_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN, MAVLINK_MSG_ID_TERRAIN_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REQUEST_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REQUEST_LEN); +#endif +} + /** * @brief Pack a terrain_request message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_terrain_request_encode_chan(uint8_t system_id return mavlink_msg_terrain_request_pack_chan(system_id, component_id, chan, msg, terrain_request->lat, terrain_request->lon, terrain_request->grid_spacing, terrain_request->mask); } +/** + * @brief Encode a terrain_request struct with provided status structure + * + * @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 terrain_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_terrain_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_terrain_request_t* terrain_request) +{ + return mavlink_msg_terrain_request_pack_status(system_id, component_id, _status, msg, terrain_request->lat, terrain_request->lon, terrain_request->grid_spacing, terrain_request->mask); +} + /** * @brief Send a terrain_request message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_time_estimate_to_target.h b/common/mavlink_msg_time_estimate_to_target.h index dd69e4cc..a9d6ece5 100644 --- a/common/mavlink_msg_time_estimate_to_target.h +++ b/common/mavlink_msg_time_estimate_to_target.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_time_estimate_to_target_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_MIN_LEN, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_CRC); } +/** + * @brief Pack a time_estimate_to_target 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 safe_return [s] Estimated time to complete the vehicle's configured "safe return" action from its current position (e.g. RTL, Smart RTL, etc.). -1 indicates that the vehicle is landed, or that no time estimate available. + * @param land [s] Estimated time for vehicle to complete the LAND action from its current position. -1 indicates that the vehicle is landed, or that no time estimate available. + * @param mission_next_item [s] Estimated time for reaching/completing the currently active mission item. -1 means no time estimate available. + * @param mission_end [s] Estimated time for completing the current mission. -1 means no mission active and/or no estimate available. + * @param commanded_action [s] Estimated time for completing the current commanded action (i.e. Go To, Takeoff, Land, etc.). -1 means no action active and/or no estimate available. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_time_estimate_to_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int32_t safe_return, int32_t land, int32_t mission_next_item, int32_t mission_end, int32_t commanded_action) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN]; + _mav_put_int32_t(buf, 0, safe_return); + _mav_put_int32_t(buf, 4, land); + _mav_put_int32_t(buf, 8, mission_next_item); + _mav_put_int32_t(buf, 12, mission_end); + _mav_put_int32_t(buf, 16, commanded_action); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN); +#else + mavlink_time_estimate_to_target_t packet; + packet.safe_return = safe_return; + packet.land = land; + packet.mission_next_item = mission_next_item; + packet.mission_end = mission_end; + packet.commanded_action = commanded_action; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_MIN_LEN, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_MIN_LEN, MAVLINK_MSG_ID_TIME_ESTIMATE_TO_TARGET_LEN); +#endif +} + /** * @brief Pack a time_estimate_to_target message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_time_estimate_to_target_encode_chan(uint8_t s return mavlink_msg_time_estimate_to_target_pack_chan(system_id, component_id, chan, msg, time_estimate_to_target->safe_return, time_estimate_to_target->land, time_estimate_to_target->mission_next_item, time_estimate_to_target->mission_end, time_estimate_to_target->commanded_action); } +/** + * @brief Encode a time_estimate_to_target struct with provided status structure + * + * @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 time_estimate_to_target C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_time_estimate_to_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_time_estimate_to_target_t* time_estimate_to_target) +{ + return mavlink_msg_time_estimate_to_target_pack_status(system_id, component_id, _status, msg, time_estimate_to_target->safe_return, time_estimate_to_target->land, time_estimate_to_target->mission_next_item, time_estimate_to_target->mission_end, time_estimate_to_target->commanded_action); +} + /** * @brief Send a time_estimate_to_target message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_timesync.h b/common/mavlink_msg_timesync.h index 6f514ecd..0f8ec960 100644 --- a/common/mavlink_msg_timesync.h +++ b/common/mavlink_msg_timesync.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_timesync_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); } +/** + * @brief Pack a timesync 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 tc1 [ns] Time sync timestamp 1. Syncing: 0. Responding: Timestamp of responding component. + * @param ts1 [ns] Time sync timestamp 2. Timestamp of syncing component (mirrored in response). + * @param target_system Target system id. Request: 0 (broadcast) or id of specific system. Response must contain system id of the requesting component. + * @param target_component Target component id. Request: 0 (broadcast) or id of specific component. Response must contain component id of the requesting component. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_timesync_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int64_t tc1, int64_t ts1, uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TIMESYNC_LEN]; + _mav_put_int64_t(buf, 0, tc1); + _mav_put_int64_t(buf, 8, ts1); + _mav_put_uint8_t(buf, 16, target_system); + _mav_put_uint8_t(buf, 17, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TIMESYNC_LEN); +#else + mavlink_timesync_t packet; + packet.tc1 = tc1; + packet.ts1 = ts1; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TIMESYNC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TIMESYNC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN, MAVLINK_MSG_ID_TIMESYNC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TIMESYNC_MIN_LEN, MAVLINK_MSG_ID_TIMESYNC_LEN); +#endif +} + /** * @brief Pack a timesync message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_timesync_encode_chan(uint8_t system_id, uint8 return mavlink_msg_timesync_pack_chan(system_id, component_id, chan, msg, timesync->tc1, timesync->ts1, timesync->target_system, timesync->target_component); } +/** + * @brief Encode a timesync struct with provided status structure + * + * @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 timesync C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_timesync_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_timesync_t* timesync) +{ + return mavlink_msg_timesync_pack_status(system_id, component_id, _status, msg, timesync->tc1, timesync->ts1, timesync->target_system, timesync->target_component); +} + /** * @brief Send a timesync message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_trajectory_representation_bezier.h b/common/mavlink_msg_trajectory_representation_bezier.h index 8764da35..dafb2e20 100644 --- a/common/mavlink_msg_trajectory_representation_bezier.h +++ b/common/mavlink_msg_trajectory_representation_bezier.h @@ -101,6 +101,55 @@ static inline uint16_t mavlink_msg_trajectory_representation_bezier_pack(uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_CRC); } +/** + * @brief Pack a trajectory_representation_bezier 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param valid_points Number of valid control points (up-to 5 points are possible) + * @param pos_x [m] X-coordinate of bezier control points. Set to NaN if not being used + * @param pos_y [m] Y-coordinate of bezier control points. Set to NaN if not being used + * @param pos_z [m] Z-coordinate of bezier control points. Set to NaN if not being used + * @param delta [s] Bezier time horizon. Set to NaN if velocity/acceleration should not be incorporated + * @param pos_yaw [rad] Yaw. Set to NaN for unchanged + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_trajectory_representation_bezier_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t valid_points, const float *pos_x, const float *pos_y, const float *pos_z, const float *delta, const float *pos_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 108, valid_points); + _mav_put_float_array(buf, 8, pos_x, 5); + _mav_put_float_array(buf, 28, pos_y, 5); + _mav_put_float_array(buf, 48, pos_z, 5); + _mav_put_float_array(buf, 68, delta, 5); + _mav_put_float_array(buf, 88, pos_yaw, 5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN); +#else + mavlink_trajectory_representation_bezier_t packet; + packet.time_usec = time_usec; + packet.valid_points = valid_points; + mav_array_memcpy(packet.pos_x, pos_x, sizeof(float)*5); + mav_array_memcpy(packet.pos_y, pos_y, sizeof(float)*5); + mav_array_memcpy(packet.pos_z, pos_z, sizeof(float)*5); + mav_array_memcpy(packet.delta, delta, sizeof(float)*5); + mav_array_memcpy(packet.pos_yaw, pos_yaw, sizeof(float)*5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_BEZIER_LEN); +#endif +} + /** * @brief Pack a trajectory_representation_bezier message on a channel * @param system_id ID of this system @@ -173,6 +222,20 @@ static inline uint16_t mavlink_msg_trajectory_representation_bezier_encode_chan( return mavlink_msg_trajectory_representation_bezier_pack_chan(system_id, component_id, chan, msg, trajectory_representation_bezier->time_usec, trajectory_representation_bezier->valid_points, trajectory_representation_bezier->pos_x, trajectory_representation_bezier->pos_y, trajectory_representation_bezier->pos_z, trajectory_representation_bezier->delta, trajectory_representation_bezier->pos_yaw); } +/** + * @brief Encode a trajectory_representation_bezier struct with provided status structure + * + * @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 trajectory_representation_bezier C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_trajectory_representation_bezier_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_trajectory_representation_bezier_t* trajectory_representation_bezier) +{ + return mavlink_msg_trajectory_representation_bezier_pack_status(system_id, component_id, _status, msg, trajectory_representation_bezier->time_usec, trajectory_representation_bezier->valid_points, trajectory_representation_bezier->pos_x, trajectory_representation_bezier->pos_y, trajectory_representation_bezier->pos_z, trajectory_representation_bezier->delta, trajectory_representation_bezier->pos_yaw); +} + /** * @brief Send a trajectory_representation_bezier message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_trajectory_representation_waypoints.h b/common/mavlink_msg_trajectory_representation_waypoints.h index 45798ccd..4966e4c5 100644 --- a/common/mavlink_msg_trajectory_representation_waypoints.h +++ b/common/mavlink_msg_trajectory_representation_waypoints.h @@ -150,6 +150,76 @@ static inline uint16_t mavlink_msg_trajectory_representation_waypoints_pack(uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_CRC); } +/** + * @brief Pack a trajectory_representation_waypoints 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param valid_points Number of valid points (up-to 5 waypoints are possible) + * @param pos_x [m] X-coordinate of waypoint, set to NaN if not being used + * @param pos_y [m] Y-coordinate of waypoint, set to NaN if not being used + * @param pos_z [m] Z-coordinate of waypoint, set to NaN if not being used + * @param vel_x [m/s] X-velocity of waypoint, set to NaN if not being used + * @param vel_y [m/s] Y-velocity of waypoint, set to NaN if not being used + * @param vel_z [m/s] Z-velocity of waypoint, set to NaN if not being used + * @param acc_x [m/s/s] X-acceleration of waypoint, set to NaN if not being used + * @param acc_y [m/s/s] Y-acceleration of waypoint, set to NaN if not being used + * @param acc_z [m/s/s] Z-acceleration of waypoint, set to NaN if not being used + * @param pos_yaw [rad] Yaw angle, set to NaN if not being used + * @param vel_yaw [rad/s] Yaw rate, set to NaN if not being used + * @param command MAV_CMD command id of waypoint, set to UINT16_MAX if not being used. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_trajectory_representation_waypoints_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t valid_points, const float *pos_x, const float *pos_y, const float *pos_z, const float *vel_x, const float *vel_y, const float *vel_z, const float *acc_x, const float *acc_y, const float *acc_z, const float *pos_yaw, const float *vel_yaw, const uint16_t *command) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 238, valid_points); + _mav_put_float_array(buf, 8, pos_x, 5); + _mav_put_float_array(buf, 28, pos_y, 5); + _mav_put_float_array(buf, 48, pos_z, 5); + _mav_put_float_array(buf, 68, vel_x, 5); + _mav_put_float_array(buf, 88, vel_y, 5); + _mav_put_float_array(buf, 108, vel_z, 5); + _mav_put_float_array(buf, 128, acc_x, 5); + _mav_put_float_array(buf, 148, acc_y, 5); + _mav_put_float_array(buf, 168, acc_z, 5); + _mav_put_float_array(buf, 188, pos_yaw, 5); + _mav_put_float_array(buf, 208, vel_yaw, 5); + _mav_put_uint16_t_array(buf, 228, command, 5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN); +#else + mavlink_trajectory_representation_waypoints_t packet; + packet.time_usec = time_usec; + packet.valid_points = valid_points; + mav_array_memcpy(packet.pos_x, pos_x, sizeof(float)*5); + mav_array_memcpy(packet.pos_y, pos_y, sizeof(float)*5); + mav_array_memcpy(packet.pos_z, pos_z, sizeof(float)*5); + mav_array_memcpy(packet.vel_x, vel_x, sizeof(float)*5); + mav_array_memcpy(packet.vel_y, vel_y, sizeof(float)*5); + mav_array_memcpy(packet.vel_z, vel_z, sizeof(float)*5); + mav_array_memcpy(packet.acc_x, acc_x, sizeof(float)*5); + mav_array_memcpy(packet.acc_y, acc_y, sizeof(float)*5); + mav_array_memcpy(packet.acc_z, acc_z, sizeof(float)*5); + mav_array_memcpy(packet.pos_yaw, pos_yaw, sizeof(float)*5); + mav_array_memcpy(packet.vel_yaw, vel_yaw, sizeof(float)*5); + mav_array_memcpy(packet.command, command, sizeof(uint16_t)*5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_MIN_LEN, MAVLINK_MSG_ID_TRAJECTORY_REPRESENTATION_WAYPOINTS_LEN); +#endif +} + /** * @brief Pack a trajectory_representation_waypoints message on a channel * @param system_id ID of this system @@ -243,6 +313,20 @@ static inline uint16_t mavlink_msg_trajectory_representation_waypoints_encode_ch return mavlink_msg_trajectory_representation_waypoints_pack_chan(system_id, component_id, chan, msg, trajectory_representation_waypoints->time_usec, trajectory_representation_waypoints->valid_points, trajectory_representation_waypoints->pos_x, trajectory_representation_waypoints->pos_y, trajectory_representation_waypoints->pos_z, trajectory_representation_waypoints->vel_x, trajectory_representation_waypoints->vel_y, trajectory_representation_waypoints->vel_z, trajectory_representation_waypoints->acc_x, trajectory_representation_waypoints->acc_y, trajectory_representation_waypoints->acc_z, trajectory_representation_waypoints->pos_yaw, trajectory_representation_waypoints->vel_yaw, trajectory_representation_waypoints->command); } +/** + * @brief Encode a trajectory_representation_waypoints struct with provided status structure + * + * @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 trajectory_representation_waypoints C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_trajectory_representation_waypoints_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_trajectory_representation_waypoints_t* trajectory_representation_waypoints) +{ + return mavlink_msg_trajectory_representation_waypoints_pack_status(system_id, component_id, _status, msg, trajectory_representation_waypoints->time_usec, trajectory_representation_waypoints->valid_points, trajectory_representation_waypoints->pos_x, trajectory_representation_waypoints->pos_y, trajectory_representation_waypoints->pos_z, trajectory_representation_waypoints->vel_x, trajectory_representation_waypoints->vel_y, trajectory_representation_waypoints->vel_z, trajectory_representation_waypoints->acc_x, trajectory_representation_waypoints->acc_y, trajectory_representation_waypoints->acc_z, trajectory_representation_waypoints->pos_yaw, trajectory_representation_waypoints->vel_yaw, trajectory_representation_waypoints->command); +} + /** * @brief Send a trajectory_representation_waypoints message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_tunnel.h b/common/mavlink_msg_tunnel.h index 1541e134..59d9df87 100644 --- a/common/mavlink_msg_tunnel.h +++ b/common/mavlink_msg_tunnel.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_tunnel_pack(uint8_t system_id, uint8_t compon return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TUNNEL_MIN_LEN, MAVLINK_MSG_ID_TUNNEL_LEN, MAVLINK_MSG_ID_TUNNEL_CRC); } +/** + * @brief Pack a tunnel 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 target_system System ID (can be 0 for broadcast, but this is discouraged) + * @param target_component Component ID (can be 0 for broadcast, but this is discouraged) + * @param payload_type A code that identifies the content of the payload (0 for unknown, which is the default). If this code is less than 32768, it is a 'registered' payload type and the corresponding code should be added to the MAV_TUNNEL_PAYLOAD_TYPE enum. Software creators can register blocks of types as needed. Codes greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase. + * @param payload_length Length of the data transported in payload + * @param payload Variable length payload. The payload length is defined by payload_length. The entire content of this block is opaque unless you understand the encoding specified by payload_type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_tunnel_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t payload_type, uint8_t payload_length, const uint8_t *payload) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TUNNEL_LEN]; + _mav_put_uint16_t(buf, 0, payload_type); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, payload_length); + _mav_put_uint8_t_array(buf, 5, payload, 128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TUNNEL_LEN); +#else + mavlink_tunnel_t packet; + packet.payload_type = payload_type; + packet.target_system = target_system; + packet.target_component = target_component; + packet.payload_length = payload_length; + mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*128); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TUNNEL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TUNNEL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TUNNEL_MIN_LEN, MAVLINK_MSG_ID_TUNNEL_LEN, MAVLINK_MSG_ID_TUNNEL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TUNNEL_MIN_LEN, MAVLINK_MSG_ID_TUNNEL_LEN); +#endif +} + /** * @brief Pack a tunnel message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_tunnel_encode_chan(uint8_t system_id, uint8_t return mavlink_msg_tunnel_pack_chan(system_id, component_id, chan, msg, tunnel->target_system, tunnel->target_component, tunnel->payload_type, tunnel->payload_length, tunnel->payload); } +/** + * @brief Encode a tunnel struct with provided status structure + * + * @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 tunnel C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_tunnel_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_tunnel_t* tunnel) +{ + return mavlink_msg_tunnel_pack_status(system_id, component_id, _status, msg, tunnel->target_system, tunnel->target_component, tunnel->payload_type, tunnel->payload_length, tunnel->payload); +} + /** * @brief Send a tunnel message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_uavcan_node_info.h b/common/mavlink_msg_uavcan_node_info.h index 83a4be5a..c5b00a99 100644 --- a/common/mavlink_msg_uavcan_node_info.h +++ b/common/mavlink_msg_uavcan_node_info.h @@ -110,6 +110,61 @@ static inline uint16_t mavlink_msg_uavcan_node_info_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_CRC); } +/** + * @brief Pack a uavcan_node_info 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param uptime_sec [s] Time since the start-up of the node. + * @param name Node name string. For example, "sapog.px4.io". + * @param hw_version_major Hardware major version number. + * @param hw_version_minor Hardware minor version number. + * @param hw_unique_id Hardware unique 128-bit ID. + * @param sw_version_major Software major version number. + * @param sw_version_minor Software minor version number. + * @param sw_vcs_commit Version control system (VCS) revision identifier (e.g. git short commit hash). 0 if unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_uavcan_node_info_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t uptime_sec, const char *name, uint8_t hw_version_major, uint8_t hw_version_minor, const uint8_t *hw_unique_id, uint8_t sw_version_major, uint8_t sw_version_minor, uint32_t sw_vcs_commit) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, uptime_sec); + _mav_put_uint32_t(buf, 12, sw_vcs_commit); + _mav_put_uint8_t(buf, 96, hw_version_major); + _mav_put_uint8_t(buf, 97, hw_version_minor); + _mav_put_uint8_t(buf, 114, sw_version_major); + _mav_put_uint8_t(buf, 115, sw_version_minor); + _mav_put_char_array(buf, 16, name, 80); + _mav_put_uint8_t_array(buf, 98, hw_unique_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN); +#else + mavlink_uavcan_node_info_t packet; + packet.time_usec = time_usec; + packet.uptime_sec = uptime_sec; + packet.sw_vcs_commit = sw_vcs_commit; + packet.hw_version_major = hw_version_major; + packet.hw_version_minor = hw_version_minor; + packet.sw_version_major = sw_version_major; + packet.sw_version_minor = sw_version_minor; + mav_array_memcpy(packet.name, name, sizeof(char)*80); + mav_array_memcpy(packet.hw_unique_id, hw_unique_id, sizeof(uint8_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UAVCAN_NODE_INFO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_INFO_LEN); +#endif +} + /** * @brief Pack a uavcan_node_info message on a channel * @param system_id ID of this system @@ -188,6 +243,20 @@ static inline uint16_t mavlink_msg_uavcan_node_info_encode_chan(uint8_t system_i return mavlink_msg_uavcan_node_info_pack_chan(system_id, component_id, chan, msg, uavcan_node_info->time_usec, uavcan_node_info->uptime_sec, uavcan_node_info->name, uavcan_node_info->hw_version_major, uavcan_node_info->hw_version_minor, uavcan_node_info->hw_unique_id, uavcan_node_info->sw_version_major, uavcan_node_info->sw_version_minor, uavcan_node_info->sw_vcs_commit); } +/** + * @brief Encode a uavcan_node_info struct with provided status structure + * + * @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 uavcan_node_info C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_uavcan_node_info_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_uavcan_node_info_t* uavcan_node_info) +{ + return mavlink_msg_uavcan_node_info_pack_status(system_id, component_id, _status, msg, uavcan_node_info->time_usec, uavcan_node_info->uptime_sec, uavcan_node_info->name, uavcan_node_info->hw_version_major, uavcan_node_info->hw_version_minor, uavcan_node_info->hw_unique_id, uavcan_node_info->sw_version_major, uavcan_node_info->sw_version_minor, uavcan_node_info->sw_vcs_commit); +} + /** * @brief Send a uavcan_node_info message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_uavcan_node_status.h b/common/mavlink_msg_uavcan_node_status.h index 50e3af6e..4be9fc00 100644 --- a/common/mavlink_msg_uavcan_node_status.h +++ b/common/mavlink_msg_uavcan_node_status.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_uavcan_node_status_pack(uint8_t system_id, ui return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC); } +/** + * @brief Pack a uavcan_node_status 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param uptime_sec [s] Time since the start-up of the node. + * @param health Generalized node health status. + * @param mode Generalized operating mode. + * @param sub_mode Not used currently. + * @param vendor_specific_status_code Vendor-specific status information. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_uavcan_node_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint32_t uptime_sec, uint8_t health, uint8_t mode, uint8_t sub_mode, uint16_t vendor_specific_status_code) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, uptime_sec); + _mav_put_uint16_t(buf, 12, vendor_specific_status_code); + _mav_put_uint8_t(buf, 14, health); + _mav_put_uint8_t(buf, 15, mode); + _mav_put_uint8_t(buf, 16, sub_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN); +#else + mavlink_uavcan_node_status_t packet; + packet.time_usec = time_usec; + packet.uptime_sec = uptime_sec; + packet.vendor_specific_status_code = vendor_specific_status_code; + packet.health = health; + packet.mode = mode; + packet.sub_mode = sub_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UAVCAN_NODE_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN); +#endif +} + /** * @brief Pack a uavcan_node_status message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_uavcan_node_status_encode_chan(uint8_t system return mavlink_msg_uavcan_node_status_pack_chan(system_id, component_id, chan, msg, uavcan_node_status->time_usec, uavcan_node_status->uptime_sec, uavcan_node_status->health, uavcan_node_status->mode, uavcan_node_status->sub_mode, uavcan_node_status->vendor_specific_status_code); } +/** + * @brief Encode a uavcan_node_status struct with provided status structure + * + * @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 uavcan_node_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_uavcan_node_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_uavcan_node_status_t* uavcan_node_status) +{ + return mavlink_msg_uavcan_node_status_pack_status(system_id, component_id, _status, msg, uavcan_node_status->time_usec, uavcan_node_status->uptime_sec, uavcan_node_status->health, uavcan_node_status->mode, uavcan_node_status->sub_mode, uavcan_node_status->vendor_specific_status_code); +} + /** * @brief Send a uavcan_node_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_utm_global_position.h b/common/mavlink_msg_utm_global_position.h index 587f7bb6..309ba5a1 100644 --- a/common/mavlink_msg_utm_global_position.h +++ b/common/mavlink_msg_utm_global_position.h @@ -163,6 +163,88 @@ static inline uint16_t mavlink_msg_utm_global_position_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC); } +/** + * @brief Pack a utm_global_position 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 time [us] Time of applicability of position (microseconds since UNIX epoch). + * @param uas_id Unique UAS ID. + * @param lat [degE7] Latitude (WGS84) + * @param lon [degE7] Longitude (WGS84) + * @param alt [mm] Altitude (WGS84) + * @param relative_alt [mm] Altitude above ground + * @param vx [cm/s] Ground X speed (latitude, positive north) + * @param vy [cm/s] Ground Y speed (longitude, positive east) + * @param vz [cm/s] Ground Z speed (altitude, positive down) + * @param h_acc [mm] Horizontal position uncertainty (standard deviation) + * @param v_acc [mm] Altitude uncertainty (standard deviation) + * @param vel_acc [cm/s] Speed uncertainty (standard deviation) + * @param next_lat [degE7] Next waypoint, latitude (WGS84) + * @param next_lon [degE7] Next waypoint, longitude (WGS84) + * @param next_alt [mm] Next waypoint, altitude (WGS84) + * @param update_rate [cs] Time until next update. Set to 0 if unknown or in data driven mode. + * @param flight_state Flight state + * @param flags Bitwise OR combination of the data available flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_utm_global_position_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time, const uint8_t *uas_id, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t h_acc, uint16_t v_acc, uint16_t vel_acc, int32_t next_lat, int32_t next_lon, int32_t next_alt, uint16_t update_rate, uint8_t flight_state, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN]; + _mav_put_uint64_t(buf, 0, time); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_int32_t(buf, 16, alt); + _mav_put_int32_t(buf, 20, relative_alt); + _mav_put_int32_t(buf, 24, next_lat); + _mav_put_int32_t(buf, 28, next_lon); + _mav_put_int32_t(buf, 32, next_alt); + _mav_put_int16_t(buf, 36, vx); + _mav_put_int16_t(buf, 38, vy); + _mav_put_int16_t(buf, 40, vz); + _mav_put_uint16_t(buf, 42, h_acc); + _mav_put_uint16_t(buf, 44, v_acc); + _mav_put_uint16_t(buf, 46, vel_acc); + _mav_put_uint16_t(buf, 48, update_rate); + _mav_put_uint8_t(buf, 68, flight_state); + _mav_put_uint8_t(buf, 69, flags); + _mav_put_uint8_t_array(buf, 50, uas_id, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN); +#else + mavlink_utm_global_position_t packet; + packet.time = time; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.relative_alt = relative_alt; + packet.next_lat = next_lat; + packet.next_lon = next_lon; + packet.next_alt = next_alt; + packet.vx = vx; + packet.vy = vy; + packet.vz = vz; + packet.h_acc = h_acc; + packet.v_acc = v_acc; + packet.vel_acc = vel_acc; + packet.update_rate = update_rate; + packet.flight_state = flight_state; + packet.flags = flags; + mav_array_memcpy(packet.uas_id, uas_id, sizeof(uint8_t)*18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UTM_GLOBAL_POSITION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN); +#endif +} + /** * @brief Pack a utm_global_position message on a channel * @param system_id ID of this system @@ -268,6 +350,20 @@ static inline uint16_t mavlink_msg_utm_global_position_encode_chan(uint8_t syste return mavlink_msg_utm_global_position_pack_chan(system_id, component_id, chan, msg, utm_global_position->time, utm_global_position->uas_id, utm_global_position->lat, utm_global_position->lon, utm_global_position->alt, utm_global_position->relative_alt, utm_global_position->vx, utm_global_position->vy, utm_global_position->vz, utm_global_position->h_acc, utm_global_position->v_acc, utm_global_position->vel_acc, utm_global_position->next_lat, utm_global_position->next_lon, utm_global_position->next_alt, utm_global_position->update_rate, utm_global_position->flight_state, utm_global_position->flags); } +/** + * @brief Encode a utm_global_position struct with provided status structure + * + * @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 utm_global_position C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_utm_global_position_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_utm_global_position_t* utm_global_position) +{ + return mavlink_msg_utm_global_position_pack_status(system_id, component_id, _status, msg, utm_global_position->time, utm_global_position->uas_id, utm_global_position->lat, utm_global_position->lon, utm_global_position->alt, utm_global_position->relative_alt, utm_global_position->vx, utm_global_position->vy, utm_global_position->vz, utm_global_position->h_acc, utm_global_position->v_acc, utm_global_position->vel_acc, utm_global_position->next_lat, utm_global_position->next_lon, utm_global_position->next_alt, utm_global_position->update_rate, utm_global_position->flight_state, utm_global_position->flags); +} + /** * @brief Send a utm_global_position message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_v2_extension.h b/common/mavlink_msg_v2_extension.h index 93c652e6..7e91a26d 100644 --- a/common/mavlink_msg_v2_extension.h +++ b/common/mavlink_msg_v2_extension.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_v2_extension_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC); } +/** + * @brief Pack a v2_extension 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 target_network Network ID (0 for broadcast) + * @param target_system System ID (0 for broadcast) + * @param target_component Component ID (0 for broadcast) + * @param message_type A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase. + * @param payload Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_v2_extension_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_network, uint8_t target_system, uint8_t target_component, uint16_t message_type, const uint8_t *payload) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN]; + _mav_put_uint16_t(buf, 0, message_type); + _mav_put_uint8_t(buf, 2, target_network); + _mav_put_uint8_t(buf, 3, target_system); + _mav_put_uint8_t(buf, 4, target_component); + _mav_put_uint8_t_array(buf, 5, payload, 249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN); +#else + mavlink_v2_extension_t packet; + packet.message_type = message_type; + packet.target_network = target_network; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_V2_EXTENSION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN); +#endif +} + /** * @brief Pack a v2_extension message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_v2_extension_encode_chan(uint8_t system_id, u return mavlink_msg_v2_extension_pack_chan(system_id, component_id, chan, msg, v2_extension->target_network, v2_extension->target_system, v2_extension->target_component, v2_extension->message_type, v2_extension->payload); } +/** + * @brief Encode a v2_extension struct with provided status structure + * + * @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 v2_extension C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_v2_extension_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_v2_extension_t* v2_extension) +{ + return mavlink_msg_v2_extension_pack_status(system_id, component_id, _status, msg, v2_extension->target_network, v2_extension->target_system, v2_extension->target_component, v2_extension->message_type, v2_extension->payload); +} + /** * @brief Send a v2_extension message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_vfr_hud.h b/common/mavlink_msg_vfr_hud.h index 517ec8c5..b4438744 100644 --- a/common/mavlink_msg_vfr_hud.h +++ b/common/mavlink_msg_vfr_hud.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t compo return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC); } +/** + * @brief Pack a vfr_hud 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 airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed. + * @param groundspeed [m/s] Current ground speed. + * @param heading [deg] Current heading in compass units (0-360, 0=north). + * @param throttle [%] Current throttle setting (0 to 100). + * @param alt [m] Current altitude (MSL). + * @param climb [m/s] Current climb rate. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vfr_hud_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VFR_HUD_LEN]; + _mav_put_float(buf, 0, airspeed); + _mav_put_float(buf, 4, groundspeed); + _mav_put_float(buf, 8, alt); + _mav_put_float(buf, 12, climb); + _mav_put_int16_t(buf, 16, heading); + _mav_put_uint16_t(buf, 18, throttle); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN); +#else + mavlink_vfr_hud_t packet; + packet.airspeed = airspeed; + packet.groundspeed = groundspeed; + packet.alt = alt; + packet.climb = climb; + packet.heading = heading; + packet.throttle = throttle; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VFR_HUD; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN); +#endif +} + /** * @brief Pack a vfr_hud message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_vfr_hud_encode_chan(uint8_t system_id, uint8_ return mavlink_msg_vfr_hud_pack_chan(system_id, component_id, chan, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb); } +/** + * @brief Encode a vfr_hud struct with provided status structure + * + * @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 vfr_hud C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vfr_hud_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud) +{ + return mavlink_msg_vfr_hud_pack_status(system_id, component_id, _status, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb); +} + /** * @brief Send a vfr_hud message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_vibration.h b/common/mavlink_msg_vibration.h index 1d029260..b9aa15cc 100644 --- a/common/mavlink_msg_vibration.h +++ b/common/mavlink_msg_vibration.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_vibration_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VIBRATION_MIN_LEN, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); } +/** + * @brief Pack a vibration 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param vibration_x Vibration levels on X-axis + * @param vibration_y Vibration levels on Y-axis + * @param vibration_z Vibration levels on Z-axis + * @param clipping_0 first accelerometer clipping count + * @param clipping_1 second accelerometer clipping count + * @param clipping_2 third accelerometer clipping count + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vibration_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float vibration_x, float vibration_y, float vibration_z, uint32_t clipping_0, uint32_t clipping_1, uint32_t clipping_2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VIBRATION_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, vibration_x); + _mav_put_float(buf, 12, vibration_y); + _mav_put_float(buf, 16, vibration_z); + _mav_put_uint32_t(buf, 20, clipping_0); + _mav_put_uint32_t(buf, 24, clipping_1); + _mav_put_uint32_t(buf, 28, clipping_2); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VIBRATION_LEN); +#else + mavlink_vibration_t packet; + packet.time_usec = time_usec; + packet.vibration_x = vibration_x; + packet.vibration_y = vibration_y; + packet.vibration_z = vibration_z; + packet.clipping_0 = clipping_0; + packet.clipping_1 = clipping_1; + packet.clipping_2 = clipping_2; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VIBRATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VIBRATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIBRATION_MIN_LEN, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIBRATION_MIN_LEN, MAVLINK_MSG_ID_VIBRATION_LEN); +#endif +} + /** * @brief Pack a vibration message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_vibration_encode_chan(uint8_t system_id, uint return mavlink_msg_vibration_pack_chan(system_id, component_id, chan, msg, vibration->time_usec, vibration->vibration_x, vibration->vibration_y, vibration->vibration_z, vibration->clipping_0, vibration->clipping_1, vibration->clipping_2); } +/** + * @brief Encode a vibration struct with provided status structure + * + * @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 vibration C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vibration_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vibration_t* vibration) +{ + return mavlink_msg_vibration_pack_status(system_id, component_id, _status, msg, vibration->time_usec, vibration->vibration_x, vibration->vibration_y, vibration->vibration_z, vibration->clipping_0, vibration->clipping_1, vibration->clipping_2); +} + /** * @brief Send a vibration message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_vicon_position_estimate.h b/common/mavlink_msg_vicon_position_estimate.h index 8dc89fcf..00e51933 100644 --- a/common/mavlink_msg_vicon_position_estimate.h +++ b/common/mavlink_msg_vicon_position_estimate.h @@ -103,6 +103,58 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_CRC); } +/** + * @brief Pack a vicon_position_estimate 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 usec [us] Timestamp (UNIX time or time since system boot) + * @param x [m] Global X position + * @param y [m] Global Y position + * @param z [m] Global Z position + * @param roll [rad] Roll angle + * @param pitch [rad] Pitch angle + * @param yaw [rad] Yaw angle + * @param covariance Row-major representation of 6x6 pose cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vicon_position_estimate_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw, const float *covariance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN]; + _mav_put_uint64_t(buf, 0, usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 20, roll); + _mav_put_float(buf, 24, pitch); + _mav_put_float(buf, 28, yaw); + _mav_put_float_array(buf, 32, covariance, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN); +#else + mavlink_vicon_position_estimate_t packet; + packet.usec = usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE_LEN); +#endif +} + /** * @brief Pack a vicon_position_estimate message on a channel * @param system_id ID of this system @@ -178,6 +230,20 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_encode_chan(uint8_t s return mavlink_msg_vicon_position_estimate_pack_chan(system_id, component_id, chan, msg, vicon_position_estimate->usec, vicon_position_estimate->x, vicon_position_estimate->y, vicon_position_estimate->z, vicon_position_estimate->roll, vicon_position_estimate->pitch, vicon_position_estimate->yaw, vicon_position_estimate->covariance); } +/** + * @brief Encode a vicon_position_estimate struct with provided status structure + * + * @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 vicon_position_estimate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vicon_position_estimate_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vicon_position_estimate_t* vicon_position_estimate) +{ + return mavlink_msg_vicon_position_estimate_pack_status(system_id, component_id, _status, msg, vicon_position_estimate->usec, vicon_position_estimate->x, vicon_position_estimate->y, vicon_position_estimate->z, vicon_position_estimate->roll, vicon_position_estimate->pitch, vicon_position_estimate->yaw, vicon_position_estimate->covariance); +} + /** * @brief Send a vicon_position_estimate message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_video_stream_information.h b/common/mavlink_msg_video_stream_information.h index 2e9ea7f4..91d6ab2b 100644 --- a/common/mavlink_msg_video_stream_information.h +++ b/common/mavlink_msg_video_stream_information.h @@ -128,6 +128,70 @@ static inline uint16_t mavlink_msg_video_stream_information_pack(uint8_t system_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_CRC); } +/** + * @brief Pack a video_stream_information 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 stream_id Video Stream ID (1 for first, 2 for second, etc.) + * @param count Number of streams available. + * @param type Type of stream. + * @param flags Bitmap of stream status flags. + * @param framerate [Hz] Frame rate. + * @param resolution_h [pix] Horizontal resolution. + * @param resolution_v [pix] Vertical resolution. + * @param bitrate [bits/s] Bit rate. + * @param rotation [deg] Video image rotation clockwise. + * @param hfov [deg] Horizontal Field of view. + * @param name Stream name. + * @param uri Video stream URI (TCP or RTSP URI ground station should connect to) or port number (UDP port ground station should listen to). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_video_stream_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t stream_id, uint8_t count, uint8_t type, uint16_t flags, float framerate, uint16_t resolution_h, uint16_t resolution_v, uint32_t bitrate, uint16_t rotation, uint16_t hfov, const char *name, const char *uri) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN]; + _mav_put_float(buf, 0, framerate); + _mav_put_uint32_t(buf, 4, bitrate); + _mav_put_uint16_t(buf, 8, flags); + _mav_put_uint16_t(buf, 10, resolution_h); + _mav_put_uint16_t(buf, 12, resolution_v); + _mav_put_uint16_t(buf, 14, rotation); + _mav_put_uint16_t(buf, 16, hfov); + _mav_put_uint8_t(buf, 18, stream_id); + _mav_put_uint8_t(buf, 19, count); + _mav_put_uint8_t(buf, 20, type); + _mav_put_char_array(buf, 21, name, 32); + _mav_put_char_array(buf, 53, uri, 160); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN); +#else + mavlink_video_stream_information_t packet; + packet.framerate = framerate; + packet.bitrate = bitrate; + packet.flags = flags; + packet.resolution_h = resolution_h; + packet.resolution_v = resolution_v; + packet.rotation = rotation; + packet.hfov = hfov; + packet.stream_id = stream_id; + packet.count = count; + packet.type = type; + mav_array_memcpy(packet.name, name, sizeof(char)*32); + mav_array_memcpy(packet.uri, uri, sizeof(char)*160); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_INFORMATION_LEN); +#endif +} + /** * @brief Pack a video_stream_information message on a channel * @param system_id ID of this system @@ -215,6 +279,20 @@ static inline uint16_t mavlink_msg_video_stream_information_encode_chan(uint8_t return mavlink_msg_video_stream_information_pack_chan(system_id, component_id, chan, msg, video_stream_information->stream_id, video_stream_information->count, video_stream_information->type, video_stream_information->flags, video_stream_information->framerate, video_stream_information->resolution_h, video_stream_information->resolution_v, video_stream_information->bitrate, video_stream_information->rotation, video_stream_information->hfov, video_stream_information->name, video_stream_information->uri); } +/** + * @brief Encode a video_stream_information struct with provided status structure + * + * @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 video_stream_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_video_stream_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_video_stream_information_t* video_stream_information) +{ + return mavlink_msg_video_stream_information_pack_status(system_id, component_id, _status, msg, video_stream_information->stream_id, video_stream_information->count, video_stream_information->type, video_stream_information->flags, video_stream_information->framerate, video_stream_information->resolution_h, video_stream_information->resolution_v, video_stream_information->bitrate, video_stream_information->rotation, video_stream_information->hfov, video_stream_information->name, video_stream_information->uri); +} + /** * @brief Send a video_stream_information message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_video_stream_status.h b/common/mavlink_msg_video_stream_status.h index 8058b05f..57a71bf3 100644 --- a/common/mavlink_msg_video_stream_status.h +++ b/common/mavlink_msg_video_stream_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_video_stream_status_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_CRC); } +/** + * @brief Pack a video_stream_status 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 stream_id Video Stream ID (1 for first, 2 for second, etc.) + * @param flags Bitmap of stream status flags + * @param framerate [Hz] Frame rate + * @param resolution_h [pix] Horizontal resolution + * @param resolution_v [pix] Vertical resolution + * @param bitrate [bits/s] Bit rate + * @param rotation [deg] Video image rotation clockwise + * @param hfov [deg] Horizontal Field of view + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_video_stream_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t stream_id, uint16_t flags, float framerate, uint16_t resolution_h, uint16_t resolution_v, uint32_t bitrate, uint16_t rotation, uint16_t hfov) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN]; + _mav_put_float(buf, 0, framerate); + _mav_put_uint32_t(buf, 4, bitrate); + _mav_put_uint16_t(buf, 8, flags); + _mav_put_uint16_t(buf, 10, resolution_h); + _mav_put_uint16_t(buf, 12, resolution_v); + _mav_put_uint16_t(buf, 14, rotation); + _mav_put_uint16_t(buf, 16, hfov); + _mav_put_uint8_t(buf, 18, stream_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN); +#else + mavlink_video_stream_status_t packet; + packet.framerate = framerate; + packet.bitrate = bitrate; + packet.flags = flags; + packet.resolution_h = resolution_h; + packet.resolution_v = resolution_v; + packet.rotation = rotation; + packet.hfov = hfov; + packet.stream_id = stream_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VIDEO_STREAM_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_MIN_LEN, MAVLINK_MSG_ID_VIDEO_STREAM_STATUS_LEN); +#endif +} + /** * @brief Pack a video_stream_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_video_stream_status_encode_chan(uint8_t syste return mavlink_msg_video_stream_status_pack_chan(system_id, component_id, chan, msg, video_stream_status->stream_id, video_stream_status->flags, video_stream_status->framerate, video_stream_status->resolution_h, video_stream_status->resolution_v, video_stream_status->bitrate, video_stream_status->rotation, video_stream_status->hfov); } +/** + * @brief Encode a video_stream_status struct with provided status structure + * + * @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 video_stream_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_video_stream_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_video_stream_status_t* video_stream_status) +{ + return mavlink_msg_video_stream_status_pack_status(system_id, component_id, _status, msg, video_stream_status->stream_id, video_stream_status->flags, video_stream_status->framerate, video_stream_status->resolution_h, video_stream_status->resolution_v, video_stream_status->bitrate, video_stream_status->rotation, video_stream_status->hfov); +} + /** * @brief Send a video_stream_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_vision_position_estimate.h b/common/mavlink_msg_vision_position_estimate.h index e0ebff7d..06656249 100644 --- a/common/mavlink_msg_vision_position_estimate.h +++ b/common/mavlink_msg_vision_position_estimate.h @@ -109,6 +109,61 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack(uint8_t system_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_CRC); } +/** + * @brief Pack a vision_position_estimate 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 usec [us] Timestamp (UNIX time or time since system boot) + * @param x [m] Local X position + * @param y [m] Local Y position + * @param z [m] Local Z position + * @param roll [rad] Roll angle + * @param pitch [rad] Pitch angle + * @param yaw [rad] Yaw angle + * @param covariance Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array. + * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vision_position_estimate_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t usec, float x, float y, float z, float roll, float pitch, float yaw, const float *covariance, uint8_t reset_counter) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN]; + _mav_put_uint64_t(buf, 0, usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 20, roll); + _mav_put_float(buf, 24, pitch); + _mav_put_float(buf, 28, yaw); + _mav_put_uint8_t(buf, 116, reset_counter); + _mav_put_float_array(buf, 32, covariance, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN); +#else + mavlink_vision_position_estimate_t packet; + packet.usec = usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.reset_counter = reset_counter; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE_LEN); +#endif +} + /** * @brief Pack a vision_position_estimate message on a channel * @param system_id ID of this system @@ -187,6 +242,20 @@ static inline uint16_t mavlink_msg_vision_position_estimate_encode_chan(uint8_t return mavlink_msg_vision_position_estimate_pack_chan(system_id, component_id, chan, msg, vision_position_estimate->usec, vision_position_estimate->x, vision_position_estimate->y, vision_position_estimate->z, vision_position_estimate->roll, vision_position_estimate->pitch, vision_position_estimate->yaw, vision_position_estimate->covariance, vision_position_estimate->reset_counter); } +/** + * @brief Encode a vision_position_estimate struct with provided status structure + * + * @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 vision_position_estimate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vision_position_estimate_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vision_position_estimate_t* vision_position_estimate) +{ + return mavlink_msg_vision_position_estimate_pack_status(system_id, component_id, _status, msg, vision_position_estimate->usec, vision_position_estimate->x, vision_position_estimate->y, vision_position_estimate->z, vision_position_estimate->roll, vision_position_estimate->pitch, vision_position_estimate->yaw, vision_position_estimate->covariance, vision_position_estimate->reset_counter); +} + /** * @brief Send a vision_position_estimate message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_vision_speed_estimate.h b/common/mavlink_msg_vision_speed_estimate.h index c12206a2..004717e0 100644 --- a/common/mavlink_msg_vision_speed_estimate.h +++ b/common/mavlink_msg_vision_speed_estimate.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_CRC); } +/** + * @brief Pack a vision_speed_estimate 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 usec [us] Timestamp (UNIX time or time since system boot) + * @param x [m/s] Global X speed + * @param y [m/s] Global Y speed + * @param z [m/s] Global Z speed + * @param covariance Row-major representation of 3x3 linear velocity covariance matrix (states: vx, vy, vz; 1st three entries - 1st row, etc.). If unknown, assign NaN value to first element in the array. + * @param reset_counter Estimate reset counter. This should be incremented when the estimate resets in any of the dimensions (position, velocity, attitude, angular speed). This is designed to be used when e.g an external SLAM system detects a loop-closure and the estimate jumps. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_vision_speed_estimate_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t usec, float x, float y, float z, const float *covariance, uint8_t reset_counter) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN]; + _mav_put_uint64_t(buf, 0, usec); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_uint8_t(buf, 56, reset_counter); + _mav_put_float_array(buf, 20, covariance, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN); +#else + mavlink_vision_speed_estimate_t packet; + packet.usec = usec; + packet.x = x; + packet.y = y; + packet.z = z; + packet.reset_counter = reset_counter; + mav_array_memcpy(packet.covariance, covariance, sizeof(float)*9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_MIN_LEN, MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE_LEN); +#endif +} + /** * @brief Pack a vision_speed_estimate message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_encode_chan(uint8_t sys return mavlink_msg_vision_speed_estimate_pack_chan(system_id, component_id, chan, msg, vision_speed_estimate->usec, vision_speed_estimate->x, vision_speed_estimate->y, vision_speed_estimate->z, vision_speed_estimate->covariance, vision_speed_estimate->reset_counter); } +/** + * @brief Encode a vision_speed_estimate struct with provided status structure + * + * @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 vision_speed_estimate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_vision_speed_estimate_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vision_speed_estimate_t* vision_speed_estimate) +{ + return mavlink_msg_vision_speed_estimate_pack_status(system_id, component_id, _status, msg, vision_speed_estimate->usec, vision_speed_estimate->x, vision_speed_estimate->y, vision_speed_estimate->z, vision_speed_estimate->covariance, vision_speed_estimate->reset_counter); +} + /** * @brief Send a vision_speed_estimate message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_wheel_distance.h b/common/mavlink_msg_wheel_distance.h index 6a177c88..4a5820f7 100644 --- a/common/mavlink_msg_wheel_distance.h +++ b/common/mavlink_msg_wheel_distance.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_wheel_distance_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC); } +/** + * @brief Pack a wheel_distance 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 time_usec [us] Timestamp (synced to UNIX time or since system boot). + * @param count Number of wheels reported. + * @param distance [m] Distance reported by individual wheel encoders. Forward rotations increase values, reverse rotations decrease them. Not all wheels will necessarily have wheel encoders; the mapping of encoders to wheel positions must be agreed/understood by the endpoints. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wheel_distance_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, uint8_t count, const double *distance) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint8_t(buf, 136, count); + _mav_put_double_array(buf, 8, distance, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN); +#else + mavlink_wheel_distance_t packet; + packet.time_usec = time_usec; + packet.count = count; + mav_array_memcpy(packet.distance, distance, sizeof(double)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WHEEL_DISTANCE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WHEEL_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_WHEEL_DISTANCE_LEN); +#endif +} + /** * @brief Pack a wheel_distance message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_wheel_distance_encode_chan(uint8_t system_id, return mavlink_msg_wheel_distance_pack_chan(system_id, component_id, chan, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance); } +/** + * @brief Encode a wheel_distance struct with provided status structure + * + * @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 wheel_distance C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wheel_distance_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wheel_distance_t* wheel_distance) +{ + return mavlink_msg_wheel_distance_pack_status(system_id, component_id, _status, msg, wheel_distance->time_usec, wheel_distance->count, wheel_distance->distance); +} + /** * @brief Send a wheel_distance message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_wifi_config_ap.h b/common/mavlink_msg_wifi_config_ap.h index 743452d0..37daa7c5 100644 --- a/common/mavlink_msg_wifi_config_ap.h +++ b/common/mavlink_msg_wifi_config_ap.h @@ -80,6 +80,46 @@ static inline uint16_t mavlink_msg_wifi_config_ap_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WIFI_CONFIG_AP_MIN_LEN, MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN, MAVLINK_MSG_ID_WIFI_CONFIG_AP_CRC); } +/** + * @brief Pack a wifi_config_ap 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 ssid Name of Wi-Fi network (SSID). Blank to leave it unchanged when setting. Current SSID when sent back as a response. + * @param password Password. Blank for an open AP. MD5 hash when message is sent back as a response. + * @param mode WiFi Mode. + * @param response Message acceptance response (sent back to GS). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wifi_config_ap_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *ssid, const char *password, int8_t mode, int8_t response) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN]; + _mav_put_int8_t(buf, 96, mode); + _mav_put_int8_t(buf, 97, response); + _mav_put_char_array(buf, 0, ssid, 32); + _mav_put_char_array(buf, 32, password, 64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN); +#else + mavlink_wifi_config_ap_t packet; + packet.mode = mode; + packet.response = response; + mav_array_memcpy(packet.ssid, ssid, sizeof(char)*32); + mav_array_memcpy(packet.password, password, sizeof(char)*64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIFI_CONFIG_AP; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIFI_CONFIG_AP_MIN_LEN, MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN, MAVLINK_MSG_ID_WIFI_CONFIG_AP_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIFI_CONFIG_AP_MIN_LEN, MAVLINK_MSG_ID_WIFI_CONFIG_AP_LEN); +#endif +} + /** * @brief Pack a wifi_config_ap message on a channel * @param system_id ID of this system @@ -143,6 +183,20 @@ static inline uint16_t mavlink_msg_wifi_config_ap_encode_chan(uint8_t system_id, return mavlink_msg_wifi_config_ap_pack_chan(system_id, component_id, chan, msg, wifi_config_ap->ssid, wifi_config_ap->password, wifi_config_ap->mode, wifi_config_ap->response); } +/** + * @brief Encode a wifi_config_ap struct with provided status structure + * + * @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 wifi_config_ap C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wifi_config_ap_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wifi_config_ap_t* wifi_config_ap) +{ + return mavlink_msg_wifi_config_ap_pack_status(system_id, component_id, _status, msg, wifi_config_ap->ssid, wifi_config_ap->password, wifi_config_ap->mode, wifi_config_ap->response); +} + /** * @brief Send a wifi_config_ap message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_winch_status.h b/common/mavlink_msg_winch_status.h index d164007c..34f73d96 100644 --- a/common/mavlink_msg_winch_status.h +++ b/common/mavlink_msg_winch_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_winch_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC); } +/** + * @brief Pack a winch_status 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 time_usec [us] Timestamp (synced to UNIX time or since system boot). + * @param line_length [m] Length of line released. NaN if unknown + * @param speed [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown + * @param tension [kg] Tension on the line. NaN if unknown + * @param voltage [V] Voltage of the battery supplying the winch. NaN if unknown + * @param current [A] Current draw from the winch. NaN if unknown + * @param temperature [degC] Temperature of the motor. INT16_MAX if unknown + * @param status Status flags + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_winch_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float line_length, float speed, float tension, float voltage, float current, int16_t temperature, uint32_t status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WINCH_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, line_length); + _mav_put_float(buf, 12, speed); + _mav_put_float(buf, 16, tension); + _mav_put_float(buf, 20, voltage); + _mav_put_float(buf, 24, current); + _mav_put_uint32_t(buf, 28, status); + _mav_put_int16_t(buf, 32, temperature); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WINCH_STATUS_LEN); +#else + mavlink_winch_status_t packet; + packet.time_usec = time_usec; + packet.line_length = line_length; + packet.speed = speed; + packet.tension = tension; + packet.voltage = voltage; + packet.current = current; + packet.status = status; + packet.temperature = temperature; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WINCH_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WINCH_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN); +#endif +} + /** * @brief Pack a winch_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_winch_status_encode_chan(uint8_t system_id, u return mavlink_msg_winch_status_pack_chan(system_id, component_id, chan, msg, winch_status->time_usec, winch_status->line_length, winch_status->speed, winch_status->tension, winch_status->voltage, winch_status->current, winch_status->temperature, winch_status->status); } +/** + * @brief Encode a winch_status struct with provided status structure + * + * @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 winch_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_winch_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_winch_status_t* winch_status) +{ + return mavlink_msg_winch_status_pack_status(system_id, component_id, _status, msg, winch_status->time_usec, winch_status->line_length, winch_status->speed, winch_status->tension, winch_status->voltage, winch_status->current, winch_status->temperature, winch_status->status); +} + /** * @brief Send a winch_status message * @param chan MAVLink channel to send the message diff --git a/common/mavlink_msg_wind_cov.h b/common/mavlink_msg_wind_cov.h index 27c0d18e..d2a11140 100644 --- a/common/mavlink_msg_wind_cov.h +++ b/common/mavlink_msg_wind_cov.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_wind_cov_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WIND_COV_MIN_LEN, MAVLINK_MSG_ID_WIND_COV_LEN, MAVLINK_MSG_ID_WIND_COV_CRC); } +/** + * @brief Pack a wind_cov 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param wind_x [m/s] Wind in North (NED) direction (NAN if unknown) + * @param wind_y [m/s] Wind in East (NED) direction (NAN if unknown) + * @param wind_z [m/s] Wind in down (NED) direction (NAN if unknown) + * @param var_horiz [m/s] Variability of wind in XY, 1-STD estimated from a 1 Hz lowpassed wind estimate (NAN if unknown) + * @param var_vert [m/s] Variability of wind in Z, 1-STD estimated from a 1 Hz lowpassed wind estimate (NAN if unknown) + * @param wind_alt [m] Altitude (MSL) that this measurement was taken at (NAN if unknown) + * @param horiz_accuracy [m/s] Horizontal speed 1-STD accuracy (0 if unknown) + * @param vert_accuracy [m/s] Vertical speed 1-STD accuracy (0 if unknown) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wind_cov_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float wind_x, float wind_y, float wind_z, float var_horiz, float var_vert, float wind_alt, float horiz_accuracy, float vert_accuracy) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WIND_COV_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, wind_x); + _mav_put_float(buf, 12, wind_y); + _mav_put_float(buf, 16, wind_z); + _mav_put_float(buf, 20, var_horiz); + _mav_put_float(buf, 24, var_vert); + _mav_put_float(buf, 28, wind_alt); + _mav_put_float(buf, 32, horiz_accuracy); + _mav_put_float(buf, 36, vert_accuracy); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIND_COV_LEN); +#else + mavlink_wind_cov_t packet; + packet.time_usec = time_usec; + packet.wind_x = wind_x; + packet.wind_y = wind_y; + packet.wind_z = wind_z; + packet.var_horiz = var_horiz; + packet.var_vert = var_vert; + packet.wind_alt = wind_alt; + packet.horiz_accuracy = horiz_accuracy; + packet.vert_accuracy = vert_accuracy; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIND_COV_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIND_COV; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIND_COV_MIN_LEN, MAVLINK_MSG_ID_WIND_COV_LEN, MAVLINK_MSG_ID_WIND_COV_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIND_COV_MIN_LEN, MAVLINK_MSG_ID_WIND_COV_LEN); +#endif +} + /** * @brief Pack a wind_cov message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_wind_cov_encode_chan(uint8_t system_id, uint8 return mavlink_msg_wind_cov_pack_chan(system_id, component_id, chan, msg, wind_cov->time_usec, wind_cov->wind_x, wind_cov->wind_y, wind_cov->wind_z, wind_cov->var_horiz, wind_cov->var_vert, wind_cov->wind_alt, wind_cov->horiz_accuracy, wind_cov->vert_accuracy); } +/** + * @brief Encode a wind_cov struct with provided status structure + * + * @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 wind_cov C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wind_cov_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wind_cov_t* wind_cov) +{ + return mavlink_msg_wind_cov_pack_status(system_id, component_id, _status, msg, wind_cov->time_usec, wind_cov->wind_x, wind_cov->wind_y, wind_cov->wind_z, wind_cov->var_horiz, wind_cov->var_vert, wind_cov->wind_alt, wind_cov->horiz_accuracy, wind_cov->vert_accuracy); +} + /** * @brief Send a wind_cov message * @param chan MAVLink channel to send the message diff --git a/common/version.h b/common/version.h index b08ab40d..f8324397 100644 --- a/common/version.h +++ b/common/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/csAirLink/csAirLink.h b/csAirLink/csAirLink.h index e8acdbe0..45c955a2 100644 --- a/csAirLink/csAirLink.h +++ b/csAirLink/csAirLink.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_CSAIRLINK.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_CSAIRLINK_XML_HASH 2600860254062997646 +#define MAVLINK_CSAIRLINK_XML_HASH -8008154180194613001 #ifdef __cplusplus extern "C" { diff --git a/csAirLink/mavlink.h b/csAirLink/mavlink.h index f9b48687..2b9e0451 100644 --- a/csAirLink/mavlink.h +++ b/csAirLink/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 2600860254062997646 +#define MAVLINK_PRIMARY_XML_HASH -8008154180194613001 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/csAirLink/mavlink_msg_airlink_auth.h b/csAirLink/mavlink_msg_airlink_auth.h index 4ff1d083..afca86ca 100644 --- a/csAirLink/mavlink_msg_airlink_auth.h +++ b/csAirLink/mavlink_msg_airlink_auth.h @@ -70,6 +70,42 @@ static inline uint16_t mavlink_msg_airlink_auth_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_AUTH_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_CRC); } +/** + * @brief Pack a airlink_auth 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 login Login + * @param password Password + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_auth_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *login, const char *password) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_AUTH_LEN]; + + _mav_put_char_array(buf, 0, login, 50); + _mav_put_char_array(buf, 50, password, 50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_AUTH_LEN); +#else + mavlink_airlink_auth_t packet; + + mav_array_memcpy(packet.login, login, sizeof(char)*50); + mav_array_memcpy(packet.password, password, sizeof(char)*50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_AUTH_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_AUTH; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_AUTH_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_AUTH_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_LEN); +#endif +} + /** * @brief Pack a airlink_auth message on a channel * @param system_id ID of this system @@ -129,6 +165,20 @@ static inline uint16_t mavlink_msg_airlink_auth_encode_chan(uint8_t system_id, u return mavlink_msg_airlink_auth_pack_chan(system_id, component_id, chan, msg, airlink_auth->login, airlink_auth->password); } +/** + * @brief Encode a airlink_auth struct with provided status structure + * + * @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 airlink_auth C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_auth_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_auth_t* airlink_auth) +{ + return mavlink_msg_airlink_auth_pack_status(system_id, component_id, _status, msg, airlink_auth->login, airlink_auth->password); +} + /** * @brief Send a airlink_auth message * @param chan MAVLink channel to send the message diff --git a/csAirLink/mavlink_msg_airlink_auth_response.h b/csAirLink/mavlink_msg_airlink_auth_response.h index eb16b303..f88f00e9 100644 --- a/csAirLink/mavlink_msg_airlink_auth_response.h +++ b/csAirLink/mavlink_msg_airlink_auth_response.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_airlink_auth_response_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_CRC); } +/** + * @brief Pack a airlink_auth_response 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 resp_type Response type + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_auth_response_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t resp_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN]; + _mav_put_uint8_t(buf, 0, resp_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN); +#else + mavlink_airlink_auth_response_t packet; + packet.resp_type = resp_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_AUTH_RESPONSE_LEN); +#endif +} + /** * @brief Pack a airlink_auth_response message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_airlink_auth_response_encode_chan(uint8_t sys return mavlink_msg_airlink_auth_response_pack_chan(system_id, component_id, chan, msg, airlink_auth_response->resp_type); } +/** + * @brief Encode a airlink_auth_response struct with provided status structure + * + * @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 airlink_auth_response C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_auth_response_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_auth_response_t* airlink_auth_response) +{ + return mavlink_msg_airlink_auth_response_pack_status(system_id, component_id, _status, msg, airlink_auth_response->resp_type); +} + /** * @brief Send a airlink_auth_response message * @param chan MAVLink channel to send the message diff --git a/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_request.h b/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_request.h index d7e3ee42..4bddd1d9 100644 --- a/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_request.h +++ b/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_request.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_request_pack(uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_CRC); } +/** + * @brief Pack a airlink_eye_gs_hole_push_request 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 resp_type Hole push response type + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t resp_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN]; + _mav_put_uint8_t(buf, 0, resp_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN); +#else + mavlink_airlink_eye_gs_hole_push_request_t packet; + packet.resp_type = resp_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_REQUEST_LEN); +#endif +} + /** * @brief Pack a airlink_eye_gs_hole_push_request message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_request_encode_chan( return mavlink_msg_airlink_eye_gs_hole_push_request_pack_chan(system_id, component_id, chan, msg, airlink_eye_gs_hole_push_request->resp_type); } +/** + * @brief Encode a airlink_eye_gs_hole_push_request struct with provided status structure + * + * @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 airlink_eye_gs_hole_push_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_eye_gs_hole_push_request_t* airlink_eye_gs_hole_push_request) +{ + return mavlink_msg_airlink_eye_gs_hole_push_request_pack_status(system_id, component_id, _status, msg, airlink_eye_gs_hole_push_request->resp_type); +} + /** * @brief Send a airlink_eye_gs_hole_push_request message * @param chan MAVLink channel to send the message diff --git a/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_response.h b/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_response.h index 32863f2a..8205ff44 100644 --- a/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_response.h +++ b/csAirLink/mavlink_msg_airlink_eye_gs_hole_push_response.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_response_pack(uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_CRC); } +/** + * @brief Pack a airlink_eye_gs_hole_push_response 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 resp_type Hole push response type + * @param ip_version ip version + * @param ip_address_4 ip 4 address + * @param ip_address_6 ip 6 address + * @param ip_port port + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_response_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t resp_type, uint8_t ip_version, const uint8_t *ip_address_4, const uint8_t *ip_address_6, uint32_t ip_port) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN]; + _mav_put_uint32_t(buf, 0, ip_port); + _mav_put_uint8_t(buf, 4, resp_type); + _mav_put_uint8_t(buf, 5, ip_version); + _mav_put_uint8_t_array(buf, 6, ip_address_4, 4); + _mav_put_uint8_t_array(buf, 10, ip_address_6, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN); +#else + mavlink_airlink_eye_gs_hole_push_response_t packet; + packet.ip_port = ip_port; + packet.resp_type = resp_type; + packet.ip_version = ip_version; + mav_array_memcpy(packet.ip_address_4, ip_address_4, sizeof(uint8_t)*4); + mav_array_memcpy(packet.ip_address_6, ip_address_6, sizeof(uint8_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_GS_HOLE_PUSH_RESPONSE_LEN); +#endif +} + /** * @brief Pack a airlink_eye_gs_hole_push_response message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_response_encode_chan return mavlink_msg_airlink_eye_gs_hole_push_response_pack_chan(system_id, component_id, chan, msg, airlink_eye_gs_hole_push_response->resp_type, airlink_eye_gs_hole_push_response->ip_version, airlink_eye_gs_hole_push_response->ip_address_4, airlink_eye_gs_hole_push_response->ip_address_6, airlink_eye_gs_hole_push_response->ip_port); } +/** + * @brief Encode a airlink_eye_gs_hole_push_response struct with provided status structure + * + * @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 airlink_eye_gs_hole_push_response C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_eye_gs_hole_push_response_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_eye_gs_hole_push_response_t* airlink_eye_gs_hole_push_response) +{ + return mavlink_msg_airlink_eye_gs_hole_push_response_pack_status(system_id, component_id, _status, msg, airlink_eye_gs_hole_push_response->resp_type, airlink_eye_gs_hole_push_response->ip_version, airlink_eye_gs_hole_push_response->ip_address_4, airlink_eye_gs_hole_push_response->ip_address_6, airlink_eye_gs_hole_push_response->ip_port); +} + /** * @brief Send a airlink_eye_gs_hole_push_response message * @param chan MAVLink channel to send the message diff --git a/csAirLink/mavlink_msg_airlink_eye_hp.h b/csAirLink/mavlink_msg_airlink_eye_hp.h index 5d47fed7..a98dd33e 100644 --- a/csAirLink/mavlink_msg_airlink_eye_hp.h +++ b/csAirLink/mavlink_msg_airlink_eye_hp.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_airlink_eye_hp_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_EYE_HP_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_HP_CRC); } +/** + * @brief Pack a airlink_eye_hp 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 resp_type Hole push response type + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_eye_hp_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t resp_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN]; + _mav_put_uint8_t(buf, 0, resp_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN); +#else + mavlink_airlink_eye_hp_t packet; + packet.resp_type = resp_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_EYE_HP; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_HP_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_HP_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_HP_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_HP_LEN); +#endif +} + /** * @brief Pack a airlink_eye_hp message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_airlink_eye_hp_encode_chan(uint8_t system_id, return mavlink_msg_airlink_eye_hp_pack_chan(system_id, component_id, chan, msg, airlink_eye_hp->resp_type); } +/** + * @brief Encode a airlink_eye_hp struct with provided status structure + * + * @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 airlink_eye_hp C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_eye_hp_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_eye_hp_t* airlink_eye_hp) +{ + return mavlink_msg_airlink_eye_hp_pack_status(system_id, component_id, _status, msg, airlink_eye_hp->resp_type); +} + /** * @brief Send a airlink_eye_hp message * @param chan MAVLink channel to send the message diff --git a/csAirLink/mavlink_msg_airlink_eye_turn_init.h b/csAirLink/mavlink_msg_airlink_eye_turn_init.h index 8f7ef95f..94e2e70a 100644 --- a/csAirLink/mavlink_msg_airlink_eye_turn_init.h +++ b/csAirLink/mavlink_msg_airlink_eye_turn_init.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_airlink_eye_turn_init_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_CRC); } +/** + * @brief Pack a airlink_eye_turn_init 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 resp_type Turn init type + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airlink_eye_turn_init_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t resp_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN]; + _mav_put_uint8_t(buf, 0, resp_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN); +#else + mavlink_airlink_eye_turn_init_t packet; + packet.resp_type = resp_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_MIN_LEN, MAVLINK_MSG_ID_AIRLINK_EYE_TURN_INIT_LEN); +#endif +} + /** * @brief Pack a airlink_eye_turn_init message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_airlink_eye_turn_init_encode_chan(uint8_t sys return mavlink_msg_airlink_eye_turn_init_pack_chan(system_id, component_id, chan, msg, airlink_eye_turn_init->resp_type); } +/** + * @brief Encode a airlink_eye_turn_init struct with provided status structure + * + * @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 airlink_eye_turn_init C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airlink_eye_turn_init_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airlink_eye_turn_init_t* airlink_eye_turn_init) +{ + return mavlink_msg_airlink_eye_turn_init_pack_status(system_id, component_id, _status, msg, airlink_eye_turn_init->resp_type); +} + /** * @brief Send a airlink_eye_turn_init message * @param chan MAVLink channel to send the message diff --git a/csAirLink/version.h b/csAirLink/version.h index 429ff3f4..cff5f220 100644 --- a/csAirLink/version.h +++ b/csAirLink/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 100 diff --git a/cubepilot/cubepilot.h b/cubepilot/cubepilot.h index 37092ea3..b4666336 100644 --- a/cubepilot/cubepilot.h +++ b/cubepilot/cubepilot.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_CUBEPILOT.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_CUBEPILOT_XML_HASH 7949515554575392665 +#define MAVLINK_CUBEPILOT_XML_HASH 9040590893731547459 #ifdef __cplusplus extern "C" { diff --git a/cubepilot/mavlink.h b/cubepilot/mavlink.h index 50c31961..beb0dfab 100644 --- a/cubepilot/mavlink.h +++ b/cubepilot/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 7949515554575392665 +#define MAVLINK_PRIMARY_XML_HASH 9040590893731547459 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/cubepilot/mavlink_msg_cubepilot_firmware_update_resp.h b/cubepilot/mavlink_msg_cubepilot_firmware_update_resp.h index 6a953bfa..f3086d5f 100644 --- a/cubepilot/mavlink_msg_cubepilot_firmware_update_resp.h +++ b/cubepilot/mavlink_msg_cubepilot_firmware_update_resp.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_cubepilot_firmware_update_resp_pack(uint8_t s return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_CRC); } +/** + * @brief Pack a cubepilot_firmware_update_resp 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 target_system System ID. + * @param target_component Component ID. + * @param offset [bytes] FW Offset. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_cubepilot_firmware_update_resp_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t offset) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN]; + _mav_put_uint32_t(buf, 0, offset); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN); +#else + mavlink_cubepilot_firmware_update_resp_t packet; + packet.offset = offset; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_RESP_LEN); +#endif +} + /** * @brief Pack a cubepilot_firmware_update_resp message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_cubepilot_firmware_update_resp_encode_chan(ui return mavlink_msg_cubepilot_firmware_update_resp_pack_chan(system_id, component_id, chan, msg, cubepilot_firmware_update_resp->target_system, cubepilot_firmware_update_resp->target_component, cubepilot_firmware_update_resp->offset); } +/** + * @brief Encode a cubepilot_firmware_update_resp struct with provided status structure + * + * @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 cubepilot_firmware_update_resp C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_cubepilot_firmware_update_resp_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cubepilot_firmware_update_resp_t* cubepilot_firmware_update_resp) +{ + return mavlink_msg_cubepilot_firmware_update_resp_pack_status(system_id, component_id, _status, msg, cubepilot_firmware_update_resp->target_system, cubepilot_firmware_update_resp->target_component, cubepilot_firmware_update_resp->offset); +} + /** * @brief Send a cubepilot_firmware_update_resp message * @param chan MAVLink channel to send the message diff --git a/cubepilot/mavlink_msg_cubepilot_firmware_update_start.h b/cubepilot/mavlink_msg_cubepilot_firmware_update_start.h index e2e8c0d5..ca50bdc9 100644 --- a/cubepilot/mavlink_msg_cubepilot_firmware_update_start.h +++ b/cubepilot/mavlink_msg_cubepilot_firmware_update_start.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_cubepilot_firmware_update_start_pack(uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_CRC); } +/** + * @brief Pack a cubepilot_firmware_update_start 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 target_system System ID. + * @param target_component Component ID. + * @param size [bytes] FW Size. + * @param crc FW CRC. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_cubepilot_firmware_update_start_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint32_t size, uint32_t crc) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN]; + _mav_put_uint32_t(buf, 0, size); + _mav_put_uint32_t(buf, 4, crc); + _mav_put_uint8_t(buf, 8, target_system); + _mav_put_uint8_t(buf, 9, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN); +#else + mavlink_cubepilot_firmware_update_start_t packet; + packet.size = size; + packet.crc = crc; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_FIRMWARE_UPDATE_START_LEN); +#endif +} + /** * @brief Pack a cubepilot_firmware_update_start message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_cubepilot_firmware_update_start_encode_chan(u return mavlink_msg_cubepilot_firmware_update_start_pack_chan(system_id, component_id, chan, msg, cubepilot_firmware_update_start->target_system, cubepilot_firmware_update_start->target_component, cubepilot_firmware_update_start->size, cubepilot_firmware_update_start->crc); } +/** + * @brief Encode a cubepilot_firmware_update_start struct with provided status structure + * + * @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 cubepilot_firmware_update_start C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_cubepilot_firmware_update_start_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cubepilot_firmware_update_start_t* cubepilot_firmware_update_start) +{ + return mavlink_msg_cubepilot_firmware_update_start_pack_status(system_id, component_id, _status, msg, cubepilot_firmware_update_start->target_system, cubepilot_firmware_update_start->target_component, cubepilot_firmware_update_start->size, cubepilot_firmware_update_start->crc); +} + /** * @brief Send a cubepilot_firmware_update_start message * @param chan MAVLink channel to send the message diff --git a/cubepilot/mavlink_msg_cubepilot_raw_rc.h b/cubepilot/mavlink_msg_cubepilot_raw_rc.h index 0718aff8..997d0e97 100644 --- a/cubepilot/mavlink_msg_cubepilot_raw_rc.h +++ b/cubepilot/mavlink_msg_cubepilot_raw_rc.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_cubepilot_raw_rc_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_CRC); } +/** + * @brief Pack a cubepilot_raw_rc 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 rc_raw + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_cubepilot_raw_rc_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *rc_raw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN]; + + _mav_put_uint8_t_array(buf, 0, rc_raw, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN); +#else + mavlink_cubepilot_raw_rc_t packet; + + mav_array_memcpy(packet.rc_raw, rc_raw, sizeof(uint8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CUBEPILOT_RAW_RC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_MIN_LEN, MAVLINK_MSG_ID_CUBEPILOT_RAW_RC_LEN); +#endif +} + /** * @brief Pack a cubepilot_raw_rc message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_cubepilot_raw_rc_encode_chan(uint8_t system_i return mavlink_msg_cubepilot_raw_rc_pack_chan(system_id, component_id, chan, msg, cubepilot_raw_rc->rc_raw); } +/** + * @brief Encode a cubepilot_raw_rc struct with provided status structure + * + * @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 cubepilot_raw_rc C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_cubepilot_raw_rc_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cubepilot_raw_rc_t* cubepilot_raw_rc) +{ + return mavlink_msg_cubepilot_raw_rc_pack_status(system_id, component_id, _status, msg, cubepilot_raw_rc->rc_raw); +} + /** * @brief Send a cubepilot_raw_rc message * @param chan MAVLink channel to send the message diff --git a/cubepilot/mavlink_msg_herelink_telem.h b/cubepilot/mavlink_msg_herelink_telem.h index 7efd4bdb..73a5a69d 100644 --- a/cubepilot/mavlink_msg_herelink_telem.h +++ b/cubepilot/mavlink_msg_herelink_telem.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_herelink_telem_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HERELINK_TELEM_MIN_LEN, MAVLINK_MSG_ID_HERELINK_TELEM_LEN, MAVLINK_MSG_ID_HERELINK_TELEM_CRC); } +/** + * @brief Pack a herelink_telem 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 rssi + * @param snr + * @param rf_freq + * @param link_bw + * @param link_rate + * @param cpu_temp + * @param board_temp + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_herelink_telem_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t rssi, int16_t snr, uint32_t rf_freq, uint32_t link_bw, uint32_t link_rate, int16_t cpu_temp, int16_t board_temp) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HERELINK_TELEM_LEN]; + _mav_put_uint32_t(buf, 0, rf_freq); + _mav_put_uint32_t(buf, 4, link_bw); + _mav_put_uint32_t(buf, 8, link_rate); + _mav_put_int16_t(buf, 12, snr); + _mav_put_int16_t(buf, 14, cpu_temp); + _mav_put_int16_t(buf, 16, board_temp); + _mav_put_uint8_t(buf, 18, rssi); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HERELINK_TELEM_LEN); +#else + mavlink_herelink_telem_t packet; + packet.rf_freq = rf_freq; + packet.link_bw = link_bw; + packet.link_rate = link_rate; + packet.snr = snr; + packet.cpu_temp = cpu_temp; + packet.board_temp = board_temp; + packet.rssi = rssi; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HERELINK_TELEM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HERELINK_TELEM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HERELINK_TELEM_MIN_LEN, MAVLINK_MSG_ID_HERELINK_TELEM_LEN, MAVLINK_MSG_ID_HERELINK_TELEM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HERELINK_TELEM_MIN_LEN, MAVLINK_MSG_ID_HERELINK_TELEM_LEN); +#endif +} + /** * @brief Pack a herelink_telem message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_herelink_telem_encode_chan(uint8_t system_id, return mavlink_msg_herelink_telem_pack_chan(system_id, component_id, chan, msg, herelink_telem->rssi, herelink_telem->snr, herelink_telem->rf_freq, herelink_telem->link_bw, herelink_telem->link_rate, herelink_telem->cpu_temp, herelink_telem->board_temp); } +/** + * @brief Encode a herelink_telem struct with provided status structure + * + * @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 herelink_telem C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_herelink_telem_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_herelink_telem_t* herelink_telem) +{ + return mavlink_msg_herelink_telem_pack_status(system_id, component_id, _status, msg, herelink_telem->rssi, herelink_telem->snr, herelink_telem->rf_freq, herelink_telem->link_bw, herelink_telem->link_rate, herelink_telem->cpu_temp, herelink_telem->board_temp); +} + /** * @brief Send a herelink_telem message * @param chan MAVLink channel to send the message diff --git a/cubepilot/mavlink_msg_herelink_video_stream_information.h b/cubepilot/mavlink_msg_herelink_video_stream_information.h index e5c4f5e0..7a4630d5 100644 --- a/cubepilot/mavlink_msg_herelink_video_stream_information.h +++ b/cubepilot/mavlink_msg_herelink_video_stream_information.h @@ -103,6 +103,58 @@ static inline uint16_t mavlink_msg_herelink_video_stream_information_pack(uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_CRC); } +/** + * @brief Pack a herelink_video_stream_information 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 camera_id Video Stream ID (1 for first, 2 for second, etc.) + * @param status Number of streams available. + * @param framerate [Hz] Frame rate. + * @param resolution_h [pix] Horizontal resolution. + * @param resolution_v [pix] Vertical resolution. + * @param bitrate [bits/s] Bit rate. + * @param rotation [deg] Video image rotation clockwise. + * @param uri Video stream URI (TCP or RTSP URI ground station should connect to) or port number (UDP port ground station should listen to). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_herelink_video_stream_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t camera_id, uint8_t status, float framerate, uint16_t resolution_h, uint16_t resolution_v, uint32_t bitrate, uint16_t rotation, const char *uri) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN]; + _mav_put_float(buf, 0, framerate); + _mav_put_uint32_t(buf, 4, bitrate); + _mav_put_uint16_t(buf, 8, resolution_h); + _mav_put_uint16_t(buf, 10, resolution_v); + _mav_put_uint16_t(buf, 12, rotation); + _mav_put_uint8_t(buf, 14, camera_id); + _mav_put_uint8_t(buf, 15, status); + _mav_put_char_array(buf, 16, uri, 230); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN); +#else + mavlink_herelink_video_stream_information_t packet; + packet.framerate = framerate; + packet.bitrate = bitrate; + packet.resolution_h = resolution_h; + packet.resolution_v = resolution_v; + packet.rotation = rotation; + packet.camera_id = camera_id; + packet.status = status; + mav_array_memcpy(packet.uri, uri, sizeof(char)*230); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_HERELINK_VIDEO_STREAM_INFORMATION_LEN); +#endif +} + /** * @brief Pack a herelink_video_stream_information message on a channel * @param system_id ID of this system @@ -178,6 +230,20 @@ static inline uint16_t mavlink_msg_herelink_video_stream_information_encode_chan return mavlink_msg_herelink_video_stream_information_pack_chan(system_id, component_id, chan, msg, herelink_video_stream_information->camera_id, herelink_video_stream_information->status, herelink_video_stream_information->framerate, herelink_video_stream_information->resolution_h, herelink_video_stream_information->resolution_v, herelink_video_stream_information->bitrate, herelink_video_stream_information->rotation, herelink_video_stream_information->uri); } +/** + * @brief Encode a herelink_video_stream_information struct with provided status structure + * + * @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 herelink_video_stream_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_herelink_video_stream_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_herelink_video_stream_information_t* herelink_video_stream_information) +{ + return mavlink_msg_herelink_video_stream_information_pack_status(system_id, component_id, _status, msg, herelink_video_stream_information->camera_id, herelink_video_stream_information->status, herelink_video_stream_information->framerate, herelink_video_stream_information->resolution_h, herelink_video_stream_information->resolution_v, herelink_video_stream_information->bitrate, herelink_video_stream_information->rotation, herelink_video_stream_information->uri); +} + /** * @brief Send a herelink_video_stream_information message * @param chan MAVLink channel to send the message diff --git a/cubepilot/version.h b/cubepilot/version.h index 79f0968f..bafed89a 100644 --- a/cubepilot/version.h +++ b/cubepilot/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/development/development.h b/development/development.h index b0ca717b..7733694d 100644 --- a/development/development.h +++ b/development/development.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_DEVELOPMENT.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_DEVELOPMENT_XML_HASH -2294259275137767143 +#define MAVLINK_DEVELOPMENT_XML_HASH 6456154506280024969 #ifdef __cplusplus extern "C" { diff --git a/development/mavlink.h b/development/mavlink.h index 8dafca5d..a96402d4 100644 --- a/development/mavlink.h +++ b/development/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -2294259275137767143 +#define MAVLINK_PRIMARY_XML_HASH 6456154506280024969 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/development/mavlink_msg_airspeed.h b/development/mavlink_msg_airspeed.h index 40282a2d..f64d2800 100644 --- a/development/mavlink_msg_airspeed.h +++ b/development/mavlink_msg_airspeed.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_airspeed_pack(uint8_t system_id, uint8_t comp return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRSPEED_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_LEN, MAVLINK_MSG_ID_AIRSPEED_CRC); } +/** + * @brief Pack a airspeed 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 id Sensor ID. + * @param airspeed [m/s] Calibrated airspeed (CAS). + * @param temperature [cdegC] Temperature. INT16_MAX for value unknown/not supplied. + * @param raw_press [hPa] Raw differential pressure. NaN for value unknown/not supplied. + * @param flags Airspeed sensor flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airspeed_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, float airspeed, int16_t temperature, float raw_press, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRSPEED_LEN]; + _mav_put_float(buf, 0, airspeed); + _mav_put_float(buf, 4, raw_press); + _mav_put_int16_t(buf, 8, temperature); + _mav_put_uint8_t(buf, 10, id); + _mav_put_uint8_t(buf, 11, flags); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRSPEED_LEN); +#else + mavlink_airspeed_t packet; + packet.airspeed = airspeed; + packet.raw_press = raw_press; + packet.temperature = temperature; + packet.id = id; + packet.flags = flags; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRSPEED_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRSPEED; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEED_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_LEN, MAVLINK_MSG_ID_AIRSPEED_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEED_MIN_LEN, MAVLINK_MSG_ID_AIRSPEED_LEN); +#endif +} + /** * @brief Pack a airspeed message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_airspeed_encode_chan(uint8_t system_id, uint8 return mavlink_msg_airspeed_pack_chan(system_id, component_id, chan, msg, airspeed->id, airspeed->airspeed, airspeed->temperature, airspeed->raw_press, airspeed->flags); } +/** + * @brief Encode a airspeed struct with provided status structure + * + * @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 airspeed C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airspeed_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airspeed_t* airspeed) +{ + return mavlink_msg_airspeed_pack_status(system_id, component_id, _status, msg, airspeed->id, airspeed->airspeed, airspeed->temperature, airspeed->raw_press, airspeed->flags); +} + /** * @brief Send a airspeed message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_available_modes.h b/development/mavlink_msg_available_modes.h index 586bcce1..ee7112f2 100644 --- a/development/mavlink_msg_available_modes.h +++ b/development/mavlink_msg_available_modes.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_available_modes_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC); } +/** + * @brief Pack a available_modes 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 number_modes The total number of available modes for the current vehicle type. + * @param mode_index The current mode index within number_modes, indexed from 1. + * @param standard_mode Standard mode. + * @param custom_mode A bitfield for use for autopilot-specific flags + * @param properties Mode properties. + * @param mode_name Name of custom mode, with null termination character. Should be omitted for standard modes. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_available_modes_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t number_modes, uint8_t mode_index, uint8_t standard_mode, uint32_t custom_mode, uint32_t properties, const char *mode_name) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVAILABLE_MODES_LEN]; + _mav_put_uint32_t(buf, 0, custom_mode); + _mav_put_uint32_t(buf, 4, properties); + _mav_put_uint8_t(buf, 8, number_modes); + _mav_put_uint8_t(buf, 9, mode_index); + _mav_put_uint8_t(buf, 10, standard_mode); + _mav_put_char_array(buf, 11, mode_name, 35); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN); +#else + mavlink_available_modes_t packet; + packet.custom_mode = custom_mode; + packet.properties = properties; + packet.number_modes = number_modes; + packet.mode_index = mode_index; + packet.standard_mode = standard_mode; + mav_array_memcpy(packet.mode_name, mode_name, sizeof(char)*35); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVAILABLE_MODES; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN); +#endif +} + /** * @brief Pack a available_modes message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_available_modes_encode_chan(uint8_t system_id return mavlink_msg_available_modes_pack_chan(system_id, component_id, chan, msg, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name); } +/** + * @brief Encode a available_modes struct with provided status structure + * + * @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 available_modes C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_available_modes_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_available_modes_t* available_modes) +{ + return mavlink_msg_available_modes_pack_status(system_id, component_id, _status, msg, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name); +} + /** * @brief Send a available_modes message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_available_modes_monitor.h b/development/mavlink_msg_available_modes_monitor.h index e51f3c1e..48821cc2 100644 --- a/development/mavlink_msg_available_modes_monitor.h +++ b/development/mavlink_msg_available_modes_monitor.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_available_modes_monitor_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_CRC); } +/** + * @brief Pack a available_modes_monitor 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 seq Sequence number. The value iterates sequentially whenever AVAILABLE_MODES changes (e.g. support for a new mode is added/removed dynamically). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_available_modes_monitor_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN]; + _mav_put_uint8_t(buf, 0, seq); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN); +#else + mavlink_available_modes_monitor_t packet; + packet.seq = seq; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR_LEN); +#endif +} + /** * @brief Pack a available_modes_monitor message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_available_modes_monitor_encode_chan(uint8_t s return mavlink_msg_available_modes_monitor_pack_chan(system_id, component_id, chan, msg, available_modes_monitor->seq); } +/** + * @brief Encode a available_modes_monitor struct with provided status structure + * + * @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 available_modes_monitor C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_available_modes_monitor_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_available_modes_monitor_t* available_modes_monitor) +{ + return mavlink_msg_available_modes_monitor_pack_status(system_id, component_id, _status, msg, available_modes_monitor->seq); +} + /** * @brief Send a available_modes_monitor message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_battery_status_v2.h b/development/mavlink_msg_battery_status_v2.h index 74f8fa35..4d450ebd 100644 --- a/development/mavlink_msg_battery_status_v2.h +++ b/development/mavlink_msg_battery_status_v2.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_battery_status_v2_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BATTERY_STATUS_V2_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_V2_CRC); } +/** + * @brief Pack a battery_status_v2 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 id Battery ID + * @param temperature [cdegC] Temperature of the whole battery pack (not internal electronics). INT16_MAX field not provided. + * @param voltage [V] Battery voltage (total). NaN: field not provided. + * @param current [A] Battery current (through all cells/loads). Positive value when discharging and negative if charging. NaN: field not provided. + * @param capacity_consumed [Ah] Consumed charge. NaN: field not provided. This is either the consumption since power-on or since the battery was full, depending on the value of MAV_BATTERY_STATUS_FLAGS_CAPACITY_RELATIVE_TO_FULL. + * @param capacity_remaining [Ah] Remaining charge (until empty). UINT32_MAX: field not provided. Note: If MAV_BATTERY_STATUS_FLAGS_CAPACITY_RELATIVE_TO_FULL is unset, this value is based on the assumption the battery was full when the system was powered. + * @param percent_remaining [%] Remaining battery energy. Values: [0-100], UINT8_MAX: field not provided. + * @param status_flags Fault, health, readiness, and other status indications. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery_status_v2_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t id, int16_t temperature, float voltage, float current, float capacity_consumed, float capacity_remaining, uint8_t percent_remaining, uint32_t status_flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN]; + _mav_put_float(buf, 0, voltage); + _mav_put_float(buf, 4, current); + _mav_put_float(buf, 8, capacity_consumed); + _mav_put_float(buf, 12, capacity_remaining); + _mav_put_uint32_t(buf, 16, status_flags); + _mav_put_int16_t(buf, 20, temperature); + _mav_put_uint8_t(buf, 22, id); + _mav_put_uint8_t(buf, 23, percent_remaining); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN); +#else + mavlink_battery_status_v2_t packet; + packet.voltage = voltage; + packet.current = current; + packet.capacity_consumed = capacity_consumed; + packet.capacity_remaining = capacity_remaining; + packet.status_flags = status_flags; + packet.temperature = temperature; + packet.id = id; + packet.percent_remaining = percent_remaining; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS_V2; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_STATUS_V2_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_V2_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_BATTERY_STATUS_V2_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_V2_LEN); +#endif +} + /** * @brief Pack a battery_status_v2 message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_battery_status_v2_encode_chan(uint8_t system_ return mavlink_msg_battery_status_v2_pack_chan(system_id, component_id, chan, msg, battery_status_v2->id, battery_status_v2->temperature, battery_status_v2->voltage, battery_status_v2->current, battery_status_v2->capacity_consumed, battery_status_v2->capacity_remaining, battery_status_v2->percent_remaining, battery_status_v2->status_flags); } +/** + * @brief Encode a battery_status_v2 struct with provided status structure + * + * @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 battery_status_v2 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_battery_status_v2_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_battery_status_v2_t* battery_status_v2) +{ + return mavlink_msg_battery_status_v2_pack_status(system_id, component_id, _status, msg, battery_status_v2->id, battery_status_v2->temperature, battery_status_v2->voltage, battery_status_v2->current, battery_status_v2->capacity_consumed, battery_status_v2->capacity_remaining, battery_status_v2->percent_remaining, battery_status_v2->status_flags); +} + /** * @brief Send a battery_status_v2 message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_component_information_basic.h b/development/mavlink_msg_component_information_basic.h index 05dabed4..f935b467 100644 --- a/development/mavlink_msg_component_information_basic.h +++ b/development/mavlink_msg_component_information_basic.h @@ -107,6 +107,58 @@ static inline uint16_t mavlink_msg_component_information_basic_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_CRC); } +/** + * @brief Pack a component_information_basic 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param capabilities Component capability flags + * @param time_manufacture_s [s] Date of manufacture as a UNIX Epoch time (since 1.1.1970) in seconds. + * @param vendor_name Name of the component vendor. Needs to be zero terminated. The field is optional and can be empty/all zeros. + * @param model_name Name of the component model. Needs to be zero terminated. The field is optional and can be empty/all zeros. + * @param software_version Software version. The recommended format is SEMVER: 'major.minor.patch' (any format may be used). The field must be zero terminated if it has a value. The field is optional and can be empty/all zeros. + * @param hardware_version Hardware version. The recommended format is SEMVER: 'major.minor.patch' (any format may be used). The field must be zero terminated if it has a value. The field is optional and can be empty/all zeros. + * @param serial_number Hardware serial number. The field must be zero terminated if it has a value. The field is optional and can be empty/all zeros. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_component_information_basic_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint64_t capabilities, uint32_t time_manufacture_s, const char *vendor_name, const char *model_name, const char *software_version, const char *hardware_version, const char *serial_number) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN]; + _mav_put_uint64_t(buf, 0, capabilities); + _mav_put_uint32_t(buf, 8, time_boot_ms); + _mav_put_uint32_t(buf, 12, time_manufacture_s); + _mav_put_char_array(buf, 16, vendor_name, 32); + _mav_put_char_array(buf, 48, model_name, 32); + _mav_put_char_array(buf, 80, software_version, 24); + _mav_put_char_array(buf, 104, hardware_version, 24); + _mav_put_char_array(buf, 128, serial_number, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN); +#else + mavlink_component_information_basic_t packet; + packet.capabilities = capabilities; + packet.time_boot_ms = time_boot_ms; + packet.time_manufacture_s = time_manufacture_s; + mav_array_memcpy(packet.vendor_name, vendor_name, sizeof(char)*32); + mav_array_memcpy(packet.model_name, model_name, sizeof(char)*32); + mav_array_memcpy(packet.software_version, software_version, sizeof(char)*24); + mav_array_memcpy(packet.hardware_version, hardware_version, sizeof(char)*24); + mav_array_memcpy(packet.serial_number, serial_number, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_INFORMATION_BASIC_LEN); +#endif +} + /** * @brief Pack a component_information_basic message on a channel * @param system_id ID of this system @@ -182,6 +234,20 @@ static inline uint16_t mavlink_msg_component_information_basic_encode_chan(uint8 return mavlink_msg_component_information_basic_pack_chan(system_id, component_id, chan, msg, component_information_basic->time_boot_ms, component_information_basic->capabilities, component_information_basic->time_manufacture_s, component_information_basic->vendor_name, component_information_basic->model_name, component_information_basic->software_version, component_information_basic->hardware_version, component_information_basic->serial_number); } +/** + * @brief Encode a component_information_basic struct with provided status structure + * + * @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 component_information_basic C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_component_information_basic_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_component_information_basic_t* component_information_basic) +{ + return mavlink_msg_component_information_basic_pack_status(system_id, component_id, _status, msg, component_information_basic->time_boot_ms, component_information_basic->capabilities, component_information_basic->time_manufacture_s, component_information_basic->vendor_name, component_information_basic->model_name, component_information_basic->software_version, component_information_basic->hardware_version, component_information_basic->serial_number); +} + /** * @brief Send a component_information_basic message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_current_mode.h b/development/mavlink_msg_current_mode.h index 4f949fd5..cc19e250 100644 --- a/development/mavlink_msg_current_mode.h +++ b/development/mavlink_msg_current_mode.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_current_mode_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CURRENT_MODE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_MODE_LEN, MAVLINK_MSG_ID_CURRENT_MODE_CRC); } +/** + * @brief Pack a current_mode 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 standard_mode Standard mode. + * @param custom_mode A bitfield for use for autopilot-specific flags + * @param intended_custom_mode The custom_mode of the mode that was last commanded by the user (for example, with MAV_CMD_DO_SET_STANDARD_MODE, MAV_CMD_DO_SET_MODE or via RC). This should usually be the same as custom_mode. It will be different if the vehicle is unable to enter the intended mode, or has left that mode due to a failsafe condition. 0 indicates the intended custom mode is unknown/not supplied + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_current_mode_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t standard_mode, uint32_t custom_mode, uint32_t intended_custom_mode) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_CURRENT_MODE_LEN]; + _mav_put_uint32_t(buf, 0, custom_mode); + _mav_put_uint32_t(buf, 4, intended_custom_mode); + _mav_put_uint8_t(buf, 8, standard_mode); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CURRENT_MODE_LEN); +#else + mavlink_current_mode_t packet; + packet.custom_mode = custom_mode; + packet.intended_custom_mode = intended_custom_mode; + packet.standard_mode = standard_mode; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CURRENT_MODE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_CURRENT_MODE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CURRENT_MODE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_MODE_LEN, MAVLINK_MSG_ID_CURRENT_MODE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CURRENT_MODE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_MODE_LEN); +#endif +} + /** * @brief Pack a current_mode message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_current_mode_encode_chan(uint8_t system_id, u return mavlink_msg_current_mode_pack_chan(system_id, component_id, chan, msg, current_mode->standard_mode, current_mode->custom_mode, current_mode->intended_custom_mode); } +/** + * @brief Encode a current_mode struct with provided status structure + * + * @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 current_mode C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_current_mode_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_current_mode_t* current_mode) +{ + return mavlink_msg_current_mode_pack_status(system_id, component_id, _status, msg, current_mode->standard_mode, current_mode->custom_mode, current_mode->intended_custom_mode); +} + /** * @brief Send a current_mode message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_figure_eight_execution_status.h b/development/mavlink_msg_figure_eight_execution_status.h index 1df1c401..8786f53c 100644 --- a/development/mavlink_msg_figure_eight_execution_status.h +++ b/development/mavlink_msg_figure_eight_execution_status.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_figure_eight_execution_status_pack(uint8_t sy return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_CRC); } +/** + * @brief Pack a figure_eight_execution_status 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 time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @param major_radius [m] Major axis radius of the figure eight. Positive: orbit the north circle clockwise. Negative: orbit the north circle counter-clockwise. + * @param minor_radius [m] Minor axis radius of the figure eight. Defines the radius of two circles that make up the figure. + * @param orientation [rad] Orientation of the figure eight major axis with respect to true north in [-pi,pi). + * @param frame The coordinate system of the fields: x, y, z. + * @param x X coordinate of center point. Coordinate system depends on frame field. + * @param y Y coordinate of center point. Coordinate system depends on frame field. + * @param z [m] Altitude of center point. Coordinate system depends on frame field. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_figure_eight_execution_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t time_usec, float major_radius, float minor_radius, float orientation, uint8_t frame, int32_t x, int32_t y, float z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, major_radius); + _mav_put_float(buf, 12, minor_radius); + _mav_put_float(buf, 16, orientation); + _mav_put_int32_t(buf, 20, x); + _mav_put_int32_t(buf, 24, y); + _mav_put_float(buf, 28, z); + _mav_put_uint8_t(buf, 32, frame); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN); +#else + mavlink_figure_eight_execution_status_t packet; + packet.time_usec = time_usec; + packet.major_radius = major_radius; + packet.minor_radius = minor_radius; + packet.orientation = orientation; + packet.x = x; + packet.y = y; + packet.z = z; + packet.frame = frame; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_MIN_LEN, MAVLINK_MSG_ID_FIGURE_EIGHT_EXECUTION_STATUS_LEN); +#endif +} + /** * @brief Pack a figure_eight_execution_status message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_figure_eight_execution_status_encode_chan(uin return mavlink_msg_figure_eight_execution_status_pack_chan(system_id, component_id, chan, msg, figure_eight_execution_status->time_usec, figure_eight_execution_status->major_radius, figure_eight_execution_status->minor_radius, figure_eight_execution_status->orientation, figure_eight_execution_status->frame, figure_eight_execution_status->x, figure_eight_execution_status->y, figure_eight_execution_status->z); } +/** + * @brief Encode a figure_eight_execution_status struct with provided status structure + * + * @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 figure_eight_execution_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_figure_eight_execution_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_figure_eight_execution_status_t* figure_eight_execution_status) +{ + return mavlink_msg_figure_eight_execution_status_pack_status(system_id, component_id, _status, msg, figure_eight_execution_status->time_usec, figure_eight_execution_status->major_radius, figure_eight_execution_status->minor_radius, figure_eight_execution_status->orientation, figure_eight_execution_status->frame, figure_eight_execution_status->x, figure_eight_execution_status->y, figure_eight_execution_status->z); +} + /** * @brief Send a figure_eight_execution_status message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_group_end.h b/development/mavlink_msg_group_end.h index 854c934f..115af86a 100644 --- a/development/mavlink_msg_group_end.h +++ b/development/mavlink_msg_group_end.h @@ -77,6 +77,46 @@ static inline uint16_t mavlink_msg_group_end_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GROUP_END_MIN_LEN, MAVLINK_MSG_ID_GROUP_END_LEN, MAVLINK_MSG_ID_GROUP_END_CRC); } +/** + * @brief Pack a group_end 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 group_id Mission-unique group id (from MAV_CMD_GROUP_END). + * @param mission_checksum CRC32 checksum of current plan for MAV_MISSION_TYPE_ALL. As defined in MISSION_CHECKSUM message. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). + The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_group_end_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t group_id, uint32_t mission_checksum, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GROUP_END_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, group_id); + _mav_put_uint32_t(buf, 12, mission_checksum); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GROUP_END_LEN); +#else + mavlink_group_end_t packet; + packet.time_usec = time_usec; + packet.group_id = group_id; + packet.mission_checksum = mission_checksum; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GROUP_END_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GROUP_END; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GROUP_END_MIN_LEN, MAVLINK_MSG_ID_GROUP_END_LEN, MAVLINK_MSG_ID_GROUP_END_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GROUP_END_MIN_LEN, MAVLINK_MSG_ID_GROUP_END_LEN); +#endif +} + /** * @brief Pack a group_end message on a channel * @param system_id ID of this system @@ -140,6 +180,20 @@ static inline uint16_t mavlink_msg_group_end_encode_chan(uint8_t system_id, uint return mavlink_msg_group_end_pack_chan(system_id, component_id, chan, msg, group_end->group_id, group_end->mission_checksum, group_end->time_usec); } +/** + * @brief Encode a group_end struct with provided status structure + * + * @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 group_end C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_group_end_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_group_end_t* group_end) +{ + return mavlink_msg_group_end_pack_status(system_id, component_id, _status, msg, group_end->group_id, group_end->mission_checksum, group_end->time_usec); +} + /** * @brief Send a group_end message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_group_start.h b/development/mavlink_msg_group_start.h index ae84c3b1..e1f1037b 100644 --- a/development/mavlink_msg_group_start.h +++ b/development/mavlink_msg_group_start.h @@ -77,6 +77,46 @@ static inline uint16_t mavlink_msg_group_start_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GROUP_START_MIN_LEN, MAVLINK_MSG_ID_GROUP_START_LEN, MAVLINK_MSG_ID_GROUP_START_CRC); } +/** + * @brief Pack a group_start 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 group_id Mission-unique group id (from MAV_CMD_GROUP_START). + * @param mission_checksum CRC32 checksum of current plan for MAV_MISSION_TYPE_ALL. As defined in MISSION_CHECKSUM message. + * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). + The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_group_start_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t group_id, uint32_t mission_checksum, uint64_t time_usec) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_GROUP_START_LEN]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_uint32_t(buf, 8, group_id); + _mav_put_uint32_t(buf, 12, mission_checksum); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GROUP_START_LEN); +#else + mavlink_group_start_t packet; + packet.time_usec = time_usec; + packet.group_id = group_id; + packet.mission_checksum = mission_checksum; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GROUP_START_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_GROUP_START; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GROUP_START_MIN_LEN, MAVLINK_MSG_ID_GROUP_START_LEN, MAVLINK_MSG_ID_GROUP_START_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GROUP_START_MIN_LEN, MAVLINK_MSG_ID_GROUP_START_LEN); +#endif +} + /** * @brief Pack a group_start message on a channel * @param system_id ID of this system @@ -140,6 +180,20 @@ static inline uint16_t mavlink_msg_group_start_encode_chan(uint8_t system_id, ui return mavlink_msg_group_start_pack_chan(system_id, component_id, chan, msg, group_start->group_id, group_start->mission_checksum, group_start->time_usec); } +/** + * @brief Encode a group_start struct with provided status structure + * + * @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 group_start C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_group_start_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_group_start_t* group_start) +{ + return mavlink_msg_group_start_pack_status(system_id, component_id, _status, msg, group_start->group_id, group_start->mission_checksum, group_start->time_usec); +} + /** * @brief Send a group_start message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_param_ack_transaction.h b/development/mavlink_msg_param_ack_transaction.h index 3fe5d7d4..6e5e5785 100644 --- a/development/mavlink_msg_param_ack_transaction.h +++ b/development/mavlink_msg_param_ack_transaction.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_param_ack_transaction_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_MIN_LEN, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_CRC); } +/** + * @brief Pack a param_ack_transaction 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 target_system Id of system that sent PARAM_SET message. + * @param target_component Id of system that sent PARAM_SET message. + * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_value Parameter value (new value if PARAM_ACCEPTED, current value otherwise) + * @param param_type Parameter type. + * @param param_result Result code. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_ack_transaction_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, const char *param_id, float param_value, uint8_t param_type, uint8_t param_result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN]; + _mav_put_float(buf, 0, param_value); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 22, param_type); + _mav_put_uint8_t(buf, 23, param_result); + _mav_put_char_array(buf, 6, param_id, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN); +#else + mavlink_param_ack_transaction_t packet; + packet.param_value = param_value; + packet.target_system = target_system; + packet.target_component = target_component; + packet.param_type = param_type; + packet.param_result = param_result; + mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_MIN_LEN, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_MIN_LEN, MAVLINK_MSG_ID_PARAM_ACK_TRANSACTION_LEN); +#endif +} + /** * @brief Pack a param_ack_transaction message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_param_ack_transaction_encode_chan(uint8_t sys return mavlink_msg_param_ack_transaction_pack_chan(system_id, component_id, chan, msg, param_ack_transaction->target_system, param_ack_transaction->target_component, param_ack_transaction->param_id, param_ack_transaction->param_value, param_ack_transaction->param_type, param_ack_transaction->param_result); } +/** + * @brief Encode a param_ack_transaction struct with provided status structure + * + * @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 param_ack_transaction C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_ack_transaction_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ack_transaction_t* param_ack_transaction) +{ + return mavlink_msg_param_ack_transaction_pack_status(system_id, component_id, _status, msg, param_ack_transaction->target_system, param_ack_transaction->target_component, param_ack_transaction->param_id, param_ack_transaction->param_value, param_ack_transaction->param_type, param_ack_transaction->param_result); +} + /** * @brief Send a param_ack_transaction message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_set_velocity_limits.h b/development/mavlink_msg_set_velocity_limits.h index b1823053..366de796 100644 --- a/development/mavlink_msg_set_velocity_limits.h +++ b/development/mavlink_msg_set_velocity_limits.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_set_velocity_limits_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_CRC); } +/** + * @brief Pack a set_velocity_limits 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 target_system System ID (0 for broadcast). + * @param target_component Component ID (0 for broadcast). + * @param horizontal_speed_limit [m/s] Limit for horizontal movement in MAV_FRAME_LOCAL_NED. NaN: Field not used (ignore) + * @param vertical_speed_limit [m/s] Limit for vertical movement in MAV_FRAME_LOCAL_NED. NaN: Field not used (ignore) + * @param yaw_rate_limit [rad/s] Limit for vehicle turn rate around its yaw axis. NaN: Field not used (ignore) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_velocity_limits_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, float horizontal_speed_limit, float vertical_speed_limit, float yaw_rate_limit) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN]; + _mav_put_float(buf, 0, horizontal_speed_limit); + _mav_put_float(buf, 4, vertical_speed_limit); + _mav_put_float(buf, 8, yaw_rate_limit); + _mav_put_uint8_t(buf, 12, target_system); + _mav_put_uint8_t(buf, 13, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN); +#else + mavlink_set_velocity_limits_t packet; + packet.horizontal_speed_limit = horizontal_speed_limit; + packet.vertical_speed_limit = vertical_speed_limit; + packet.yaw_rate_limit = yaw_rate_limit; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_VELOCITY_LIMITS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_SET_VELOCITY_LIMITS_LEN); +#endif +} + /** * @brief Pack a set_velocity_limits message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_set_velocity_limits_encode_chan(uint8_t syste return mavlink_msg_set_velocity_limits_pack_chan(system_id, component_id, chan, msg, set_velocity_limits->target_system, set_velocity_limits->target_component, set_velocity_limits->horizontal_speed_limit, set_velocity_limits->vertical_speed_limit, set_velocity_limits->yaw_rate_limit); } +/** + * @brief Encode a set_velocity_limits struct with provided status structure + * + * @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 set_velocity_limits C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_velocity_limits_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_velocity_limits_t* set_velocity_limits) +{ + return mavlink_msg_set_velocity_limits_pack_status(system_id, component_id, _status, msg, set_velocity_limits->target_system, set_velocity_limits->target_component, set_velocity_limits->horizontal_speed_limit, set_velocity_limits->vertical_speed_limit, set_velocity_limits->yaw_rate_limit); +} + /** * @brief Send a set_velocity_limits message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_target_absolute.h b/development/mavlink_msg_target_absolute.h index 293a0feb..462d1b8e 100644 --- a/development/mavlink_msg_target_absolute.h +++ b/development/mavlink_msg_target_absolute.h @@ -139,6 +139,73 @@ static inline uint16_t mavlink_msg_target_absolute_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TARGET_ABSOLUTE_MIN_LEN, MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN, MAVLINK_MSG_ID_TARGET_ABSOLUTE_CRC); } +/** + * @brief Pack a target_absolute 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 timestamp [us] Timestamp (UNIX epoch time). + * @param id The ID of the target if multiple targets are present + * @param sensor_capabilities Bitmap to indicate the sensor's reporting capabilities + * @param lat [degE7] Target's latitude (WGS84) + * @param lon [degE7] Target's longitude (WGS84) + * @param alt [m] Target's altitude (AMSL) + * @param vel [m/s] Target's velocity in its body frame + * @param acc [m/s/s] Linear target's acceleration in its body frame + * @param q_target Quaternion of the target's orientation from its body frame to the vehicle's NED frame. + * @param rates [rad/s] Target's roll, pitch and yaw rates + * @param position_std [m] Standard deviation of horizontal (eph) and vertical (epv) position errors + * @param vel_std [m/s] Standard deviation of the target's velocity in its body frame + * @param acc_std [m/s/s] Standard deviation of the target's acceleration in its body frame + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_target_absolute_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t id, uint8_t sensor_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *q_target, const float *rates, const float *position_std, const float *vel_std, const float *acc_std) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_int32_t(buf, 8, lat); + _mav_put_int32_t(buf, 12, lon); + _mav_put_float(buf, 16, alt); + _mav_put_uint8_t(buf, 104, id); + _mav_put_uint8_t(buf, 105, sensor_capabilities); + _mav_put_float_array(buf, 20, vel, 3); + _mav_put_float_array(buf, 32, acc, 3); + _mav_put_float_array(buf, 44, q_target, 4); + _mav_put_float_array(buf, 60, rates, 3); + _mav_put_float_array(buf, 72, position_std, 2); + _mav_put_float_array(buf, 80, vel_std, 3); + _mav_put_float_array(buf, 92, acc_std, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN); +#else + mavlink_target_absolute_t packet; + packet.timestamp = timestamp; + packet.lat = lat; + packet.lon = lon; + packet.alt = alt; + packet.id = id; + packet.sensor_capabilities = sensor_capabilities; + mav_array_memcpy(packet.vel, vel, sizeof(float)*3); + mav_array_memcpy(packet.acc, acc, sizeof(float)*3); + mav_array_memcpy(packet.q_target, q_target, sizeof(float)*4); + mav_array_memcpy(packet.rates, rates, sizeof(float)*3); + mav_array_memcpy(packet.position_std, position_std, sizeof(float)*2); + mav_array_memcpy(packet.vel_std, vel_std, sizeof(float)*3); + mav_array_memcpy(packet.acc_std, acc_std, sizeof(float)*3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TARGET_ABSOLUTE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TARGET_ABSOLUTE_MIN_LEN, MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN, MAVLINK_MSG_ID_TARGET_ABSOLUTE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TARGET_ABSOLUTE_MIN_LEN, MAVLINK_MSG_ID_TARGET_ABSOLUTE_LEN); +#endif +} + /** * @brief Pack a target_absolute message on a channel * @param system_id ID of this system @@ -229,6 +296,20 @@ static inline uint16_t mavlink_msg_target_absolute_encode_chan(uint8_t system_id return mavlink_msg_target_absolute_pack_chan(system_id, component_id, chan, msg, target_absolute->timestamp, target_absolute->id, target_absolute->sensor_capabilities, target_absolute->lat, target_absolute->lon, target_absolute->alt, target_absolute->vel, target_absolute->acc, target_absolute->q_target, target_absolute->rates, target_absolute->position_std, target_absolute->vel_std, target_absolute->acc_std); } +/** + * @brief Encode a target_absolute struct with provided status structure + * + * @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 target_absolute C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_target_absolute_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_target_absolute_t* target_absolute) +{ + return mavlink_msg_target_absolute_pack_status(system_id, component_id, _status, msg, target_absolute->timestamp, target_absolute->id, target_absolute->sensor_capabilities, target_absolute->lat, target_absolute->lon, target_absolute->alt, target_absolute->vel, target_absolute->acc, target_absolute->q_target, target_absolute->rates, target_absolute->position_std, target_absolute->vel_std, target_absolute->acc_std); +} + /** * @brief Send a target_absolute message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_target_relative.h b/development/mavlink_msg_target_relative.h index 7c74a51c..06109469 100644 --- a/development/mavlink_msg_target_relative.h +++ b/development/mavlink_msg_target_relative.h @@ -123,6 +123,67 @@ static inline uint16_t mavlink_msg_target_relative_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TARGET_RELATIVE_MIN_LEN, MAVLINK_MSG_ID_TARGET_RELATIVE_LEN, MAVLINK_MSG_ID_TARGET_RELATIVE_CRC); } +/** + * @brief Pack a target_relative 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 timestamp [us] Timestamp (UNIX epoch time) + * @param id The ID of the target if multiple targets are present + * @param frame Coordinate frame used for following fields. + * @param x [m] X Position of the target in TARGET_OBS_FRAME + * @param y [m] Y Position of the target in TARGET_OBS_FRAME + * @param z [m] Z Position of the target in TARGET_OBS_FRAME + * @param pos_std [m] Standard deviation of the target's position in TARGET_OBS_FRAME + * @param yaw_std [rad] Standard deviation of the target's orientation in TARGET_OBS_FRAME + * @param q_target Quaternion of the target's orientation from the target's frame to the TARGET_OBS_FRAME (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param q_sensor Quaternion of the sensor's orientation from TARGET_OBS_FRAME to vehicle-carried NED. (Ignored if set to (0,0,0,0)) (w, x, y, z order, zero-rotation is 1, 0, 0, 0) + * @param type Type of target + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_target_relative_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t timestamp, uint8_t id, uint8_t frame, float x, float y, float z, const float *pos_std, float yaw_std, const float *q_target, const float *q_sensor, uint8_t type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TARGET_RELATIVE_LEN]; + _mav_put_uint64_t(buf, 0, timestamp); + _mav_put_float(buf, 8, x); + _mav_put_float(buf, 12, y); + _mav_put_float(buf, 16, z); + _mav_put_float(buf, 32, yaw_std); + _mav_put_uint8_t(buf, 68, id); + _mav_put_uint8_t(buf, 69, frame); + _mav_put_uint8_t(buf, 70, type); + _mav_put_float_array(buf, 20, pos_std, 3); + _mav_put_float_array(buf, 36, q_target, 4); + _mav_put_float_array(buf, 52, q_sensor, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TARGET_RELATIVE_LEN); +#else + mavlink_target_relative_t packet; + packet.timestamp = timestamp; + packet.x = x; + packet.y = y; + packet.z = z; + packet.yaw_std = yaw_std; + packet.id = id; + packet.frame = frame; + packet.type = type; + mav_array_memcpy(packet.pos_std, pos_std, sizeof(float)*3); + mav_array_memcpy(packet.q_target, q_target, sizeof(float)*4); + mav_array_memcpy(packet.q_sensor, q_sensor, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TARGET_RELATIVE_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TARGET_RELATIVE; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TARGET_RELATIVE_MIN_LEN, MAVLINK_MSG_ID_TARGET_RELATIVE_LEN, MAVLINK_MSG_ID_TARGET_RELATIVE_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TARGET_RELATIVE_MIN_LEN, MAVLINK_MSG_ID_TARGET_RELATIVE_LEN); +#endif +} + /** * @brief Pack a target_relative message on a channel * @param system_id ID of this system @@ -207,6 +268,20 @@ static inline uint16_t mavlink_msg_target_relative_encode_chan(uint8_t system_id return mavlink_msg_target_relative_pack_chan(system_id, component_id, chan, msg, target_relative->timestamp, target_relative->id, target_relative->frame, target_relative->x, target_relative->y, target_relative->z, target_relative->pos_std, target_relative->yaw_std, target_relative->q_target, target_relative->q_sensor, target_relative->type); } +/** + * @brief Encode a target_relative struct with provided status structure + * + * @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 target_relative C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_target_relative_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_target_relative_t* target_relative) +{ + return mavlink_msg_target_relative_pack_status(system_id, component_id, _status, msg, target_relative->timestamp, target_relative->id, target_relative->frame, target_relative->x, target_relative->y, target_relative->z, target_relative->pos_std, target_relative->yaw_std, target_relative->q_target, target_relative->q_sensor, target_relative->type); +} + /** * @brief Send a target_relative message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_velocity_limits.h b/development/mavlink_msg_velocity_limits.h index a4d981e4..3ef48cc9 100644 --- a/development/mavlink_msg_velocity_limits.h +++ b/development/mavlink_msg_velocity_limits.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_velocity_limits_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN, MAVLINK_MSG_ID_VELOCITY_LIMITS_CRC); } +/** + * @brief Pack a velocity_limits 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 horizontal_speed_limit [m/s] Limit for horizontal movement in MAV_FRAME_LOCAL_NED. NaN: No limit applied + * @param vertical_speed_limit [m/s] Limit for vertical movement in MAV_FRAME_LOCAL_NED. NaN: No limit applied + * @param yaw_rate_limit [rad/s] Limit for vehicle turn rate around its yaw axis. NaN: No limit applied + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_velocity_limits_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float horizontal_speed_limit, float vertical_speed_limit, float yaw_rate_limit) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN]; + _mav_put_float(buf, 0, horizontal_speed_limit); + _mav_put_float(buf, 4, vertical_speed_limit); + _mav_put_float(buf, 8, yaw_rate_limit); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN); +#else + mavlink_velocity_limits_t packet; + packet.horizontal_speed_limit = horizontal_speed_limit; + packet.vertical_speed_limit = vertical_speed_limit; + packet.yaw_rate_limit = yaw_rate_limit; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_VELOCITY_LIMITS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN, MAVLINK_MSG_ID_VELOCITY_LIMITS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VELOCITY_LIMITS_MIN_LEN, MAVLINK_MSG_ID_VELOCITY_LIMITS_LEN); +#endif +} + /** * @brief Pack a velocity_limits message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_velocity_limits_encode_chan(uint8_t system_id return mavlink_msg_velocity_limits_pack_chan(system_id, component_id, chan, msg, velocity_limits->horizontal_speed_limit, velocity_limits->vertical_speed_limit, velocity_limits->yaw_rate_limit); } +/** + * @brief Encode a velocity_limits struct with provided status structure + * + * @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 velocity_limits C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_velocity_limits_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_velocity_limits_t* velocity_limits) +{ + return mavlink_msg_velocity_limits_pack_status(system_id, component_id, _status, msg, velocity_limits->horizontal_speed_limit, velocity_limits->vertical_speed_limit, velocity_limits->yaw_rate_limit); +} + /** * @brief Send a velocity_limits message * @param chan MAVLink channel to send the message diff --git a/development/mavlink_msg_wifi_network_info.h b/development/mavlink_msg_wifi_network_info.h index 90f932a4..958963f9 100644 --- a/development/mavlink_msg_wifi_network_info.h +++ b/development/mavlink_msg_wifi_network_info.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_wifi_network_info_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC); } +/** + * @brief Pack a wifi_network_info 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 ssid Name of Wi-Fi network (SSID). + * @param channel_id WiFi network operating channel ID. Set to 0 if unknown or unidentified. + * @param signal_quality [%] WiFi network signal quality. + * @param data_rate [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied. + * @param security WiFi network security type. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wifi_network_info_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *ssid, uint8_t channel_id, uint8_t signal_quality, uint16_t data_rate, uint8_t security) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN]; + _mav_put_uint16_t(buf, 0, data_rate); + _mav_put_uint8_t(buf, 34, channel_id); + _mav_put_uint8_t(buf, 35, signal_quality); + _mav_put_uint8_t(buf, 36, security); + _mav_put_char_array(buf, 2, ssid, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN); +#else + mavlink_wifi_network_info_t packet; + packet.data_rate = data_rate; + packet.channel_id = channel_id; + packet.signal_quality = signal_quality; + packet.security = security; + mav_array_memcpy(packet.ssid, ssid, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIFI_NETWORK_INFO; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN); +#endif +} + /** * @brief Pack a wifi_network_info message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_wifi_network_info_encode_chan(uint8_t system_ return mavlink_msg_wifi_network_info_pack_chan(system_id, component_id, chan, msg, wifi_network_info->ssid, wifi_network_info->channel_id, wifi_network_info->signal_quality, wifi_network_info->data_rate, wifi_network_info->security); } +/** + * @brief Encode a wifi_network_info struct with provided status structure + * + * @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 wifi_network_info C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wifi_network_info_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_wifi_network_info_t* wifi_network_info) +{ + return mavlink_msg_wifi_network_info_pack_status(system_id, component_id, _status, msg, wifi_network_info->ssid, wifi_network_info->channel_id, wifi_network_info->signal_quality, wifi_network_info->data_rate, wifi_network_info->security); +} + /** * @brief Send a wifi_network_info message * @param chan MAVLink channel to send the message diff --git a/development/version.h b/development/version.h index 4f4c42be..e30baa95 100644 --- a/development/version.h +++ b/development/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/icarous/icarous.h b/icarous/icarous.h index d48487af..1f0081c2 100644 --- a/icarous/icarous.h +++ b/icarous/icarous.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_ICAROUS.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_ICAROUS_XML_HASH 3103496647561256558 +#define MAVLINK_ICAROUS_XML_HASH 5764215696998564492 #ifdef __cplusplus extern "C" { diff --git a/icarous/mavlink.h b/icarous/mavlink.h index 32dcc561..0c288b59 100644 --- a/icarous/mavlink.h +++ b/icarous/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 3103496647561256558 +#define MAVLINK_PRIMARY_XML_HASH 5764215696998564492 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/icarous/mavlink_msg_icarous_heartbeat.h b/icarous/mavlink_msg_icarous_heartbeat.h index 8a1d9ba9..b8bff805 100644 --- a/icarous/mavlink_msg_icarous_heartbeat.h +++ b/icarous/mavlink_msg_icarous_heartbeat.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_icarous_heartbeat_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_CRC); } +/** + * @brief Pack a icarous_heartbeat 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 status See the FMS_STATE enum. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_icarous_heartbeat_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN]; + _mav_put_uint8_t(buf, 0, status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN); +#else + mavlink_icarous_heartbeat_t packet; + packet.status = status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ICAROUS_HEARTBEAT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_LEN); +#endif +} + /** * @brief Pack a icarous_heartbeat message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_icarous_heartbeat_encode_chan(uint8_t system_ return mavlink_msg_icarous_heartbeat_pack_chan(system_id, component_id, chan, msg, icarous_heartbeat->status); } +/** + * @brief Encode a icarous_heartbeat struct with provided status structure + * + * @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 icarous_heartbeat C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_icarous_heartbeat_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_icarous_heartbeat_t* icarous_heartbeat) +{ + return mavlink_msg_icarous_heartbeat_pack_status(system_id, component_id, _status, msg, icarous_heartbeat->status); +} + /** * @brief Send a icarous_heartbeat message * @param chan MAVLink channel to send the message diff --git a/icarous/mavlink_msg_icarous_kinematic_bands.h b/icarous/mavlink_msg_icarous_kinematic_bands.h index dfe6b9d3..47087f88 100644 --- a/icarous/mavlink_msg_icarous_kinematic_bands.h +++ b/icarous/mavlink_msg_icarous_kinematic_bands.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_icarous_kinematic_bands_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_CRC); } +/** + * @brief Pack a icarous_kinematic_bands 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 numBands Number of track bands + * @param type1 See the TRACK_BAND_TYPES enum. + * @param min1 [deg] min angle (degrees) + * @param max1 [deg] max angle (degrees) + * @param type2 See the TRACK_BAND_TYPES enum. + * @param min2 [deg] min angle (degrees) + * @param max2 [deg] max angle (degrees) + * @param type3 See the TRACK_BAND_TYPES enum. + * @param min3 [deg] min angle (degrees) + * @param max3 [deg] max angle (degrees) + * @param type4 See the TRACK_BAND_TYPES enum. + * @param min4 [deg] min angle (degrees) + * @param max4 [deg] max angle (degrees) + * @param type5 See the TRACK_BAND_TYPES enum. + * @param min5 [deg] min angle (degrees) + * @param max5 [deg] max angle (degrees) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_icarous_kinematic_bands_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int8_t numBands, uint8_t type1, float min1, float max1, uint8_t type2, float min2, float max2, uint8_t type3, float min3, float max3, uint8_t type4, float min4, float max4, uint8_t type5, float min5, float max5) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN]; + _mav_put_float(buf, 0, min1); + _mav_put_float(buf, 4, max1); + _mav_put_float(buf, 8, min2); + _mav_put_float(buf, 12, max2); + _mav_put_float(buf, 16, min3); + _mav_put_float(buf, 20, max3); + _mav_put_float(buf, 24, min4); + _mav_put_float(buf, 28, max4); + _mav_put_float(buf, 32, min5); + _mav_put_float(buf, 36, max5); + _mav_put_int8_t(buf, 40, numBands); + _mav_put_uint8_t(buf, 41, type1); + _mav_put_uint8_t(buf, 42, type2); + _mav_put_uint8_t(buf, 43, type3); + _mav_put_uint8_t(buf, 44, type4); + _mav_put_uint8_t(buf, 45, type5); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN); +#else + mavlink_icarous_kinematic_bands_t packet; + packet.min1 = min1; + packet.max1 = max1; + packet.min2 = min2; + packet.max2 = max2; + packet.min3 = min3; + packet.max3 = max3; + packet.min4 = min4; + packet.max4 = max4; + packet.min5 = min5; + packet.max5 = max5; + packet.numBands = numBands; + packet.type1 = type1; + packet.type2 = type2; + packet.type3 = type3; + packet.type4 = type4; + packet.type5 = type5; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_MIN_LEN, MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_LEN); +#endif +} + /** * @brief Pack a icarous_kinematic_bands message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_icarous_kinematic_bands_encode_chan(uint8_t s return mavlink_msg_icarous_kinematic_bands_pack_chan(system_id, component_id, chan, msg, icarous_kinematic_bands->numBands, icarous_kinematic_bands->type1, icarous_kinematic_bands->min1, icarous_kinematic_bands->max1, icarous_kinematic_bands->type2, icarous_kinematic_bands->min2, icarous_kinematic_bands->max2, icarous_kinematic_bands->type3, icarous_kinematic_bands->min3, icarous_kinematic_bands->max3, icarous_kinematic_bands->type4, icarous_kinematic_bands->min4, icarous_kinematic_bands->max4, icarous_kinematic_bands->type5, icarous_kinematic_bands->min5, icarous_kinematic_bands->max5); } +/** + * @brief Encode a icarous_kinematic_bands struct with provided status structure + * + * @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 icarous_kinematic_bands C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_icarous_kinematic_bands_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_icarous_kinematic_bands_t* icarous_kinematic_bands) +{ + return mavlink_msg_icarous_kinematic_bands_pack_status(system_id, component_id, _status, msg, icarous_kinematic_bands->numBands, icarous_kinematic_bands->type1, icarous_kinematic_bands->min1, icarous_kinematic_bands->max1, icarous_kinematic_bands->type2, icarous_kinematic_bands->min2, icarous_kinematic_bands->max2, icarous_kinematic_bands->type3, icarous_kinematic_bands->min3, icarous_kinematic_bands->max3, icarous_kinematic_bands->type4, icarous_kinematic_bands->min4, icarous_kinematic_bands->max4, icarous_kinematic_bands->type5, icarous_kinematic_bands->min5, icarous_kinematic_bands->max5); +} + /** * @brief Send a icarous_kinematic_bands message * @param chan MAVLink channel to send the message diff --git a/icarous/version.h b/icarous/version.h index 7bf133fe..b68008e6 100644 --- a/icarous/version.h +++ b/icarous/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 46 diff --git a/matrixpilot/matrixpilot.h b/matrixpilot/matrixpilot.h index 465a6535..af0718a4 100644 --- a/matrixpilot/matrixpilot.h +++ b/matrixpilot/matrixpilot.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_MATRIXPILOT.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_MATRIXPILOT_XML_HASH -5689291503530213427 +#define MAVLINK_MATRIXPILOT_XML_HASH 4721764854766189735 #ifdef __cplusplus extern "C" { diff --git a/matrixpilot/mavlink.h b/matrixpilot/mavlink.h index 8b14ebe1..498777e6 100644 --- a/matrixpilot/mavlink.h +++ b/matrixpilot/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -5689291503530213427 +#define MAVLINK_PRIMARY_XML_HASH 4721764854766189735 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/matrixpilot/mavlink_msg_airspeeds.h b/matrixpilot/mavlink_msg_airspeeds.h index b886723b..ea473ec8 100644 --- a/matrixpilot/mavlink_msg_airspeeds.h +++ b/matrixpilot/mavlink_msg_airspeeds.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_airspeeds_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AIRSPEEDS_MIN_LEN, MAVLINK_MSG_ID_AIRSPEEDS_LEN, MAVLINK_MSG_ID_AIRSPEEDS_CRC); } +/** + * @brief Pack a airspeeds 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 time_boot_ms Timestamp (milliseconds since system boot) + * @param airspeed_imu Airspeed estimate from IMU, cm/s + * @param airspeed_pitot Pitot measured forward airpseed, cm/s + * @param airspeed_hot_wire Hot wire anenometer measured airspeed, cm/s + * @param airspeed_ultrasonic Ultrasonic measured airspeed, cm/s + * @param aoa Angle of attack sensor, degrees * 10 + * @param aoy Yaw angle sensor, degrees * 10 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_airspeeds_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, int16_t airspeed_imu, int16_t airspeed_pitot, int16_t airspeed_hot_wire, int16_t airspeed_ultrasonic, int16_t aoa, int16_t aoy) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_AIRSPEEDS_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int16_t(buf, 4, airspeed_imu); + _mav_put_int16_t(buf, 6, airspeed_pitot); + _mav_put_int16_t(buf, 8, airspeed_hot_wire); + _mav_put_int16_t(buf, 10, airspeed_ultrasonic); + _mav_put_int16_t(buf, 12, aoa); + _mav_put_int16_t(buf, 14, aoy); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AIRSPEEDS_LEN); +#else + mavlink_airspeeds_t packet; + packet.time_boot_ms = time_boot_ms; + packet.airspeed_imu = airspeed_imu; + packet.airspeed_pitot = airspeed_pitot; + packet.airspeed_hot_wire = airspeed_hot_wire; + packet.airspeed_ultrasonic = airspeed_ultrasonic; + packet.aoa = aoa; + packet.aoy = aoy; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AIRSPEEDS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_AIRSPEEDS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEEDS_MIN_LEN, MAVLINK_MSG_ID_AIRSPEEDS_LEN, MAVLINK_MSG_ID_AIRSPEEDS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AIRSPEEDS_MIN_LEN, MAVLINK_MSG_ID_AIRSPEEDS_LEN); +#endif +} + /** * @brief Pack a airspeeds message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_airspeeds_encode_chan(uint8_t system_id, uint return mavlink_msg_airspeeds_pack_chan(system_id, component_id, chan, msg, airspeeds->time_boot_ms, airspeeds->airspeed_imu, airspeeds->airspeed_pitot, airspeeds->airspeed_hot_wire, airspeeds->airspeed_ultrasonic, airspeeds->aoa, airspeeds->aoy); } +/** + * @brief Encode a airspeeds struct with provided status structure + * + * @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 airspeeds C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_airspeeds_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_airspeeds_t* airspeeds) +{ + return mavlink_msg_airspeeds_pack_status(system_id, component_id, _status, msg, airspeeds->time_boot_ms, airspeeds->airspeed_imu, airspeeds->airspeed_pitot, airspeeds->airspeed_hot_wire, airspeeds->airspeed_ultrasonic, airspeeds->aoa, airspeeds->aoy); +} + /** * @brief Send a airspeeds message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_altitudes.h b/matrixpilot/mavlink_msg_altitudes.h index 0afb67ed..16e9e5a2 100644 --- a/matrixpilot/mavlink_msg_altitudes.h +++ b/matrixpilot/mavlink_msg_altitudes.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_altitudes_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ALTITUDES_MIN_LEN, MAVLINK_MSG_ID_ALTITUDES_LEN, MAVLINK_MSG_ID_ALTITUDES_CRC); } +/** + * @brief Pack a altitudes 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 time_boot_ms Timestamp (milliseconds since system boot) + * @param alt_gps GPS altitude (MSL) in meters, expressed as * 1000 (millimeters) + * @param alt_imu IMU altitude above ground in meters, expressed as * 1000 (millimeters) + * @param alt_barometric barometeric altitude above ground in meters, expressed as * 1000 (millimeters) + * @param alt_optical_flow Optical flow altitude above ground in meters, expressed as * 1000 (millimeters) + * @param alt_range_finder Rangefinder Altitude above ground in meters, expressed as * 1000 (millimeters) + * @param alt_extra Extra altitude above ground in meters, expressed as * 1000 (millimeters) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_altitudes_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, int32_t alt_gps, int32_t alt_imu, int32_t alt_barometric, int32_t alt_optical_flow, int32_t alt_range_finder, int32_t alt_extra) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ALTITUDES_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_int32_t(buf, 4, alt_gps); + _mav_put_int32_t(buf, 8, alt_imu); + _mav_put_int32_t(buf, 12, alt_barometric); + _mav_put_int32_t(buf, 16, alt_optical_flow); + _mav_put_int32_t(buf, 20, alt_range_finder); + _mav_put_int32_t(buf, 24, alt_extra); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ALTITUDES_LEN); +#else + mavlink_altitudes_t packet; + packet.time_boot_ms = time_boot_ms; + packet.alt_gps = alt_gps; + packet.alt_imu = alt_imu; + packet.alt_barometric = alt_barometric; + packet.alt_optical_flow = alt_optical_flow; + packet.alt_range_finder = alt_range_finder; + packet.alt_extra = alt_extra; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ALTITUDES_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ALTITUDES; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ALTITUDES_MIN_LEN, MAVLINK_MSG_ID_ALTITUDES_LEN, MAVLINK_MSG_ID_ALTITUDES_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ALTITUDES_MIN_LEN, MAVLINK_MSG_ID_ALTITUDES_LEN); +#endif +} + /** * @brief Pack a altitudes message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_altitudes_encode_chan(uint8_t system_id, uint return mavlink_msg_altitudes_pack_chan(system_id, component_id, chan, msg, altitudes->time_boot_ms, altitudes->alt_gps, altitudes->alt_imu, altitudes->alt_barometric, altitudes->alt_optical_flow, altitudes->alt_range_finder, altitudes->alt_extra); } +/** + * @brief Encode a altitudes struct with provided status structure + * + * @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 altitudes C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_altitudes_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_altitudes_t* altitudes) +{ + return mavlink_msg_altitudes_pack_status(system_id, component_id, _status, msg, altitudes->time_boot_ms, altitudes->alt_gps, altitudes->alt_imu, altitudes->alt_barometric, altitudes->alt_optical_flow, altitudes->alt_range_finder, altitudes->alt_extra); +} + /** * @brief Send a altitudes message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_buffer_function.h b/matrixpilot/mavlink_msg_flexifunction_buffer_function.h index b5d5d938..1bb04dff 100644 --- a/matrixpilot/mavlink_msg_flexifunction_buffer_function.h +++ b/matrixpilot/mavlink_msg_flexifunction_buffer_function.h @@ -97,6 +97,55 @@ static inline uint16_t mavlink_msg_flexifunction_buffer_function_pack(uint8_t sy return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_CRC); } +/** + * @brief Pack a flexifunction_buffer_function 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 target_system System ID + * @param target_component Component ID + * @param func_index Function index + * @param func_count Total count of functions + * @param data_address Address in the flexifunction data, Set to 0xFFFF to use address in target memory + * @param data_size Size of the + * @param data Settings data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_buffer_function_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t func_index, uint16_t func_count, uint16_t data_address, uint16_t data_size, const int8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN]; + _mav_put_uint16_t(buf, 0, func_index); + _mav_put_uint16_t(buf, 2, func_count); + _mav_put_uint16_t(buf, 4, data_address); + _mav_put_uint16_t(buf, 6, data_size); + _mav_put_uint8_t(buf, 8, target_system); + _mav_put_uint8_t(buf, 9, target_component); + _mav_put_int8_t_array(buf, 10, data, 48); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN); +#else + mavlink_flexifunction_buffer_function_t packet; + packet.func_index = func_index; + packet.func_count = func_count; + packet.data_address = data_address; + packet.data_size = data_size; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.data, data, sizeof(int8_t)*48); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_LEN); +#endif +} + /** * @brief Pack a flexifunction_buffer_function message on a channel * @param system_id ID of this system @@ -169,6 +218,20 @@ static inline uint16_t mavlink_msg_flexifunction_buffer_function_encode_chan(uin return mavlink_msg_flexifunction_buffer_function_pack_chan(system_id, component_id, chan, msg, flexifunction_buffer_function->target_system, flexifunction_buffer_function->target_component, flexifunction_buffer_function->func_index, flexifunction_buffer_function->func_count, flexifunction_buffer_function->data_address, flexifunction_buffer_function->data_size, flexifunction_buffer_function->data); } +/** + * @brief Encode a flexifunction_buffer_function struct with provided status structure + * + * @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 flexifunction_buffer_function C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_buffer_function_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_buffer_function_t* flexifunction_buffer_function) +{ + return mavlink_msg_flexifunction_buffer_function_pack_status(system_id, component_id, _status, msg, flexifunction_buffer_function->target_system, flexifunction_buffer_function->target_component, flexifunction_buffer_function->func_index, flexifunction_buffer_function->func_count, flexifunction_buffer_function->data_address, flexifunction_buffer_function->data_size, flexifunction_buffer_function->data); +} + /** * @brief Send a flexifunction_buffer_function message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_buffer_function_ack.h b/matrixpilot/mavlink_msg_flexifunction_buffer_function_ack.h index b8d8dd2e..5041fa46 100644 --- a/matrixpilot/mavlink_msg_flexifunction_buffer_function_ack.h +++ b/matrixpilot/mavlink_msg_flexifunction_buffer_function_ack.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_flexifunction_buffer_function_ack_pack(uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_CRC); } +/** + * @brief Pack a flexifunction_buffer_function_ack 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 target_system System ID + * @param target_component Component ID + * @param func_index Function index + * @param result result of acknowledge, 0=fail, 1=good + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_buffer_function_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t func_index, uint16_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN]; + _mav_put_uint16_t(buf, 0, func_index); + _mav_put_uint16_t(buf, 2, result); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN); +#else + mavlink_flexifunction_buffer_function_ack_t packet; + packet.func_index = func_index; + packet.result = result; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_BUFFER_FUNCTION_ACK_LEN); +#endif +} + /** * @brief Pack a flexifunction_buffer_function_ack message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_flexifunction_buffer_function_ack_encode_chan return mavlink_msg_flexifunction_buffer_function_ack_pack_chan(system_id, component_id, chan, msg, flexifunction_buffer_function_ack->target_system, flexifunction_buffer_function_ack->target_component, flexifunction_buffer_function_ack->func_index, flexifunction_buffer_function_ack->result); } +/** + * @brief Encode a flexifunction_buffer_function_ack struct with provided status structure + * + * @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 flexifunction_buffer_function_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_buffer_function_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_buffer_function_ack_t* flexifunction_buffer_function_ack) +{ + return mavlink_msg_flexifunction_buffer_function_ack_pack_status(system_id, component_id, _status, msg, flexifunction_buffer_function_ack->target_system, flexifunction_buffer_function_ack->target_component, flexifunction_buffer_function_ack->func_index, flexifunction_buffer_function_ack->result); +} + /** * @brief Send a flexifunction_buffer_function_ack message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_command.h b/matrixpilot/mavlink_msg_flexifunction_command.h index 7de0d8c0..d61d9b6a 100644 --- a/matrixpilot/mavlink_msg_flexifunction_command.h +++ b/matrixpilot/mavlink_msg_flexifunction_command.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_flexifunction_command_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_CRC); } +/** + * @brief Pack a flexifunction_command 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 target_system System ID + * @param target_component Component ID + * @param command_type Flexifunction command type + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_command_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t command_type) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, command_type); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN); +#else + mavlink_flexifunction_command_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.command_type = command_type; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_LEN); +#endif +} + /** * @brief Pack a flexifunction_command message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_flexifunction_command_encode_chan(uint8_t sys return mavlink_msg_flexifunction_command_pack_chan(system_id, component_id, chan, msg, flexifunction_command->target_system, flexifunction_command->target_component, flexifunction_command->command_type); } +/** + * @brief Encode a flexifunction_command struct with provided status structure + * + * @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 flexifunction_command C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_command_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_command_t* flexifunction_command) +{ + return mavlink_msg_flexifunction_command_pack_status(system_id, component_id, _status, msg, flexifunction_command->target_system, flexifunction_command->target_component, flexifunction_command->command_type); +} + /** * @brief Send a flexifunction_command message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_command_ack.h b/matrixpilot/mavlink_msg_flexifunction_command_ack.h index 148bf3d8..f19deb93 100644 --- a/matrixpilot/mavlink_msg_flexifunction_command_ack.h +++ b/matrixpilot/mavlink_msg_flexifunction_command_ack.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_flexifunction_command_ack_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_CRC); } +/** + * @brief Pack a flexifunction_command_ack 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 command_type Command acknowledged + * @param result result of acknowledge + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_command_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t command_type, uint16_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN]; + _mav_put_uint16_t(buf, 0, command_type); + _mav_put_uint16_t(buf, 2, result); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN); +#else + mavlink_flexifunction_command_ack_t packet; + packet.command_type = command_type; + packet.result = result; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_COMMAND_ACK_LEN); +#endif +} + /** * @brief Pack a flexifunction_command_ack message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_flexifunction_command_ack_encode_chan(uint8_t return mavlink_msg_flexifunction_command_ack_pack_chan(system_id, component_id, chan, msg, flexifunction_command_ack->command_type, flexifunction_command_ack->result); } +/** + * @brief Encode a flexifunction_command_ack struct with provided status structure + * + * @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 flexifunction_command_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_command_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_command_ack_t* flexifunction_command_ack) +{ + return mavlink_msg_flexifunction_command_ack_pack_status(system_id, component_id, _status, msg, flexifunction_command_ack->command_type, flexifunction_command_ack->result); +} + /** * @brief Send a flexifunction_command_ack message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_directory.h b/matrixpilot/mavlink_msg_flexifunction_directory.h index 60602792..d5b8e8b1 100644 --- a/matrixpilot/mavlink_msg_flexifunction_directory.h +++ b/matrixpilot/mavlink_msg_flexifunction_directory.h @@ -91,6 +91,52 @@ static inline uint16_t mavlink_msg_flexifunction_directory_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_CRC); } +/** + * @brief Pack a flexifunction_directory 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 target_system System ID + * @param target_component Component ID + * @param directory_type 0=inputs, 1=outputs + * @param start_index index of first directory entry to write + * @param count count of directory entries to write + * @param directory_data Settings data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_directory_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t directory_type, uint8_t start_index, uint8_t count, const int8_t *directory_data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + _mav_put_uint8_t(buf, 2, directory_type); + _mav_put_uint8_t(buf, 3, start_index); + _mav_put_uint8_t(buf, 4, count); + _mav_put_int8_t_array(buf, 5, directory_data, 48); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN); +#else + mavlink_flexifunction_directory_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + packet.directory_type = directory_type; + packet.start_index = start_index; + packet.count = count; + mav_array_memcpy(packet.directory_data, directory_data, sizeof(int8_t)*48); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_LEN); +#endif +} + /** * @brief Pack a flexifunction_directory message on a channel * @param system_id ID of this system @@ -160,6 +206,20 @@ static inline uint16_t mavlink_msg_flexifunction_directory_encode_chan(uint8_t s return mavlink_msg_flexifunction_directory_pack_chan(system_id, component_id, chan, msg, flexifunction_directory->target_system, flexifunction_directory->target_component, flexifunction_directory->directory_type, flexifunction_directory->start_index, flexifunction_directory->count, flexifunction_directory->directory_data); } +/** + * @brief Encode a flexifunction_directory struct with provided status structure + * + * @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 flexifunction_directory C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_directory_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_directory_t* flexifunction_directory) +{ + return mavlink_msg_flexifunction_directory_pack_status(system_id, component_id, _status, msg, flexifunction_directory->target_system, flexifunction_directory->target_component, flexifunction_directory->directory_type, flexifunction_directory->start_index, flexifunction_directory->count, flexifunction_directory->directory_data); +} + /** * @brief Send a flexifunction_directory message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_directory_ack.h b/matrixpilot/mavlink_msg_flexifunction_directory_ack.h index 6f2e50f4..d86a8f7d 100644 --- a/matrixpilot/mavlink_msg_flexifunction_directory_ack.h +++ b/matrixpilot/mavlink_msg_flexifunction_directory_ack.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_flexifunction_directory_ack_pack(uint8_t syst return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_CRC); } +/** + * @brief Pack a flexifunction_directory_ack 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 target_system System ID + * @param target_component Component ID + * @param directory_type 0=inputs, 1=outputs + * @param start_index index of first directory entry to write + * @param count count of directory entries to write + * @param result result of acknowledge, 0=fail, 1=good + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_directory_ack_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t directory_type, uint8_t start_index, uint8_t count, uint16_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN]; + _mav_put_uint16_t(buf, 0, result); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_uint8_t(buf, 4, directory_type); + _mav_put_uint8_t(buf, 5, start_index); + _mav_put_uint8_t(buf, 6, count); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN); +#else + mavlink_flexifunction_directory_ack_t packet; + packet.result = result; + packet.target_system = target_system; + packet.target_component = target_component; + packet.directory_type = directory_type; + packet.start_index = start_index; + packet.count = count; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_DIRECTORY_ACK_LEN); +#endif +} + /** * @brief Pack a flexifunction_directory_ack message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_flexifunction_directory_ack_encode_chan(uint8 return mavlink_msg_flexifunction_directory_ack_pack_chan(system_id, component_id, chan, msg, flexifunction_directory_ack->target_system, flexifunction_directory_ack->target_component, flexifunction_directory_ack->directory_type, flexifunction_directory_ack->start_index, flexifunction_directory_ack->count, flexifunction_directory_ack->result); } +/** + * @brief Encode a flexifunction_directory_ack struct with provided status structure + * + * @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 flexifunction_directory_ack C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_directory_ack_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_directory_ack_t* flexifunction_directory_ack) +{ + return mavlink_msg_flexifunction_directory_ack_pack_status(system_id, component_id, _status, msg, flexifunction_directory_ack->target_system, flexifunction_directory_ack->target_component, flexifunction_directory_ack->directory_type, flexifunction_directory_ack->start_index, flexifunction_directory_ack->count, flexifunction_directory_ack->result); +} + /** * @brief Send a flexifunction_directory_ack message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_read_req.h b/matrixpilot/mavlink_msg_flexifunction_read_req.h index 84a3d551..b3a15c5c 100644 --- a/matrixpilot/mavlink_msg_flexifunction_read_req.h +++ b/matrixpilot/mavlink_msg_flexifunction_read_req.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_flexifunction_read_req_pack(uint8_t system_id return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_CRC); } +/** + * @brief Pack a flexifunction_read_req 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 target_system System ID + * @param target_component Component ID + * @param read_req_type Type of flexifunction data requested + * @param data_index index into data where needed + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_read_req_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, int16_t read_req_type, int16_t data_index) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN]; + _mav_put_int16_t(buf, 0, read_req_type); + _mav_put_int16_t(buf, 2, data_index); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN); +#else + mavlink_flexifunction_read_req_t packet; + packet.read_req_type = read_req_type; + packet.data_index = data_index; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_READ_REQ_LEN); +#endif +} + /** * @brief Pack a flexifunction_read_req message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_flexifunction_read_req_encode_chan(uint8_t sy return mavlink_msg_flexifunction_read_req_pack_chan(system_id, component_id, chan, msg, flexifunction_read_req->target_system, flexifunction_read_req->target_component, flexifunction_read_req->read_req_type, flexifunction_read_req->data_index); } +/** + * @brief Encode a flexifunction_read_req struct with provided status structure + * + * @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 flexifunction_read_req C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_read_req_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_read_req_t* flexifunction_read_req) +{ + return mavlink_msg_flexifunction_read_req_pack_status(system_id, component_id, _status, msg, flexifunction_read_req->target_system, flexifunction_read_req->target_component, flexifunction_read_req->read_req_type, flexifunction_read_req->data_index); +} + /** * @brief Send a flexifunction_read_req message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_flexifunction_set.h b/matrixpilot/mavlink_msg_flexifunction_set.h index 4705bb22..0e43ca2c 100644 --- a/matrixpilot/mavlink_msg_flexifunction_set.h +++ b/matrixpilot/mavlink_msg_flexifunction_set.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_flexifunction_set_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_CRC); } +/** + * @brief Pack a flexifunction_set 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_flexifunction_set_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN); +#else + mavlink_flexifunction_set_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FLEXIFUNCTION_SET; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_MIN_LEN, MAVLINK_MSG_ID_FLEXIFUNCTION_SET_LEN); +#endif +} + /** * @brief Pack a flexifunction_set message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_flexifunction_set_encode_chan(uint8_t system_ return mavlink_msg_flexifunction_set_pack_chan(system_id, component_id, chan, msg, flexifunction_set->target_system, flexifunction_set->target_component); } +/** + * @brief Encode a flexifunction_set struct with provided status structure + * + * @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 flexifunction_set C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_flexifunction_set_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_flexifunction_set_t* flexifunction_set) +{ + return mavlink_msg_flexifunction_set_pack_status(system_id, component_id, _status, msg, flexifunction_set->target_system, flexifunction_set->target_component); +} + /** * @brief Send a flexifunction_set message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f13.h b/matrixpilot/mavlink_msg_serial_udb_extra_f13.h index 4e4f71da..24ff226a 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f13.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f13.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f13_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_CRC); } +/** + * @brief Pack a serial_udb_extra_f13 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 sue_week_no Serial UDB Extra GPS Week Number + * @param sue_lat_origin Serial UDB Extra MP Origin Latitude + * @param sue_lon_origin Serial UDB Extra MP Origin Longitude + * @param sue_alt_origin Serial UDB Extra MP Origin Altitude Above Sea Level + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f13_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int16_t sue_week_no, int32_t sue_lat_origin, int32_t sue_lon_origin, int32_t sue_alt_origin) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN]; + _mav_put_int32_t(buf, 0, sue_lat_origin); + _mav_put_int32_t(buf, 4, sue_lon_origin); + _mav_put_int32_t(buf, 8, sue_alt_origin); + _mav_put_int16_t(buf, 12, sue_week_no); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN); +#else + mavlink_serial_udb_extra_f13_t packet; + packet.sue_lat_origin = sue_lat_origin; + packet.sue_lon_origin = sue_lon_origin; + packet.sue_alt_origin = sue_alt_origin; + packet.sue_week_no = sue_week_no; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F13_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f13 message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f13_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f13_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f13->sue_week_no, serial_udb_extra_f13->sue_lat_origin, serial_udb_extra_f13->sue_lon_origin, serial_udb_extra_f13->sue_alt_origin); } +/** + * @brief Encode a serial_udb_extra_f13 struct with provided status structure + * + * @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 serial_udb_extra_f13 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f13_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f13_t* serial_udb_extra_f13) +{ + return mavlink_msg_serial_udb_extra_f13_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f13->sue_week_no, serial_udb_extra_f13->sue_lat_origin, serial_udb_extra_f13->sue_lon_origin, serial_udb_extra_f13->sue_alt_origin); +} + /** * @brief Send a serial_udb_extra_f13 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f14.h b/matrixpilot/mavlink_msg_serial_udb_extra_f14.h index f278b733..6e6e5bd6 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f14.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f14.h @@ -123,6 +123,69 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f14_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_CRC); } +/** + * @brief Pack a serial_udb_extra_f14 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 sue_WIND_ESTIMATION Serial UDB Extra Wind Estimation Enabled + * @param sue_GPS_TYPE Serial UDB Extra Type of GPS Unit + * @param sue_DR Serial UDB Extra Dead Reckoning Enabled + * @param sue_BOARD_TYPE Serial UDB Extra Type of UDB Hardware + * @param sue_AIRFRAME Serial UDB Extra Type of Airframe + * @param sue_RCON Serial UDB Extra Reboot Register of DSPIC + * @param sue_TRAP_FLAGS Serial UDB Extra Last dspic Trap Flags + * @param sue_TRAP_SOURCE Serial UDB Extra Type Program Address of Last Trap + * @param sue_osc_fail_count Serial UDB Extra Number of Ocillator Failures + * @param sue_CLOCK_CONFIG Serial UDB Extra UDB Internal Clock Configuration + * @param sue_FLIGHT_PLAN_TYPE Serial UDB Extra Type of Flight Plan + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f14_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t sue_WIND_ESTIMATION, uint8_t sue_GPS_TYPE, uint8_t sue_DR, uint8_t sue_BOARD_TYPE, uint8_t sue_AIRFRAME, int16_t sue_RCON, int16_t sue_TRAP_FLAGS, uint32_t sue_TRAP_SOURCE, int16_t sue_osc_fail_count, uint8_t sue_CLOCK_CONFIG, uint8_t sue_FLIGHT_PLAN_TYPE) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN]; + _mav_put_uint32_t(buf, 0, sue_TRAP_SOURCE); + _mav_put_int16_t(buf, 4, sue_RCON); + _mav_put_int16_t(buf, 6, sue_TRAP_FLAGS); + _mav_put_int16_t(buf, 8, sue_osc_fail_count); + _mav_put_uint8_t(buf, 10, sue_WIND_ESTIMATION); + _mav_put_uint8_t(buf, 11, sue_GPS_TYPE); + _mav_put_uint8_t(buf, 12, sue_DR); + _mav_put_uint8_t(buf, 13, sue_BOARD_TYPE); + _mav_put_uint8_t(buf, 14, sue_AIRFRAME); + _mav_put_uint8_t(buf, 15, sue_CLOCK_CONFIG); + _mav_put_uint8_t(buf, 16, sue_FLIGHT_PLAN_TYPE); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN); +#else + mavlink_serial_udb_extra_f14_t packet; + packet.sue_TRAP_SOURCE = sue_TRAP_SOURCE; + packet.sue_RCON = sue_RCON; + packet.sue_TRAP_FLAGS = sue_TRAP_FLAGS; + packet.sue_osc_fail_count = sue_osc_fail_count; + packet.sue_WIND_ESTIMATION = sue_WIND_ESTIMATION; + packet.sue_GPS_TYPE = sue_GPS_TYPE; + packet.sue_DR = sue_DR; + packet.sue_BOARD_TYPE = sue_BOARD_TYPE; + packet.sue_AIRFRAME = sue_AIRFRAME; + packet.sue_CLOCK_CONFIG = sue_CLOCK_CONFIG; + packet.sue_FLIGHT_PLAN_TYPE = sue_FLIGHT_PLAN_TYPE; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F14_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f14 message on a channel * @param system_id ID of this system @@ -209,6 +272,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f14_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f14_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f14->sue_WIND_ESTIMATION, serial_udb_extra_f14->sue_GPS_TYPE, serial_udb_extra_f14->sue_DR, serial_udb_extra_f14->sue_BOARD_TYPE, serial_udb_extra_f14->sue_AIRFRAME, serial_udb_extra_f14->sue_RCON, serial_udb_extra_f14->sue_TRAP_FLAGS, serial_udb_extra_f14->sue_TRAP_SOURCE, serial_udb_extra_f14->sue_osc_fail_count, serial_udb_extra_f14->sue_CLOCK_CONFIG, serial_udb_extra_f14->sue_FLIGHT_PLAN_TYPE); } +/** + * @brief Encode a serial_udb_extra_f14 struct with provided status structure + * + * @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 serial_udb_extra_f14 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f14_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f14_t* serial_udb_extra_f14) +{ + return mavlink_msg_serial_udb_extra_f14_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f14->sue_WIND_ESTIMATION, serial_udb_extra_f14->sue_GPS_TYPE, serial_udb_extra_f14->sue_DR, serial_udb_extra_f14->sue_BOARD_TYPE, serial_udb_extra_f14->sue_AIRFRAME, serial_udb_extra_f14->sue_RCON, serial_udb_extra_f14->sue_TRAP_FLAGS, serial_udb_extra_f14->sue_TRAP_SOURCE, serial_udb_extra_f14->sue_osc_fail_count, serial_udb_extra_f14->sue_CLOCK_CONFIG, serial_udb_extra_f14->sue_FLIGHT_PLAN_TYPE); +} + /** * @brief Send a serial_udb_extra_f14 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f15.h b/matrixpilot/mavlink_msg_serial_udb_extra_f15.h index dc6e4673..dd9db765 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f15.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f15.h @@ -70,6 +70,42 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f15_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_CRC); } +/** + * @brief Pack a serial_udb_extra_f15 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 sue_ID_VEHICLE_MODEL_NAME Serial UDB Extra Model Name Of Vehicle + * @param sue_ID_VEHICLE_REGISTRATION Serial UDB Extra Registraton Number of Vehicle + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f15_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *sue_ID_VEHICLE_MODEL_NAME, const uint8_t *sue_ID_VEHICLE_REGISTRATION) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN]; + + _mav_put_uint8_t_array(buf, 0, sue_ID_VEHICLE_MODEL_NAME, 40); + _mav_put_uint8_t_array(buf, 40, sue_ID_VEHICLE_REGISTRATION, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN); +#else + mavlink_serial_udb_extra_f15_t packet; + + mav_array_memcpy(packet.sue_ID_VEHICLE_MODEL_NAME, sue_ID_VEHICLE_MODEL_NAME, sizeof(uint8_t)*40); + mav_array_memcpy(packet.sue_ID_VEHICLE_REGISTRATION, sue_ID_VEHICLE_REGISTRATION, sizeof(uint8_t)*20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F15_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f15 message on a channel * @param system_id ID of this system @@ -129,6 +165,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f15_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f15_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f15->sue_ID_VEHICLE_MODEL_NAME, serial_udb_extra_f15->sue_ID_VEHICLE_REGISTRATION); } +/** + * @brief Encode a serial_udb_extra_f15 struct with provided status structure + * + * @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 serial_udb_extra_f15 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f15_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f15_t* serial_udb_extra_f15) +{ + return mavlink_msg_serial_udb_extra_f15_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f15->sue_ID_VEHICLE_MODEL_NAME, serial_udb_extra_f15->sue_ID_VEHICLE_REGISTRATION); +} + /** * @brief Send a serial_udb_extra_f15 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f16.h b/matrixpilot/mavlink_msg_serial_udb_extra_f16.h index b683ab80..2662eebe 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f16.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f16.h @@ -70,6 +70,42 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f16_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_CRC); } +/** + * @brief Pack a serial_udb_extra_f16 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 sue_ID_LEAD_PILOT Serial UDB Extra Name of Expected Lead Pilot + * @param sue_ID_DIY_DRONES_URL Serial UDB Extra URL of Lead Pilot or Team + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f16_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint8_t *sue_ID_LEAD_PILOT, const uint8_t *sue_ID_DIY_DRONES_URL) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN]; + + _mav_put_uint8_t_array(buf, 0, sue_ID_LEAD_PILOT, 40); + _mav_put_uint8_t_array(buf, 40, sue_ID_DIY_DRONES_URL, 70); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN); +#else + mavlink_serial_udb_extra_f16_t packet; + + mav_array_memcpy(packet.sue_ID_LEAD_PILOT, sue_ID_LEAD_PILOT, sizeof(uint8_t)*40); + mav_array_memcpy(packet.sue_ID_DIY_DRONES_URL, sue_ID_DIY_DRONES_URL, sizeof(uint8_t)*70); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F16_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f16 message on a channel * @param system_id ID of this system @@ -129,6 +165,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f16_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f16_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f16->sue_ID_LEAD_PILOT, serial_udb_extra_f16->sue_ID_DIY_DRONES_URL); } +/** + * @brief Encode a serial_udb_extra_f16 struct with provided status structure + * + * @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 serial_udb_extra_f16 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f16_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f16_t* serial_udb_extra_f16) +{ + return mavlink_msg_serial_udb_extra_f16_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f16->sue_ID_LEAD_PILOT, serial_udb_extra_f16->sue_ID_DIY_DRONES_URL); +} + /** * @brief Send a serial_udb_extra_f16 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f17.h b/matrixpilot/mavlink_msg_serial_udb_extra_f17.h index 4fd35413..f5daa92f 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f17.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f17.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f17_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_CRC); } +/** + * @brief Pack a serial_udb_extra_f17 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 sue_feed_forward SUE Feed Forward Gain + * @param sue_turn_rate_nav SUE Max Turn Rate when Navigating + * @param sue_turn_rate_fbw SUE Max Turn Rate in Fly By Wire Mode + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f17_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float sue_feed_forward, float sue_turn_rate_nav, float sue_turn_rate_fbw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN]; + _mav_put_float(buf, 0, sue_feed_forward); + _mav_put_float(buf, 4, sue_turn_rate_nav); + _mav_put_float(buf, 8, sue_turn_rate_fbw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN); +#else + mavlink_serial_udb_extra_f17_t packet; + packet.sue_feed_forward = sue_feed_forward; + packet.sue_turn_rate_nav = sue_turn_rate_nav; + packet.sue_turn_rate_fbw = sue_turn_rate_fbw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F17_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f17 message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f17_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f17_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f17->sue_feed_forward, serial_udb_extra_f17->sue_turn_rate_nav, serial_udb_extra_f17->sue_turn_rate_fbw); } +/** + * @brief Encode a serial_udb_extra_f17 struct with provided status structure + * + * @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 serial_udb_extra_f17 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f17_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f17_t* serial_udb_extra_f17) +{ + return mavlink_msg_serial_udb_extra_f17_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f17->sue_feed_forward, serial_udb_extra_f17->sue_turn_rate_nav, serial_udb_extra_f17->sue_turn_rate_fbw); +} + /** * @brief Send a serial_udb_extra_f17 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f18.h b/matrixpilot/mavlink_msg_serial_udb_extra_f18.h index 480ea5bf..ad34afdd 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f18.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f18.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f18_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_CRC); } +/** + * @brief Pack a serial_udb_extra_f18 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 angle_of_attack_normal SUE Angle of Attack Normal + * @param angle_of_attack_inverted SUE Angle of Attack Inverted + * @param elevator_trim_normal SUE Elevator Trim Normal + * @param elevator_trim_inverted SUE Elevator Trim Inverted + * @param reference_speed SUE reference_speed + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f18_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float angle_of_attack_normal, float angle_of_attack_inverted, float elevator_trim_normal, float elevator_trim_inverted, float reference_speed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN]; + _mav_put_float(buf, 0, angle_of_attack_normal); + _mav_put_float(buf, 4, angle_of_attack_inverted); + _mav_put_float(buf, 8, elevator_trim_normal); + _mav_put_float(buf, 12, elevator_trim_inverted); + _mav_put_float(buf, 16, reference_speed); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN); +#else + mavlink_serial_udb_extra_f18_t packet; + packet.angle_of_attack_normal = angle_of_attack_normal; + packet.angle_of_attack_inverted = angle_of_attack_inverted; + packet.elevator_trim_normal = elevator_trim_normal; + packet.elevator_trim_inverted = elevator_trim_inverted; + packet.reference_speed = reference_speed; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F18_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f18 message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f18_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f18_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f18->angle_of_attack_normal, serial_udb_extra_f18->angle_of_attack_inverted, serial_udb_extra_f18->elevator_trim_normal, serial_udb_extra_f18->elevator_trim_inverted, serial_udb_extra_f18->reference_speed); } +/** + * @brief Encode a serial_udb_extra_f18 struct with provided status structure + * + * @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 serial_udb_extra_f18 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f18_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f18_t* serial_udb_extra_f18) +{ + return mavlink_msg_serial_udb_extra_f18_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f18->angle_of_attack_normal, serial_udb_extra_f18->angle_of_attack_inverted, serial_udb_extra_f18->elevator_trim_normal, serial_udb_extra_f18->elevator_trim_inverted, serial_udb_extra_f18->reference_speed); +} + /** * @brief Send a serial_udb_extra_f18 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f19.h b/matrixpilot/mavlink_msg_serial_udb_extra_f19.h index 9119f0ab..8e3cbd84 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f19.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f19.h @@ -105,6 +105,60 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f19_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_CRC); } +/** + * @brief Pack a serial_udb_extra_f19 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 sue_aileron_output_channel SUE aileron output channel + * @param sue_aileron_reversed SUE aileron reversed + * @param sue_elevator_output_channel SUE elevator output channel + * @param sue_elevator_reversed SUE elevator reversed + * @param sue_throttle_output_channel SUE throttle output channel + * @param sue_throttle_reversed SUE throttle reversed + * @param sue_rudder_output_channel SUE rudder output channel + * @param sue_rudder_reversed SUE rudder reversed + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f19_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t sue_aileron_output_channel, uint8_t sue_aileron_reversed, uint8_t sue_elevator_output_channel, uint8_t sue_elevator_reversed, uint8_t sue_throttle_output_channel, uint8_t sue_throttle_reversed, uint8_t sue_rudder_output_channel, uint8_t sue_rudder_reversed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN]; + _mav_put_uint8_t(buf, 0, sue_aileron_output_channel); + _mav_put_uint8_t(buf, 1, sue_aileron_reversed); + _mav_put_uint8_t(buf, 2, sue_elevator_output_channel); + _mav_put_uint8_t(buf, 3, sue_elevator_reversed); + _mav_put_uint8_t(buf, 4, sue_throttle_output_channel); + _mav_put_uint8_t(buf, 5, sue_throttle_reversed); + _mav_put_uint8_t(buf, 6, sue_rudder_output_channel); + _mav_put_uint8_t(buf, 7, sue_rudder_reversed); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN); +#else + mavlink_serial_udb_extra_f19_t packet; + packet.sue_aileron_output_channel = sue_aileron_output_channel; + packet.sue_aileron_reversed = sue_aileron_reversed; + packet.sue_elevator_output_channel = sue_elevator_output_channel; + packet.sue_elevator_reversed = sue_elevator_reversed; + packet.sue_throttle_output_channel = sue_throttle_output_channel; + packet.sue_throttle_reversed = sue_throttle_reversed; + packet.sue_rudder_output_channel = sue_rudder_output_channel; + packet.sue_rudder_reversed = sue_rudder_reversed; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F19_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f19 message on a channel * @param system_id ID of this system @@ -182,6 +236,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f19_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f19_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f19->sue_aileron_output_channel, serial_udb_extra_f19->sue_aileron_reversed, serial_udb_extra_f19->sue_elevator_output_channel, serial_udb_extra_f19->sue_elevator_reversed, serial_udb_extra_f19->sue_throttle_output_channel, serial_udb_extra_f19->sue_throttle_reversed, serial_udb_extra_f19->sue_rudder_output_channel, serial_udb_extra_f19->sue_rudder_reversed); } +/** + * @brief Encode a serial_udb_extra_f19 struct with provided status structure + * + * @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 serial_udb_extra_f19 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f19_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f19_t* serial_udb_extra_f19) +{ + return mavlink_msg_serial_udb_extra_f19_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f19->sue_aileron_output_channel, serial_udb_extra_f19->sue_aileron_reversed, serial_udb_extra_f19->sue_elevator_output_channel, serial_udb_extra_f19->sue_elevator_reversed, serial_udb_extra_f19->sue_throttle_output_channel, serial_udb_extra_f19->sue_throttle_reversed, serial_udb_extra_f19->sue_rudder_output_channel, serial_udb_extra_f19->sue_rudder_reversed); +} + /** * @brief Send a serial_udb_extra_f19 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f20.h b/matrixpilot/mavlink_msg_serial_udb_extra_f20.h index a4fb5299..99116ad4 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f20.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f20.h @@ -135,6 +135,75 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f20_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_CRC); } +/** + * @brief Pack a serial_udb_extra_f20 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 sue_number_of_inputs SUE Number of Input Channels + * @param sue_trim_value_input_1 SUE UDB PWM Trim Value on Input 1 + * @param sue_trim_value_input_2 SUE UDB PWM Trim Value on Input 2 + * @param sue_trim_value_input_3 SUE UDB PWM Trim Value on Input 3 + * @param sue_trim_value_input_4 SUE UDB PWM Trim Value on Input 4 + * @param sue_trim_value_input_5 SUE UDB PWM Trim Value on Input 5 + * @param sue_trim_value_input_6 SUE UDB PWM Trim Value on Input 6 + * @param sue_trim_value_input_7 SUE UDB PWM Trim Value on Input 7 + * @param sue_trim_value_input_8 SUE UDB PWM Trim Value on Input 8 + * @param sue_trim_value_input_9 SUE UDB PWM Trim Value on Input 9 + * @param sue_trim_value_input_10 SUE UDB PWM Trim Value on Input 10 + * @param sue_trim_value_input_11 SUE UDB PWM Trim Value on Input 11 + * @param sue_trim_value_input_12 SUE UDB PWM Trim Value on Input 12 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f20_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t sue_number_of_inputs, int16_t sue_trim_value_input_1, int16_t sue_trim_value_input_2, int16_t sue_trim_value_input_3, int16_t sue_trim_value_input_4, int16_t sue_trim_value_input_5, int16_t sue_trim_value_input_6, int16_t sue_trim_value_input_7, int16_t sue_trim_value_input_8, int16_t sue_trim_value_input_9, int16_t sue_trim_value_input_10, int16_t sue_trim_value_input_11, int16_t sue_trim_value_input_12) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN]; + _mav_put_int16_t(buf, 0, sue_trim_value_input_1); + _mav_put_int16_t(buf, 2, sue_trim_value_input_2); + _mav_put_int16_t(buf, 4, sue_trim_value_input_3); + _mav_put_int16_t(buf, 6, sue_trim_value_input_4); + _mav_put_int16_t(buf, 8, sue_trim_value_input_5); + _mav_put_int16_t(buf, 10, sue_trim_value_input_6); + _mav_put_int16_t(buf, 12, sue_trim_value_input_7); + _mav_put_int16_t(buf, 14, sue_trim_value_input_8); + _mav_put_int16_t(buf, 16, sue_trim_value_input_9); + _mav_put_int16_t(buf, 18, sue_trim_value_input_10); + _mav_put_int16_t(buf, 20, sue_trim_value_input_11); + _mav_put_int16_t(buf, 22, sue_trim_value_input_12); + _mav_put_uint8_t(buf, 24, sue_number_of_inputs); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN); +#else + mavlink_serial_udb_extra_f20_t packet; + packet.sue_trim_value_input_1 = sue_trim_value_input_1; + packet.sue_trim_value_input_2 = sue_trim_value_input_2; + packet.sue_trim_value_input_3 = sue_trim_value_input_3; + packet.sue_trim_value_input_4 = sue_trim_value_input_4; + packet.sue_trim_value_input_5 = sue_trim_value_input_5; + packet.sue_trim_value_input_6 = sue_trim_value_input_6; + packet.sue_trim_value_input_7 = sue_trim_value_input_7; + packet.sue_trim_value_input_8 = sue_trim_value_input_8; + packet.sue_trim_value_input_9 = sue_trim_value_input_9; + packet.sue_trim_value_input_10 = sue_trim_value_input_10; + packet.sue_trim_value_input_11 = sue_trim_value_input_11; + packet.sue_trim_value_input_12 = sue_trim_value_input_12; + packet.sue_number_of_inputs = sue_number_of_inputs; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F20_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f20 message on a channel * @param system_id ID of this system @@ -227,6 +296,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f20_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f20_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f20->sue_number_of_inputs, serial_udb_extra_f20->sue_trim_value_input_1, serial_udb_extra_f20->sue_trim_value_input_2, serial_udb_extra_f20->sue_trim_value_input_3, serial_udb_extra_f20->sue_trim_value_input_4, serial_udb_extra_f20->sue_trim_value_input_5, serial_udb_extra_f20->sue_trim_value_input_6, serial_udb_extra_f20->sue_trim_value_input_7, serial_udb_extra_f20->sue_trim_value_input_8, serial_udb_extra_f20->sue_trim_value_input_9, serial_udb_extra_f20->sue_trim_value_input_10, serial_udb_extra_f20->sue_trim_value_input_11, serial_udb_extra_f20->sue_trim_value_input_12); } +/** + * @brief Encode a serial_udb_extra_f20 struct with provided status structure + * + * @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 serial_udb_extra_f20 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f20_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f20_t* serial_udb_extra_f20) +{ + return mavlink_msg_serial_udb_extra_f20_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f20->sue_number_of_inputs, serial_udb_extra_f20->sue_trim_value_input_1, serial_udb_extra_f20->sue_trim_value_input_2, serial_udb_extra_f20->sue_trim_value_input_3, serial_udb_extra_f20->sue_trim_value_input_4, serial_udb_extra_f20->sue_trim_value_input_5, serial_udb_extra_f20->sue_trim_value_input_6, serial_udb_extra_f20->sue_trim_value_input_7, serial_udb_extra_f20->sue_trim_value_input_8, serial_udb_extra_f20->sue_trim_value_input_9, serial_udb_extra_f20->sue_trim_value_input_10, serial_udb_extra_f20->sue_trim_value_input_11, serial_udb_extra_f20->sue_trim_value_input_12); +} + /** * @brief Send a serial_udb_extra_f20 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f21.h b/matrixpilot/mavlink_msg_serial_udb_extra_f21.h index af4e2f60..0984b69e 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f21.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f21.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f21_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_CRC); } +/** + * @brief Pack a serial_udb_extra_f21 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 sue_accel_x_offset SUE X accelerometer offset + * @param sue_accel_y_offset SUE Y accelerometer offset + * @param sue_accel_z_offset SUE Z accelerometer offset + * @param sue_gyro_x_offset SUE X gyro offset + * @param sue_gyro_y_offset SUE Y gyro offset + * @param sue_gyro_z_offset SUE Z gyro offset + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f21_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int16_t sue_accel_x_offset, int16_t sue_accel_y_offset, int16_t sue_accel_z_offset, int16_t sue_gyro_x_offset, int16_t sue_gyro_y_offset, int16_t sue_gyro_z_offset) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN]; + _mav_put_int16_t(buf, 0, sue_accel_x_offset); + _mav_put_int16_t(buf, 2, sue_accel_y_offset); + _mav_put_int16_t(buf, 4, sue_accel_z_offset); + _mav_put_int16_t(buf, 6, sue_gyro_x_offset); + _mav_put_int16_t(buf, 8, sue_gyro_y_offset); + _mav_put_int16_t(buf, 10, sue_gyro_z_offset); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN); +#else + mavlink_serial_udb_extra_f21_t packet; + packet.sue_accel_x_offset = sue_accel_x_offset; + packet.sue_accel_y_offset = sue_accel_y_offset; + packet.sue_accel_z_offset = sue_accel_z_offset; + packet.sue_gyro_x_offset = sue_gyro_x_offset; + packet.sue_gyro_y_offset = sue_gyro_y_offset; + packet.sue_gyro_z_offset = sue_gyro_z_offset; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F21_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f21 message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f21_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f21_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f21->sue_accel_x_offset, serial_udb_extra_f21->sue_accel_y_offset, serial_udb_extra_f21->sue_accel_z_offset, serial_udb_extra_f21->sue_gyro_x_offset, serial_udb_extra_f21->sue_gyro_y_offset, serial_udb_extra_f21->sue_gyro_z_offset); } +/** + * @brief Encode a serial_udb_extra_f21 struct with provided status structure + * + * @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 serial_udb_extra_f21 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f21_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f21_t* serial_udb_extra_f21) +{ + return mavlink_msg_serial_udb_extra_f21_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f21->sue_accel_x_offset, serial_udb_extra_f21->sue_accel_y_offset, serial_udb_extra_f21->sue_accel_z_offset, serial_udb_extra_f21->sue_gyro_x_offset, serial_udb_extra_f21->sue_gyro_y_offset, serial_udb_extra_f21->sue_gyro_z_offset); +} + /** * @brief Send a serial_udb_extra_f21 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f22.h b/matrixpilot/mavlink_msg_serial_udb_extra_f22.h index a139fa4b..d2aa61c7 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f22.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f22.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f22_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_CRC); } +/** + * @brief Pack a serial_udb_extra_f22 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 sue_accel_x_at_calibration SUE X accelerometer at calibration time + * @param sue_accel_y_at_calibration SUE Y accelerometer at calibration time + * @param sue_accel_z_at_calibration SUE Z accelerometer at calibration time + * @param sue_gyro_x_at_calibration SUE X gyro at calibration time + * @param sue_gyro_y_at_calibration SUE Y gyro at calibration time + * @param sue_gyro_z_at_calibration SUE Z gyro at calibration time + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f22_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + int16_t sue_accel_x_at_calibration, int16_t sue_accel_y_at_calibration, int16_t sue_accel_z_at_calibration, int16_t sue_gyro_x_at_calibration, int16_t sue_gyro_y_at_calibration, int16_t sue_gyro_z_at_calibration) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN]; + _mav_put_int16_t(buf, 0, sue_accel_x_at_calibration); + _mav_put_int16_t(buf, 2, sue_accel_y_at_calibration); + _mav_put_int16_t(buf, 4, sue_accel_z_at_calibration); + _mav_put_int16_t(buf, 6, sue_gyro_x_at_calibration); + _mav_put_int16_t(buf, 8, sue_gyro_y_at_calibration); + _mav_put_int16_t(buf, 10, sue_gyro_z_at_calibration); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN); +#else + mavlink_serial_udb_extra_f22_t packet; + packet.sue_accel_x_at_calibration = sue_accel_x_at_calibration; + packet.sue_accel_y_at_calibration = sue_accel_y_at_calibration; + packet.sue_accel_z_at_calibration = sue_accel_z_at_calibration; + packet.sue_gyro_x_at_calibration = sue_gyro_x_at_calibration; + packet.sue_gyro_y_at_calibration = sue_gyro_y_at_calibration; + packet.sue_gyro_z_at_calibration = sue_gyro_z_at_calibration; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F22_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f22 message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f22_encode_chan(uint8_t syst return mavlink_msg_serial_udb_extra_f22_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f22->sue_accel_x_at_calibration, serial_udb_extra_f22->sue_accel_y_at_calibration, serial_udb_extra_f22->sue_accel_z_at_calibration, serial_udb_extra_f22->sue_gyro_x_at_calibration, serial_udb_extra_f22->sue_gyro_y_at_calibration, serial_udb_extra_f22->sue_gyro_z_at_calibration); } +/** + * @brief Encode a serial_udb_extra_f22 struct with provided status structure + * + * @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 serial_udb_extra_f22 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f22_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f22_t* serial_udb_extra_f22) +{ + return mavlink_msg_serial_udb_extra_f22_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f22->sue_accel_x_at_calibration, serial_udb_extra_f22->sue_accel_y_at_calibration, serial_udb_extra_f22->sue_accel_z_at_calibration, serial_udb_extra_f22->sue_gyro_x_at_calibration, serial_udb_extra_f22->sue_gyro_y_at_calibration, serial_udb_extra_f22->sue_gyro_z_at_calibration); +} + /** * @brief Send a serial_udb_extra_f22 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f2_a.h b/matrixpilot/mavlink_msg_serial_udb_extra_f2_a.h index a4b378a8..c5182fd7 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f2_a.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f2_a.h @@ -219,6 +219,117 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f2_a_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_CRC); } +/** + * @brief Pack a serial_udb_extra_f2_a 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 sue_time Serial UDB Extra Time + * @param sue_status Serial UDB Extra Status + * @param sue_latitude Serial UDB Extra Latitude + * @param sue_longitude Serial UDB Extra Longitude + * @param sue_altitude Serial UDB Extra Altitude + * @param sue_waypoint_index Serial UDB Extra Waypoint Index + * @param sue_rmat0 Serial UDB Extra Rmat 0 + * @param sue_rmat1 Serial UDB Extra Rmat 1 + * @param sue_rmat2 Serial UDB Extra Rmat 2 + * @param sue_rmat3 Serial UDB Extra Rmat 3 + * @param sue_rmat4 Serial UDB Extra Rmat 4 + * @param sue_rmat5 Serial UDB Extra Rmat 5 + * @param sue_rmat6 Serial UDB Extra Rmat 6 + * @param sue_rmat7 Serial UDB Extra Rmat 7 + * @param sue_rmat8 Serial UDB Extra Rmat 8 + * @param sue_cog Serial UDB Extra GPS Course Over Ground + * @param sue_sog Serial UDB Extra Speed Over Ground + * @param sue_cpu_load Serial UDB Extra CPU Load + * @param sue_air_speed_3DIMU Serial UDB Extra 3D IMU Air Speed + * @param sue_estimated_wind_0 Serial UDB Extra Estimated Wind 0 + * @param sue_estimated_wind_1 Serial UDB Extra Estimated Wind 1 + * @param sue_estimated_wind_2 Serial UDB Extra Estimated Wind 2 + * @param sue_magFieldEarth0 Serial UDB Extra Magnetic Field Earth 0 + * @param sue_magFieldEarth1 Serial UDB Extra Magnetic Field Earth 1 + * @param sue_magFieldEarth2 Serial UDB Extra Magnetic Field Earth 2 + * @param sue_svs Serial UDB Extra Number of Satellites in View + * @param sue_hdop Serial UDB Extra GPS Horizontal Dilution of Precision + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f2_a_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t sue_time, uint8_t sue_status, int32_t sue_latitude, int32_t sue_longitude, int32_t sue_altitude, uint16_t sue_waypoint_index, int16_t sue_rmat0, int16_t sue_rmat1, int16_t sue_rmat2, int16_t sue_rmat3, int16_t sue_rmat4, int16_t sue_rmat5, int16_t sue_rmat6, int16_t sue_rmat7, int16_t sue_rmat8, uint16_t sue_cog, int16_t sue_sog, uint16_t sue_cpu_load, uint16_t sue_air_speed_3DIMU, int16_t sue_estimated_wind_0, int16_t sue_estimated_wind_1, int16_t sue_estimated_wind_2, int16_t sue_magFieldEarth0, int16_t sue_magFieldEarth1, int16_t sue_magFieldEarth2, int16_t sue_svs, int16_t sue_hdop) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN]; + _mav_put_uint32_t(buf, 0, sue_time); + _mav_put_int32_t(buf, 4, sue_latitude); + _mav_put_int32_t(buf, 8, sue_longitude); + _mav_put_int32_t(buf, 12, sue_altitude); + _mav_put_uint16_t(buf, 16, sue_waypoint_index); + _mav_put_int16_t(buf, 18, sue_rmat0); + _mav_put_int16_t(buf, 20, sue_rmat1); + _mav_put_int16_t(buf, 22, sue_rmat2); + _mav_put_int16_t(buf, 24, sue_rmat3); + _mav_put_int16_t(buf, 26, sue_rmat4); + _mav_put_int16_t(buf, 28, sue_rmat5); + _mav_put_int16_t(buf, 30, sue_rmat6); + _mav_put_int16_t(buf, 32, sue_rmat7); + _mav_put_int16_t(buf, 34, sue_rmat8); + _mav_put_uint16_t(buf, 36, sue_cog); + _mav_put_int16_t(buf, 38, sue_sog); + _mav_put_uint16_t(buf, 40, sue_cpu_load); + _mav_put_uint16_t(buf, 42, sue_air_speed_3DIMU); + _mav_put_int16_t(buf, 44, sue_estimated_wind_0); + _mav_put_int16_t(buf, 46, sue_estimated_wind_1); + _mav_put_int16_t(buf, 48, sue_estimated_wind_2); + _mav_put_int16_t(buf, 50, sue_magFieldEarth0); + _mav_put_int16_t(buf, 52, sue_magFieldEarth1); + _mav_put_int16_t(buf, 54, sue_magFieldEarth2); + _mav_put_int16_t(buf, 56, sue_svs); + _mav_put_int16_t(buf, 58, sue_hdop); + _mav_put_uint8_t(buf, 60, sue_status); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN); +#else + mavlink_serial_udb_extra_f2_a_t packet; + packet.sue_time = sue_time; + packet.sue_latitude = sue_latitude; + packet.sue_longitude = sue_longitude; + packet.sue_altitude = sue_altitude; + packet.sue_waypoint_index = sue_waypoint_index; + packet.sue_rmat0 = sue_rmat0; + packet.sue_rmat1 = sue_rmat1; + packet.sue_rmat2 = sue_rmat2; + packet.sue_rmat3 = sue_rmat3; + packet.sue_rmat4 = sue_rmat4; + packet.sue_rmat5 = sue_rmat5; + packet.sue_rmat6 = sue_rmat6; + packet.sue_rmat7 = sue_rmat7; + packet.sue_rmat8 = sue_rmat8; + packet.sue_cog = sue_cog; + packet.sue_sog = sue_sog; + packet.sue_cpu_load = sue_cpu_load; + packet.sue_air_speed_3DIMU = sue_air_speed_3DIMU; + packet.sue_estimated_wind_0 = sue_estimated_wind_0; + packet.sue_estimated_wind_1 = sue_estimated_wind_1; + packet.sue_estimated_wind_2 = sue_estimated_wind_2; + packet.sue_magFieldEarth0 = sue_magFieldEarth0; + packet.sue_magFieldEarth1 = sue_magFieldEarth1; + packet.sue_magFieldEarth2 = sue_magFieldEarth2; + packet.sue_svs = sue_svs; + packet.sue_hdop = sue_hdop; + packet.sue_status = sue_status; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_A_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f2_a message on a channel * @param system_id ID of this system @@ -353,6 +464,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f2_a_encode_chan(uint8_t sys return mavlink_msg_serial_udb_extra_f2_a_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f2_a->sue_time, serial_udb_extra_f2_a->sue_status, serial_udb_extra_f2_a->sue_latitude, serial_udb_extra_f2_a->sue_longitude, serial_udb_extra_f2_a->sue_altitude, serial_udb_extra_f2_a->sue_waypoint_index, serial_udb_extra_f2_a->sue_rmat0, serial_udb_extra_f2_a->sue_rmat1, serial_udb_extra_f2_a->sue_rmat2, serial_udb_extra_f2_a->sue_rmat3, serial_udb_extra_f2_a->sue_rmat4, serial_udb_extra_f2_a->sue_rmat5, serial_udb_extra_f2_a->sue_rmat6, serial_udb_extra_f2_a->sue_rmat7, serial_udb_extra_f2_a->sue_rmat8, serial_udb_extra_f2_a->sue_cog, serial_udb_extra_f2_a->sue_sog, serial_udb_extra_f2_a->sue_cpu_load, serial_udb_extra_f2_a->sue_air_speed_3DIMU, serial_udb_extra_f2_a->sue_estimated_wind_0, serial_udb_extra_f2_a->sue_estimated_wind_1, serial_udb_extra_f2_a->sue_estimated_wind_2, serial_udb_extra_f2_a->sue_magFieldEarth0, serial_udb_extra_f2_a->sue_magFieldEarth1, serial_udb_extra_f2_a->sue_magFieldEarth2, serial_udb_extra_f2_a->sue_svs, serial_udb_extra_f2_a->sue_hdop); } +/** + * @brief Encode a serial_udb_extra_f2_a struct with provided status structure + * + * @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 serial_udb_extra_f2_a C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f2_a_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f2_a_t* serial_udb_extra_f2_a) +{ + return mavlink_msg_serial_udb_extra_f2_a_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f2_a->sue_time, serial_udb_extra_f2_a->sue_status, serial_udb_extra_f2_a->sue_latitude, serial_udb_extra_f2_a->sue_longitude, serial_udb_extra_f2_a->sue_altitude, serial_udb_extra_f2_a->sue_waypoint_index, serial_udb_extra_f2_a->sue_rmat0, serial_udb_extra_f2_a->sue_rmat1, serial_udb_extra_f2_a->sue_rmat2, serial_udb_extra_f2_a->sue_rmat3, serial_udb_extra_f2_a->sue_rmat4, serial_udb_extra_f2_a->sue_rmat5, serial_udb_extra_f2_a->sue_rmat6, serial_udb_extra_f2_a->sue_rmat7, serial_udb_extra_f2_a->sue_rmat8, serial_udb_extra_f2_a->sue_cog, serial_udb_extra_f2_a->sue_sog, serial_udb_extra_f2_a->sue_cpu_load, serial_udb_extra_f2_a->sue_air_speed_3DIMU, serial_udb_extra_f2_a->sue_estimated_wind_0, serial_udb_extra_f2_a->sue_estimated_wind_1, serial_udb_extra_f2_a->sue_estimated_wind_2, serial_udb_extra_f2_a->sue_magFieldEarth0, serial_udb_extra_f2_a->sue_magFieldEarth1, serial_udb_extra_f2_a->sue_magFieldEarth2, serial_udb_extra_f2_a->sue_svs, serial_udb_extra_f2_a->sue_hdop); +} + /** * @brief Send a serial_udb_extra_f2_a message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f2_b.h b/matrixpilot/mavlink_msg_serial_udb_extra_f2_b.h index b1194ef8..7ff4cc44 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f2_b.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f2_b.h @@ -357,6 +357,186 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f2_b_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_CRC); } +/** + * @brief Pack a serial_udb_extra_f2_b 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 sue_time Serial UDB Extra Time + * @param sue_pwm_input_1 Serial UDB Extra PWM Input Channel 1 + * @param sue_pwm_input_2 Serial UDB Extra PWM Input Channel 2 + * @param sue_pwm_input_3 Serial UDB Extra PWM Input Channel 3 + * @param sue_pwm_input_4 Serial UDB Extra PWM Input Channel 4 + * @param sue_pwm_input_5 Serial UDB Extra PWM Input Channel 5 + * @param sue_pwm_input_6 Serial UDB Extra PWM Input Channel 6 + * @param sue_pwm_input_7 Serial UDB Extra PWM Input Channel 7 + * @param sue_pwm_input_8 Serial UDB Extra PWM Input Channel 8 + * @param sue_pwm_input_9 Serial UDB Extra PWM Input Channel 9 + * @param sue_pwm_input_10 Serial UDB Extra PWM Input Channel 10 + * @param sue_pwm_input_11 Serial UDB Extra PWM Input Channel 11 + * @param sue_pwm_input_12 Serial UDB Extra PWM Input Channel 12 + * @param sue_pwm_output_1 Serial UDB Extra PWM Output Channel 1 + * @param sue_pwm_output_2 Serial UDB Extra PWM Output Channel 2 + * @param sue_pwm_output_3 Serial UDB Extra PWM Output Channel 3 + * @param sue_pwm_output_4 Serial UDB Extra PWM Output Channel 4 + * @param sue_pwm_output_5 Serial UDB Extra PWM Output Channel 5 + * @param sue_pwm_output_6 Serial UDB Extra PWM Output Channel 6 + * @param sue_pwm_output_7 Serial UDB Extra PWM Output Channel 7 + * @param sue_pwm_output_8 Serial UDB Extra PWM Output Channel 8 + * @param sue_pwm_output_9 Serial UDB Extra PWM Output Channel 9 + * @param sue_pwm_output_10 Serial UDB Extra PWM Output Channel 10 + * @param sue_pwm_output_11 Serial UDB Extra PWM Output Channel 11 + * @param sue_pwm_output_12 Serial UDB Extra PWM Output Channel 12 + * @param sue_imu_location_x Serial UDB Extra IMU Location X + * @param sue_imu_location_y Serial UDB Extra IMU Location Y + * @param sue_imu_location_z Serial UDB Extra IMU Location Z + * @param sue_location_error_earth_x Serial UDB Location Error Earth X + * @param sue_location_error_earth_y Serial UDB Location Error Earth Y + * @param sue_location_error_earth_z Serial UDB Location Error Earth Z + * @param sue_flags Serial UDB Extra Status Flags + * @param sue_osc_fails Serial UDB Extra Oscillator Failure Count + * @param sue_imu_velocity_x Serial UDB Extra IMU Velocity X + * @param sue_imu_velocity_y Serial UDB Extra IMU Velocity Y + * @param sue_imu_velocity_z Serial UDB Extra IMU Velocity Z + * @param sue_waypoint_goal_x Serial UDB Extra Current Waypoint Goal X + * @param sue_waypoint_goal_y Serial UDB Extra Current Waypoint Goal Y + * @param sue_waypoint_goal_z Serial UDB Extra Current Waypoint Goal Z + * @param sue_aero_x Aeroforce in UDB X Axis + * @param sue_aero_y Aeroforce in UDB Y Axis + * @param sue_aero_z Aeroforce in UDB Z axis + * @param sue_barom_temp SUE barometer temperature + * @param sue_barom_press SUE barometer pressure + * @param sue_barom_alt SUE barometer altitude + * @param sue_bat_volt SUE battery voltage + * @param sue_bat_amp SUE battery current + * @param sue_bat_amp_hours SUE battery milli amp hours used + * @param sue_desired_height Sue autopilot desired height + * @param sue_memory_stack_free Serial UDB Extra Stack Memory Free + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f2_b_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t sue_time, int16_t sue_pwm_input_1, int16_t sue_pwm_input_2, int16_t sue_pwm_input_3, int16_t sue_pwm_input_4, int16_t sue_pwm_input_5, int16_t sue_pwm_input_6, int16_t sue_pwm_input_7, int16_t sue_pwm_input_8, int16_t sue_pwm_input_9, int16_t sue_pwm_input_10, int16_t sue_pwm_input_11, int16_t sue_pwm_input_12, int16_t sue_pwm_output_1, int16_t sue_pwm_output_2, int16_t sue_pwm_output_3, int16_t sue_pwm_output_4, int16_t sue_pwm_output_5, int16_t sue_pwm_output_6, int16_t sue_pwm_output_7, int16_t sue_pwm_output_8, int16_t sue_pwm_output_9, int16_t sue_pwm_output_10, int16_t sue_pwm_output_11, int16_t sue_pwm_output_12, int16_t sue_imu_location_x, int16_t sue_imu_location_y, int16_t sue_imu_location_z, int16_t sue_location_error_earth_x, int16_t sue_location_error_earth_y, int16_t sue_location_error_earth_z, uint32_t sue_flags, int16_t sue_osc_fails, int16_t sue_imu_velocity_x, int16_t sue_imu_velocity_y, int16_t sue_imu_velocity_z, int16_t sue_waypoint_goal_x, int16_t sue_waypoint_goal_y, int16_t sue_waypoint_goal_z, int16_t sue_aero_x, int16_t sue_aero_y, int16_t sue_aero_z, int16_t sue_barom_temp, int32_t sue_barom_press, int32_t sue_barom_alt, int16_t sue_bat_volt, int16_t sue_bat_amp, int16_t sue_bat_amp_hours, int16_t sue_desired_height, int16_t sue_memory_stack_free) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN]; + _mav_put_uint32_t(buf, 0, sue_time); + _mav_put_uint32_t(buf, 4, sue_flags); + _mav_put_int32_t(buf, 8, sue_barom_press); + _mav_put_int32_t(buf, 12, sue_barom_alt); + _mav_put_int16_t(buf, 16, sue_pwm_input_1); + _mav_put_int16_t(buf, 18, sue_pwm_input_2); + _mav_put_int16_t(buf, 20, sue_pwm_input_3); + _mav_put_int16_t(buf, 22, sue_pwm_input_4); + _mav_put_int16_t(buf, 24, sue_pwm_input_5); + _mav_put_int16_t(buf, 26, sue_pwm_input_6); + _mav_put_int16_t(buf, 28, sue_pwm_input_7); + _mav_put_int16_t(buf, 30, sue_pwm_input_8); + _mav_put_int16_t(buf, 32, sue_pwm_input_9); + _mav_put_int16_t(buf, 34, sue_pwm_input_10); + _mav_put_int16_t(buf, 36, sue_pwm_input_11); + _mav_put_int16_t(buf, 38, sue_pwm_input_12); + _mav_put_int16_t(buf, 40, sue_pwm_output_1); + _mav_put_int16_t(buf, 42, sue_pwm_output_2); + _mav_put_int16_t(buf, 44, sue_pwm_output_3); + _mav_put_int16_t(buf, 46, sue_pwm_output_4); + _mav_put_int16_t(buf, 48, sue_pwm_output_5); + _mav_put_int16_t(buf, 50, sue_pwm_output_6); + _mav_put_int16_t(buf, 52, sue_pwm_output_7); + _mav_put_int16_t(buf, 54, sue_pwm_output_8); + _mav_put_int16_t(buf, 56, sue_pwm_output_9); + _mav_put_int16_t(buf, 58, sue_pwm_output_10); + _mav_put_int16_t(buf, 60, sue_pwm_output_11); + _mav_put_int16_t(buf, 62, sue_pwm_output_12); + _mav_put_int16_t(buf, 64, sue_imu_location_x); + _mav_put_int16_t(buf, 66, sue_imu_location_y); + _mav_put_int16_t(buf, 68, sue_imu_location_z); + _mav_put_int16_t(buf, 70, sue_location_error_earth_x); + _mav_put_int16_t(buf, 72, sue_location_error_earth_y); + _mav_put_int16_t(buf, 74, sue_location_error_earth_z); + _mav_put_int16_t(buf, 76, sue_osc_fails); + _mav_put_int16_t(buf, 78, sue_imu_velocity_x); + _mav_put_int16_t(buf, 80, sue_imu_velocity_y); + _mav_put_int16_t(buf, 82, sue_imu_velocity_z); + _mav_put_int16_t(buf, 84, sue_waypoint_goal_x); + _mav_put_int16_t(buf, 86, sue_waypoint_goal_y); + _mav_put_int16_t(buf, 88, sue_waypoint_goal_z); + _mav_put_int16_t(buf, 90, sue_aero_x); + _mav_put_int16_t(buf, 92, sue_aero_y); + _mav_put_int16_t(buf, 94, sue_aero_z); + _mav_put_int16_t(buf, 96, sue_barom_temp); + _mav_put_int16_t(buf, 98, sue_bat_volt); + _mav_put_int16_t(buf, 100, sue_bat_amp); + _mav_put_int16_t(buf, 102, sue_bat_amp_hours); + _mav_put_int16_t(buf, 104, sue_desired_height); + _mav_put_int16_t(buf, 106, sue_memory_stack_free); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN); +#else + mavlink_serial_udb_extra_f2_b_t packet; + packet.sue_time = sue_time; + packet.sue_flags = sue_flags; + packet.sue_barom_press = sue_barom_press; + packet.sue_barom_alt = sue_barom_alt; + packet.sue_pwm_input_1 = sue_pwm_input_1; + packet.sue_pwm_input_2 = sue_pwm_input_2; + packet.sue_pwm_input_3 = sue_pwm_input_3; + packet.sue_pwm_input_4 = sue_pwm_input_4; + packet.sue_pwm_input_5 = sue_pwm_input_5; + packet.sue_pwm_input_6 = sue_pwm_input_6; + packet.sue_pwm_input_7 = sue_pwm_input_7; + packet.sue_pwm_input_8 = sue_pwm_input_8; + packet.sue_pwm_input_9 = sue_pwm_input_9; + packet.sue_pwm_input_10 = sue_pwm_input_10; + packet.sue_pwm_input_11 = sue_pwm_input_11; + packet.sue_pwm_input_12 = sue_pwm_input_12; + packet.sue_pwm_output_1 = sue_pwm_output_1; + packet.sue_pwm_output_2 = sue_pwm_output_2; + packet.sue_pwm_output_3 = sue_pwm_output_3; + packet.sue_pwm_output_4 = sue_pwm_output_4; + packet.sue_pwm_output_5 = sue_pwm_output_5; + packet.sue_pwm_output_6 = sue_pwm_output_6; + packet.sue_pwm_output_7 = sue_pwm_output_7; + packet.sue_pwm_output_8 = sue_pwm_output_8; + packet.sue_pwm_output_9 = sue_pwm_output_9; + packet.sue_pwm_output_10 = sue_pwm_output_10; + packet.sue_pwm_output_11 = sue_pwm_output_11; + packet.sue_pwm_output_12 = sue_pwm_output_12; + packet.sue_imu_location_x = sue_imu_location_x; + packet.sue_imu_location_y = sue_imu_location_y; + packet.sue_imu_location_z = sue_imu_location_z; + packet.sue_location_error_earth_x = sue_location_error_earth_x; + packet.sue_location_error_earth_y = sue_location_error_earth_y; + packet.sue_location_error_earth_z = sue_location_error_earth_z; + packet.sue_osc_fails = sue_osc_fails; + packet.sue_imu_velocity_x = sue_imu_velocity_x; + packet.sue_imu_velocity_y = sue_imu_velocity_y; + packet.sue_imu_velocity_z = sue_imu_velocity_z; + packet.sue_waypoint_goal_x = sue_waypoint_goal_x; + packet.sue_waypoint_goal_y = sue_waypoint_goal_y; + packet.sue_waypoint_goal_z = sue_waypoint_goal_z; + packet.sue_aero_x = sue_aero_x; + packet.sue_aero_y = sue_aero_y; + packet.sue_aero_z = sue_aero_z; + packet.sue_barom_temp = sue_barom_temp; + packet.sue_bat_volt = sue_bat_volt; + packet.sue_bat_amp = sue_bat_amp; + packet.sue_bat_amp_hours = sue_bat_amp_hours; + packet.sue_desired_height = sue_desired_height; + packet.sue_memory_stack_free = sue_memory_stack_free; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F2_B_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f2_b message on a channel * @param system_id ID of this system @@ -560,6 +740,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f2_b_encode_chan(uint8_t sys return mavlink_msg_serial_udb_extra_f2_b_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f2_b->sue_time, serial_udb_extra_f2_b->sue_pwm_input_1, serial_udb_extra_f2_b->sue_pwm_input_2, serial_udb_extra_f2_b->sue_pwm_input_3, serial_udb_extra_f2_b->sue_pwm_input_4, serial_udb_extra_f2_b->sue_pwm_input_5, serial_udb_extra_f2_b->sue_pwm_input_6, serial_udb_extra_f2_b->sue_pwm_input_7, serial_udb_extra_f2_b->sue_pwm_input_8, serial_udb_extra_f2_b->sue_pwm_input_9, serial_udb_extra_f2_b->sue_pwm_input_10, serial_udb_extra_f2_b->sue_pwm_input_11, serial_udb_extra_f2_b->sue_pwm_input_12, serial_udb_extra_f2_b->sue_pwm_output_1, serial_udb_extra_f2_b->sue_pwm_output_2, serial_udb_extra_f2_b->sue_pwm_output_3, serial_udb_extra_f2_b->sue_pwm_output_4, serial_udb_extra_f2_b->sue_pwm_output_5, serial_udb_extra_f2_b->sue_pwm_output_6, serial_udb_extra_f2_b->sue_pwm_output_7, serial_udb_extra_f2_b->sue_pwm_output_8, serial_udb_extra_f2_b->sue_pwm_output_9, serial_udb_extra_f2_b->sue_pwm_output_10, serial_udb_extra_f2_b->sue_pwm_output_11, serial_udb_extra_f2_b->sue_pwm_output_12, serial_udb_extra_f2_b->sue_imu_location_x, serial_udb_extra_f2_b->sue_imu_location_y, serial_udb_extra_f2_b->sue_imu_location_z, serial_udb_extra_f2_b->sue_location_error_earth_x, serial_udb_extra_f2_b->sue_location_error_earth_y, serial_udb_extra_f2_b->sue_location_error_earth_z, serial_udb_extra_f2_b->sue_flags, serial_udb_extra_f2_b->sue_osc_fails, serial_udb_extra_f2_b->sue_imu_velocity_x, serial_udb_extra_f2_b->sue_imu_velocity_y, serial_udb_extra_f2_b->sue_imu_velocity_z, serial_udb_extra_f2_b->sue_waypoint_goal_x, serial_udb_extra_f2_b->sue_waypoint_goal_y, serial_udb_extra_f2_b->sue_waypoint_goal_z, serial_udb_extra_f2_b->sue_aero_x, serial_udb_extra_f2_b->sue_aero_y, serial_udb_extra_f2_b->sue_aero_z, serial_udb_extra_f2_b->sue_barom_temp, serial_udb_extra_f2_b->sue_barom_press, serial_udb_extra_f2_b->sue_barom_alt, serial_udb_extra_f2_b->sue_bat_volt, serial_udb_extra_f2_b->sue_bat_amp, serial_udb_extra_f2_b->sue_bat_amp_hours, serial_udb_extra_f2_b->sue_desired_height, serial_udb_extra_f2_b->sue_memory_stack_free); } +/** + * @brief Encode a serial_udb_extra_f2_b struct with provided status structure + * + * @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 serial_udb_extra_f2_b C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f2_b_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f2_b_t* serial_udb_extra_f2_b) +{ + return mavlink_msg_serial_udb_extra_f2_b_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f2_b->sue_time, serial_udb_extra_f2_b->sue_pwm_input_1, serial_udb_extra_f2_b->sue_pwm_input_2, serial_udb_extra_f2_b->sue_pwm_input_3, serial_udb_extra_f2_b->sue_pwm_input_4, serial_udb_extra_f2_b->sue_pwm_input_5, serial_udb_extra_f2_b->sue_pwm_input_6, serial_udb_extra_f2_b->sue_pwm_input_7, serial_udb_extra_f2_b->sue_pwm_input_8, serial_udb_extra_f2_b->sue_pwm_input_9, serial_udb_extra_f2_b->sue_pwm_input_10, serial_udb_extra_f2_b->sue_pwm_input_11, serial_udb_extra_f2_b->sue_pwm_input_12, serial_udb_extra_f2_b->sue_pwm_output_1, serial_udb_extra_f2_b->sue_pwm_output_2, serial_udb_extra_f2_b->sue_pwm_output_3, serial_udb_extra_f2_b->sue_pwm_output_4, serial_udb_extra_f2_b->sue_pwm_output_5, serial_udb_extra_f2_b->sue_pwm_output_6, serial_udb_extra_f2_b->sue_pwm_output_7, serial_udb_extra_f2_b->sue_pwm_output_8, serial_udb_extra_f2_b->sue_pwm_output_9, serial_udb_extra_f2_b->sue_pwm_output_10, serial_udb_extra_f2_b->sue_pwm_output_11, serial_udb_extra_f2_b->sue_pwm_output_12, serial_udb_extra_f2_b->sue_imu_location_x, serial_udb_extra_f2_b->sue_imu_location_y, serial_udb_extra_f2_b->sue_imu_location_z, serial_udb_extra_f2_b->sue_location_error_earth_x, serial_udb_extra_f2_b->sue_location_error_earth_y, serial_udb_extra_f2_b->sue_location_error_earth_z, serial_udb_extra_f2_b->sue_flags, serial_udb_extra_f2_b->sue_osc_fails, serial_udb_extra_f2_b->sue_imu_velocity_x, serial_udb_extra_f2_b->sue_imu_velocity_y, serial_udb_extra_f2_b->sue_imu_velocity_z, serial_udb_extra_f2_b->sue_waypoint_goal_x, serial_udb_extra_f2_b->sue_waypoint_goal_y, serial_udb_extra_f2_b->sue_waypoint_goal_z, serial_udb_extra_f2_b->sue_aero_x, serial_udb_extra_f2_b->sue_aero_y, serial_udb_extra_f2_b->sue_aero_z, serial_udb_extra_f2_b->sue_barom_temp, serial_udb_extra_f2_b->sue_barom_press, serial_udb_extra_f2_b->sue_barom_alt, serial_udb_extra_f2_b->sue_bat_volt, serial_udb_extra_f2_b->sue_bat_amp, serial_udb_extra_f2_b->sue_bat_amp_hours, serial_udb_extra_f2_b->sue_desired_height, serial_udb_extra_f2_b->sue_memory_stack_free); +} + /** * @brief Send a serial_udb_extra_f2_b message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f4.h b/matrixpilot/mavlink_msg_serial_udb_extra_f4.h index 66d46c4a..3db7c9d4 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f4.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f4.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f4_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_CRC); } +/** + * @brief Pack a serial_udb_extra_f4 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 sue_ROLL_STABILIZATION_AILERONS Serial UDB Extra Roll Stabilization with Ailerons Enabled + * @param sue_ROLL_STABILIZATION_RUDDER Serial UDB Extra Roll Stabilization with Rudder Enabled + * @param sue_PITCH_STABILIZATION Serial UDB Extra Pitch Stabilization Enabled + * @param sue_YAW_STABILIZATION_RUDDER Serial UDB Extra Yaw Stabilization using Rudder Enabled + * @param sue_YAW_STABILIZATION_AILERON Serial UDB Extra Yaw Stabilization using Ailerons Enabled + * @param sue_AILERON_NAVIGATION Serial UDB Extra Navigation with Ailerons Enabled + * @param sue_RUDDER_NAVIGATION Serial UDB Extra Navigation with Rudder Enabled + * @param sue_ALTITUDEHOLD_STABILIZED Serial UDB Extra Type of Alitude Hold when in Stabilized Mode + * @param sue_ALTITUDEHOLD_WAYPOINT Serial UDB Extra Type of Alitude Hold when in Waypoint Mode + * @param sue_RACING_MODE Serial UDB Extra Firmware racing mode enabled + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f4_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t sue_ROLL_STABILIZATION_AILERONS, uint8_t sue_ROLL_STABILIZATION_RUDDER, uint8_t sue_PITCH_STABILIZATION, uint8_t sue_YAW_STABILIZATION_RUDDER, uint8_t sue_YAW_STABILIZATION_AILERON, uint8_t sue_AILERON_NAVIGATION, uint8_t sue_RUDDER_NAVIGATION, uint8_t sue_ALTITUDEHOLD_STABILIZED, uint8_t sue_ALTITUDEHOLD_WAYPOINT, uint8_t sue_RACING_MODE) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN]; + _mav_put_uint8_t(buf, 0, sue_ROLL_STABILIZATION_AILERONS); + _mav_put_uint8_t(buf, 1, sue_ROLL_STABILIZATION_RUDDER); + _mav_put_uint8_t(buf, 2, sue_PITCH_STABILIZATION); + _mav_put_uint8_t(buf, 3, sue_YAW_STABILIZATION_RUDDER); + _mav_put_uint8_t(buf, 4, sue_YAW_STABILIZATION_AILERON); + _mav_put_uint8_t(buf, 5, sue_AILERON_NAVIGATION); + _mav_put_uint8_t(buf, 6, sue_RUDDER_NAVIGATION); + _mav_put_uint8_t(buf, 7, sue_ALTITUDEHOLD_STABILIZED); + _mav_put_uint8_t(buf, 8, sue_ALTITUDEHOLD_WAYPOINT); + _mav_put_uint8_t(buf, 9, sue_RACING_MODE); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN); +#else + mavlink_serial_udb_extra_f4_t packet; + packet.sue_ROLL_STABILIZATION_AILERONS = sue_ROLL_STABILIZATION_AILERONS; + packet.sue_ROLL_STABILIZATION_RUDDER = sue_ROLL_STABILIZATION_RUDDER; + packet.sue_PITCH_STABILIZATION = sue_PITCH_STABILIZATION; + packet.sue_YAW_STABILIZATION_RUDDER = sue_YAW_STABILIZATION_RUDDER; + packet.sue_YAW_STABILIZATION_AILERON = sue_YAW_STABILIZATION_AILERON; + packet.sue_AILERON_NAVIGATION = sue_AILERON_NAVIGATION; + packet.sue_RUDDER_NAVIGATION = sue_RUDDER_NAVIGATION; + packet.sue_ALTITUDEHOLD_STABILIZED = sue_ALTITUDEHOLD_STABILIZED; + packet.sue_ALTITUDEHOLD_WAYPOINT = sue_ALTITUDEHOLD_WAYPOINT; + packet.sue_RACING_MODE = sue_RACING_MODE; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F4_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f4 message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f4_encode_chan(uint8_t syste return mavlink_msg_serial_udb_extra_f4_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f4->sue_ROLL_STABILIZATION_AILERONS, serial_udb_extra_f4->sue_ROLL_STABILIZATION_RUDDER, serial_udb_extra_f4->sue_PITCH_STABILIZATION, serial_udb_extra_f4->sue_YAW_STABILIZATION_RUDDER, serial_udb_extra_f4->sue_YAW_STABILIZATION_AILERON, serial_udb_extra_f4->sue_AILERON_NAVIGATION, serial_udb_extra_f4->sue_RUDDER_NAVIGATION, serial_udb_extra_f4->sue_ALTITUDEHOLD_STABILIZED, serial_udb_extra_f4->sue_ALTITUDEHOLD_WAYPOINT, serial_udb_extra_f4->sue_RACING_MODE); } +/** + * @brief Encode a serial_udb_extra_f4 struct with provided status structure + * + * @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 serial_udb_extra_f4 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f4_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f4_t* serial_udb_extra_f4) +{ + return mavlink_msg_serial_udb_extra_f4_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f4->sue_ROLL_STABILIZATION_AILERONS, serial_udb_extra_f4->sue_ROLL_STABILIZATION_RUDDER, serial_udb_extra_f4->sue_PITCH_STABILIZATION, serial_udb_extra_f4->sue_YAW_STABILIZATION_RUDDER, serial_udb_extra_f4->sue_YAW_STABILIZATION_AILERON, serial_udb_extra_f4->sue_AILERON_NAVIGATION, serial_udb_extra_f4->sue_RUDDER_NAVIGATION, serial_udb_extra_f4->sue_ALTITUDEHOLD_STABILIZED, serial_udb_extra_f4->sue_ALTITUDEHOLD_WAYPOINT, serial_udb_extra_f4->sue_RACING_MODE); +} + /** * @brief Send a serial_udb_extra_f4 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f5.h b/matrixpilot/mavlink_msg_serial_udb_extra_f5.h index 3f262a0b..a53bfbf6 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f5.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f5.h @@ -81,6 +81,48 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f5_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_CRC); } +/** + * @brief Pack a serial_udb_extra_f5 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 sue_YAWKP_AILERON Serial UDB YAWKP_AILERON Gain for Proporional control of navigation + * @param sue_YAWKD_AILERON Serial UDB YAWKD_AILERON Gain for Rate control of navigation + * @param sue_ROLLKP Serial UDB Extra ROLLKP Gain for Proportional control of roll stabilization + * @param sue_ROLLKD Serial UDB Extra ROLLKD Gain for Rate control of roll stabilization + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f5_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float sue_YAWKP_AILERON, float sue_YAWKD_AILERON, float sue_ROLLKP, float sue_ROLLKD) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN]; + _mav_put_float(buf, 0, sue_YAWKP_AILERON); + _mav_put_float(buf, 4, sue_YAWKD_AILERON); + _mav_put_float(buf, 8, sue_ROLLKP); + _mav_put_float(buf, 12, sue_ROLLKD); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN); +#else + mavlink_serial_udb_extra_f5_t packet; + packet.sue_YAWKP_AILERON = sue_YAWKP_AILERON; + packet.sue_YAWKD_AILERON = sue_YAWKD_AILERON; + packet.sue_ROLLKP = sue_ROLLKP; + packet.sue_ROLLKD = sue_ROLLKD; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F5_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f5 message on a channel * @param system_id ID of this system @@ -146,6 +188,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f5_encode_chan(uint8_t syste return mavlink_msg_serial_udb_extra_f5_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f5->sue_YAWKP_AILERON, serial_udb_extra_f5->sue_YAWKD_AILERON, serial_udb_extra_f5->sue_ROLLKP, serial_udb_extra_f5->sue_ROLLKD); } +/** + * @brief Encode a serial_udb_extra_f5 struct with provided status structure + * + * @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 serial_udb_extra_f5 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f5_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f5_t* serial_udb_extra_f5) +{ + return mavlink_msg_serial_udb_extra_f5_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f5->sue_YAWKP_AILERON, serial_udb_extra_f5->sue_YAWKD_AILERON, serial_udb_extra_f5->sue_ROLLKP, serial_udb_extra_f5->sue_ROLLKD); +} + /** * @brief Send a serial_udb_extra_f5 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f6.h b/matrixpilot/mavlink_msg_serial_udb_extra_f6.h index bff58b85..a8d3bc9c 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f6.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f6.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f6_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_CRC); } +/** + * @brief Pack a serial_udb_extra_f6 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 sue_PITCHGAIN Serial UDB Extra PITCHGAIN Proportional Control + * @param sue_PITCHKD Serial UDB Extra Pitch Rate Control + * @param sue_RUDDER_ELEV_MIX Serial UDB Extra Rudder to Elevator Mix + * @param sue_ROLL_ELEV_MIX Serial UDB Extra Roll to Elevator Mix + * @param sue_ELEVATOR_BOOST Gain For Boosting Manual Elevator control When Plane Stabilized + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f6_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float sue_PITCHGAIN, float sue_PITCHKD, float sue_RUDDER_ELEV_MIX, float sue_ROLL_ELEV_MIX, float sue_ELEVATOR_BOOST) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN]; + _mav_put_float(buf, 0, sue_PITCHGAIN); + _mav_put_float(buf, 4, sue_PITCHKD); + _mav_put_float(buf, 8, sue_RUDDER_ELEV_MIX); + _mav_put_float(buf, 12, sue_ROLL_ELEV_MIX); + _mav_put_float(buf, 16, sue_ELEVATOR_BOOST); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN); +#else + mavlink_serial_udb_extra_f6_t packet; + packet.sue_PITCHGAIN = sue_PITCHGAIN; + packet.sue_PITCHKD = sue_PITCHKD; + packet.sue_RUDDER_ELEV_MIX = sue_RUDDER_ELEV_MIX; + packet.sue_ROLL_ELEV_MIX = sue_ROLL_ELEV_MIX; + packet.sue_ELEVATOR_BOOST = sue_ELEVATOR_BOOST; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F6_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f6 message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f6_encode_chan(uint8_t syste return mavlink_msg_serial_udb_extra_f6_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f6->sue_PITCHGAIN, serial_udb_extra_f6->sue_PITCHKD, serial_udb_extra_f6->sue_RUDDER_ELEV_MIX, serial_udb_extra_f6->sue_ROLL_ELEV_MIX, serial_udb_extra_f6->sue_ELEVATOR_BOOST); } +/** + * @brief Encode a serial_udb_extra_f6 struct with provided status structure + * + * @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 serial_udb_extra_f6 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f6_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f6_t* serial_udb_extra_f6) +{ + return mavlink_msg_serial_udb_extra_f6_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f6->sue_PITCHGAIN, serial_udb_extra_f6->sue_PITCHKD, serial_udb_extra_f6->sue_RUDDER_ELEV_MIX, serial_udb_extra_f6->sue_ROLL_ELEV_MIX, serial_udb_extra_f6->sue_ELEVATOR_BOOST); +} + /** * @brief Send a serial_udb_extra_f6 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f7.h b/matrixpilot/mavlink_msg_serial_udb_extra_f7.h index 3cb3b722..fd5e654a 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f7.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f7.h @@ -93,6 +93,54 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f7_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_CRC); } +/** + * @brief Pack a serial_udb_extra_f7 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 sue_YAWKP_RUDDER Serial UDB YAWKP_RUDDER Gain for Proporional control of navigation + * @param sue_YAWKD_RUDDER Serial UDB YAWKD_RUDDER Gain for Rate control of navigation + * @param sue_ROLLKP_RUDDER Serial UDB Extra ROLLKP_RUDDER Gain for Proportional control of roll stabilization + * @param sue_ROLLKD_RUDDER Serial UDB Extra ROLLKD_RUDDER Gain for Rate control of roll stabilization + * @param sue_RUDDER_BOOST SERIAL UDB EXTRA Rudder Boost Gain to Manual Control when stabilized + * @param sue_RTL_PITCH_DOWN Serial UDB Extra Return To Landing - Angle to Pitch Plane Down + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f7_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float sue_YAWKP_RUDDER, float sue_YAWKD_RUDDER, float sue_ROLLKP_RUDDER, float sue_ROLLKD_RUDDER, float sue_RUDDER_BOOST, float sue_RTL_PITCH_DOWN) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN]; + _mav_put_float(buf, 0, sue_YAWKP_RUDDER); + _mav_put_float(buf, 4, sue_YAWKD_RUDDER); + _mav_put_float(buf, 8, sue_ROLLKP_RUDDER); + _mav_put_float(buf, 12, sue_ROLLKD_RUDDER); + _mav_put_float(buf, 16, sue_RUDDER_BOOST); + _mav_put_float(buf, 20, sue_RTL_PITCH_DOWN); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN); +#else + mavlink_serial_udb_extra_f7_t packet; + packet.sue_YAWKP_RUDDER = sue_YAWKP_RUDDER; + packet.sue_YAWKD_RUDDER = sue_YAWKD_RUDDER; + packet.sue_ROLLKP_RUDDER = sue_ROLLKP_RUDDER; + packet.sue_ROLLKD_RUDDER = sue_ROLLKD_RUDDER; + packet.sue_RUDDER_BOOST = sue_RUDDER_BOOST; + packet.sue_RTL_PITCH_DOWN = sue_RTL_PITCH_DOWN; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F7_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f7 message on a channel * @param system_id ID of this system @@ -164,6 +212,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f7_encode_chan(uint8_t syste return mavlink_msg_serial_udb_extra_f7_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f7->sue_YAWKP_RUDDER, serial_udb_extra_f7->sue_YAWKD_RUDDER, serial_udb_extra_f7->sue_ROLLKP_RUDDER, serial_udb_extra_f7->sue_ROLLKD_RUDDER, serial_udb_extra_f7->sue_RUDDER_BOOST, serial_udb_extra_f7->sue_RTL_PITCH_DOWN); } +/** + * @brief Encode a serial_udb_extra_f7 struct with provided status structure + * + * @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 serial_udb_extra_f7 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f7_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f7_t* serial_udb_extra_f7) +{ + return mavlink_msg_serial_udb_extra_f7_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f7->sue_YAWKP_RUDDER, serial_udb_extra_f7->sue_YAWKD_RUDDER, serial_udb_extra_f7->sue_ROLLKP_RUDDER, serial_udb_extra_f7->sue_ROLLKD_RUDDER, serial_udb_extra_f7->sue_RUDDER_BOOST, serial_udb_extra_f7->sue_RTL_PITCH_DOWN); +} + /** * @brief Send a serial_udb_extra_f7 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/mavlink_msg_serial_udb_extra_f8.h b/matrixpilot/mavlink_msg_serial_udb_extra_f8.h index c8ad3a63..9372c778 100644 --- a/matrixpilot/mavlink_msg_serial_udb_extra_f8.h +++ b/matrixpilot/mavlink_msg_serial_udb_extra_f8.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f8_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_CRC); } +/** + * @brief Pack a serial_udb_extra_f8 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 sue_HEIGHT_TARGET_MAX Serial UDB Extra HEIGHT_TARGET_MAX + * @param sue_HEIGHT_TARGET_MIN Serial UDB Extra HEIGHT_TARGET_MIN + * @param sue_ALT_HOLD_THROTTLE_MIN Serial UDB Extra ALT_HOLD_THROTTLE_MIN + * @param sue_ALT_HOLD_THROTTLE_MAX Serial UDB Extra ALT_HOLD_THROTTLE_MAX + * @param sue_ALT_HOLD_PITCH_MIN Serial UDB Extra ALT_HOLD_PITCH_MIN + * @param sue_ALT_HOLD_PITCH_MAX Serial UDB Extra ALT_HOLD_PITCH_MAX + * @param sue_ALT_HOLD_PITCH_HIGH Serial UDB Extra ALT_HOLD_PITCH_HIGH + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f8_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + float sue_HEIGHT_TARGET_MAX, float sue_HEIGHT_TARGET_MIN, float sue_ALT_HOLD_THROTTLE_MIN, float sue_ALT_HOLD_THROTTLE_MAX, float sue_ALT_HOLD_PITCH_MIN, float sue_ALT_HOLD_PITCH_MAX, float sue_ALT_HOLD_PITCH_HIGH) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN]; + _mav_put_float(buf, 0, sue_HEIGHT_TARGET_MAX); + _mav_put_float(buf, 4, sue_HEIGHT_TARGET_MIN); + _mav_put_float(buf, 8, sue_ALT_HOLD_THROTTLE_MIN); + _mav_put_float(buf, 12, sue_ALT_HOLD_THROTTLE_MAX); + _mav_put_float(buf, 16, sue_ALT_HOLD_PITCH_MIN); + _mav_put_float(buf, 20, sue_ALT_HOLD_PITCH_MAX); + _mav_put_float(buf, 24, sue_ALT_HOLD_PITCH_HIGH); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN); +#else + mavlink_serial_udb_extra_f8_t packet; + packet.sue_HEIGHT_TARGET_MAX = sue_HEIGHT_TARGET_MAX; + packet.sue_HEIGHT_TARGET_MIN = sue_HEIGHT_TARGET_MIN; + packet.sue_ALT_HOLD_THROTTLE_MIN = sue_ALT_HOLD_THROTTLE_MIN; + packet.sue_ALT_HOLD_THROTTLE_MAX = sue_ALT_HOLD_THROTTLE_MAX; + packet.sue_ALT_HOLD_PITCH_MIN = sue_ALT_HOLD_PITCH_MIN; + packet.sue_ALT_HOLD_PITCH_MAX = sue_ALT_HOLD_PITCH_MAX; + packet.sue_ALT_HOLD_PITCH_HIGH = sue_ALT_HOLD_PITCH_HIGH; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_MIN_LEN, MAVLINK_MSG_ID_SERIAL_UDB_EXTRA_F8_LEN); +#endif +} + /** * @brief Pack a serial_udb_extra_f8 message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_serial_udb_extra_f8_encode_chan(uint8_t syste return mavlink_msg_serial_udb_extra_f8_pack_chan(system_id, component_id, chan, msg, serial_udb_extra_f8->sue_HEIGHT_TARGET_MAX, serial_udb_extra_f8->sue_HEIGHT_TARGET_MIN, serial_udb_extra_f8->sue_ALT_HOLD_THROTTLE_MIN, serial_udb_extra_f8->sue_ALT_HOLD_THROTTLE_MAX, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_MIN, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_MAX, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_HIGH); } +/** + * @brief Encode a serial_udb_extra_f8 struct with provided status structure + * + * @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 serial_udb_extra_f8 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_serial_udb_extra_f8_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_serial_udb_extra_f8_t* serial_udb_extra_f8) +{ + return mavlink_msg_serial_udb_extra_f8_pack_status(system_id, component_id, _status, msg, serial_udb_extra_f8->sue_HEIGHT_TARGET_MAX, serial_udb_extra_f8->sue_HEIGHT_TARGET_MIN, serial_udb_extra_f8->sue_ALT_HOLD_THROTTLE_MIN, serial_udb_extra_f8->sue_ALT_HOLD_THROTTLE_MAX, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_MIN, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_MAX, serial_udb_extra_f8->sue_ALT_HOLD_PITCH_HIGH); +} + /** * @brief Send a serial_udb_extra_f8 message * @param chan MAVLink channel to send the message diff --git a/matrixpilot/version.h b/matrixpilot/version.h index 1ce11086..4adadf85 100644 --- a/matrixpilot/version.h +++ b/matrixpilot/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/mavlink_helpers.h b/mavlink_helpers.h index b36f51e4..75c75d07 100644 --- a/mavlink_helpers.h +++ b/mavlink_helpers.h @@ -707,7 +707,7 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg, break; case MAVLINK_PARSE_STATE_GOT_MSGID1: - rxmsg->msgid |= c<<8; + rxmsg->msgid |= ((uint32_t)c)<<8; mavlink_update_checksum(rxmsg, c); status->parse_state = MAVLINK_PARSE_STATE_GOT_MSGID2; break; diff --git a/minimal/mavlink.h b/minimal/mavlink.h index 309a84c0..a7d040c0 100644 --- a/minimal/mavlink.h +++ b/minimal/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 5259551351902742847 +#define MAVLINK_PRIMARY_XML_HASH 628599850151937956 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/minimal/mavlink_msg_heartbeat.h b/minimal/mavlink_msg_heartbeat.h index 15d63931..c617c03f 100644 --- a/minimal/mavlink_msg_heartbeat.h +++ b/minimal/mavlink_msg_heartbeat.h @@ -92,6 +92,53 @@ static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t com return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC); } +/** + * @brief Pack a heartbeat 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 type Vehicle or component type. For a flight controller component the vehicle type (quadrotor, helicopter, etc.). For other components the component type (e.g. camera, gimbal, etc.). This should be used in preference to component id for identifying the component type. + * @param autopilot Autopilot type / class. Use MAV_AUTOPILOT_INVALID for components that are not flight controllers. + * @param base_mode System mode bitmap. + * @param custom_mode A bitfield for use for autopilot-specific flags + * @param system_status System status flag. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_heartbeat_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN]; + _mav_put_uint32_t(buf, 0, custom_mode); + _mav_put_uint8_t(buf, 4, type); + _mav_put_uint8_t(buf, 5, autopilot); + _mav_put_uint8_t(buf, 6, base_mode); + _mav_put_uint8_t(buf, 7, system_status); + _mav_put_uint8_t(buf, 8, 3); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HEARTBEAT_LEN); +#else + mavlink_heartbeat_t packet; + packet.custom_mode = custom_mode; + packet.type = type; + packet.autopilot = autopilot; + packet.base_mode = base_mode; + packet.system_status = system_status; + packet.mavlink_version = 3; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HEARTBEAT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_HEARTBEAT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN, MAVLINK_MSG_ID_HEARTBEAT_LEN); +#endif +} + /** * @brief Pack a heartbeat message on a channel * @param system_id ID of this system @@ -162,6 +209,20 @@ static inline uint16_t mavlink_msg_heartbeat_encode_chan(uint8_t system_id, uint return mavlink_msg_heartbeat_pack_chan(system_id, component_id, chan, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status); } +/** + * @brief Encode a heartbeat struct with provided status structure + * + * @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 heartbeat C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_heartbeat_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_heartbeat_t* heartbeat) +{ + return mavlink_msg_heartbeat_pack_status(system_id, component_id, _status, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status); +} + /** * @brief Send a heartbeat message * @param chan MAVLink channel to send the message diff --git a/minimal/mavlink_msg_protocol_version.h b/minimal/mavlink_msg_protocol_version.h index 00ce8158..367d8225 100644 --- a/minimal/mavlink_msg_protocol_version.h +++ b/minimal/mavlink_msg_protocol_version.h @@ -86,6 +86,49 @@ static inline uint16_t mavlink_msg_protocol_version_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC); } +/** + * @brief Pack a protocol_version 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 version Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc. + * @param min_version Minimum MAVLink version supported + * @param max_version Maximum MAVLink version supported (set to the same value as version by default) + * @param spec_version_hash The first 8 bytes (not characters printed in hex!) of the git hash. + * @param library_version_hash The first 8 bytes (not characters printed in hex!) of the git hash. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_protocol_version_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t version, uint16_t min_version, uint16_t max_version, const uint8_t *spec_version_hash, const uint8_t *library_version_hash) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN]; + _mav_put_uint16_t(buf, 0, version); + _mav_put_uint16_t(buf, 2, min_version); + _mav_put_uint16_t(buf, 4, max_version); + _mav_put_uint8_t_array(buf, 6, spec_version_hash, 8); + _mav_put_uint8_t_array(buf, 14, library_version_hash, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN); +#else + mavlink_protocol_version_t packet; + packet.version = version; + packet.min_version = min_version; + packet.max_version = max_version; + mav_array_memcpy(packet.spec_version_hash, spec_version_hash, sizeof(uint8_t)*8); + mav_array_memcpy(packet.library_version_hash, library_version_hash, sizeof(uint8_t)*8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PROTOCOL_VERSION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN); +#endif +} + /** * @brief Pack a protocol_version message on a channel * @param system_id ID of this system @@ -152,6 +195,20 @@ static inline uint16_t mavlink_msg_protocol_version_encode_chan(uint8_t system_i return mavlink_msg_protocol_version_pack_chan(system_id, component_id, chan, msg, protocol_version->version, protocol_version->min_version, protocol_version->max_version, protocol_version->spec_version_hash, protocol_version->library_version_hash); } +/** + * @brief Encode a protocol_version struct with provided status structure + * + * @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 protocol_version C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_protocol_version_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_protocol_version_t* protocol_version) +{ + return mavlink_msg_protocol_version_pack_status(system_id, component_id, _status, msg, protocol_version->version, protocol_version->min_version, protocol_version->max_version, protocol_version->spec_version_hash, protocol_version->library_version_hash); +} + /** * @brief Send a protocol_version message * @param chan MAVLink channel to send the message diff --git a/minimal/minimal.h b/minimal/minimal.h index 5b430e1b..3e73f23e 100644 --- a/minimal/minimal.h +++ b/minimal/minimal.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_MINIMAL.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_MINIMAL_XML_HASH 5259551351902742847 +#define MAVLINK_MINIMAL_XML_HASH 628599850151937956 #ifdef __cplusplus extern "C" { diff --git a/minimal/version.h b/minimal/version.h index 01cbec37..c143cc85 100644 --- a/minimal/version.h +++ b/minimal/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 22 diff --git a/paparazzi/mavlink.h b/paparazzi/mavlink.h index a4c79a48..341a6c6d 100644 --- a/paparazzi/mavlink.h +++ b/paparazzi/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -4885643007926429097 +#define MAVLINK_PRIMARY_XML_HASH 5871778279825601656 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/paparazzi/mavlink_msg_script_count.h b/paparazzi/mavlink_msg_script_count.h index 91e2851e..54bc66bf 100644 --- a/paparazzi/mavlink_msg_script_count.h +++ b/paparazzi/mavlink_msg_script_count.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_script_count_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCRIPT_COUNT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_COUNT_LEN, MAVLINK_MSG_ID_SCRIPT_COUNT_CRC); } +/** + * @brief Pack a script_count 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 target_system System ID + * @param target_component Component ID + * @param count Number of script items in the sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_script_count_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t count) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCRIPT_COUNT_LEN]; + _mav_put_uint16_t(buf, 0, count); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCRIPT_COUNT_LEN); +#else + mavlink_script_count_t packet; + packet.count = count; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCRIPT_COUNT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCRIPT_COUNT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_COUNT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_COUNT_LEN, MAVLINK_MSG_ID_SCRIPT_COUNT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_COUNT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_COUNT_LEN); +#endif +} + /** * @brief Pack a script_count message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_script_count_encode_chan(uint8_t system_id, u return mavlink_msg_script_count_pack_chan(system_id, component_id, chan, msg, script_count->target_system, script_count->target_component, script_count->count); } +/** + * @brief Encode a script_count struct with provided status structure + * + * @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 script_count C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_script_count_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_script_count_t* script_count) +{ + return mavlink_msg_script_count_pack_status(system_id, component_id, _status, msg, script_count->target_system, script_count->target_component, script_count->count); +} + /** * @brief Send a script_count message * @param chan MAVLink channel to send the message diff --git a/paparazzi/mavlink_msg_script_current.h b/paparazzi/mavlink_msg_script_current.h index a386ae87..5ff4817d 100644 --- a/paparazzi/mavlink_msg_script_current.h +++ b/paparazzi/mavlink_msg_script_current.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_script_current_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCRIPT_CURRENT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN, MAVLINK_MSG_ID_SCRIPT_CURRENT_CRC); } +/** + * @brief Pack a script_current 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 seq Active Sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_script_current_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN]; + _mav_put_uint16_t(buf, 0, seq); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN); +#else + mavlink_script_current_t packet; + packet.seq = seq; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCRIPT_CURRENT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_CURRENT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN, MAVLINK_MSG_ID_SCRIPT_CURRENT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_CURRENT_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_CURRENT_LEN); +#endif +} + /** * @brief Pack a script_current message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_script_current_encode_chan(uint8_t system_id, return mavlink_msg_script_current_pack_chan(system_id, component_id, chan, msg, script_current->seq); } +/** + * @brief Encode a script_current struct with provided status structure + * + * @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 script_current C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_script_current_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_script_current_t* script_current) +{ + return mavlink_msg_script_current_pack_status(system_id, component_id, _status, msg, script_current->seq); +} + /** * @brief Send a script_current message * @param chan MAVLink channel to send the message diff --git a/paparazzi/mavlink_msg_script_item.h b/paparazzi/mavlink_msg_script_item.h index 3a267948..17077e48 100644 --- a/paparazzi/mavlink_msg_script_item.h +++ b/paparazzi/mavlink_msg_script_item.h @@ -79,6 +79,46 @@ static inline uint16_t mavlink_msg_script_item_pack(uint8_t system_id, uint8_t c return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCRIPT_ITEM_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_ITEM_LEN, MAVLINK_MSG_ID_SCRIPT_ITEM_CRC); } +/** + * @brief Pack a script_item 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @param name The name of the mission script, NULL terminated. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_script_item_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq, const char *name) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCRIPT_ITEM_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + _mav_put_char_array(buf, 4, name, 50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCRIPT_ITEM_LEN); +#else + mavlink_script_item_t packet; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + mav_array_memcpy(packet.name, name, sizeof(char)*50); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCRIPT_ITEM_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCRIPT_ITEM; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_ITEM_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_ITEM_LEN, MAVLINK_MSG_ID_SCRIPT_ITEM_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_ITEM_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_ITEM_LEN); +#endif +} + /** * @brief Pack a script_item message on a channel * @param system_id ID of this system @@ -142,6 +182,20 @@ static inline uint16_t mavlink_msg_script_item_encode_chan(uint8_t system_id, ui return mavlink_msg_script_item_pack_chan(system_id, component_id, chan, msg, script_item->target_system, script_item->target_component, script_item->seq, script_item->name); } +/** + * @brief Encode a script_item struct with provided status structure + * + * @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 script_item C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_script_item_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_script_item_t* script_item) +{ + return mavlink_msg_script_item_pack_status(system_id, component_id, _status, msg, script_item->target_system, script_item->target_component, script_item->seq, script_item->name); +} + /** * @brief Send a script_item message * @param chan MAVLink channel to send the message diff --git a/paparazzi/mavlink_msg_script_request.h b/paparazzi/mavlink_msg_script_request.h index 954f6983..824b3856 100644 --- a/paparazzi/mavlink_msg_script_request.h +++ b/paparazzi/mavlink_msg_script_request.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_script_request_pack(uint8_t system_id, uint8_ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCRIPT_REQUEST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_CRC); } +/** + * @brief Pack a script_request 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 target_system System ID + * @param target_component Component ID + * @param seq Sequence + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_script_request_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint16_t seq) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN]; + _mav_put_uint16_t(buf, 0, seq); + _mav_put_uint8_t(buf, 2, target_system); + _mav_put_uint8_t(buf, 3, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN); +#else + mavlink_script_request_t packet; + packet.seq = seq; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCRIPT_REQUEST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_REQUEST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_REQUEST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LEN); +#endif +} + /** * @brief Pack a script_request message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_script_request_encode_chan(uint8_t system_id, return mavlink_msg_script_request_pack_chan(system_id, component_id, chan, msg, script_request->target_system, script_request->target_component, script_request->seq); } +/** + * @brief Encode a script_request struct with provided status structure + * + * @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 script_request C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_script_request_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_script_request_t* script_request) +{ + return mavlink_msg_script_request_pack_status(system_id, component_id, _status, msg, script_request->target_system, script_request->target_component, script_request->seq); +} + /** * @brief Send a script_request message * @param chan MAVLink channel to send the message diff --git a/paparazzi/mavlink_msg_script_request_list.h b/paparazzi/mavlink_msg_script_request_list.h index 1a4f53e8..64c33cc1 100644 --- a/paparazzi/mavlink_msg_script_request_list.h +++ b/paparazzi/mavlink_msg_script_request_list.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_script_request_list_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_CRC); } +/** + * @brief Pack a script_request_list 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 target_system System ID + * @param target_component Component ID + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_script_request_list_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN]; + _mav_put_uint8_t(buf, 0, target_system); + _mav_put_uint8_t(buf, 1, target_component); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN); +#else + mavlink_script_request_list_t packet; + packet.target_system = target_system; + packet.target_component = target_component; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_SCRIPT_REQUEST_LIST_LEN); +#endif +} + /** * @brief Pack a script_request_list message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_script_request_list_encode_chan(uint8_t syste return mavlink_msg_script_request_list_pack_chan(system_id, component_id, chan, msg, script_request_list->target_system, script_request_list->target_component); } +/** + * @brief Encode a script_request_list struct with provided status structure + * + * @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 script_request_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_script_request_list_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_script_request_list_t* script_request_list) +{ + return mavlink_msg_script_request_list_pack_status(system_id, component_id, _status, msg, script_request_list->target_system, script_request_list->target_component); +} + /** * @brief Send a script_request_list message * @param chan MAVLink channel to send the message diff --git a/paparazzi/paparazzi.h b/paparazzi/paparazzi.h index 3eaf4784..563cd13f 100644 --- a/paparazzi/paparazzi.h +++ b/paparazzi/paparazzi.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_PAPARAZZI.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_PAPARAZZI_XML_HASH -4885643007926429097 +#define MAVLINK_PAPARAZZI_XML_HASH 5871778279825601656 #ifdef __cplusplus extern "C" { diff --git a/paparazzi/version.h b/paparazzi/version.h index 61d9101c..22c13624 100644 --- a/paparazzi/version.h +++ b/paparazzi/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/protocol.h b/protocol.h index d9227303..ec593c3a 100644 --- a/protocol.h +++ b/protocol.h @@ -43,6 +43,8 @@ MAVLINK_HELPER mavlink_status_t* mavlink_get_channel_status(uint8_t chan); #endif MAVLINK_HELPER void mavlink_reset_channel_status(uint8_t chan); + MAVLINK_HELPER uint16_t mavlink_finalize_message_buffer(mavlink_message_t* msg, uint8_t system_id, uint8_t component_id, + mavlink_status_t* status, uint8_t min_length, uint8_t length, uint8_t crc_extra); MAVLINK_HELPER uint16_t mavlink_finalize_message_chan(mavlink_message_t* msg, uint8_t system_id, uint8_t component_id, uint8_t chan, uint8_t min_length, uint8_t length, uint8_t crc_extra); MAVLINK_HELPER uint16_t mavlink_finalize_message(mavlink_message_t* msg, uint8_t system_id, uint8_t component_id, diff --git a/python_array_test/mavlink.h b/python_array_test/mavlink.h index 38badf93..d9f4e78a 100644 --- a/python_array_test/mavlink.h +++ b/python_array_test/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 5310555058936034931 +#define MAVLINK_PRIMARY_XML_HASH 9106919784104748946 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/python_array_test/mavlink_msg_array_test_0.h b/python_array_test/mavlink_msg_array_test_0.h index ce5d8290..f32dafe4 100644 --- a/python_array_test/mavlink_msg_array_test_0.h +++ b/python_array_test/mavlink_msg_array_test_0.h @@ -88,6 +88,49 @@ static inline uint16_t mavlink_msg_array_test_0_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_0_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_0_LEN, MAVLINK_MSG_ID_ARRAY_TEST_0_CRC); } +/** + * @brief Pack a array_test_0 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 v1 Stub field + * @param ar_i8 Value array + * @param ar_u8 Value array + * @param ar_u16 Value array + * @param ar_u32 Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_0_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t v1, const int8_t *ar_i8, const uint8_t *ar_u8, const uint16_t *ar_u16, const uint32_t *ar_u32) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_0_LEN]; + _mav_put_uint8_t(buf, 24, v1); + _mav_put_uint32_t_array(buf, 0, ar_u32, 4); + _mav_put_uint16_t_array(buf, 16, ar_u16, 4); + _mav_put_int8_t_array(buf, 25, ar_i8, 4); + _mav_put_uint8_t_array(buf, 29, ar_u8, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_0_LEN); +#else + mavlink_array_test_0_t packet; + packet.v1 = v1; + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*4); + mav_array_memcpy(packet.ar_u16, ar_u16, sizeof(uint16_t)*4); + mav_array_memcpy(packet.ar_i8, ar_i8, sizeof(int8_t)*4); + mav_array_memcpy(packet.ar_u8, ar_u8, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_0_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_0; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_0_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_0_LEN, MAVLINK_MSG_ID_ARRAY_TEST_0_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_0_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_0_LEN); +#endif +} + /** * @brief Pack a array_test_0 message on a channel * @param system_id ID of this system @@ -154,6 +197,20 @@ static inline uint16_t mavlink_msg_array_test_0_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_0_pack_chan(system_id, component_id, chan, msg, array_test_0->v1, array_test_0->ar_i8, array_test_0->ar_u8, array_test_0->ar_u16, array_test_0->ar_u32); } +/** + * @brief Encode a array_test_0 struct with provided status structure + * + * @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 array_test_0 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_0_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_0_t* array_test_0) +{ + return mavlink_msg_array_test_0_pack_status(system_id, component_id, _status, msg, array_test_0->v1, array_test_0->ar_i8, array_test_0->ar_u8, array_test_0->ar_u16, array_test_0->ar_u32); +} + /** * @brief Send a array_test_0 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_1.h b/python_array_test/mavlink_msg_array_test_1.h index c0eb4b65..e6cdb593 100644 --- a/python_array_test/mavlink_msg_array_test_1.h +++ b/python_array_test/mavlink_msg_array_test_1.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_array_test_1_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_1_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_1_LEN, MAVLINK_MSG_ID_ARRAY_TEST_1_CRC); } +/** + * @brief Pack a array_test_1 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 ar_u32 Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_1_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint32_t *ar_u32) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_1_LEN]; + + _mav_put_uint32_t_array(buf, 0, ar_u32, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_1_LEN); +#else + mavlink_array_test_1_t packet; + + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_1_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_1; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_1_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_1_LEN, MAVLINK_MSG_ID_ARRAY_TEST_1_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_1_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_1_LEN); +#endif +} + /** * @brief Pack a array_test_1 message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_array_test_1_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_1_pack_chan(system_id, component_id, chan, msg, array_test_1->ar_u32); } +/** + * @brief Encode a array_test_1 struct with provided status structure + * + * @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 array_test_1 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_1_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_1_t* array_test_1) +{ + return mavlink_msg_array_test_1_pack_status(system_id, component_id, _status, msg, array_test_1->ar_u32); +} + /** * @brief Send a array_test_1 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_3.h b/python_array_test/mavlink_msg_array_test_3.h index fb4a1eb5..c74eecc5 100644 --- a/python_array_test/mavlink_msg_array_test_3.h +++ b/python_array_test/mavlink_msg_array_test_3.h @@ -67,6 +67,40 @@ static inline uint16_t mavlink_msg_array_test_3_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_3_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_3_LEN, MAVLINK_MSG_ID_ARRAY_TEST_3_CRC); } +/** + * @brief Pack a array_test_3 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 v Stub field + * @param ar_u32 Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_3_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t v, const uint32_t *ar_u32) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_3_LEN]; + _mav_put_uint8_t(buf, 16, v); + _mav_put_uint32_t_array(buf, 0, ar_u32, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_3_LEN); +#else + mavlink_array_test_3_t packet; + packet.v = v; + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_3_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_3; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_3_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_3_LEN, MAVLINK_MSG_ID_ARRAY_TEST_3_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_3_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_3_LEN); +#endif +} + /** * @brief Pack a array_test_3 message on a channel * @param system_id ID of this system @@ -124,6 +158,20 @@ static inline uint16_t mavlink_msg_array_test_3_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_3_pack_chan(system_id, component_id, chan, msg, array_test_3->v, array_test_3->ar_u32); } +/** + * @brief Encode a array_test_3 struct with provided status structure + * + * @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 array_test_3 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_3_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_3_t* array_test_3) +{ + return mavlink_msg_array_test_3_pack_status(system_id, component_id, _status, msg, array_test_3->v, array_test_3->ar_u32); +} + /** * @brief Send a array_test_3 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_4.h b/python_array_test/mavlink_msg_array_test_4.h index a12d5b53..1cf808b3 100644 --- a/python_array_test/mavlink_msg_array_test_4.h +++ b/python_array_test/mavlink_msg_array_test_4.h @@ -67,6 +67,40 @@ static inline uint16_t mavlink_msg_array_test_4_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_4_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_4_LEN, MAVLINK_MSG_ID_ARRAY_TEST_4_CRC); } +/** + * @brief Pack a array_test_4 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 ar_u32 Value array + * @param v Stub field + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_4_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint32_t *ar_u32, uint8_t v) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_4_LEN]; + _mav_put_uint8_t(buf, 16, v); + _mav_put_uint32_t_array(buf, 0, ar_u32, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_4_LEN); +#else + mavlink_array_test_4_t packet; + packet.v = v; + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_4_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_4; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_4_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_4_LEN, MAVLINK_MSG_ID_ARRAY_TEST_4_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_4_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_4_LEN); +#endif +} + /** * @brief Pack a array_test_4 message on a channel * @param system_id ID of this system @@ -124,6 +158,20 @@ static inline uint16_t mavlink_msg_array_test_4_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_4_pack_chan(system_id, component_id, chan, msg, array_test_4->ar_u32, array_test_4->v); } +/** + * @brief Encode a array_test_4 struct with provided status structure + * + * @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 array_test_4 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_4_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_4_t* array_test_4) +{ + return mavlink_msg_array_test_4_pack_status(system_id, component_id, _status, msg, array_test_4->ar_u32, array_test_4->v); +} + /** * @brief Send a array_test_4 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_5.h b/python_array_test/mavlink_msg_array_test_5.h index 0e7c7174..0f3b3347 100644 --- a/python_array_test/mavlink_msg_array_test_5.h +++ b/python_array_test/mavlink_msg_array_test_5.h @@ -70,6 +70,42 @@ static inline uint16_t mavlink_msg_array_test_5_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_5_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_5_LEN, MAVLINK_MSG_ID_ARRAY_TEST_5_CRC); } +/** + * @brief Pack a array_test_5 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 c1 Value array + * @param c2 Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_5_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const char *c1, const char *c2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_5_LEN]; + + _mav_put_char_array(buf, 0, c1, 5); + _mav_put_char_array(buf, 5, c2, 5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_5_LEN); +#else + mavlink_array_test_5_t packet; + + mav_array_memcpy(packet.c1, c1, sizeof(char)*5); + mav_array_memcpy(packet.c2, c2, sizeof(char)*5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_5_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_5; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_5_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_5_LEN, MAVLINK_MSG_ID_ARRAY_TEST_5_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_5_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_5_LEN); +#endif +} + /** * @brief Pack a array_test_5 message on a channel * @param system_id ID of this system @@ -129,6 +165,20 @@ static inline uint16_t mavlink_msg_array_test_5_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_5_pack_chan(system_id, component_id, chan, msg, array_test_5->c1, array_test_5->c2); } +/** + * @brief Encode a array_test_5 struct with provided status structure + * + * @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 array_test_5 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_5_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_5_t* array_test_5) +{ + return mavlink_msg_array_test_5_pack_status(system_id, component_id, _status, msg, array_test_5->c1, array_test_5->c2); +} + /** * @brief Send a array_test_5 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_6.h b/python_array_test/mavlink_msg_array_test_6.h index 3a973913..8f8a3595 100644 --- a/python_array_test/mavlink_msg_array_test_6.h +++ b/python_array_test/mavlink_msg_array_test_6.h @@ -135,6 +135,70 @@ static inline uint16_t mavlink_msg_array_test_6_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_6_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_6_LEN, MAVLINK_MSG_ID_ARRAY_TEST_6_CRC); } +/** + * @brief Pack a array_test_6 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 v1 Stub field + * @param v2 Stub field + * @param v3 Stub field + * @param ar_u32 Value array + * @param ar_i32 Value array + * @param ar_u16 Value array + * @param ar_i16 Value array + * @param ar_u8 Value array + * @param ar_i8 Value array + * @param ar_c Value array + * @param ar_d Value array + * @param ar_f Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_6_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t v1, uint16_t v2, uint32_t v3, const uint32_t *ar_u32, const int32_t *ar_i32, const uint16_t *ar_u16, const int16_t *ar_i16, const uint8_t *ar_u8, const int8_t *ar_i8, const char *ar_c, const double *ar_d, const float *ar_f) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_6_LEN]; + _mav_put_uint32_t(buf, 16, v3); + _mav_put_uint16_t(buf, 44, v2); + _mav_put_uint8_t(buf, 54, v1); + _mav_put_double_array(buf, 0, ar_d, 2); + _mav_put_uint32_t_array(buf, 20, ar_u32, 2); + _mav_put_int32_t_array(buf, 28, ar_i32, 2); + _mav_put_float_array(buf, 36, ar_f, 2); + _mav_put_uint16_t_array(buf, 46, ar_u16, 2); + _mav_put_int16_t_array(buf, 50, ar_i16, 2); + _mav_put_uint8_t_array(buf, 55, ar_u8, 2); + _mav_put_int8_t_array(buf, 57, ar_i8, 2); + _mav_put_char_array(buf, 59, ar_c, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_6_LEN); +#else + mavlink_array_test_6_t packet; + packet.v3 = v3; + packet.v2 = v2; + packet.v1 = v1; + mav_array_memcpy(packet.ar_d, ar_d, sizeof(double)*2); + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*2); + mav_array_memcpy(packet.ar_i32, ar_i32, sizeof(int32_t)*2); + mav_array_memcpy(packet.ar_f, ar_f, sizeof(float)*2); + mav_array_memcpy(packet.ar_u16, ar_u16, sizeof(uint16_t)*2); + mav_array_memcpy(packet.ar_i16, ar_i16, sizeof(int16_t)*2); + mav_array_memcpy(packet.ar_u8, ar_u8, sizeof(uint8_t)*2); + mav_array_memcpy(packet.ar_i8, ar_i8, sizeof(int8_t)*2); + mav_array_memcpy(packet.ar_c, ar_c, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_6_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_6; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_6_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_6_LEN, MAVLINK_MSG_ID_ARRAY_TEST_6_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_6_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_6_LEN); +#endif +} + /** * @brief Pack a array_test_6 message on a channel * @param system_id ID of this system @@ -222,6 +286,20 @@ static inline uint16_t mavlink_msg_array_test_6_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_6_pack_chan(system_id, component_id, chan, msg, array_test_6->v1, array_test_6->v2, array_test_6->v3, array_test_6->ar_u32, array_test_6->ar_i32, array_test_6->ar_u16, array_test_6->ar_i16, array_test_6->ar_u8, array_test_6->ar_i8, array_test_6->ar_c, array_test_6->ar_d, array_test_6->ar_f); } +/** + * @brief Encode a array_test_6 struct with provided status structure + * + * @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 array_test_6 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_6_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_6_t* array_test_6) +{ + return mavlink_msg_array_test_6_pack_status(system_id, component_id, _status, msg, array_test_6->v1, array_test_6->v2, array_test_6->v3, array_test_6->ar_u32, array_test_6->ar_i32, array_test_6->ar_u16, array_test_6->ar_i16, array_test_6->ar_u8, array_test_6->ar_i8, array_test_6->ar_c, array_test_6->ar_d, array_test_6->ar_f); +} + /** * @brief Send a array_test_6 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_7.h b/python_array_test/mavlink_msg_array_test_7.h index 354f46e3..40e7265b 100644 --- a/python_array_test/mavlink_msg_array_test_7.h +++ b/python_array_test/mavlink_msg_array_test_7.h @@ -119,6 +119,63 @@ static inline uint16_t mavlink_msg_array_test_7_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_7_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_7_LEN, MAVLINK_MSG_ID_ARRAY_TEST_7_CRC); } +/** + * @brief Pack a array_test_7 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 ar_d Value array + * @param ar_f Value array + * @param ar_u32 Value array + * @param ar_i32 Value array + * @param ar_u16 Value array + * @param ar_i16 Value array + * @param ar_u8 Value array + * @param ar_i8 Value array + * @param ar_c Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_7_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const double *ar_d, const float *ar_f, const uint32_t *ar_u32, const int32_t *ar_i32, const uint16_t *ar_u16, const int16_t *ar_i16, const uint8_t *ar_u8, const int8_t *ar_i8, const char *ar_c) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_7_LEN]; + + _mav_put_double_array(buf, 0, ar_d, 2); + _mav_put_float_array(buf, 16, ar_f, 2); + _mav_put_uint32_t_array(buf, 24, ar_u32, 2); + _mav_put_int32_t_array(buf, 32, ar_i32, 2); + _mav_put_uint16_t_array(buf, 40, ar_u16, 2); + _mav_put_int16_t_array(buf, 44, ar_i16, 2); + _mav_put_uint8_t_array(buf, 48, ar_u8, 2); + _mav_put_int8_t_array(buf, 50, ar_i8, 2); + _mav_put_char_array(buf, 52, ar_c, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_7_LEN); +#else + mavlink_array_test_7_t packet; + + mav_array_memcpy(packet.ar_d, ar_d, sizeof(double)*2); + mav_array_memcpy(packet.ar_f, ar_f, sizeof(float)*2); + mav_array_memcpy(packet.ar_u32, ar_u32, sizeof(uint32_t)*2); + mav_array_memcpy(packet.ar_i32, ar_i32, sizeof(int32_t)*2); + mav_array_memcpy(packet.ar_u16, ar_u16, sizeof(uint16_t)*2); + mav_array_memcpy(packet.ar_i16, ar_i16, sizeof(int16_t)*2); + mav_array_memcpy(packet.ar_u8, ar_u8, sizeof(uint8_t)*2); + mav_array_memcpy(packet.ar_i8, ar_i8, sizeof(int8_t)*2); + mav_array_memcpy(packet.ar_c, ar_c, sizeof(char)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_7_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_7; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_7_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_7_LEN, MAVLINK_MSG_ID_ARRAY_TEST_7_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_7_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_7_LEN); +#endif +} + /** * @brief Pack a array_test_7 message on a channel * @param system_id ID of this system @@ -199,6 +256,20 @@ static inline uint16_t mavlink_msg_array_test_7_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_7_pack_chan(system_id, component_id, chan, msg, array_test_7->ar_d, array_test_7->ar_f, array_test_7->ar_u32, array_test_7->ar_i32, array_test_7->ar_u16, array_test_7->ar_i16, array_test_7->ar_u8, array_test_7->ar_i8, array_test_7->ar_c); } +/** + * @brief Encode a array_test_7 struct with provided status structure + * + * @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 array_test_7 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_7_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_7_t* array_test_7) +{ + return mavlink_msg_array_test_7_pack_status(system_id, component_id, _status, msg, array_test_7->ar_d, array_test_7->ar_f, array_test_7->ar_u32, array_test_7->ar_i32, array_test_7->ar_u16, array_test_7->ar_i16, array_test_7->ar_u8, array_test_7->ar_i8, array_test_7->ar_c); +} + /** * @brief Send a array_test_7 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/mavlink_msg_array_test_8.h b/python_array_test/mavlink_msg_array_test_8.h index 0a618631..ad900770 100644 --- a/python_array_test/mavlink_msg_array_test_8.h +++ b/python_array_test/mavlink_msg_array_test_8.h @@ -74,6 +74,43 @@ static inline uint16_t mavlink_msg_array_test_8_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ARRAY_TEST_8_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_8_LEN, MAVLINK_MSG_ID_ARRAY_TEST_8_CRC); } +/** + * @brief Pack a array_test_8 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 v3 Stub field + * @param ar_d Value array + * @param ar_u16 Value array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_array_test_8_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t v3, const double *ar_d, const uint16_t *ar_u16) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_ARRAY_TEST_8_LEN]; + _mav_put_uint32_t(buf, 16, v3); + _mav_put_double_array(buf, 0, ar_d, 2); + _mav_put_uint16_t_array(buf, 20, ar_u16, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ARRAY_TEST_8_LEN); +#else + mavlink_array_test_8_t packet; + packet.v3 = v3; + mav_array_memcpy(packet.ar_d, ar_d, sizeof(double)*2); + mav_array_memcpy(packet.ar_u16, ar_u16, sizeof(uint16_t)*2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ARRAY_TEST_8_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_ARRAY_TEST_8; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_8_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_8_LEN, MAVLINK_MSG_ID_ARRAY_TEST_8_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ARRAY_TEST_8_MIN_LEN, MAVLINK_MSG_ID_ARRAY_TEST_8_LEN); +#endif +} + /** * @brief Pack a array_test_8 message on a channel * @param system_id ID of this system @@ -134,6 +171,20 @@ static inline uint16_t mavlink_msg_array_test_8_encode_chan(uint8_t system_id, u return mavlink_msg_array_test_8_pack_chan(system_id, component_id, chan, msg, array_test_8->v3, array_test_8->ar_d, array_test_8->ar_u16); } +/** + * @brief Encode a array_test_8 struct with provided status structure + * + * @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 array_test_8 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_array_test_8_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_array_test_8_t* array_test_8) +{ + return mavlink_msg_array_test_8_pack_status(system_id, component_id, _status, msg, array_test_8->v3, array_test_8->ar_d, array_test_8->ar_u16); +} + /** * @brief Send a array_test_8 message * @param chan MAVLink channel to send the message diff --git a/python_array_test/python_array_test.h b/python_array_test/python_array_test.h index 7ec35bd6..a570a8f9 100644 --- a/python_array_test/python_array_test.h +++ b/python_array_test/python_array_test.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_PYTHON_ARRAY_TEST.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_PYTHON_ARRAY_TEST_XML_HASH 5310555058936034931 +#define MAVLINK_PYTHON_ARRAY_TEST_XML_HASH 9106919784104748946 #ifdef __cplusplus extern "C" { diff --git a/python_array_test/version.h b/python_array_test/version.h index cf66a417..e9301e4d 100644 --- a/python_array_test/version.h +++ b/python_array_test/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/standard/mavlink.h b/standard/mavlink.h index ccf9dd4b..ae4ff0c8 100644 --- a/standard/mavlink.h +++ b/standard/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 2877595257224861749 +#define MAVLINK_PRIMARY_XML_HASH 7810127370362683152 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/standard/standard.h b/standard/standard.h index 5d748efc..30d9f905 100644 --- a/standard/standard.h +++ b/standard/standard.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_STANDARD.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_STANDARD_XML_HASH 2877595257224861749 +#define MAVLINK_STANDARD_XML_HASH 7810127370362683152 #ifdef __cplusplus extern "C" { diff --git a/standard/version.h b/standard/version.h index 38e8e1a9..5ba254c2 100644 --- a/standard/version.h +++ b/standard/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 22 diff --git a/storm32/mavlink.h b/storm32/mavlink.h index 2518e5a3..4a81dda0 100644 --- a/storm32/mavlink.h +++ b/storm32/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -3559734713156637117 +#define MAVLINK_PRIMARY_XML_HASH -1492842404727780309 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/storm32/mavlink_msg_frsky_passthrough_array.h b/storm32/mavlink_msg_frsky_passthrough_array.h index 7563ddf5..8a22be5e 100644 --- a/storm32/mavlink_msg_frsky_passthrough_array.h +++ b/storm32/mavlink_msg_frsky_passthrough_array.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_frsky_passthrough_array_pack(uint8_t system_i return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_MIN_LEN, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_CRC); } +/** + * @brief Pack a frsky_passthrough_array 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 time_boot_ms [ms] Timestamp (time since system boot). + * @param count Number of passthrough packets in this message. + * @param packet_buf Passthrough packet buffer. A packet has 6 bytes: uint16_t id + uint32_t data. The array has space for 40 packets. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_frsky_passthrough_array_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t time_boot_ms, uint8_t count, const uint8_t *packet_buf) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_uint8_t(buf, 4, count); + _mav_put_uint8_t_array(buf, 5, packet_buf, 240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN); +#else + mavlink_frsky_passthrough_array_t packet; + packet.time_boot_ms = time_boot_ms; + packet.count = count; + mav_array_memcpy(packet.packet_buf, packet_buf, sizeof(uint8_t)*240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_MIN_LEN, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_MIN_LEN, MAVLINK_MSG_ID_FRSKY_PASSTHROUGH_ARRAY_LEN); +#endif +} + /** * @brief Pack a frsky_passthrough_array message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_frsky_passthrough_array_encode_chan(uint8_t s return mavlink_msg_frsky_passthrough_array_pack_chan(system_id, component_id, chan, msg, frsky_passthrough_array->time_boot_ms, frsky_passthrough_array->count, frsky_passthrough_array->packet_buf); } +/** + * @brief Encode a frsky_passthrough_array struct with provided status structure + * + * @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 frsky_passthrough_array C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_frsky_passthrough_array_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_frsky_passthrough_array_t* frsky_passthrough_array) +{ + return mavlink_msg_frsky_passthrough_array_pack_status(system_id, component_id, _status, msg, frsky_passthrough_array->time_boot_ms, frsky_passthrough_array->count, frsky_passthrough_array->packet_buf); +} + /** * @brief Send a frsky_passthrough_array message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_param_value_array.h b/storm32/mavlink_msg_param_value_array.h index 78a5dc67..5685bf03 100644 --- a/storm32/mavlink_msg_param_value_array.h +++ b/storm32/mavlink_msg_param_value_array.h @@ -85,6 +85,49 @@ static inline uint16_t mavlink_msg_param_value_array_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_CRC); } +/** + * @brief Pack a param_value_array 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 param_count Total number of onboard parameters. + * @param param_index_first Index of the first onboard parameter in this array. + * @param param_array_len Number of onboard parameters in this array. + * @param flags Flags. + * @param packet_buf Parameters buffer. Contains a series of variable length parameter blocks, one per parameter, with format as specifed elsewhere. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_param_value_array_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t param_count, uint16_t param_index_first, uint8_t param_array_len, uint16_t flags, const uint8_t *packet_buf) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN]; + _mav_put_uint16_t(buf, 0, param_count); + _mav_put_uint16_t(buf, 2, param_index_first); + _mav_put_uint16_t(buf, 4, flags); + _mav_put_uint8_t(buf, 6, param_array_len); + _mav_put_uint8_t_array(buf, 7, packet_buf, 248); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN); +#else + mavlink_param_value_array_t packet; + packet.param_count = param_count; + packet.param_index_first = param_index_first; + packet.flags = flags; + packet.param_array_len = param_array_len; + mav_array_memcpy(packet.packet_buf, packet_buf, sizeof(uint8_t)*248); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE_ARRAY; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_MIN_LEN, MAVLINK_MSG_ID_PARAM_VALUE_ARRAY_LEN); +#endif +} + /** * @brief Pack a param_value_array message on a channel * @param system_id ID of this system @@ -151,6 +194,20 @@ static inline uint16_t mavlink_msg_param_value_array_encode_chan(uint8_t system_ return mavlink_msg_param_value_array_pack_chan(system_id, component_id, chan, msg, param_value_array->param_count, param_value_array->param_index_first, param_value_array->param_array_len, param_value_array->flags, param_value_array->packet_buf); } +/** + * @brief Encode a param_value_array struct with provided status structure + * + * @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 param_value_array C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_param_value_array_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_value_array_t* param_value_array) +{ + return mavlink_msg_param_value_array_pack_status(system_id, component_id, _status, msg, param_value_array->param_count, param_value_array->param_index_first, param_value_array->param_array_len, param_value_array->flags, param_value_array->packet_buf); +} + /** * @brief Send a param_value_array message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_qshot_status.h b/storm32/mavlink_msg_qshot_status.h index 171ac45f..7ec05ccd 100644 --- a/storm32/mavlink_msg_qshot_status.h +++ b/storm32/mavlink_msg_qshot_status.h @@ -69,6 +69,42 @@ static inline uint16_t mavlink_msg_qshot_status_pack(uint8_t system_id, uint8_t return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_QSHOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_QSHOT_STATUS_LEN, MAVLINK_MSG_ID_QSHOT_STATUS_CRC); } +/** + * @brief Pack a qshot_status 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 mode Current shot mode. + * @param shot_state Current state in the shot. States are specific to the selected shot mode. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_qshot_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint16_t mode, uint16_t shot_state) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_QSHOT_STATUS_LEN]; + _mav_put_uint16_t(buf, 0, mode); + _mav_put_uint16_t(buf, 2, shot_state); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_QSHOT_STATUS_LEN); +#else + mavlink_qshot_status_t packet; + packet.mode = mode; + packet.shot_state = shot_state; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_QSHOT_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_QSHOT_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_QSHOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_QSHOT_STATUS_LEN, MAVLINK_MSG_ID_QSHOT_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_QSHOT_STATUS_MIN_LEN, MAVLINK_MSG_ID_QSHOT_STATUS_LEN); +#endif +} + /** * @brief Pack a qshot_status message on a channel * @param system_id ID of this system @@ -128,6 +164,20 @@ static inline uint16_t mavlink_msg_qshot_status_encode_chan(uint8_t system_id, u return mavlink_msg_qshot_status_pack_chan(system_id, component_id, chan, msg, qshot_status->mode, qshot_status->shot_state); } +/** + * @brief Encode a qshot_status struct with provided status structure + * + * @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 qshot_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_qshot_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_qshot_status_t* qshot_status) +{ + return mavlink_msg_qshot_status_pack_status(system_id, component_id, _status, msg, qshot_status->mode, qshot_status->shot_state); +} + /** * @brief Send a qshot_status message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_radio_link_stats.h b/storm32/mavlink_msg_radio_link_stats.h index 605b3440..a840e827 100644 --- a/storm32/mavlink_msg_radio_link_stats.h +++ b/storm32/mavlink_msg_radio_link_stats.h @@ -147,6 +147,81 @@ static inline uint16_t mavlink_msg_radio_link_stats_pack(uint8_t system_id, uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_LINK_STATS_MIN_LEN, MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN, MAVLINK_MSG_ID_RADIO_LINK_STATS_CRC); } +/** + * @brief Pack a radio_link_stats 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 flags Radio link statistics flags. + * @param rx_LQ [c%] Values: 0..100. UINT8_MAX: invalid/unknown. + * @param rx_rssi1 Rssi of antenna1. UINT8_MAX: invalid/unknown. + * @param rx_snr1 Noise on antenna1. Radio dependent. INT8_MAX: invalid/unknown. + * @param rx_rssi2 Rssi of antenna2. UINT8_MAX: ignore/unknown, use rx_rssi1. + * @param rx_snr2 Noise on antenna2. Radio dependent. INT8_MAX: ignore/unknown, use rx_snr1. + * @param rx_receive_antenna 0: antenna1, 1: antenna2, UINT8_MAX: ignore, no Rx receive diversity, use rx_rssi1, rx_snr1. + * @param rx_transmit_antenna 0: antenna1, 1: antenna2, UINT8_MAX: ignore, no Rx transmit diversity. + * @param tx_LQ [c%] Values: 0..100. UINT8_MAX: invalid/unknown. + * @param tx_rssi1 Rssi of antenna1. UINT8_MAX: invalid/unknown. + * @param tx_snr1 Noise on antenna1. Radio dependent. INT8_MAX: invalid/unknown. + * @param tx_rssi2 Rssi of antenna2. UINT8_MAX: ignore/unknown, use tx_rssi1. + * @param tx_snr2 Noise on antenna2. Radio dependent. INT8_MAX: ignore/unknown, use tx_snr1. + * @param tx_receive_antenna 0: antenna1, 1: antenna2, UINT8_MAX: ignore, no Tx receive diversity, use tx_rssi1, tx_snr1. + * @param tx_transmit_antenna 0: antenna1, 1: antenna2, UINT8_MAX: ignore, no Tx transmit diversity. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_link_stats_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t flags, uint8_t rx_LQ, uint8_t rx_rssi1, int8_t rx_snr1, uint8_t rx_rssi2, int8_t rx_snr2, uint8_t rx_receive_antenna, uint8_t rx_transmit_antenna, uint8_t tx_LQ, uint8_t tx_rssi1, int8_t tx_snr1, uint8_t tx_rssi2, int8_t tx_snr2, uint8_t tx_receive_antenna, uint8_t tx_transmit_antenna) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN]; + _mav_put_uint8_t(buf, 0, flags); + _mav_put_uint8_t(buf, 1, rx_LQ); + _mav_put_uint8_t(buf, 2, rx_rssi1); + _mav_put_int8_t(buf, 3, rx_snr1); + _mav_put_uint8_t(buf, 4, rx_rssi2); + _mav_put_int8_t(buf, 5, rx_snr2); + _mav_put_uint8_t(buf, 6, rx_receive_antenna); + _mav_put_uint8_t(buf, 7, rx_transmit_antenna); + _mav_put_uint8_t(buf, 8, tx_LQ); + _mav_put_uint8_t(buf, 9, tx_rssi1); + _mav_put_int8_t(buf, 10, tx_snr1); + _mav_put_uint8_t(buf, 11, tx_rssi2); + _mav_put_int8_t(buf, 12, tx_snr2); + _mav_put_uint8_t(buf, 13, tx_receive_antenna); + _mav_put_uint8_t(buf, 14, tx_transmit_antenna); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN); +#else + mavlink_radio_link_stats_t packet; + packet.flags = flags; + packet.rx_LQ = rx_LQ; + packet.rx_rssi1 = rx_rssi1; + packet.rx_snr1 = rx_snr1; + packet.rx_rssi2 = rx_rssi2; + packet.rx_snr2 = rx_snr2; + packet.rx_receive_antenna = rx_receive_antenna; + packet.rx_transmit_antenna = rx_transmit_antenna; + packet.tx_LQ = tx_LQ; + packet.tx_rssi1 = tx_rssi1; + packet.tx_snr1 = tx_snr1; + packet.tx_rssi2 = tx_rssi2; + packet.tx_snr2 = tx_snr2; + packet.tx_receive_antenna = tx_receive_antenna; + packet.tx_transmit_antenna = tx_transmit_antenna; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO_LINK_STATS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_LINK_STATS_MIN_LEN, MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN, MAVLINK_MSG_ID_RADIO_LINK_STATS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_LINK_STATS_MIN_LEN, MAVLINK_MSG_ID_RADIO_LINK_STATS_LEN); +#endif +} + /** * @brief Pack a radio_link_stats message on a channel * @param system_id ID of this system @@ -245,6 +320,20 @@ static inline uint16_t mavlink_msg_radio_link_stats_encode_chan(uint8_t system_i return mavlink_msg_radio_link_stats_pack_chan(system_id, component_id, chan, msg, radio_link_stats->flags, radio_link_stats->rx_LQ, radio_link_stats->rx_rssi1, radio_link_stats->rx_snr1, radio_link_stats->rx_rssi2, radio_link_stats->rx_snr2, radio_link_stats->rx_receive_antenna, radio_link_stats->rx_transmit_antenna, radio_link_stats->tx_LQ, radio_link_stats->tx_rssi1, radio_link_stats->tx_snr1, radio_link_stats->tx_rssi2, radio_link_stats->tx_snr2, radio_link_stats->tx_receive_antenna, radio_link_stats->tx_transmit_antenna); } +/** + * @brief Encode a radio_link_stats struct with provided status structure + * + * @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 radio_link_stats C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_link_stats_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_radio_link_stats_t* radio_link_stats) +{ + return mavlink_msg_radio_link_stats_pack_status(system_id, component_id, _status, msg, radio_link_stats->flags, radio_link_stats->rx_LQ, radio_link_stats->rx_rssi1, radio_link_stats->rx_snr1, radio_link_stats->rx_rssi2, radio_link_stats->rx_snr2, radio_link_stats->rx_receive_antenna, radio_link_stats->rx_transmit_antenna, radio_link_stats->tx_LQ, radio_link_stats->tx_rssi1, radio_link_stats->tx_snr1, radio_link_stats->tx_rssi2, radio_link_stats->tx_snr2, radio_link_stats->tx_receive_antenna, radio_link_stats->tx_transmit_antenna); +} + /** * @brief Send a radio_link_stats message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_radio_rc_channels.h b/storm32/mavlink_msg_radio_rc_channels.h index 8df5264d..2e47eb13 100644 --- a/storm32/mavlink_msg_radio_rc_channels.h +++ b/storm32/mavlink_msg_radio_rc_channels.h @@ -73,6 +73,43 @@ static inline uint16_t mavlink_msg_radio_rc_channels_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_CRC); } +/** + * @brief Pack a radio_rc_channels 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 count Total number of RC channels being received. This can be larger than 24, indicating that more channels are available but not given in this message. + * @param flags Radio channels status flags. + * @param channels RC channels. Channels above count should be set to 0, to benefit from MAVLink's zero padding. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_rc_channels_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t count, uint8_t flags, const int16_t *channels) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN]; + _mav_put_uint8_t(buf, 0, count); + _mav_put_uint8_t(buf, 1, flags); + _mav_put_int16_t_array(buf, 2, channels, 24); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN); +#else + mavlink_radio_rc_channels_t packet; + packet.count = count; + packet.flags = flags; + mav_array_memcpy(packet.channels, channels, sizeof(int16_t)*24); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO_RC_CHANNELS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_MIN_LEN, MAVLINK_MSG_ID_RADIO_RC_CHANNELS_LEN); +#endif +} + /** * @brief Pack a radio_rc_channels message on a channel * @param system_id ID of this system @@ -133,6 +170,20 @@ static inline uint16_t mavlink_msg_radio_rc_channels_encode_chan(uint8_t system_ return mavlink_msg_radio_rc_channels_pack_chan(system_id, component_id, chan, msg, radio_rc_channels->count, radio_rc_channels->flags, radio_rc_channels->channels); } +/** + * @brief Encode a radio_rc_channels struct with provided status structure + * + * @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 radio_rc_channels C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_rc_channels_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_radio_rc_channels_t* radio_rc_channels) +{ + return mavlink_msg_radio_rc_channels_pack_status(system_id, component_id, _status, msg, radio_rc_channels->count, radio_rc_channels->flags, radio_rc_channels->channels); +} + /** * @brief Send a radio_rc_channels message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_storm32_gimbal_manager_control.h b/storm32/mavlink_msg_storm32_gimbal_manager_control.h index 268d98f4..565a8a2b 100644 --- a/storm32/mavlink_msg_storm32_gimbal_manager_control.h +++ b/storm32/mavlink_msg_storm32_gimbal_manager_control.h @@ -115,6 +115,64 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pack(uint8_t s return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_CRC); } +/** + * @brief Pack a storm32_gimbal_manager_control 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 target_system System ID + * @param target_component Component ID + * @param gimbal_id Gimbal ID of the gimbal manager to address (component ID or 1-6 for non-MAVLink gimbal, 0 for all gimbals). Send command multiple times for more than one but not all gimbals. + * @param client Client which is contacting the gimbal manager (must be set). + * @param device_flags Gimbal device flags to be applied (UINT16_MAX to be ignored). Same flags as used in GIMBAL_DEVICE_SET_ATTITUDE. + * @param manager_flags Gimbal manager flags to be applied (0 to be ignored). + * @param q Quaternion components, w, x, y, z (1 0 0 0 is the null-rotation). Set first element to NaN to be ignored. The frame is determined by the GIMBAL_DEVICE_FLAGS_YAW_IN_xxx_FRAME flags. + * @param angular_velocity_x [rad/s] X component of angular velocity (positive: roll to the right). NaN to be ignored. + * @param angular_velocity_y [rad/s] Y component of angular velocity (positive: tilt up). NaN to be ignored. + * @param angular_velocity_z [rad/s] Z component of angular velocity (positive: pan to the right). NaN to be ignored. The frame is determined by the GIMBAL_DEVICE_FLAGS_YAW_IN_xxx_FRAME flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t gimbal_id, uint8_t client, uint16_t device_flags, uint16_t manager_flags, const float *q, float angular_velocity_x, float angular_velocity_y, float angular_velocity_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN]; + _mav_put_float(buf, 16, angular_velocity_x); + _mav_put_float(buf, 20, angular_velocity_y); + _mav_put_float(buf, 24, angular_velocity_z); + _mav_put_uint16_t(buf, 28, device_flags); + _mav_put_uint16_t(buf, 30, manager_flags); + _mav_put_uint8_t(buf, 32, target_system); + _mav_put_uint8_t(buf, 33, target_component); + _mav_put_uint8_t(buf, 34, gimbal_id); + _mav_put_uint8_t(buf, 35, client); + _mav_put_float_array(buf, 0, q, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN); +#else + mavlink_storm32_gimbal_manager_control_t packet; + packet.angular_velocity_x = angular_velocity_x; + packet.angular_velocity_y = angular_velocity_y; + packet.angular_velocity_z = angular_velocity_z; + packet.device_flags = device_flags; + packet.manager_flags = manager_flags; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_id = gimbal_id; + packet.client = client; + mav_array_memcpy(packet.q, q, sizeof(float)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_LEN); +#endif +} + /** * @brief Pack a storm32_gimbal_manager_control message on a channel * @param system_id ID of this system @@ -196,6 +254,20 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_encode_chan(ui return mavlink_msg_storm32_gimbal_manager_control_pack_chan(system_id, component_id, chan, msg, storm32_gimbal_manager_control->target_system, storm32_gimbal_manager_control->target_component, storm32_gimbal_manager_control->gimbal_id, storm32_gimbal_manager_control->client, storm32_gimbal_manager_control->device_flags, storm32_gimbal_manager_control->manager_flags, storm32_gimbal_manager_control->q, storm32_gimbal_manager_control->angular_velocity_x, storm32_gimbal_manager_control->angular_velocity_y, storm32_gimbal_manager_control->angular_velocity_z); } +/** + * @brief Encode a storm32_gimbal_manager_control struct with provided status structure + * + * @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 storm32_gimbal_manager_control C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storm32_gimbal_manager_control_t* storm32_gimbal_manager_control) +{ + return mavlink_msg_storm32_gimbal_manager_control_pack_status(system_id, component_id, _status, msg, storm32_gimbal_manager_control->target_system, storm32_gimbal_manager_control->target_component, storm32_gimbal_manager_control->gimbal_id, storm32_gimbal_manager_control->client, storm32_gimbal_manager_control->device_flags, storm32_gimbal_manager_control->manager_flags, storm32_gimbal_manager_control->q, storm32_gimbal_manager_control->angular_velocity_x, storm32_gimbal_manager_control->angular_velocity_y, storm32_gimbal_manager_control->angular_velocity_z); +} + /** * @brief Send a storm32_gimbal_manager_control message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_storm32_gimbal_manager_control_pitchyaw.h b/storm32/mavlink_msg_storm32_gimbal_manager_control_pitchyaw.h index e22164e3..4941227a 100644 --- a/storm32/mavlink_msg_storm32_gimbal_manager_control_pitchyaw.h +++ b/storm32/mavlink_msg_storm32_gimbal_manager_control_pitchyaw.h @@ -117,6 +117,66 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pitchyaw_pack( return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_CRC); } +/** + * @brief Pack a storm32_gimbal_manager_control_pitchyaw 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 target_system System ID + * @param target_component Component ID + * @param gimbal_id Gimbal ID of the gimbal manager to address (component ID or 1-6 for non-MAVLink gimbal, 0 for all gimbals). Send command multiple times for more than one but not all gimbals. + * @param client Client which is contacting the gimbal manager (must be set). + * @param device_flags Gimbal device flags to be applied (UINT16_MAX to be ignored). Same flags as used in GIMBAL_DEVICE_SET_ATTITUDE. + * @param manager_flags Gimbal manager flags to be applied (0 to be ignored). + * @param pitch [rad] Pitch/tilt angle (positive: tilt up). NaN to be ignored. + * @param yaw [rad] Yaw/pan angle (positive: pan the right). NaN to be ignored. The frame is determined by the GIMBAL_DEVICE_FLAGS_YAW_IN_xxx_FRAME flags. + * @param pitch_rate [rad/s] Pitch/tilt angular rate (positive: tilt up). NaN to be ignored. + * @param yaw_rate [rad/s] Yaw/pan angular rate (positive: pan to the right). NaN to be ignored. The frame is determined by the GIMBAL_DEVICE_FLAGS_YAW_IN_xxx_FRAME flags. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pitchyaw_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t gimbal_id, uint8_t client, uint16_t device_flags, uint16_t manager_flags, float pitch, float yaw, float pitch_rate, float yaw_rate) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN]; + _mav_put_float(buf, 0, pitch); + _mav_put_float(buf, 4, yaw); + _mav_put_float(buf, 8, pitch_rate); + _mav_put_float(buf, 12, yaw_rate); + _mav_put_uint16_t(buf, 16, device_flags); + _mav_put_uint16_t(buf, 18, manager_flags); + _mav_put_uint8_t(buf, 20, target_system); + _mav_put_uint8_t(buf, 21, target_component); + _mav_put_uint8_t(buf, 22, gimbal_id); + _mav_put_uint8_t(buf, 23, client); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN); +#else + mavlink_storm32_gimbal_manager_control_pitchyaw_t packet; + packet.pitch = pitch; + packet.yaw = yaw; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.device_flags = device_flags; + packet.manager_flags = manager_flags; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_id = gimbal_id; + packet.client = client; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CONTROL_PITCHYAW_LEN); +#endif +} + /** * @brief Pack a storm32_gimbal_manager_control_pitchyaw message on a channel * @param system_id ID of this system @@ -200,6 +260,20 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pitchyaw_encod return mavlink_msg_storm32_gimbal_manager_control_pitchyaw_pack_chan(system_id, component_id, chan, msg, storm32_gimbal_manager_control_pitchyaw->target_system, storm32_gimbal_manager_control_pitchyaw->target_component, storm32_gimbal_manager_control_pitchyaw->gimbal_id, storm32_gimbal_manager_control_pitchyaw->client, storm32_gimbal_manager_control_pitchyaw->device_flags, storm32_gimbal_manager_control_pitchyaw->manager_flags, storm32_gimbal_manager_control_pitchyaw->pitch, storm32_gimbal_manager_control_pitchyaw->yaw, storm32_gimbal_manager_control_pitchyaw->pitch_rate, storm32_gimbal_manager_control_pitchyaw->yaw_rate); } +/** + * @brief Encode a storm32_gimbal_manager_control_pitchyaw struct with provided status structure + * + * @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 storm32_gimbal_manager_control_pitchyaw C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_control_pitchyaw_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storm32_gimbal_manager_control_pitchyaw_t* storm32_gimbal_manager_control_pitchyaw) +{ + return mavlink_msg_storm32_gimbal_manager_control_pitchyaw_pack_status(system_id, component_id, _status, msg, storm32_gimbal_manager_control_pitchyaw->target_system, storm32_gimbal_manager_control_pitchyaw->target_component, storm32_gimbal_manager_control_pitchyaw->gimbal_id, storm32_gimbal_manager_control_pitchyaw->client, storm32_gimbal_manager_control_pitchyaw->device_flags, storm32_gimbal_manager_control_pitchyaw->manager_flags, storm32_gimbal_manager_control_pitchyaw->pitch, storm32_gimbal_manager_control_pitchyaw->yaw, storm32_gimbal_manager_control_pitchyaw->pitch_rate, storm32_gimbal_manager_control_pitchyaw->yaw_rate); +} + /** * @brief Send a storm32_gimbal_manager_control_pitchyaw message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_storm32_gimbal_manager_correct_roll.h b/storm32/mavlink_msg_storm32_gimbal_manager_correct_roll.h index 7f8c9e90..0abf5cc2 100644 --- a/storm32/mavlink_msg_storm32_gimbal_manager_correct_roll.h +++ b/storm32/mavlink_msg_storm32_gimbal_manager_correct_roll.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_correct_roll_pack(uint return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_CRC); } +/** + * @brief Pack a storm32_gimbal_manager_correct_roll 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 target_system System ID + * @param target_component Component ID + * @param gimbal_id Gimbal ID of the gimbal manager to address (component ID or 1-6 for non-MAVLink gimbal, 0 for all gimbals). Send command multiple times for more than one but not all gimbals. + * @param client Client which is contacting the gimbal manager (must be set). + * @param roll [rad] Roll angle (positive to roll to the right). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_correct_roll_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t target_system, uint8_t target_component, uint8_t gimbal_id, uint8_t client, float roll) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN]; + _mav_put_float(buf, 0, roll); + _mav_put_uint8_t(buf, 4, target_system); + _mav_put_uint8_t(buf, 5, target_component); + _mav_put_uint8_t(buf, 6, gimbal_id); + _mav_put_uint8_t(buf, 7, client); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN); +#else + mavlink_storm32_gimbal_manager_correct_roll_t packet; + packet.roll = roll; + packet.target_system = target_system; + packet.target_component = target_component; + packet.gimbal_id = gimbal_id; + packet.client = client; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_CORRECT_ROLL_LEN); +#endif +} + /** * @brief Pack a storm32_gimbal_manager_correct_roll message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_correct_roll_encode_ch return mavlink_msg_storm32_gimbal_manager_correct_roll_pack_chan(system_id, component_id, chan, msg, storm32_gimbal_manager_correct_roll->target_system, storm32_gimbal_manager_correct_roll->target_component, storm32_gimbal_manager_correct_roll->gimbal_id, storm32_gimbal_manager_correct_roll->client, storm32_gimbal_manager_correct_roll->roll); } +/** + * @brief Encode a storm32_gimbal_manager_correct_roll struct with provided status structure + * + * @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 storm32_gimbal_manager_correct_roll C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_correct_roll_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storm32_gimbal_manager_correct_roll_t* storm32_gimbal_manager_correct_roll) +{ + return mavlink_msg_storm32_gimbal_manager_correct_roll_pack_status(system_id, component_id, _status, msg, storm32_gimbal_manager_correct_roll->target_system, storm32_gimbal_manager_correct_roll->target_component, storm32_gimbal_manager_correct_roll->gimbal_id, storm32_gimbal_manager_correct_roll->client, storm32_gimbal_manager_correct_roll->roll); +} + /** * @brief Send a storm32_gimbal_manager_correct_roll message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_storm32_gimbal_manager_information.h b/storm32/mavlink_msg_storm32_gimbal_manager_information.h index 300b809f..339c67cf 100644 --- a/storm32/mavlink_msg_storm32_gimbal_manager_information.h +++ b/storm32/mavlink_msg_storm32_gimbal_manager_information.h @@ -111,6 +111,63 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_information_pack(uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_CRC); } +/** + * @brief Pack a storm32_gimbal_manager_information 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 gimbal_id Gimbal ID (component ID or 1-6 for non-MAVLink gimbal) that this gimbal manager is responsible for. + * @param device_cap_flags Gimbal device capability flags. Same flags as reported by GIMBAL_DEVICE_INFORMATION. The flag is only 16 bit wide, but stored in 32 bit, for backwards compatibility (high word is zero). + * @param manager_cap_flags Gimbal manager capability flags. + * @param roll_min [rad] Hardware minimum roll angle (positive: roll to the right). NaN if unknown. + * @param roll_max [rad] Hardware maximum roll angle (positive: roll to the right). NaN if unknown. + * @param pitch_min [rad] Hardware minimum pitch/tilt angle (positive: tilt up). NaN if unknown. + * @param pitch_max [rad] Hardware maximum pitch/tilt angle (positive: tilt up). NaN if unknown. + * @param yaw_min [rad] Hardware minimum yaw/pan angle (positive: pan to the right, relative to the vehicle/gimbal base). NaN if unknown. + * @param yaw_max [rad] Hardware maximum yaw/pan angle (positive: pan to the right, relative to the vehicle/gimbal base). NaN if unknown. + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t gimbal_id, uint32_t device_cap_flags, uint32_t manager_cap_flags, float roll_min, float roll_max, float pitch_min, float pitch_max, float yaw_min, float yaw_max) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN]; + _mav_put_uint32_t(buf, 0, device_cap_flags); + _mav_put_uint32_t(buf, 4, manager_cap_flags); + _mav_put_float(buf, 8, roll_min); + _mav_put_float(buf, 12, roll_max); + _mav_put_float(buf, 16, pitch_min); + _mav_put_float(buf, 20, pitch_max); + _mav_put_float(buf, 24, yaw_min); + _mav_put_float(buf, 28, yaw_max); + _mav_put_uint8_t(buf, 32, gimbal_id); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN); +#else + mavlink_storm32_gimbal_manager_information_t packet; + packet.device_cap_flags = device_cap_flags; + packet.manager_cap_flags = manager_cap_flags; + packet.roll_min = roll_min; + packet.roll_max = roll_max; + packet.pitch_min = pitch_min; + packet.pitch_max = pitch_max; + packet.yaw_min = yaw_min; + packet.yaw_max = yaw_max; + packet.gimbal_id = gimbal_id; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_INFORMATION_LEN); +#endif +} + /** * @brief Pack a storm32_gimbal_manager_information message on a channel * @param system_id ID of this system @@ -191,6 +248,20 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_information_encode_cha return mavlink_msg_storm32_gimbal_manager_information_pack_chan(system_id, component_id, chan, msg, storm32_gimbal_manager_information->gimbal_id, storm32_gimbal_manager_information->device_cap_flags, storm32_gimbal_manager_information->manager_cap_flags, storm32_gimbal_manager_information->roll_min, storm32_gimbal_manager_information->roll_max, storm32_gimbal_manager_information->pitch_min, storm32_gimbal_manager_information->pitch_max, storm32_gimbal_manager_information->yaw_min, storm32_gimbal_manager_information->yaw_max); } +/** + * @brief Encode a storm32_gimbal_manager_information struct with provided status structure + * + * @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 storm32_gimbal_manager_information C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storm32_gimbal_manager_information_t* storm32_gimbal_manager_information) +{ + return mavlink_msg_storm32_gimbal_manager_information_pack_status(system_id, component_id, _status, msg, storm32_gimbal_manager_information->gimbal_id, storm32_gimbal_manager_information->device_cap_flags, storm32_gimbal_manager_information->manager_cap_flags, storm32_gimbal_manager_information->roll_min, storm32_gimbal_manager_information->roll_max, storm32_gimbal_manager_information->pitch_min, storm32_gimbal_manager_information->pitch_max, storm32_gimbal_manager_information->yaw_min, storm32_gimbal_manager_information->yaw_max); +} + /** * @brief Send a storm32_gimbal_manager_information message * @param chan MAVLink channel to send the message diff --git a/storm32/mavlink_msg_storm32_gimbal_manager_status.h b/storm32/mavlink_msg_storm32_gimbal_manager_status.h index dd4e8e8f..befb9a3d 100644 --- a/storm32/mavlink_msg_storm32_gimbal_manager_status.h +++ b/storm32/mavlink_msg_storm32_gimbal_manager_status.h @@ -87,6 +87,51 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_status_pack(uint8_t sy return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_CRC); } +/** + * @brief Pack a storm32_gimbal_manager_status 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 gimbal_id Gimbal ID (component ID or 1-6 for non-MAVLink gimbal) that this gimbal manager is responsible for. + * @param supervisor Client who is currently supervisor (0 = none). + * @param device_flags Gimbal device flags currently applied. Same flags as reported by GIMBAL_DEVICE_ATTITUDE_STATUS. + * @param manager_flags Gimbal manager flags currently applied. + * @param profile Profile currently applied (0 = default). + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t gimbal_id, uint8_t supervisor, uint16_t device_flags, uint16_t manager_flags, uint8_t profile) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN]; + _mav_put_uint16_t(buf, 0, device_flags); + _mav_put_uint16_t(buf, 2, manager_flags); + _mav_put_uint8_t(buf, 4, gimbal_id); + _mav_put_uint8_t(buf, 5, supervisor); + _mav_put_uint8_t(buf, 6, profile); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN); +#else + mavlink_storm32_gimbal_manager_status_t packet; + packet.device_flags = device_flags; + packet.manager_flags = manager_flags; + packet.gimbal_id = gimbal_id; + packet.supervisor = supervisor; + packet.profile = profile; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_MIN_LEN, MAVLINK_MSG_ID_STORM32_GIMBAL_MANAGER_STATUS_LEN); +#endif +} + /** * @brief Pack a storm32_gimbal_manager_status message on a channel * @param system_id ID of this system @@ -155,6 +200,20 @@ static inline uint16_t mavlink_msg_storm32_gimbal_manager_status_encode_chan(uin return mavlink_msg_storm32_gimbal_manager_status_pack_chan(system_id, component_id, chan, msg, storm32_gimbal_manager_status->gimbal_id, storm32_gimbal_manager_status->supervisor, storm32_gimbal_manager_status->device_flags, storm32_gimbal_manager_status->manager_flags, storm32_gimbal_manager_status->profile); } +/** + * @brief Encode a storm32_gimbal_manager_status struct with provided status structure + * + * @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 storm32_gimbal_manager_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_storm32_gimbal_manager_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storm32_gimbal_manager_status_t* storm32_gimbal_manager_status) +{ + return mavlink_msg_storm32_gimbal_manager_status_pack_status(system_id, component_id, _status, msg, storm32_gimbal_manager_status->gimbal_id, storm32_gimbal_manager_status->supervisor, storm32_gimbal_manager_status->device_flags, storm32_gimbal_manager_status->manager_flags, storm32_gimbal_manager_status->profile); +} + /** * @brief Send a storm32_gimbal_manager_status message * @param chan MAVLink channel to send the message diff --git a/storm32/storm32.h b/storm32/storm32.h index 73873624..5bee2f4c 100644 --- a/storm32/storm32.h +++ b/storm32/storm32.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_STORM32.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_STORM32_XML_HASH -3559734713156637117 +#define MAVLINK_STORM32_XML_HASH -1492842404727780309 #ifdef __cplusplus extern "C" { diff --git a/storm32/version.h b/storm32/version.h index ebe7ad89..1afaea1c 100644 --- a/storm32/version.h +++ b/storm32/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/test/mavlink.h b/test/mavlink.h index eb227c3d..929fea48 100644 --- a/test/mavlink.h +++ b/test/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH -7165503250871205590 +#define MAVLINK_PRIMARY_XML_HASH 8009848575217127560 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/test/mavlink_msg_test_types.h b/test/mavlink_msg_test_types.h index 28aff00c..ea70e205 100644 --- a/test/mavlink_msg_test_types.h +++ b/test/mavlink_msg_test_types.h @@ -197,6 +197,100 @@ static inline uint16_t mavlink_msg_test_types_pack(uint8_t system_id, uint8_t co return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TEST_TYPES_MIN_LEN, MAVLINK_MSG_ID_TEST_TYPES_LEN, MAVLINK_MSG_ID_TEST_TYPES_CRC); } +/** + * @brief Pack a test_types 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 c char + * @param s string + * @param u8 uint8_t + * @param u16 uint16_t + * @param u32 uint32_t + * @param u64 uint64_t + * @param s8 int8_t + * @param s16 int16_t + * @param s32 int32_t + * @param s64 int64_t + * @param f float + * @param d double + * @param u8_array uint8_t_array + * @param u16_array uint16_t_array + * @param u32_array uint32_t_array + * @param u64_array uint64_t_array + * @param s8_array int8_t_array + * @param s16_array int16_t_array + * @param s32_array int32_t_array + * @param s64_array int64_t_array + * @param f_array float_array + * @param d_array double_array + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_test_types_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + char c, const char *s, uint8_t u8, uint16_t u16, uint32_t u32, uint64_t u64, int8_t s8, int16_t s16, int32_t s32, int64_t s64, float f, double d, const uint8_t *u8_array, const uint16_t *u16_array, const uint32_t *u32_array, const uint64_t *u64_array, const int8_t *s8_array, const int16_t *s16_array, const int32_t *s32_array, const int64_t *s64_array, const float *f_array, const double *d_array) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_TEST_TYPES_LEN]; + _mav_put_uint64_t(buf, 0, u64); + _mav_put_int64_t(buf, 8, s64); + _mav_put_double(buf, 16, d); + _mav_put_uint32_t(buf, 96, u32); + _mav_put_int32_t(buf, 100, s32); + _mav_put_float(buf, 104, f); + _mav_put_uint16_t(buf, 144, u16); + _mav_put_int16_t(buf, 146, s16); + _mav_put_char(buf, 160, c); + _mav_put_uint8_t(buf, 171, u8); + _mav_put_int8_t(buf, 172, s8); + _mav_put_uint64_t_array(buf, 24, u64_array, 3); + _mav_put_int64_t_array(buf, 48, s64_array, 3); + _mav_put_double_array(buf, 72, d_array, 3); + _mav_put_uint32_t_array(buf, 108, u32_array, 3); + _mav_put_int32_t_array(buf, 120, s32_array, 3); + _mav_put_float_array(buf, 132, f_array, 3); + _mav_put_uint16_t_array(buf, 148, u16_array, 3); + _mav_put_int16_t_array(buf, 154, s16_array, 3); + _mav_put_char_array(buf, 161, s, 10); + _mav_put_uint8_t_array(buf, 173, u8_array, 3); + _mav_put_int8_t_array(buf, 176, s8_array, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TEST_TYPES_LEN); +#else + mavlink_test_types_t packet; + packet.u64 = u64; + packet.s64 = s64; + packet.d = d; + packet.u32 = u32; + packet.s32 = s32; + packet.f = f; + packet.u16 = u16; + packet.s16 = s16; + packet.c = c; + packet.u8 = u8; + packet.s8 = s8; + mav_array_memcpy(packet.u64_array, u64_array, sizeof(uint64_t)*3); + mav_array_memcpy(packet.s64_array, s64_array, sizeof(int64_t)*3); + mav_array_memcpy(packet.d_array, d_array, sizeof(double)*3); + mav_array_memcpy(packet.u32_array, u32_array, sizeof(uint32_t)*3); + mav_array_memcpy(packet.s32_array, s32_array, sizeof(int32_t)*3); + mav_array_memcpy(packet.f_array, f_array, sizeof(float)*3); + mav_array_memcpy(packet.u16_array, u16_array, sizeof(uint16_t)*3); + mav_array_memcpy(packet.s16_array, s16_array, sizeof(int16_t)*3); + mav_array_memcpy(packet.s, s, sizeof(char)*10); + mav_array_memcpy(packet.u8_array, u8_array, sizeof(uint8_t)*3); + mav_array_memcpy(packet.s8_array, s8_array, sizeof(int8_t)*3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TEST_TYPES_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_TEST_TYPES; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TEST_TYPES_MIN_LEN, MAVLINK_MSG_ID_TEST_TYPES_LEN, MAVLINK_MSG_ID_TEST_TYPES_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TEST_TYPES_MIN_LEN, MAVLINK_MSG_ID_TEST_TYPES_LEN); +#endif +} + /** * @brief Pack a test_types message on a channel * @param system_id ID of this system @@ -314,6 +408,20 @@ static inline uint16_t mavlink_msg_test_types_encode_chan(uint8_t system_id, uin return mavlink_msg_test_types_pack_chan(system_id, component_id, chan, msg, test_types->c, test_types->s, test_types->u8, test_types->u16, test_types->u32, test_types->u64, test_types->s8, test_types->s16, test_types->s32, test_types->s64, test_types->f, test_types->d, test_types->u8_array, test_types->u16_array, test_types->u32_array, test_types->u64_array, test_types->s8_array, test_types->s16_array, test_types->s32_array, test_types->s64_array, test_types->f_array, test_types->d_array); } +/** + * @brief Encode a test_types struct with provided status structure + * + * @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 test_types C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_test_types_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_test_types_t* test_types) +{ + return mavlink_msg_test_types_pack_status(system_id, component_id, _status, msg, test_types->c, test_types->s, test_types->u8, test_types->u16, test_types->u32, test_types->u64, test_types->s8, test_types->s16, test_types->s32, test_types->s64, test_types->f, test_types->d, test_types->u8_array, test_types->u16_array, test_types->u32_array, test_types->u64_array, test_types->s8_array, test_types->s16_array, test_types->s32_array, test_types->s64_array, test_types->f_array, test_types->d_array); +} + /** * @brief Send a test_types message * @param chan MAVLink channel to send the message diff --git a/test/test.h b/test/test.h index 5da1f141..f3d43230 100644 --- a/test/test.h +++ b/test/test.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_TEST.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_TEST_XML_HASH -7165503250871205590 +#define MAVLINK_TEST_XML_HASH 8009848575217127560 #ifdef __cplusplus extern "C" { diff --git a/test/version.h b/test/version.h index a70e9cca..3b32ba46 100644 --- a/test/version.h +++ b/test/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 179 diff --git a/uAvionix/mavlink.h b/uAvionix/mavlink.h index f856c4e4..29acc174 100644 --- a/uAvionix/mavlink.h +++ b/uAvionix/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 2193915101736088877 +#define MAVLINK_PRIMARY_XML_HASH 3188479802552619192 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/uAvionix/mavlink_msg_uavionix_adsb_out_cfg.h b/uAvionix/mavlink_msg_uavionix_adsb_out_cfg.h index ae1b0f46..460b21f8 100644 --- a/uAvionix/mavlink_msg_uavionix_adsb_out_cfg.h +++ b/uAvionix/mavlink_msg_uavionix_adsb_out_cfg.h @@ -103,6 +103,58 @@ static inline uint16_t mavlink_msg_uavionix_adsb_out_cfg_pack(uint8_t system_id, return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_CRC); } +/** + * @brief Pack a uavionix_adsb_out_cfg 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 ICAO Vehicle address (24 bit) + * @param callsign Vehicle identifier (8 characters, null terminated, valid characters are A-Z, 0-9, " " only) + * @param emitterType Transmitting vehicle type. See ADSB_EMITTER_TYPE enum + * @param aircraftSize Aircraft length and width encoding (table 2-35 of DO-282B) + * @param gpsOffsetLat GPS antenna lateral offset (table 2-36 of DO-282B) + * @param gpsOffsetLon GPS antenna longitudinal offset from nose [if non-zero, take position (in meters) divide by 2 and add one] (table 2-37 DO-282B) + * @param stallSpeed [cm/s] Aircraft stall speed in cm/s + * @param rfSelect ADS-B transponder receiver and transmit enable flags + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_uavionix_adsb_out_cfg_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t ICAO, const char *callsign, uint8_t emitterType, uint8_t aircraftSize, uint8_t gpsOffsetLat, uint8_t gpsOffsetLon, uint16_t stallSpeed, uint8_t rfSelect) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN]; + _mav_put_uint32_t(buf, 0, ICAO); + _mav_put_uint16_t(buf, 4, stallSpeed); + _mav_put_uint8_t(buf, 15, emitterType); + _mav_put_uint8_t(buf, 16, aircraftSize); + _mav_put_uint8_t(buf, 17, gpsOffsetLat); + _mav_put_uint8_t(buf, 18, gpsOffsetLon); + _mav_put_uint8_t(buf, 19, rfSelect); + _mav_put_char_array(buf, 6, callsign, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN); +#else + mavlink_uavionix_adsb_out_cfg_t packet; + packet.ICAO = ICAO; + packet.stallSpeed = stallSpeed; + packet.emitterType = emitterType; + packet.aircraftSize = aircraftSize; + packet.gpsOffsetLat = gpsOffsetLat; + packet.gpsOffsetLon = gpsOffsetLon; + packet.rfSelect = rfSelect; + mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_CFG_LEN); +#endif +} + /** * @brief Pack a uavionix_adsb_out_cfg message on a channel * @param system_id ID of this system @@ -178,6 +230,20 @@ static inline uint16_t mavlink_msg_uavionix_adsb_out_cfg_encode_chan(uint8_t sys return mavlink_msg_uavionix_adsb_out_cfg_pack_chan(system_id, component_id, chan, msg, uavionix_adsb_out_cfg->ICAO, uavionix_adsb_out_cfg->callsign, uavionix_adsb_out_cfg->emitterType, uavionix_adsb_out_cfg->aircraftSize, uavionix_adsb_out_cfg->gpsOffsetLat, uavionix_adsb_out_cfg->gpsOffsetLon, uavionix_adsb_out_cfg->stallSpeed, uavionix_adsb_out_cfg->rfSelect); } +/** + * @brief Encode a uavionix_adsb_out_cfg struct with provided status structure + * + * @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 uavionix_adsb_out_cfg C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_uavionix_adsb_out_cfg_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_uavionix_adsb_out_cfg_t* uavionix_adsb_out_cfg) +{ + return mavlink_msg_uavionix_adsb_out_cfg_pack_status(system_id, component_id, _status, msg, uavionix_adsb_out_cfg->ICAO, uavionix_adsb_out_cfg->callsign, uavionix_adsb_out_cfg->emitterType, uavionix_adsb_out_cfg->aircraftSize, uavionix_adsb_out_cfg->gpsOffsetLat, uavionix_adsb_out_cfg->gpsOffsetLon, uavionix_adsb_out_cfg->stallSpeed, uavionix_adsb_out_cfg->rfSelect); +} + /** * @brief Send a uavionix_adsb_out_cfg message * @param chan MAVLink channel to send the message diff --git a/uAvionix/mavlink_msg_uavionix_adsb_out_dynamic.h b/uAvionix/mavlink_msg_uavionix_adsb_out_dynamic.h index 16616b2f..f00b3c02 100644 --- a/uAvionix/mavlink_msg_uavionix_adsb_out_dynamic.h +++ b/uAvionix/mavlink_msg_uavionix_adsb_out_dynamic.h @@ -153,6 +153,84 @@ static inline uint16_t mavlink_msg_uavionix_adsb_out_dynamic_pack(uint8_t system return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_CRC); } +/** + * @brief Pack a uavionix_adsb_out_dynamic 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 utcTime [s] UTC time in seconds since GPS epoch (Jan 6, 1980). If unknown set to UINT32_MAX + * @param gpsLat [degE7] Latitude WGS84 (deg * 1E7). If unknown set to INT32_MAX + * @param gpsLon [degE7] Longitude WGS84 (deg * 1E7). If unknown set to INT32_MAX + * @param gpsAlt [mm] Altitude (WGS84). UP +ve. If unknown set to INT32_MAX + * @param gpsFix 0-1: no fix, 2: 2D fix, 3: 3D fix, 4: DGPS, 5: RTK + * @param numSats Number of satellites visible. If unknown set to UINT8_MAX + * @param baroAltMSL [mbar] Barometric pressure altitude (MSL) relative to a standard atmosphere of 1013.2 mBar and NOT bar corrected altitude (m * 1E-3). (up +ve). If unknown set to INT32_MAX + * @param accuracyHor [mm] Horizontal accuracy in mm (m * 1E-3). If unknown set to UINT32_MAX + * @param accuracyVert [cm] Vertical accuracy in cm. If unknown set to UINT16_MAX + * @param accuracyVel [mm/s] Velocity accuracy in mm/s (m * 1E-3). If unknown set to UINT16_MAX + * @param velVert [cm/s] GPS vertical speed in cm/s. If unknown set to INT16_MAX + * @param velNS [cm/s] North-South velocity over ground in cm/s North +ve. If unknown set to INT16_MAX + * @param VelEW [cm/s] East-West velocity over ground in cm/s East +ve. If unknown set to INT16_MAX + * @param emergencyStatus Emergency status + * @param state ADS-B transponder dynamic input state flags + * @param squawk Mode A code (typically 1200 [0x04B0] for VFR) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_uavionix_adsb_out_dynamic_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint32_t utcTime, int32_t gpsLat, int32_t gpsLon, int32_t gpsAlt, uint8_t gpsFix, uint8_t numSats, int32_t baroAltMSL, uint32_t accuracyHor, uint16_t accuracyVert, uint16_t accuracyVel, int16_t velVert, int16_t velNS, int16_t VelEW, uint8_t emergencyStatus, uint16_t state, uint16_t squawk) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN]; + _mav_put_uint32_t(buf, 0, utcTime); + _mav_put_int32_t(buf, 4, gpsLat); + _mav_put_int32_t(buf, 8, gpsLon); + _mav_put_int32_t(buf, 12, gpsAlt); + _mav_put_int32_t(buf, 16, baroAltMSL); + _mav_put_uint32_t(buf, 20, accuracyHor); + _mav_put_uint16_t(buf, 24, accuracyVert); + _mav_put_uint16_t(buf, 26, accuracyVel); + _mav_put_int16_t(buf, 28, velVert); + _mav_put_int16_t(buf, 30, velNS); + _mav_put_int16_t(buf, 32, VelEW); + _mav_put_uint16_t(buf, 34, state); + _mav_put_uint16_t(buf, 36, squawk); + _mav_put_uint8_t(buf, 38, gpsFix); + _mav_put_uint8_t(buf, 39, numSats); + _mav_put_uint8_t(buf, 40, emergencyStatus); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN); +#else + mavlink_uavionix_adsb_out_dynamic_t packet; + packet.utcTime = utcTime; + packet.gpsLat = gpsLat; + packet.gpsLon = gpsLon; + packet.gpsAlt = gpsAlt; + packet.baroAltMSL = baroAltMSL; + packet.accuracyHor = accuracyHor; + packet.accuracyVert = accuracyVert; + packet.accuracyVel = accuracyVel; + packet.velVert = velVert; + packet.velNS = velNS; + packet.VelEW = VelEW; + packet.state = state; + packet.squawk = squawk; + packet.gpsFix = gpsFix; + packet.numSats = numSats; + packet.emergencyStatus = emergencyStatus; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_OUT_DYNAMIC_LEN); +#endif +} + /** * @brief Pack a uavionix_adsb_out_dynamic message on a channel * @param system_id ID of this system @@ -254,6 +332,20 @@ static inline uint16_t mavlink_msg_uavionix_adsb_out_dynamic_encode_chan(uint8_t return mavlink_msg_uavionix_adsb_out_dynamic_pack_chan(system_id, component_id, chan, msg, uavionix_adsb_out_dynamic->utcTime, uavionix_adsb_out_dynamic->gpsLat, uavionix_adsb_out_dynamic->gpsLon, uavionix_adsb_out_dynamic->gpsAlt, uavionix_adsb_out_dynamic->gpsFix, uavionix_adsb_out_dynamic->numSats, uavionix_adsb_out_dynamic->baroAltMSL, uavionix_adsb_out_dynamic->accuracyHor, uavionix_adsb_out_dynamic->accuracyVert, uavionix_adsb_out_dynamic->accuracyVel, uavionix_adsb_out_dynamic->velVert, uavionix_adsb_out_dynamic->velNS, uavionix_adsb_out_dynamic->VelEW, uavionix_adsb_out_dynamic->emergencyStatus, uavionix_adsb_out_dynamic->state, uavionix_adsb_out_dynamic->squawk); } +/** + * @brief Encode a uavionix_adsb_out_dynamic struct with provided status structure + * + * @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 uavionix_adsb_out_dynamic C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_uavionix_adsb_out_dynamic_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_uavionix_adsb_out_dynamic_t* uavionix_adsb_out_dynamic) +{ + return mavlink_msg_uavionix_adsb_out_dynamic_pack_status(system_id, component_id, _status, msg, uavionix_adsb_out_dynamic->utcTime, uavionix_adsb_out_dynamic->gpsLat, uavionix_adsb_out_dynamic->gpsLon, uavionix_adsb_out_dynamic->gpsAlt, uavionix_adsb_out_dynamic->gpsFix, uavionix_adsb_out_dynamic->numSats, uavionix_adsb_out_dynamic->baroAltMSL, uavionix_adsb_out_dynamic->accuracyHor, uavionix_adsb_out_dynamic->accuracyVert, uavionix_adsb_out_dynamic->accuracyVel, uavionix_adsb_out_dynamic->velVert, uavionix_adsb_out_dynamic->velNS, uavionix_adsb_out_dynamic->VelEW, uavionix_adsb_out_dynamic->emergencyStatus, uavionix_adsb_out_dynamic->state, uavionix_adsb_out_dynamic->squawk); +} + /** * @brief Send a uavionix_adsb_out_dynamic message * @param chan MAVLink channel to send the message diff --git a/uAvionix/mavlink_msg_uavionix_adsb_transceiver_health_report.h b/uAvionix/mavlink_msg_uavionix_adsb_transceiver_health_report.h index cd35c7db..55eca3c1 100644 --- a/uAvionix/mavlink_msg_uavionix_adsb_transceiver_health_report.h +++ b/uAvionix/mavlink_msg_uavionix_adsb_transceiver_health_report.h @@ -63,6 +63,39 @@ static inline uint16_t mavlink_msg_uavionix_adsb_transceiver_health_report_pack( return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_CRC); } +/** + * @brief Pack a uavionix_adsb_transceiver_health_report 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 rfHealth ADS-B transponder messages + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_uavionix_adsb_transceiver_health_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t rfHealth) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN]; + _mav_put_uint8_t(buf, 0, rfHealth); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN); +#else + mavlink_uavionix_adsb_transceiver_health_report_t packet; + packet.rfHealth = rfHealth; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_MIN_LEN, MAVLINK_MSG_ID_UAVIONIX_ADSB_TRANSCEIVER_HEALTH_REPORT_LEN); +#endif +} + /** * @brief Pack a uavionix_adsb_transceiver_health_report message on a channel * @param system_id ID of this system @@ -119,6 +152,20 @@ static inline uint16_t mavlink_msg_uavionix_adsb_transceiver_health_report_encod return mavlink_msg_uavionix_adsb_transceiver_health_report_pack_chan(system_id, component_id, chan, msg, uavionix_adsb_transceiver_health_report->rfHealth); } +/** + * @brief Encode a uavionix_adsb_transceiver_health_report struct with provided status structure + * + * @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 uavionix_adsb_transceiver_health_report C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_uavionix_adsb_transceiver_health_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_uavionix_adsb_transceiver_health_report_t* uavionix_adsb_transceiver_health_report) +{ + return mavlink_msg_uavionix_adsb_transceiver_health_report_pack_status(system_id, component_id, _status, msg, uavionix_adsb_transceiver_health_report->rfHealth); +} + /** * @brief Send a uavionix_adsb_transceiver_health_report message * @param chan MAVLink channel to send the message diff --git a/uAvionix/uAvionix.h b/uAvionix/uAvionix.h index c354b6fc..06852900 100644 --- a/uAvionix/uAvionix.h +++ b/uAvionix/uAvionix.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_UAVIONIX.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_UAVIONIX_XML_HASH 2193915101736088877 +#define MAVLINK_UAVIONIX_XML_HASH 3188479802552619192 #ifdef __cplusplus extern "C" { diff --git a/uAvionix/version.h b/uAvionix/version.h index 87f869d0..18db3a5a 100644 --- a/uAvionix/version.h +++ b/uAvionix/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 diff --git a/ualberta/mavlink.h b/ualberta/mavlink.h index e9dab551..c999f2ae 100644 --- a/ualberta/mavlink.h +++ b/ualberta/mavlink.h @@ -6,7 +6,7 @@ #ifndef MAVLINK_H #define MAVLINK_H -#define MAVLINK_PRIMARY_XML_HASH 7702562220326691030 +#define MAVLINK_PRIMARY_XML_HASH -7753273482002467612 #ifndef MAVLINK_STX #define MAVLINK_STX 253 diff --git a/ualberta/mavlink_msg_nav_filter_bias.h b/ualberta/mavlink_msg_nav_filter_bias.h index 3451314b..55992932 100644 --- a/ualberta/mavlink_msg_nav_filter_bias.h +++ b/ualberta/mavlink_msg_nav_filter_bias.h @@ -99,6 +99,57 @@ static inline uint16_t mavlink_msg_nav_filter_bias_pack(uint8_t system_id, uint8 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_NAV_FILTER_BIAS_MIN_LEN, MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN, MAVLINK_MSG_ID_NAV_FILTER_BIAS_CRC); } +/** + * @brief Pack a nav_filter_bias 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 usec Timestamp (microseconds) + * @param accel_0 b_f[0] + * @param accel_1 b_f[1] + * @param accel_2 b_f[2] + * @param gyro_0 b_f[0] + * @param gyro_1 b_f[1] + * @param gyro_2 b_f[2] + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_nav_filter_bias_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint64_t usec, float accel_0, float accel_1, float accel_2, float gyro_0, float gyro_1, float gyro_2) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN]; + _mav_put_uint64_t(buf, 0, usec); + _mav_put_float(buf, 8, accel_0); + _mav_put_float(buf, 12, accel_1); + _mav_put_float(buf, 16, accel_2); + _mav_put_float(buf, 20, gyro_0); + _mav_put_float(buf, 24, gyro_1); + _mav_put_float(buf, 28, gyro_2); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN); +#else + mavlink_nav_filter_bias_t packet; + packet.usec = usec; + packet.accel_0 = accel_0; + packet.accel_1 = accel_1; + packet.accel_2 = accel_2; + packet.gyro_0 = gyro_0; + packet.gyro_1 = gyro_1; + packet.gyro_2 = gyro_2; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_NAV_FILTER_BIAS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAV_FILTER_BIAS_MIN_LEN, MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN, MAVLINK_MSG_ID_NAV_FILTER_BIAS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_NAV_FILTER_BIAS_MIN_LEN, MAVLINK_MSG_ID_NAV_FILTER_BIAS_LEN); +#endif +} + /** * @brief Pack a nav_filter_bias message on a channel * @param system_id ID of this system @@ -173,6 +224,20 @@ static inline uint16_t mavlink_msg_nav_filter_bias_encode_chan(uint8_t system_id return mavlink_msg_nav_filter_bias_pack_chan(system_id, component_id, chan, msg, nav_filter_bias->usec, nav_filter_bias->accel_0, nav_filter_bias->accel_1, nav_filter_bias->accel_2, nav_filter_bias->gyro_0, nav_filter_bias->gyro_1, nav_filter_bias->gyro_2); } +/** + * @brief Encode a nav_filter_bias struct with provided status structure + * + * @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 nav_filter_bias C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_nav_filter_bias_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_nav_filter_bias_t* nav_filter_bias) +{ + return mavlink_msg_nav_filter_bias_pack_status(system_id, component_id, _status, msg, nav_filter_bias->usec, nav_filter_bias->accel_0, nav_filter_bias->accel_1, nav_filter_bias->accel_2, nav_filter_bias->gyro_0, nav_filter_bias->gyro_1, nav_filter_bias->gyro_2); +} + /** * @brief Send a nav_filter_bias message * @param chan MAVLink channel to send the message diff --git a/ualberta/mavlink_msg_radio_calibration.h b/ualberta/mavlink_msg_radio_calibration.h index e4ed17df..f181441a 100644 --- a/ualberta/mavlink_msg_radio_calibration.h +++ b/ualberta/mavlink_msg_radio_calibration.h @@ -98,6 +98,54 @@ static inline uint16_t mavlink_msg_radio_calibration_pack(uint8_t system_id, uin return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_CALIBRATION_MIN_LEN, MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN, MAVLINK_MSG_ID_RADIO_CALIBRATION_CRC); } +/** + * @brief Pack a radio_calibration 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 aileron Aileron setpoints: left, center, right + * @param elevator Elevator setpoints: nose down, center, nose up + * @param rudder Rudder setpoints: nose left, center, nose right + * @param gyro Tail gyro mode/gain setpoints: heading hold, rate mode + * @param pitch Pitch curve setpoints (every 25%) + * @param throttle Throttle curve setpoints (every 25%) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_calibration_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + const uint16_t *aileron, const uint16_t *elevator, const uint16_t *rudder, const uint16_t *gyro, const uint16_t *pitch, const uint16_t *throttle) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN]; + + _mav_put_uint16_t_array(buf, 0, aileron, 3); + _mav_put_uint16_t_array(buf, 6, elevator, 3); + _mav_put_uint16_t_array(buf, 12, rudder, 3); + _mav_put_uint16_t_array(buf, 18, gyro, 2); + _mav_put_uint16_t_array(buf, 22, pitch, 5); + _mav_put_uint16_t_array(buf, 32, throttle, 5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN); +#else + mavlink_radio_calibration_t packet; + + mav_array_memcpy(packet.aileron, aileron, sizeof(uint16_t)*3); + mav_array_memcpy(packet.elevator, elevator, sizeof(uint16_t)*3); + mav_array_memcpy(packet.rudder, rudder, sizeof(uint16_t)*3); + mav_array_memcpy(packet.gyro, gyro, sizeof(uint16_t)*2); + mav_array_memcpy(packet.pitch, pitch, sizeof(uint16_t)*5); + mav_array_memcpy(packet.throttle, throttle, sizeof(uint16_t)*5); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO_CALIBRATION; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_CALIBRATION_MIN_LEN, MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN, MAVLINK_MSG_ID_RADIO_CALIBRATION_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RADIO_CALIBRATION_MIN_LEN, MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN); +#endif +} + /** * @brief Pack a radio_calibration message on a channel * @param system_id ID of this system @@ -169,6 +217,20 @@ static inline uint16_t mavlink_msg_radio_calibration_encode_chan(uint8_t system_ return mavlink_msg_radio_calibration_pack_chan(system_id, component_id, chan, msg, radio_calibration->aileron, radio_calibration->elevator, radio_calibration->rudder, radio_calibration->gyro, radio_calibration->pitch, radio_calibration->throttle); } +/** + * @brief Encode a radio_calibration struct with provided status structure + * + * @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 radio_calibration C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_calibration_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_radio_calibration_t* radio_calibration) +{ + return mavlink_msg_radio_calibration_pack_status(system_id, component_id, _status, msg, radio_calibration->aileron, radio_calibration->elevator, radio_calibration->rudder, radio_calibration->gyro, radio_calibration->pitch, radio_calibration->throttle); +} + /** * @brief Send a radio_calibration message * @param chan MAVLink channel to send the message diff --git a/ualberta/mavlink_msg_ualberta_sys_status.h b/ualberta/mavlink_msg_ualberta_sys_status.h index b5c1971d..b0565dd4 100644 --- a/ualberta/mavlink_msg_ualberta_sys_status.h +++ b/ualberta/mavlink_msg_ualberta_sys_status.h @@ -75,6 +75,45 @@ static inline uint16_t mavlink_msg_ualberta_sys_status_pack(uint8_t system_id, u return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_CRC); } +/** + * @brief Pack a ualberta_sys_status 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 mode System mode, see UALBERTA_AUTOPILOT_MODE ENUM + * @param nav_mode Navigation mode, see UALBERTA_NAV_MODE ENUM + * @param pilot Pilot mode, see UALBERTA_PILOT_MODE + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ualberta_sys_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg, + uint8_t mode, uint8_t nav_mode, uint8_t pilot) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN]; + _mav_put_uint8_t(buf, 0, mode); + _mav_put_uint8_t(buf, 1, nav_mode); + _mav_put_uint8_t(buf, 2, pilot); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN); +#else + mavlink_ualberta_sys_status_t packet; + packet.mode = mode; + packet.nav_mode = nav_mode; + packet.pilot = pilot; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN); +#endif + + msg->msgid = MAVLINK_MSG_ID_UALBERTA_SYS_STATUS; +#if MAVLINK_CRC_EXTRA + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_CRC); +#else + return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_UALBERTA_SYS_STATUS_LEN); +#endif +} + /** * @brief Pack a ualberta_sys_status message on a channel * @param system_id ID of this system @@ -137,6 +176,20 @@ static inline uint16_t mavlink_msg_ualberta_sys_status_encode_chan(uint8_t syste return mavlink_msg_ualberta_sys_status_pack_chan(system_id, component_id, chan, msg, ualberta_sys_status->mode, ualberta_sys_status->nav_mode, ualberta_sys_status->pilot); } +/** + * @brief Encode a ualberta_sys_status struct with provided status structure + * + * @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 ualberta_sys_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ualberta_sys_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_ualberta_sys_status_t* ualberta_sys_status) +{ + return mavlink_msg_ualberta_sys_status_pack_status(system_id, component_id, _status, msg, ualberta_sys_status->mode, ualberta_sys_status->nav_mode, ualberta_sys_status->pilot); +} + /** * @brief Send a ualberta_sys_status message * @param chan MAVLink channel to send the message diff --git a/ualberta/ualberta.h b/ualberta/ualberta.h index a6b76e79..f7a02a7c 100644 --- a/ualberta/ualberta.h +++ b/ualberta/ualberta.h @@ -10,7 +10,7 @@ #error Wrong include order: MAVLINK_UALBERTA.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. #endif -#define MAVLINK_UALBERTA_XML_HASH 7702562220326691030 +#define MAVLINK_UALBERTA_XML_HASH -7753273482002467612 #ifdef __cplusplus extern "C" { diff --git a/ualberta/version.h b/ualberta/version.h index bcce008e..38fd3698 100644 --- a/ualberta/version.h +++ b/ualberta/version.h @@ -7,7 +7,7 @@ #ifndef MAVLINK_VERSION_H #define MAVLINK_VERSION_H -#define MAVLINK_BUILD_DATE "Mon Mar 04 2024" +#define MAVLINK_BUILD_DATE "Wed Mar 06 2024" #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255