├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── drm.c ├── drm.h ├── fpvue_config.h ├── fpvue_config.h.in ├── gstrtpreceiver.cpp ├── gstrtpreceiver.h ├── icons ├── framerate.png ├── framerate.svg ├── icons.h ├── latency.png ├── latency.svg ├── network.png └── network.svg ├── main.cpp ├── main.h ├── mavlink.c ├── mavlink.h ├── mavlink ├── checksum.h ├── common │ ├── common.h │ ├── mavlink.h │ ├── mavlink_msg_actuator_control_target.h │ ├── mavlink_msg_actuator_output_status.h │ ├── mavlink_msg_adsb_vehicle.h │ ├── mavlink_msg_ais_vessel.h │ ├── mavlink_msg_altitude.h │ ├── mavlink_msg_att_pos_mocap.h │ ├── mavlink_msg_attitude.h │ ├── mavlink_msg_attitude_quaternion.h │ ├── mavlink_msg_attitude_quaternion_cov.h │ ├── mavlink_msg_attitude_target.h │ ├── mavlink_msg_auth_key.h │ ├── mavlink_msg_autopilot_state_for_gimbal_device.h │ ├── mavlink_msg_autopilot_version.h │ ├── mavlink_msg_battery_status.h │ ├── mavlink_msg_button_change.h │ ├── mavlink_msg_camera_capture_status.h │ ├── mavlink_msg_camera_fov_status.h │ ├── mavlink_msg_camera_image_captured.h │ ├── mavlink_msg_camera_information.h │ ├── mavlink_msg_camera_settings.h │ ├── mavlink_msg_camera_tracking_geo_status.h │ ├── mavlink_msg_camera_tracking_image_status.h │ ├── mavlink_msg_camera_trigger.h │ ├── mavlink_msg_can_filter_modify.h │ ├── mavlink_msg_can_frame.h │ ├── mavlink_msg_canfd_frame.h │ ├── mavlink_msg_cellular_config.h │ ├── mavlink_msg_cellular_status.h │ ├── mavlink_msg_change_operator_control.h │ ├── mavlink_msg_change_operator_control_ack.h │ ├── mavlink_msg_collision.h │ ├── mavlink_msg_command_ack.h │ ├── mavlink_msg_command_cancel.h │ ├── mavlink_msg_command_int.h │ ├── mavlink_msg_command_long.h │ ├── mavlink_msg_component_information.h │ ├── mavlink_msg_component_metadata.h │ ├── mavlink_msg_control_system_state.h │ ├── mavlink_msg_current_event_sequence.h │ ├── mavlink_msg_data_stream.h │ ├── mavlink_msg_data_transmission_handshake.h │ ├── mavlink_msg_debug.h │ ├── mavlink_msg_debug_float_array.h │ ├── mavlink_msg_debug_vect.h │ ├── mavlink_msg_distance_sensor.h │ ├── mavlink_msg_efi_status.h │ ├── mavlink_msg_encapsulated_data.h │ ├── mavlink_msg_esc_info.h │ ├── mavlink_msg_esc_status.h │ ├── mavlink_msg_estimator_status.h │ ├── mavlink_msg_event.h │ ├── mavlink_msg_extended_sys_state.h │ ├── mavlink_msg_fence_status.h │ ├── mavlink_msg_file_transfer_protocol.h │ ├── mavlink_msg_flight_information.h │ ├── mavlink_msg_follow_target.h │ ├── mavlink_msg_generator_status.h │ ├── mavlink_msg_gimbal_device_attitude_status.h │ ├── mavlink_msg_gimbal_device_information.h │ ├── mavlink_msg_gimbal_device_set_attitude.h │ ├── mavlink_msg_gimbal_manager_information.h │ ├── mavlink_msg_gimbal_manager_set_attitude.h │ ├── mavlink_msg_gimbal_manager_set_manual_control.h │ ├── mavlink_msg_gimbal_manager_set_pitchyaw.h │ ├── mavlink_msg_gimbal_manager_status.h │ ├── mavlink_msg_global_position_int.h │ ├── mavlink_msg_global_position_int_cov.h │ ├── mavlink_msg_global_vision_position_estimate.h │ ├── mavlink_msg_gps2_raw.h │ ├── mavlink_msg_gps2_rtk.h │ ├── mavlink_msg_gps_global_origin.h │ ├── mavlink_msg_gps_inject_data.h │ ├── mavlink_msg_gps_input.h │ ├── mavlink_msg_gps_raw_int.h │ ├── mavlink_msg_gps_rtcm_data.h │ ├── mavlink_msg_gps_rtk.h │ ├── mavlink_msg_gps_status.h │ ├── mavlink_msg_high_latency.h │ ├── mavlink_msg_high_latency2.h │ ├── mavlink_msg_highres_imu.h │ ├── mavlink_msg_hil_actuator_controls.h │ ├── mavlink_msg_hil_controls.h │ ├── mavlink_msg_hil_gps.h │ ├── mavlink_msg_hil_optical_flow.h │ ├── mavlink_msg_hil_rc_inputs_raw.h │ ├── mavlink_msg_hil_sensor.h │ ├── mavlink_msg_hil_state.h │ ├── mavlink_msg_hil_state_quaternion.h │ ├── mavlink_msg_home_position.h │ ├── mavlink_msg_hygrometer_sensor.h │ ├── mavlink_msg_isbd_link_status.h │ ├── mavlink_msg_landing_target.h │ ├── mavlink_msg_link_node_status.h │ ├── mavlink_msg_local_position_ned.h │ ├── mavlink_msg_local_position_ned_cov.h │ ├── mavlink_msg_local_position_ned_system_global_offset.h │ ├── mavlink_msg_log_data.h │ ├── mavlink_msg_log_entry.h │ ├── mavlink_msg_log_erase.h │ ├── mavlink_msg_log_request_data.h │ ├── mavlink_msg_log_request_end.h │ ├── mavlink_msg_log_request_list.h │ ├── mavlink_msg_logging_ack.h │ ├── mavlink_msg_logging_data.h │ ├── mavlink_msg_logging_data_acked.h │ ├── mavlink_msg_mag_cal_report.h │ ├── mavlink_msg_manual_control.h │ ├── mavlink_msg_manual_setpoint.h │ ├── mavlink_msg_memory_vect.h │ ├── mavlink_msg_message_interval.h │ ├── mavlink_msg_mission_ack.h │ ├── mavlink_msg_mission_clear_all.h │ ├── mavlink_msg_mission_count.h │ ├── mavlink_msg_mission_current.h │ ├── mavlink_msg_mission_item.h │ ├── mavlink_msg_mission_item_int.h │ ├── mavlink_msg_mission_item_reached.h │ ├── mavlink_msg_mission_request.h │ ├── mavlink_msg_mission_request_int.h │ ├── mavlink_msg_mission_request_list.h │ ├── mavlink_msg_mission_request_partial_list.h │ ├── mavlink_msg_mission_set_current.h │ ├── mavlink_msg_mission_write_partial_list.h │ ├── mavlink_msg_mount_orientation.h │ ├── mavlink_msg_named_value_float.h │ ├── mavlink_msg_named_value_int.h │ ├── mavlink_msg_nav_controller_output.h │ ├── mavlink_msg_obstacle_distance.h │ ├── mavlink_msg_odometry.h │ ├── mavlink_msg_onboard_computer_status.h │ ├── mavlink_msg_open_drone_id_arm_status.h │ ├── mavlink_msg_open_drone_id_authentication.h │ ├── mavlink_msg_open_drone_id_basic_id.h │ ├── mavlink_msg_open_drone_id_location.h │ ├── mavlink_msg_open_drone_id_message_pack.h │ ├── mavlink_msg_open_drone_id_operator_id.h │ ├── mavlink_msg_open_drone_id_self_id.h │ ├── mavlink_msg_open_drone_id_system.h │ ├── mavlink_msg_open_drone_id_system_update.h │ ├── mavlink_msg_optical_flow.h │ ├── mavlink_msg_optical_flow_rad.h │ ├── mavlink_msg_orbit_execution_status.h │ ├── mavlink_msg_param_ext_ack.h │ ├── mavlink_msg_param_ext_request_list.h │ ├── mavlink_msg_param_ext_request_read.h │ ├── mavlink_msg_param_ext_set.h │ ├── mavlink_msg_param_ext_value.h │ ├── mavlink_msg_param_map_rc.h │ ├── mavlink_msg_param_request_list.h │ ├── mavlink_msg_param_request_read.h │ ├── mavlink_msg_param_set.h │ ├── mavlink_msg_param_value.h │ ├── mavlink_msg_ping.h │ ├── mavlink_msg_play_tune.h │ ├── mavlink_msg_play_tune_v2.h │ ├── mavlink_msg_position_target_global_int.h │ ├── mavlink_msg_position_target_local_ned.h │ ├── mavlink_msg_power_status.h │ ├── mavlink_msg_radio_status.h │ ├── mavlink_msg_raw_imu.h │ ├── mavlink_msg_raw_pressure.h │ ├── mavlink_msg_raw_rpm.h │ ├── mavlink_msg_rc_channels.h │ ├── mavlink_msg_rc_channels_override.h │ ├── mavlink_msg_rc_channels_raw.h │ ├── mavlink_msg_rc_channels_scaled.h │ ├── mavlink_msg_request_data_stream.h │ ├── mavlink_msg_request_event.h │ ├── mavlink_msg_resource_request.h │ ├── mavlink_msg_response_event_error.h │ ├── mavlink_msg_safety_allowed_area.h │ ├── mavlink_msg_safety_set_allowed_area.h │ ├── mavlink_msg_scaled_imu.h │ ├── mavlink_msg_scaled_imu2.h │ ├── mavlink_msg_scaled_imu3.h │ ├── mavlink_msg_scaled_pressure.h │ ├── mavlink_msg_scaled_pressure2.h │ ├── mavlink_msg_scaled_pressure3.h │ ├── mavlink_msg_serial_control.h │ ├── mavlink_msg_servo_output_raw.h │ ├── mavlink_msg_set_actuator_control_target.h │ ├── mavlink_msg_set_attitude_target.h │ ├── mavlink_msg_set_gps_global_origin.h │ ├── mavlink_msg_set_home_position.h │ ├── mavlink_msg_set_mode.h │ ├── mavlink_msg_set_position_target_global_int.h │ ├── mavlink_msg_set_position_target_local_ned.h │ ├── mavlink_msg_setup_signing.h │ ├── mavlink_msg_sim_state.h │ ├── mavlink_msg_smart_battery_info.h │ ├── mavlink_msg_statustext.h │ ├── mavlink_msg_storage_information.h │ ├── mavlink_msg_supported_tunes.h │ ├── mavlink_msg_sys_status.h │ ├── mavlink_msg_system_time.h │ ├── mavlink_msg_terrain_check.h │ ├── mavlink_msg_terrain_data.h │ ├── mavlink_msg_terrain_report.h │ ├── mavlink_msg_terrain_request.h │ ├── mavlink_msg_time_estimate_to_target.h │ ├── mavlink_msg_timesync.h │ ├── mavlink_msg_trajectory_representation_bezier.h │ ├── mavlink_msg_trajectory_representation_waypoints.h │ ├── mavlink_msg_tunnel.h │ ├── mavlink_msg_uavcan_node_info.h │ ├── mavlink_msg_uavcan_node_status.h │ ├── mavlink_msg_utm_global_position.h │ ├── mavlink_msg_v2_extension.h │ ├── mavlink_msg_vfr_hud.h │ ├── mavlink_msg_vibration.h │ ├── mavlink_msg_vicon_position_estimate.h │ ├── mavlink_msg_video_stream_information.h │ ├── mavlink_msg_video_stream_status.h │ ├── mavlink_msg_vision_position_estimate.h │ ├── mavlink_msg_vision_speed_estimate.h │ ├── mavlink_msg_wheel_distance.h │ ├── mavlink_msg_wifi_config_ap.h │ ├── mavlink_msg_winch_status.h │ ├── mavlink_msg_wind_cov.h │ ├── testsuite.h │ └── version.h ├── mavlink_conversions.h ├── mavlink_get_info.h ├── mavlink_helpers.h ├── mavlink_sha256.h ├── mavlink_types.h ├── minimal │ ├── mavlink.h │ ├── mavlink_msg_heartbeat.h │ ├── mavlink_msg_protocol_version.h │ ├── minimal.h │ ├── testsuite.h │ └── version.h ├── protocol.h └── standard │ ├── mavlink.h │ ├── standard.h │ ├── testsuite.h │ └── version.h ├── minimp4.h ├── notes ├── osd.c ├── osd.h ├── rtp.c ├── rtp.h ├── scheduling_helper.hpp └── time_util.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | fpvue 39 | 40 | # Debug files 41 | *.dSYM/ 42 | *.su 43 | *.idb 44 | *.pdb 45 | 46 | # Kernel Module Compile Results 47 | *.mod* 48 | *.cmd 49 | .tmp_versions/ 50 | modules.order 51 | Module.symvers 52 | Mkfile.old 53 | dkms.conf 54 | 55 | # Cmake files 56 | CMakeCache.txt 57 | CMakeFiles/ 58 | cmake_install.cmake 59 | Makefile 60 | 61 | .vscode/ 62 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | project(fpvue VERSION 0.12) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | 7 | add_compile_options("-Wno-address-of-packed-member") 8 | 9 | set(SOURCE_FILES 10 | drm.h 11 | drm.c 12 | osd.h 13 | osd.c 14 | rtp.h 15 | rtp.c 16 | mavlink.h 17 | mavlink.c 18 | main.cpp 19 | main.h 20 | scheduling_helper.hpp 21 | gstrtpreceiver.cpp 22 | gstrtpreceiver.h) 23 | 24 | include_directories("/usr/include/libdrm" "/usr/include/cairo") 25 | 26 | add_executable(${PROJECT_NAME} ${SOURCE_FILES}) 27 | target_link_libraries(${PROJECT_NAME} rockchip_mpp pthread drm m cairo) 28 | 29 | # Embed gstreamer 30 | find_package(PkgConfig REQUIRED) 31 | pkg_search_module(GST REQUIRED 32 | gstreamer-1.0>=1.4 33 | gstreamer-app-1.0>=1.4 34 | ) 35 | pkg_search_module(gstreamer REQUIRED IMPORTED_TARGET gstreamer-1.0>=1.4) 36 | pkg_search_module(gstreamer-app REQUIRED IMPORTED_TARGET gstreamer-app-1.0>=1.4) 37 | target_link_libraries(${PROJECT_NAME} PkgConfig::gstreamer PkgConfig::gstreamer-app) 38 | 39 | if(CMAKE_BUILD_TYPE MATCHES "Debug") 40 | set( 41 | CMAKE_C_FLAGS 42 | "${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address" 43 | ) 44 | target_link_options(${PROJECT_NAME} 45 | BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address 46 | ) 47 | endif() 48 | 49 | configure_file(fpvue_config.h.in fpvue_config.h) 50 | target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_BINARY_DIR}") 51 | 52 | include(GNUInstallDirs) 53 | install(TARGETS ${PROJECT_NAME} 54 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 55 | ) 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FPVue_rk 2 | 3 | > [!IMPORTANT] 4 | > August 2024: Unfortunately, this repository is now in an unmaintained state. 5 | > I don't have the time to maitain it like I would like to and there was not enough interest from external developers to contribute to it. 6 | > Feel free to fork it and take over but for now it will stay as is. 7 | 8 | WFB-ng client (Video Decoder) for Rockchip platform powered by the [Rockchip MPP library](https://github.com/rockchip-linux/mpp). 9 | It also displays a simple cairo based OSD that shows the bandwidth, decoding latency, and framerate of the decoded video, and wfb-ng link statistics. 10 | 11 | Tested on RK3566 (Radxa Zero 3W) and RK3588s (Orange Pi 5). 12 | 13 | # Compilation 14 | 15 | Build on the Rockchip linux system directly. 16 | 17 | ## Install dependencies 18 | 19 | - rockchip_mpp 20 | 21 | ``` 22 | git clone https://github.com/rockchip-linux/mpp.git 23 | cmake -B build 24 | sudo cmake --build build --target install 25 | ``` 26 | 27 | - drm, cairo 28 | 29 | ``` 30 | sudo apt install libdrm-dev libcairo-dev 31 | ``` 32 | 33 | - gstreamer 34 | 35 | ``` 36 | sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev 37 | ``` 38 | 39 | ## Build Instructions 40 | 41 | Build and run application in production environment: 42 | 43 | ``` 44 | cmake -B build 45 | sudo cmake --build build --target install 46 | build/fpvue 47 | ``` 48 | 49 | Build and run application for debugging purposes: 50 | 51 | ``` 52 | cmake -B build -DCMAKE_BUILD_TYPE=Debug 53 | cmake --build build 54 | build/fpvue --osd 55 | ``` 56 | 57 | ### Usage 58 | 59 | Show command line options: 60 | ``` 61 | fpvue --help 62 | ``` 63 | 64 | ### Known issues 65 | 66 | 1. Video is cropped when the fpv feed resolution is bigger than the screen mode. 67 | 1. Crashes when video feed resolution is higher than the screen resolution. 68 | -------------------------------------------------------------------------------- /drm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * drm.h offers a list of methods to use linux DRM and perform modeset to display video frames and the OSD. 3 | * It uses two different planes for the OSD and the video feed. 4 | * The OSD is drawn using lib cairo. 5 | */ 6 | 7 | #ifndef DRM_H 8 | #define DRM_H 9 | 10 | #define _GNU_SOURCE 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #define OSD_BUF_COUNT 2 29 | 30 | struct drm_object { 31 | drmModeObjectProperties *props; 32 | drmModePropertyRes **props_info; 33 | uint32_t id; 34 | }; 35 | 36 | struct modeset_buf { 37 | uint32_t width; 38 | uint32_t height; 39 | uint32_t stride; 40 | uint32_t size; 41 | uint32_t handle; 42 | uint8_t *map; 43 | uint32_t fb; 44 | }; 45 | 46 | struct modeset_output { 47 | struct drm_object connector; 48 | struct drm_object crtc; 49 | drmModeCrtc *saved_crtc; 50 | 51 | drmModeModeInfo mode; 52 | uint32_t mode_blob_id; 53 | uint32_t crtc_index; 54 | int video_crtc_width; 55 | int video_crtc_height; 56 | 57 | // OSD variables 58 | drmModeAtomicReq *osd_request; 59 | unsigned int osd_buf_switch; 60 | struct modeset_buf osd_bufs[OSD_BUF_COUNT]; 61 | struct drm_object osd_plane; 62 | 63 | // Video variables 64 | drmModeAtomicReq *video_request; 65 | struct drm_object video_plane; 66 | uint32_t video_frm_width; 67 | uint32_t video_frm_height; 68 | int video_fb_x, video_fb_y, video_fb_width, video_fb_height; 69 | int video_fb_id; 70 | 71 | // Used to calculate latency 72 | uint64_t decoding_pts; 73 | int video_poc; 74 | 75 | bool cleanup; 76 | }; 77 | 78 | 79 | int modeset_open(int *out, const char *node); 80 | 81 | int64_t get_property_value(int fd, drmModeObjectPropertiesPtr props,const char *name); 82 | 83 | void modeset_get_object_properties(int fd, struct drm_object *obj, uint32_t type); 84 | 85 | int set_drm_object_property(drmModeAtomicReq *req, struct drm_object *obj, const char *name, uint64_t value); 86 | 87 | int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_output *out); 88 | 89 | const char* drm_fourcc_to_string(uint32_t fourcc); 90 | 91 | int modeset_find_plane(int fd, struct modeset_output *out, struct drm_object *plane_out, uint32_t plane_format); 92 | 93 | void modeset_drm_object_fini(struct drm_object *obj); 94 | 95 | int modeset_setup_objects(int fd, struct modeset_output *out); 96 | 97 | void modeset_destroy_objects(int fd, struct modeset_output *out); 98 | 99 | int modeset_create_fb(int fd, struct modeset_buf *buf); 100 | 101 | void modeset_destroy_fb(int fd, struct modeset_buf *buf); 102 | 103 | int modeset_setup_framebuffers(int fd, drmModeConnector *conn, struct modeset_output *out); 104 | 105 | void modeset_output_destroy(int fd, struct modeset_output *out); 106 | 107 | struct modeset_output *modeset_output_create(int fd, drmModeRes *res, drmModeConnector *conn, uint16_t mode_width, uint16_t mode_height, uint32_t mode_vrefresh); 108 | 109 | int modeset_prepare(int fd, struct modeset_output *output_list, uint16_t mode_width, uint16_t mode_height, uint32_t mode_vrefresh); 110 | 111 | int modeset_perform_modeset(int fd, struct modeset_output *out, drmModeAtomicReq * req, struct drm_object *plane, int fb_id, uint32_t width, uint32_t height, int zpos); 112 | 113 | int modeset_atomic_prepare_commit(int fd, struct modeset_output *out, drmModeAtomicReq *req, struct drm_object *plane, int fb_id, uint32_t width, uint32_t height, int zpos); 114 | 115 | void restore_planes_zpos(int fd, struct modeset_output *output_list); 116 | 117 | void modeset_cleanup(int fd, struct modeset_output *output_list); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /fpvue_config.h: -------------------------------------------------------------------------------- 1 | #define fpvue_VERSION_MAJOR 0 2 | #define fpvue_VERSION_MINOR 13.1 3 | -------------------------------------------------------------------------------- /fpvue_config.h.in: -------------------------------------------------------------------------------- 1 | #define fpvue_VERSION_MAJOR @fpvue_VERSION_MAJOR@ 2 | #define fpvue_VERSION_MINOR @fpvue_VERSION_MINOR@ -------------------------------------------------------------------------------- /gstrtpreceiver.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by https://github.com/Consti10 on 09.04.24. 3 | // https://github.com/OpenHD/FPVue_RK3566/tree/openhd 4 | // 5 | 6 | #include "gstrtpreceiver.h" 7 | #include "gst/gstparse.h" 8 | #include "gst/gstpipeline.h" 9 | #include "gst/app/gstappsink.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #define qDebug() std::cout 19 | 20 | namespace pipeline { 21 | static std::string gst_create_rtp_caps(const VideoCodec& videoCodec){ 22 | std::stringstream ss; 23 | if(videoCodec==VideoCodec::H264){ 24 | ss<<"caps=\"application/x-rtp, media=(string)video, encoding-name=(string)H264, payload=(int)96\""; 25 | }else if(videoCodec==VideoCodec::H265){ 26 | ss<<"caps=\"application/x-rtp, media=(string)video, encoding-name=(string)H265\""; 27 | } 28 | return ss.str(); 29 | } 30 | static std::string create_rtp_depacketize_for_codec(const VideoCodec& codec){ 31 | if(codec==VideoCodec::H264)return "rtph264depay ! "; 32 | if(codec==VideoCodec::H265)return "rtph265depay ! "; 33 | assert(false); 34 | return ""; 35 | } 36 | static std::string create_parse_for_codec(const VideoCodec& codec){ 37 | // config-interval=-1 = makes 100% sure each keyframe has SPS and PPS 38 | if(codec==VideoCodec::H264)return "h264parse config-interval=-1 ! "; 39 | if(codec==VideoCodec::H265)return "h265parse config-interval=-1 ! "; 40 | assert(false); 41 | return ""; 42 | } 43 | static std::string create_out_caps(const VideoCodec& codec){ 44 | if(codec==VideoCodec::H264){ 45 | std::stringstream ss; 46 | ss<<"video/x-h264"; 47 | ss<<", stream-format=\"byte-stream\",alignment=nal"; 48 | //ss<<", alignment=\"nal\""; 49 | ss<<" ! "; 50 | return ss.str(); 51 | }else if(codec==VideoCodec::H265){ 52 | std::stringstream ss; 53 | ss<<"video/x-h265"; 54 | ss<<", stream-format=\"byte-stream\""; 55 | //ss<<", alignment=\"nal\""; 56 | ss<<" ! "; 57 | return ss.str(); 58 | } 59 | assert(false); 60 | } 61 | } 62 | 63 | static void initGstreamerOrThrow() { 64 | GError* error = nullptr; 65 | if (!gst_init_check(nullptr, nullptr, &error)) { 66 | g_error_free(error); 67 | throw std::runtime_error("GStreamer initialization failed"); 68 | } 69 | } 70 | 71 | GstRtpReceiver::GstRtpReceiver(int udp_port, const VideoCodec& codec) 72 | { 73 | m_port=udp_port; 74 | m_video_codec=codec; 75 | initGstreamerOrThrow(); 76 | } 77 | 78 | 79 | GstRtpReceiver::~GstRtpReceiver(){} 80 | 81 | static std::shared_ptr> gst_copy_buffer(GstBuffer* buffer){ 82 | assert(buffer); 83 | const auto buff_size = gst_buffer_get_size(buffer); 84 | auto ret = std::make_shared>(buff_size); 85 | GstMapInfo map; 86 | gst_buffer_map(buffer, &map, GST_MAP_READ); 87 | assert(map.size == buff_size); 88 | std::memcpy(ret->data(), map.data, buff_size); 89 | gst_buffer_unmap(buffer, &map); 90 | return ret; 91 | } 92 | 93 | static void loop_pull_appsink_samples(bool& keep_looping,GstElement *app_sink_element, 94 | const GstRtpReceiver::NEW_FRAME_CALLBACK out_cb){ 95 | assert(app_sink_element); 96 | assert(out_cb); 97 | const uint64_t timeout_ns=std::chrono::duration_cast(std::chrono::milliseconds(100)).count(); 98 | while (keep_looping){ 99 | //GstSample* sample = nullptr; 100 | GstSample* sample= gst_app_sink_try_pull_sample(GST_APP_SINK(app_sink_element),timeout_ns); 101 | if (sample) { 102 | //gst_debug_sample(sample); 103 | GstBuffer* buffer = gst_sample_get_buffer(sample); 104 | if (buffer) { 105 | auto buff_copy=gst_copy_buffer(buffer); 106 | out_cb(buff_copy); 107 | } 108 | gst_sample_unref(sample); 109 | } 110 | } 111 | } 112 | 113 | 114 | std::string GstRtpReceiver::construct_gstreamer_pipeline() 115 | { 116 | std::stringstream ss; 117 | ss<<"udpsrc port="<> sample){ 129 | this->on_new_sample(sample); 130 | }; 131 | loop_pull_appsink_samples(m_pull_samples_run,m_app_sink_element,cb); 132 | } 133 | 134 | void GstRtpReceiver::on_new_sample(std::shared_ptr > sample) 135 | { 136 | if(m_cb){ 137 | //debug_sample(sample); 138 | m_cb(sample); 139 | }else{ 140 | } 141 | } 142 | 143 | 144 | void GstRtpReceiver::start_receiving(NEW_FRAME_CALLBACK cb) 145 | { 146 | std::cout<<"GstRtpReceiver::start_receiving begin"<message; 156 | return; 157 | } 158 | if(!m_gst_pipeline || !(GST_IS_PIPELINE(m_gst_pipeline))){ 159 | qDebug()<<"Cannot construct pipeline"; 160 | m_gst_pipeline = nullptr; 161 | return; 162 | } 163 | gst_element_set_state (m_gst_pipeline, GST_STATE_PLAYING); 164 | // 165 | // we pull data out of the gst pipeline as cpu memory buffer(s) using the gstreamer "appsink" element 166 | m_app_sink_element=gst_bin_get_by_name(GST_BIN(m_gst_pipeline), "out_appsink"); 167 | assert(m_app_sink_element); 168 | m_pull_samples_run= true; 169 | m_pull_samples_thread=std::make_unique(&GstRtpReceiver::loop_pull_samples, this); 170 | 171 | qDebug()<<"GstRtpReceiver::start_receiving end"; 172 | } 173 | 174 | void GstRtpReceiver::stop_receiving() 175 | { 176 | m_pull_samples_run=false; 177 | if(m_pull_samples_thread){ 178 | m_pull_samples_thread->join(); 179 | m_pull_samples_thread=nullptr; 180 | } 181 | //TODO unref appsink reference 182 | if (m_gst_pipeline != nullptr) { 183 | // Needed on jetson ?! 184 | gst_element_send_event ((GstElement*)m_gst_pipeline, gst_event_new_eos ()); 185 | gst_element_set_state(m_gst_pipeline, GST_STATE_PAUSED); 186 | gst_element_set_state (m_gst_pipeline, GST_STATE_NULL); 187 | gst_object_unref (m_gst_pipeline); 188 | m_gst_pipeline=nullptr; 189 | } 190 | } -------------------------------------------------------------------------------- /gstrtpreceiver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by https://github.com/Consti10 on 09.04.24. 3 | // https://github.com/OpenHD/FPVue_RK3566/tree/openhd 4 | // 5 | 6 | #ifndef FPVUE_GSTRTPRECEIVER_H 7 | #define FPVUE_GSTRTPRECEIVER_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | enum class VideoCodec { 16 | UNKNOWN=0, 17 | H264, 18 | H265 19 | }; 20 | 21 | static VideoCodec video_codec(const char * str) { 22 | if (!strcmp(str, "h264")) { 23 | return VideoCodec::H264; 24 | } 25 | if (!strcmp(str, "h265")) { 26 | return VideoCodec::H265; 27 | } 28 | return VideoCodec::UNKNOWN; 29 | } 30 | 31 | /** 32 | * @brief Uses gstreamer and appsink to expose the functionality of receiving and parsing 33 | * rtp h264 and h265. 34 | */ 35 | class GstRtpReceiver { 36 | public: 37 | /** 38 | * The constructor is delayed, remember to use start_receiving() 39 | */ 40 | explicit GstRtpReceiver(int udp_port, const VideoCodec& codec); 41 | virtual ~GstRtpReceiver(); 42 | // Depending on the codec, these are h264,h265 or mjpeg "frames" / frame buffers 43 | // The big advantage of gstreamer is that it seems to handle all those parsing quirks the best, 44 | // e.g. the frames on this cb should be easily passable to whatever decode api is available. 45 | typedef std::function> frame)> NEW_FRAME_CALLBACK; 46 | void start_receiving(NEW_FRAME_CALLBACK cb); 47 | void stop_receiving(); 48 | private: 49 | std::string construct_gstreamer_pipeline(); 50 | void loop_pull_samples(); 51 | void on_new_sample(std::shared_ptr> sample); 52 | private: 53 | // The gstreamer pipeline 54 | GstElement * m_gst_pipeline=nullptr; 55 | NEW_FRAME_CALLBACK m_cb; 56 | VideoCodec m_video_codec; 57 | int m_port; 58 | // appsink 59 | GstElement *m_app_sink_element = nullptr; 60 | bool m_pull_samples_run; 61 | std::unique_ptr m_pull_samples_thread=nullptr; 62 | }; 63 | 64 | 65 | #endif //FPVUE_GSTRTPRECEIVER_H 66 | -------------------------------------------------------------------------------- /icons/framerate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gehee/FPVue_rk/c9ae2a484f0563fe16487be8ace1a93cef84c8e0/icons/framerate.png -------------------------------------------------------------------------------- /icons/framerate.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/icons.h: -------------------------------------------------------------------------------- 1 | const char latency_icon[463] = { 2 | 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 3 | 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 4 | 0x00, 0x18, 0x08, 0x06, 0x00, 0x00, 0x00, 0xe0, 0x77, 0x3d, 0xf8, 5 | 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 6 | 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x01, 0x84, 7 | 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xdd, 0x94, 0x3f, 0x4f, 0xc2, 8 | 0x50, 0x14, 0xc5, 0x29, 0x76, 0xd2, 0xa0, 0x0e, 0xec, 0x46, 0x1d, 9 | 0x89, 0x46, 0x47, 0x5c, 0xb4, 0x09, 0xdf, 0xa3, 0x7c, 0x0a, 0x63, 10 | 0xfc, 0xf3, 0x3d, 0x90, 0x85, 0x59, 0xfc, 0x06, 0x22, 0x1b, 0x09, 11 | 0x3a, 0xb2, 0x28, 0xca, 0xe0, 0x22, 0x30, 0xe0, 0x04, 0x38, 0xff, 12 | 0x1c, 0x7a, 0xaa, 0x2f, 0xa5, 0x7d, 0x2d, 0x83, 0x83, 0xde, 0xe4, 13 | 0x26, 0xed, 0x7d, 0xe7, 0x9e, 0x73, 0xfa, 0xde, 0x7d, 0xcd, 0xe5, 14 | 0x7e, 0x39, 0x9c, 0x2c, 0x20, 0x80, 0xd8, 0x66, 0xc7, 0x49, 0xed, 15 | 0xcf, 0x2f, 0xeb, 0xe8, 0xef, 0x05, 0xe0, 0x01, 0x75, 0xa0, 0x0f, 16 | 0xcc, 0x81, 0x4f, 0x60, 0x00, 0x34, 0x80, 0x0a, 0xe0, 0x08, 0x57, 17 | 0x04, 0xb6, 0x96, 0x21, 0xde, 0x05, 0xda, 0xa4, 0x47, 0x17, 0x38, 18 | 0x01, 0x7a, 0xc0, 0x5b, 0x26, 0x11, 0xe0, 0x08, 0xf8, 0x10, 0xc1, 19 | 0x3b, 0x70, 0x0a, 0x94, 0x80, 0x55, 0x65, 0x49, 0xb5, 0x61, 0x44, 20 | 0xac, 0x07, 0x14, 0xb3, 0x38, 0x0f, 0xc9, 0x6f, 0x80, 0x82, 0x05, 21 | 0x5b, 0x00, 0x9a, 0x86, 0xc0, 0x71, 0x16, 0xf7, 0x6d, 0x83, 0x7c, 22 | 0x61, 0xca, 0x00, 0x17, 0x78, 0x54, 0xba, 0xc0, 0x8a, 0x21, 0xd2, 23 | 0x0d, 0xcf, 0x24, 0x89, 0xdc, 0x13, 0x70, 0x08, 0x6c, 0x24, 0x60, 24 | 0x7c, 0xc3, 0xb1, 0xaf, 0xda, 0x06, 0x30, 0x52, 0xad, 0x62, 0x13, 25 | 0xa8, 0x0b, 0x74, 0x9e, 0xb0, 0xee, 0x12, 0x4c, 0x50, 0x18, 0x03, 26 | 0xc0, 0xd5, 0xda, 0xa5, 0x6a, 0x0d, 0x9b, 0xc0, 0x8b, 0x40, 0x07, 27 | 0x29, 0xee, 0x07, 0x86, 0x50, 0x55, 0x6b, 0x87, 0x7a, 0x7f, 0xb5, 28 | 0x09, 0xcc, 0x58, 0x8c, 0x8e, 0x9c, 0x9b, 0xee, 0xab, 0x91, 0xad, 29 | 0x32, 0x63, 0x6e, 0x13, 0x98, 0x26, 0x34, 0xf9, 0x22, 0xfd, 0xde, 30 | 0x16, 0x65, 0x27, 0x06, 0x3b, 0xb5, 0x09, 0xf4, 0xcd, 0x2d, 0x8a, 31 | 0x90, 0x86, 0xee, 0xfd, 0x84, 0xde, 0x70, 0x8b, 0x9e, 0x6d, 0x02, 32 | 0xd7, 0x02, 0x5d, 0xe8, 0x3d, 0xf1, 0x50, 0x63, 0x7a, 0xaf, 0x84, 33 | 0xa9, 0xd9, 0x04, 0xc2, 0x31, 0x1d, 0xa1, 0x31, 0x25, 0x66, 0x2c, 34 | 0x63, 0xfa, 0x36, 0x81, 0xb1, 0x30, 0x5e, 0xa2, 0x80, 0xc0, 0xf7, 35 | 0x02, 0x36, 0x81, 0xbc, 0xbe, 0xe2, 0x41, 0xb9, 0xe0, 0x9e, 0xe0, 36 | 0xa2, 0xdd, 0xaa, 0xe7, 0xce, 0x4a, 0xae, 0x86, 0x1d, 0x60, 0x62, 37 | 0x88, 0xd8, 0x7e, 0x15, 0xeb, 0xfc, 0xdc, 0xe2, 0x09, 0xb0, 0x9d, 38 | 0x2a, 0xa0, 0xc6, 0xb2, 0x21, 0x32, 0x02, 0xce, 0x80, 0x3d, 0x60, 39 | 0x4d, 0xb9, 0xaf, 0xda, 0xd8, 0x20, 0x2f, 0x67, 0x22, 0x8f, 0x7c, 40 | 0x49, 0x8b, 0xf4, 0x68, 0x65, 0x76, 0x9e, 0x20, 0xe4, 0x11, 0x4c, 41 | 0xd7, 0x13, 0xc1, 0x45, 0x9c, 0xe9, 0xb9, 0x96, 0x7a, 0xa0, 0xff, 42 | 0x22, 0xbe, 0x00, 0xec, 0x1b, 0x45, 0x0c, 0x8b, 0xb6, 0xa0, 0x39, 43 | 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 44 | 0x82 45 | }; 46 | 47 | const int latency_icon_length = 463; 48 | 49 | const char framerate_icon[507] = { 50 | 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 51 | 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 52 | 0x00, 0x18, 0x08, 0x06, 0x00, 0x00, 0x00, 0xe0, 0x77, 0x3d, 0xf8, 53 | 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 54 | 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x01, 0xb0, 55 | 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xd5, 0xd4, 0xbd, 0x4e, 0x54, 56 | 0x51, 0x10, 0x07, 0x70, 0x76, 0x09, 0x24, 0x66, 0x35, 0x59, 0x83, 57 | 0x12, 0x3a, 0x0b, 0xb1, 0xc2, 0xc4, 0xc4, 0xb5, 0x92, 0x80, 0x21, 58 | 0x50, 0x51, 0xd0, 0xd3, 0xfa, 0x08, 0xd4, 0x9a, 0x18, 0x78, 0x8b, 59 | 0x45, 0xde, 0x40, 0x22, 0x35, 0x46, 0xb0, 0xc0, 0xca, 0xca, 0x02, 60 | 0x05, 0x29, 0x88, 0x8d, 0x62, 0x80, 0x42, 0xc1, 0xfa, 0x67, 0x71, 61 | 0x66, 0xe3, 0xc9, 0xd5, 0xbb, 0xf7, 0x62, 0x62, 0xc1, 0x74, 0x67, 62 | 0xe6, 0xff, 0x31, 0x77, 0xce, 0x99, 0x3b, 0x30, 0xf0, 0x9f, 0xa3, 63 | 0x51, 0x07, 0x04, 0x7f, 0x25, 0x37, 0x1a, 0x95, 0xfc, 0xe6, 0x45, 64 | 0x3b, 0xba, 0x7c, 0x81, 0x19, 0x74, 0xb1, 0x87, 0x73, 0xfc, 0xc4, 65 | 0x3e, 0x9e, 0x63, 0x3a, 0xc3, 0xdd, 0xc0, 0xad, 0x8b, 0x08, 0xdf, 66 | 0xc6, 0x6b, 0xd5, 0xf1, 0x0a, 0x1d, 0xbc, 0xc7, 0x61, 0x2d, 0x13, 67 | 0x3c, 0xc4, 0x49, 0x08, 0x1c, 0xe1, 0x09, 0xee, 0xa1, 0x85, 0xab, 68 | 0x58, 0xc7, 0xdb, 0x0c, 0xd3, 0x8b, 0x5d, 0xdc, 0xac, 0xd3, 0x79, 69 | 0x8f, 0x78, 0x80, 0x76, 0xa1, 0x3e, 0x81, 0x63, 0x8c, 0xa2, 0x8d, 70 | 0x8d, 0xcc, 0x60, 0xba, 0x4c, 0x37, 0x17, 0xe8, 0x8d, 0x65, 0x03, 71 | 0x9f, 0x31, 0x59, 0xa8, 0x6f, 0x62, 0x29, 0x3b, 0x0f, 0xc6, 0x17, 72 | 0xc1, 0x9b, 0x2a, 0xf1, 0x99, 0x00, 0x1e, 0xe3, 0x3a, 0x16, 0xf1, 73 | 0x0e, 0xcd, 0xa8, 0x2f, 0xc4, 0x65, 0x0f, 0x15, 0x78, 0xed, 0x18, 74 | 0x25, 0x3c, 0xea, 0x67, 0xd0, 0x0d, 0xd0, 0xb3, 0x38, 0x37, 0xb0, 75 | 0x83, 0xc7, 0x18, 0x8e, 0x91, 0xcd, 0x97, 0x70, 0x97, 0x83, 0xbb, 76 | 0xda, 0xcf, 0x60, 0x3f, 0x40, 0x0f, 0xb2, 0x5c, 0x07, 0x5f, 0xb0, 77 | 0xa2, 0x5e, 0xec, 0xf5, 0x33, 0x38, 0x0b, 0x50, 0xab, 0x90, 0x5f, 78 | 0x2b, 0x88, 0x7c, 0xc7, 0x58, 0x01, 0x33, 0x12, 0xb5, 0xf3, 0x3a, 79 | 0x06, 0x23, 0x85, 0xfc, 0x58, 0x88, 0xe6, 0xb1, 0x56, 0xc0, 0xb4, 80 | 0x22, 0xff, 0xa3, 0xce, 0x88, 0xaa, 0x62, 0x45, 0x1a, 0x5b, 0x27, 81 | 0xe3, 0xde, 0xaf, 0x33, 0xa2, 0xd5, 0x00, 0x2d, 0x97, 0xd4, 0xe7, 82 | 0xa5, 0x8b, 0x1e, 0x96, 0x2e, 0x7e, 0x07, 0x8d, 0xa8, 0x3d, 0x0d, 83 | 0x6e, 0xb7, 0x9f, 0xc1, 0x5c, 0x80, 0x8e, 0xfc, 0xb9, 0x60, 0x43, 84 | 0xd2, 0x13, 0x5d, 0x88, 0x73, 0x53, 0x7a, 0xc2, 0x8b, 0xd2, 0x33, 85 | 0xfd, 0x16, 0xdc, 0xb9, 0x52, 0x83, 0x20, 0x6e, 0x07, 0xf0, 0x05, 86 | 0x06, 0xb3, 0xfc, 0x12, 0x36, 0x0b, 0xd8, 0x49, 0x69, 0x19, 0x7b, 87 | 0xdb, 0xbc, 0xdd, 0x57, 0x3c, 0x48, 0xe3, 0x38, 0x0d, 0xc2, 0xcb, 88 | 0xe8, 0x6e, 0x54, 0x5a, 0xbe, 0x89, 0x02, 0xb6, 0x8d, 0x4f, 0x81, 89 | 0x3d, 0xc5, 0x78, 0xa5, 0x41, 0x10, 0xa7, 0x32, 0x93, 0x13, 0xe9, 90 | 0xc7, 0xb6, 0x8e, 0x6b, 0xb8, 0x82, 0xbb, 0x31, 0xf3, 0xaf, 0x99, 91 | 0xf8, 0x54, 0x2d, 0xf1, 0xcc, 0xe4, 0x0e, 0xb6, 0x4a, 0xdf, 0xd1, 92 | 0xef, 0xd8, 0xaa, 0xdd, 0x79, 0x89, 0xd1, 0xac, 0xf4, 0x0b, 0xf9, 93 | 0x28, 0xed, 0xc9, 0x19, 0x3e, 0x44, 0x6e, 0xf6, 0x9f, 0x85, 0x2f, 94 | 0x4d, 0xfc, 0x02, 0xd9, 0xf7, 0x4c, 0x2f, 0x4d, 0x7a, 0xc8, 0x5c, 95 | 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 96 | 0x82 97 | }; 98 | 99 | const int framerate_icon_length = 507; 100 | 101 | 102 | const char bandwidth_icon[440] = { 103 | 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 104 | 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 105 | 0x00, 0x18, 0x08, 0x06, 0x00, 0x00, 0x00, 0xe0, 0x77, 0x3d, 0xf8, 106 | 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 107 | 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x01, 0x6d, 108 | 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xed, 0x92, 0xbd, 0x4a, 0x03, 109 | 0x51, 0x14, 0x84, 0xcf, 0x4d, 0x8c, 0x29, 0x56, 0x10, 0x94, 0x80, 110 | 0x85, 0x20, 0x28, 0xa4, 0x12, 0xac, 0x35, 0x85, 0xb5, 0x20, 0xa4, 111 | 0x71, 0xab, 0x08, 0x16, 0x29, 0xb4, 0xb0, 0x96, 0xe0, 0x0b, 0xe4, 112 | 0x3d, 0x2c, 0x82, 0x09, 0x79, 0x81, 0xbc, 0x83, 0x9d, 0x8a, 0xd1, 113 | 0x58, 0x68, 0xa5, 0x1b, 0x4b, 0xf3, 0x87, 0x88, 0x9f, 0xcd, 0x59, 114 | 0xb8, 0xac, 0x37, 0xc9, 0x26, 0x5a, 0x58, 0x64, 0x9a, 0x65, 0x67, 115 | 0xe6, 0xcc, 0x9d, 0x3d, 0x7b, 0x45, 0x66, 0xf8, 0xd7, 0x00, 0x52, 116 | 0xc0, 0x01, 0x50, 0x01, 0xee, 0x81, 0x0e, 0xd0, 0x03, 0x9e, 0x81, 117 | 0x4b, 0xd5, 0x52, 0xd3, 0x86, 0xe7, 0x81, 0x07, 0xc6, 0xe3, 0x0e, 118 | 0x58, 0x99, 0x24, 0x38, 0x01, 0x94, 0x81, 0x2f, 0x0d, 0xb8, 0x02, 119 | 0x8e, 0x81, 0x2c, 0xe0, 0x01, 0x8b, 0xc0, 0x16, 0x70, 0x0e, 0x34, 120 | 0x80, 0x9d, 0x49, 0x9b, 0x97, 0x35, 0x78, 0x00, 0x14, 0x01, 0x13, 121 | 0x63, 0x26, 0x03, 0xf8, 0x71, 0xc2, 0xf3, 0x56, 0xf8, 0x6e, 0xcc, 122 | 0x42, 0x3e, 0x70, 0x03, 0x64, 0xf4, 0xdd, 0xbd, 0x2e, 0xfd, 0xa1, 123 | 0x2d, 0x3d, 0xa0, 0x18, 0xb3, 0x75, 0x4d, 0xfd, 0xbe, 0x72, 0xdb, 124 | 0xc0, 0x35, 0x90, 0x1c, 0xd6, 0x24, 0xdc, 0xf9, 0xc8, 0xb5, 0xa8, 125 | 0xb7, 0xad, 0xfe, 0x9a, 0xc5, 0x37, 0x94, 0xdb, 0x77, 0x0d, 0x55, 126 | 0x54, 0x3c, 0x19, 0xd3, 0xba, 0x6a, 0xdd, 0xa0, 0x76, 0xb8, 0x1a, 127 | 0xd5, 0xcf, 0x94, 0xbf, 0x70, 0x0d, 0x87, 0xeb, 0xc9, 0x0e, 0x09, 128 | 0xdf, 0x03, 0x82, 0xc8, 0x15, 0xf5, 0x23, 0x9e, 0x4d, 0xe5, 0x5b, 129 | 0xae, 0x80, 0x77, 0x15, 0x3d, 0x87, 0x96, 0x06, 0xba, 0x91, 0xf0, 130 | 0xaa, 0xc3, 0xb7, 0xa0, 0x5a, 0xcf, 0x75, 0x40, 0x5f, 0xc5, 0x25, 131 | 0x87, 0xe6, 0x01, 0x9f, 0x56, 0x78, 0x60, 0xaf, 0xc6, 0xf2, 0x2d, 132 | 0xab, 0xde, 0x0f, 0xb9, 0x84, 0xa5, 0xbf, 0xea, 0x73, 0x23, 0x3a, 133 | 0x68, 0x8c, 0xe9, 0x8a, 0x48, 0x49, 0x44, 0x3e, 0x44, 0xa4, 0x23, 134 | 0x22, 0x47, 0xc6, 0x98, 0xb7, 0x1f, 0x2d, 0x45, 0xd6, 0xf4, 0x19, 135 | 0xb8, 0xbe, 0xa0, 0xae, 0xa7, 0x97, 0x1c, 0x83, 0xa1, 0x67, 0x1e, 136 | 0x98, 0x1b, 0xa1, 0x9f, 0x6a, 0x46, 0xdd, 0x25, 0x1e, 0xaa, 0xf8, 137 | 0x84, 0xeb, 0x1e, 0x8f, 0x01, 0x90, 0x04, 0x6e, 0x35, 0xa3, 0x10, 138 | 0xf2, 0xc6, 0x32, 0xa4, 0x45, 0xe4, 0x51, 0x44, 0x56, 0x27, 0x0d, 139 | 0x8f, 0xe0, 0x45, 0x44, 0xd6, 0x8d, 0x31, 0x03, 0x57, 0x8b, 0x1c, 140 | 0xd0, 0x64, 0x7a, 0x34, 0x81, 0xdc, 0x2f, 0x0b, 0xce, 0xf0, 0xc7, 141 | 0xf8, 0x06, 0x84, 0x6f, 0x3b, 0xdc, 0x40, 0x3c, 0x69, 0xba, 0x00, 142 | 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 143 | }; 144 | 145 | const int bandwidth_icon_length = 440; 146 | -------------------------------------------------------------------------------- /icons/latency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gehee/FPVue_rk/c9ae2a484f0563fe16487be8ace1a93cef84c8e0/icons/latency.png -------------------------------------------------------------------------------- /icons/latency.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gehee/FPVue_rk/c9ae2a484f0563fe16487be8ace1a93cef84c8e0/icons/network.png -------------------------------------------------------------------------------- /icons/network.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* --- Console arguments parser --- */ 4 | #define __BeginParseConsoleArguments__(printHelpFunction) \ 5 | if (argc < 1 || (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "/?") \ 6 | || !strcmp(argv[1], "/h")))) { printHelpFunction(); return 1; } \ 7 | for (int ArgID = 1; ArgID < argc; ArgID++) { const char* Arg = argv[ArgID]; 8 | 9 | #define __OnArgument(Name) if (!strcmp(Arg, Name)) 10 | #define __ArgValue (argc > ArgID + 1 ? argv[++ArgID] : "") 11 | #define __EndParseConsoleArguments__ else { printf("ERROR: Unknown argument\n"); return 1; } } -------------------------------------------------------------------------------- /mavlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #include "mavlink/common/mavlink.h" 23 | #include "mavlink.h" 24 | #include "osd.h" 25 | 26 | #define earthRadiusKm 6371.0 27 | #define BILLION 1000000000L 28 | 29 | # define M_PI 3.14159265358979323846 /* pi */ 30 | 31 | double deg2rad(double degrees) { 32 | return degrees * M_PI / 180.0; 33 | } 34 | 35 | double distanceEarth(double lat1d, double lon1d, double lat2d, double lon2d) { 36 | double lat1r, lon1r, lat2r, lon2r, u, v; 37 | lat1r = deg2rad(lat1d); 38 | lon1r = deg2rad(lon1d); 39 | lat2r = deg2rad(lat2d); 40 | lon2r = deg2rad(lon2d); 41 | u = sin((lat2r - lat1r) / 2); 42 | v = sin((lon2r - lon1r) / 2); 43 | 44 | return 2.0 * earthRadiusKm * asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v)); 45 | } 46 | 47 | size_t numOfChars(const char s[]) { 48 | size_t n = 0; 49 | while (s[n] != '\0') { 50 | ++n; 51 | } 52 | 53 | return n; 54 | } 55 | 56 | char* insertString(char s1[], const char s2[], size_t pos) { 57 | size_t n1 = numOfChars(s1); 58 | size_t n2 = numOfChars(s2); 59 | if (n1 < pos) { 60 | pos = n1; 61 | } 62 | 63 | for (size_t i = 0; i < n1 - pos; i++) { 64 | s1[n1 + n2 - i - 1] = s1[n1 - i - 1]; 65 | } 66 | 67 | for (size_t i = 0; i < n2; i++) { 68 | s1[pos + i] = s2[i]; 69 | } 70 | 71 | s1[n1 + n2] = '\0'; 72 | 73 | return s1; 74 | } 75 | 76 | int mavlink_port = 14550; 77 | int mavlink_thread_signal = 0; 78 | 79 | void* __MAVLINK_THREAD__(void* arg) { 80 | printf("Starting mavlink thread...\n"); 81 | // Create socket 82 | int fd = socket(AF_INET, SOCK_DGRAM, 0); 83 | if (fd < 0) { 84 | printf("ERROR: Unable to create MavLink socket: %s\n", strerror(errno)); 85 | return 0; 86 | } 87 | 88 | // Bind port 89 | struct sockaddr_in addr = {}; 90 | memset(&addr, 0, sizeof(addr)); 91 | addr.sin_family = AF_INET; 92 | inet_pton(AF_INET, "0.0.0.0", &(addr.sin_addr)); 93 | addr.sin_port = htons(mavlink_port); 94 | 95 | if (bind(fd, (struct sockaddr*)(&addr), sizeof(addr)) != 0) { 96 | printf("ERROR: Unable to bind MavLink port: %s\n", strerror(errno)); 97 | return 0; 98 | } 99 | 100 | // Set Rx timeout 101 | struct timeval tv; 102 | tv.tv_sec = 0; 103 | tv.tv_usec = 100000; 104 | if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) { 105 | printf("ERROR: Unable to bind MavLink rx timeout: %s\n", strerror(errno)); 106 | return 0; 107 | } 108 | 109 | char buffer[2048]; 110 | while (!mavlink_thread_signal) { 111 | memset(buffer, 0x00, sizeof(buffer)); 112 | int ret = recv(fd, buffer, sizeof(buffer), 0); 113 | if (ret < 0) { 114 | continue; 115 | } else if (ret == 0) { 116 | // peer has done an orderly shutdown 117 | return 0; 118 | } 119 | 120 | // Parse 121 | // Credit to openIPC:https://github.com/OpenIPC/silicon_research/blob/master/vdec/main.c#L1020 122 | mavlink_message_t message; 123 | mavlink_status_t status; 124 | for (int i = 0; i < ret; ++i) { 125 | if (mavlink_parse_char(MAVLINK_COMM_0, buffer[i], &message, &status) == 1) { 126 | switch (message.msgid) { 127 | case MAVLINK_MSG_ID_HEARTBEAT: 128 | // handle_heartbeat(&message); 129 | break; 130 | 131 | case MAVLINK_MSG_ID_SYS_STATUS: 132 | { 133 | mavlink_sys_status_t bat; 134 | mavlink_msg_sys_status_decode(&message, &bat); 135 | osd_vars.telemetry_battery = bat.voltage_battery; 136 | osd_vars.telemetry_current = bat.current_battery; 137 | } 138 | break; 139 | 140 | case MAVLINK_MSG_ID_BATTERY_STATUS: 141 | { 142 | mavlink_battery_status_t batt; 143 | mavlink_msg_battery_status_decode(&message, &batt); 144 | osd_vars.telemetry_current_consumed = batt.current_consumed; 145 | } 146 | break; 147 | 148 | case MAVLINK_MSG_ID_RC_CHANNELS_RAW: 149 | { 150 | mavlink_rc_channels_raw_t rc_channels_raw; 151 | mavlink_msg_rc_channels_raw_decode( &message, &rc_channels_raw); 152 | osd_vars.telemetry_rssi = rc_channels_raw.rssi; 153 | osd_vars.telemetry_throttle = (rc_channels_raw.chan4_raw - 1000) / 10; 154 | 155 | if (osd_vars.telemetry_throttle < 0) { 156 | osd_vars.telemetry_throttle = 0; 157 | } 158 | osd_vars.telemetry_arm = rc_channels_raw.chan5_raw; 159 | osd_vars.telemetry_resolution = rc_channels_raw.chan8_raw; 160 | if (osd_vars.telemetry_resolution > 1700) { 161 | system("/root/resolution.sh"); 162 | } 163 | } 164 | break; 165 | 166 | case MAVLINK_MSG_ID_GPS_RAW_INT: 167 | { 168 | mavlink_gps_raw_int_t gps; 169 | mavlink_msg_gps_raw_int_decode(&message, &gps); 170 | osd_vars.telemetry_sats = gps.satellites_visible; 171 | osd_vars.telemetry_lat = gps.lat; 172 | osd_vars.telemetry_lon = gps.lon; 173 | if (osd_vars.telemetry_arm > 1700) { 174 | if (osd_vars.armed < 1) { 175 | osd_vars.armed = 1; 176 | osd_vars.telemetry_lat_base = osd_vars.telemetry_lat; 177 | osd_vars.telemetry_lon_base = osd_vars.telemetry_lon; 178 | } 179 | 180 | sprintf(osd_vars.s1, "%.00f", osd_vars.telemetry_lat); 181 | if (osd_vars.telemetry_lat < 10000000) { 182 | insertString(osd_vars.s1, "0.", 0); 183 | } 184 | if (osd_vars.telemetry_lat > 9999999) { 185 | if (numOfChars(osd_vars.s1) == 8) { 186 | insertString(osd_vars.s1, ".", 1); 187 | } else { 188 | insertString(osd_vars.s1, ".", 2); 189 | } 190 | } 191 | 192 | sprintf(osd_vars.s2, "%.00f", osd_vars.telemetry_lon); 193 | if (osd_vars.telemetry_lon < 10000000) { 194 | insertString(osd_vars.s2, "0.", 0); 195 | } 196 | if (osd_vars.telemetry_lon > 9999999) { 197 | if (numOfChars(osd_vars.s2) == 8) { 198 | insertString(osd_vars.s2, ".", 1); 199 | } else { 200 | insertString(osd_vars.s2, ".", 2); 201 | } 202 | } 203 | 204 | sprintf(osd_vars.s3, "%.00f", osd_vars.telemetry_lat_base); 205 | if (osd_vars.telemetry_lat_base < 10000000) { 206 | insertString(osd_vars.s3, "0.", 0); 207 | } 208 | if (osd_vars.telemetry_lat_base > 9999999) { 209 | if (numOfChars(osd_vars.s3) == 8) { 210 | insertString(osd_vars.s3, ".", 1); 211 | } else { 212 | insertString(osd_vars.s3, ".", 2); 213 | } 214 | } 215 | 216 | sprintf(osd_vars.s4, "%.00f", osd_vars.telemetry_lon_base); 217 | if (osd_vars.telemetry_lon_base < 10000000) { 218 | insertString(osd_vars.s4, "0.", 0); 219 | } 220 | 221 | if (osd_vars.telemetry_lon_base > 9999999) { 222 | if (numOfChars(osd_vars.s4) == 8) { 223 | insertString(osd_vars.s4, ".", 1); 224 | } else { 225 | insertString(osd_vars.s4, ".", 2); 226 | } 227 | } 228 | 229 | osd_vars.s1_double = strtod(osd_vars.s1, &osd_vars.ptr); 230 | osd_vars.s2_double = strtod(osd_vars.s2, &osd_vars.ptr); 231 | osd_vars.s3_double = strtod(osd_vars.s3, &osd_vars.ptr); 232 | osd_vars.s4_double = strtod(osd_vars.s4, &osd_vars.ptr); 233 | } 234 | osd_vars.telemetry_distance = distanceEarth(osd_vars.s1_double, osd_vars.s2_double, osd_vars.s3_double, osd_vars.s4_double); 235 | } 236 | break; 237 | 238 | case MAVLINK_MSG_ID_VFR_HUD: 239 | { 240 | mavlink_vfr_hud_t vfr; 241 | mavlink_msg_vfr_hud_decode(&message, &vfr); 242 | osd_vars.telemetry_gspeed = vfr.groundspeed * 3.6; 243 | osd_vars.telemetry_vspeed = vfr.climb; 244 | osd_vars.telemetry_altitude = vfr.alt; 245 | } 246 | break; 247 | 248 | case MAVLINK_MSG_ID_GLOBAL_POSITION_INT: 249 | { 250 | mavlink_global_position_int_t global_position_int; 251 | mavlink_msg_global_position_int_decode( &message, &global_position_int); 252 | osd_vars.telemetry_hdg = global_position_int.hdg / 100; 253 | } 254 | break; 255 | 256 | case MAVLINK_MSG_ID_ATTITUDE: 257 | { 258 | mavlink_attitude_t att; 259 | mavlink_msg_attitude_decode(&message, &att); 260 | osd_vars.telemetry_pitch = att.pitch * (180.0 / 3.141592653589793238463); 261 | osd_vars.telemetry_roll = att.roll * (180.0 / 3.141592653589793238463); 262 | osd_vars.telemetry_yaw = att.yaw * (180.0 / 3.141592653589793238463); 263 | } 264 | break; 265 | 266 | case MAVLINK_MSG_ID_RADIO_STATUS: 267 | { 268 | if ((message.sysid != 3) || (message.compid != 68)) { 269 | break; 270 | } 271 | 272 | osd_vars.wfb_rssi = (int8_t)mavlink_msg_radio_status_get_rssi(&message); 273 | osd_vars.wfb_errors = mavlink_msg_radio_status_get_rxerrors(&message); 274 | osd_vars.wfb_fec_fixed = mavlink_msg_radio_status_get_fixed(&message); 275 | osd_vars.wfb_flags = mavlink_msg_radio_status_get_remnoise(&message); 276 | 277 | // printf("wfb_rssi=%d, wfb_errors=%d, wfb_fec_fixed=%d, wfb_flags=%d\n", osd_vars.wfb_rssi, osd_vars.wfb_errors, osd_vars.wfb_fec_fixed, osd_vars.wfb_flags); 278 | } 279 | break; 280 | 281 | default: 282 | // printf("> MavLink message %d from %d/%d\n", 283 | // message.msgid, message.sysid, message.compid); 284 | break; 285 | } 286 | } 287 | } 288 | 289 | usleep(1); 290 | } 291 | 292 | printf("Mavlink thread done.\n"); 293 | return 0; 294 | } -------------------------------------------------------------------------------- /mavlink.h: -------------------------------------------------------------------------------- 1 | #ifndef MVLINK_H 2 | #define MVLINK_H 3 | 4 | extern int mavlink_port; 5 | extern int mavlink_thread_signal; 6 | 7 | void* __MAVLINK_THREAD__(void* arg); 8 | 9 | size_t numOfChars(const char s[]); 10 | 11 | char* insertString(char s1[], const char s2[], size_t pos); 12 | 13 | #endif -------------------------------------------------------------------------------- /mavlink/checksum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(MAVLINK_USE_CXX_NAMESPACE) 4 | namespace mavlink { 5 | #elif defined(__cplusplus) 6 | extern "C" { 7 | #endif 8 | 9 | // Visual Studio versions before 2010 don't have stdint.h, so we just error out. 10 | #if (defined _MSC_VER) && (_MSC_VER < 1600) 11 | #error "The C-MAVLink implementation requires Visual Studio 2010 or greater" 12 | #endif 13 | 14 | #include 15 | 16 | /** 17 | * 18 | * CALCULATE THE CHECKSUM 19 | * 20 | */ 21 | 22 | #define X25_INIT_CRC 0xffff 23 | #define X25_VALIDATE_CRC 0xf0b8 24 | 25 | #ifndef HAVE_CRC_ACCUMULATE 26 | /** 27 | * @brief Accumulate the CRC16_MCRF4XX checksum by adding one char at a time. 28 | * 29 | * The checksum function adds the hash of one char at a time to the 30 | * 16 bit checksum (uint16_t). 31 | * 32 | * @param data new char to hash 33 | * @param crcAccum the already accumulated checksum 34 | **/ 35 | static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum) 36 | { 37 | /*Accumulate one byte of data into the CRC*/ 38 | uint8_t tmp; 39 | 40 | tmp = data ^ (uint8_t)(*crcAccum &0xff); 41 | tmp ^= (tmp<<4); 42 | *crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4); 43 | } 44 | #endif 45 | 46 | 47 | /** 48 | * @brief Initialize the buffer for the MCRF4XX CRC16 49 | * 50 | * @param crcAccum the 16 bit MCRF4XX CRC16 51 | */ 52 | static inline void crc_init(uint16_t* crcAccum) 53 | { 54 | *crcAccum = X25_INIT_CRC; 55 | } 56 | 57 | 58 | /** 59 | * @brief Calculates the CRC16_MCRF4XX checksum on a byte buffer 60 | * 61 | * @param pBuffer buffer containing the byte array to hash 62 | * @param length length of the byte array 63 | * @return the checksum over the buffer bytes 64 | **/ 65 | static inline uint16_t crc_calculate(const uint8_t* pBuffer, uint16_t length) 66 | { 67 | uint16_t crcTmp; 68 | crc_init(&crcTmp); 69 | while (length--) { 70 | crc_accumulate(*pBuffer++, &crcTmp); 71 | } 72 | return crcTmp; 73 | } 74 | 75 | 76 | /** 77 | * @brief Accumulate the MCRF4XX CRC16 by adding an array of bytes 78 | * 79 | * The checksum function adds the hash of one char at a time to the 80 | * 16 bit checksum (uint16_t). 81 | * 82 | * @param data new bytes to hash 83 | * @param crcAccum the already accumulated checksum 84 | **/ 85 | static inline void crc_accumulate_buffer(uint16_t *crcAccum, const char *pBuffer, uint16_t length) 86 | { 87 | const uint8_t *p = (const uint8_t *)pBuffer; 88 | while (length--) { 89 | crc_accumulate(*p++, crcAccum); 90 | } 91 | } 92 | 93 | #if defined(MAVLINK_USE_CXX_NAMESPACE) || defined(__cplusplus) 94 | } 95 | #endif 96 | -------------------------------------------------------------------------------- /mavlink/common/mavlink.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from common.xml 3 | * @see http://mavlink.org 4 | */ 5 | #pragma once 6 | #ifndef MAVLINK_H 7 | #define MAVLINK_H 8 | 9 | #define MAVLINK_PRIMARY_XML_HASH -6444967149487557671 10 | 11 | #ifndef MAVLINK_STX 12 | #define MAVLINK_STX 253 13 | #endif 14 | 15 | #ifndef MAVLINK_ENDIAN 16 | #define MAVLINK_ENDIAN MAVLINK_LITTLE_ENDIAN 17 | #endif 18 | 19 | #ifndef MAVLINK_ALIGNED_FIELDS 20 | #define MAVLINK_ALIGNED_FIELDS 1 21 | #endif 22 | 23 | #ifndef MAVLINK_CRC_EXTRA 24 | #define MAVLINK_CRC_EXTRA 1 25 | #endif 26 | 27 | #ifndef MAVLINK_COMMAND_24BIT 28 | #define MAVLINK_COMMAND_24BIT 1 29 | #endif 30 | 31 | #include "version.h" 32 | #include "common.h" 33 | 34 | #endif // MAVLINK_H 35 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_auth_key.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE AUTH_KEY PACKING 3 | 4 | #define MAVLINK_MSG_ID_AUTH_KEY 7 5 | 6 | 7 | typedef struct __mavlink_auth_key_t { 8 | char key[32]; /*< key*/ 9 | } mavlink_auth_key_t; 10 | 11 | #define MAVLINK_MSG_ID_AUTH_KEY_LEN 32 12 | #define MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN 32 13 | #define MAVLINK_MSG_ID_7_LEN 32 14 | #define MAVLINK_MSG_ID_7_MIN_LEN 32 15 | 16 | #define MAVLINK_MSG_ID_AUTH_KEY_CRC 119 17 | #define MAVLINK_MSG_ID_7_CRC 119 18 | 19 | #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \ 23 | 7, \ 24 | "AUTH_KEY", \ 25 | 1, \ 26 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \ 27 | } \ 28 | } 29 | #else 30 | #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \ 31 | "AUTH_KEY", \ 32 | 1, \ 33 | { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \ 34 | } \ 35 | } 36 | #endif 37 | 38 | /** 39 | * @brief Pack a auth_key message 40 | * @param system_id ID of this system 41 | * @param component_id ID of this component (e.g. 200 for IMU) 42 | * @param msg The MAVLink message to compress the data into 43 | * 44 | * @param key key 45 | * @return length of the message in bytes (excluding serial stream start sign) 46 | */ 47 | static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 48 | const char *key) 49 | { 50 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 51 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 52 | 53 | _mav_put_char_array(buf, 0, key, 32); 54 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN); 55 | #else 56 | mavlink_auth_key_t packet; 57 | 58 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN); 60 | #endif 61 | 62 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; 63 | 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); 64 | } 65 | 66 | /** 67 | * @brief Pack a auth_key message on a channel 68 | * @param system_id ID of this system 69 | * @param component_id ID of this component (e.g. 200 for IMU) 70 | * @param chan The MAVLink channel this message will be sent over 71 | * @param msg The MAVLink message to compress the data into 72 | * @param key key 73 | * @return length of the message in bytes (excluding serial stream start sign) 74 | */ 75 | static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 76 | mavlink_message_t* msg, 77 | const char *key) 78 | { 79 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 80 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 81 | 82 | _mav_put_char_array(buf, 0, key, 32); 83 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN); 84 | #else 85 | mavlink_auth_key_t packet; 86 | 87 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 88 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN); 89 | #endif 90 | 91 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; 92 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 93 | } 94 | 95 | /** 96 | * @brief Encode a auth_key struct 97 | * 98 | * @param system_id ID of this system 99 | * @param component_id ID of this component (e.g. 200 for IMU) 100 | * @param msg The MAVLink message to compress the data into 101 | * @param auth_key C-struct to read the message contents from 102 | */ 103 | static inline uint16_t mavlink_msg_auth_key_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key) 104 | { 105 | return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key); 106 | } 107 | 108 | /** 109 | * @brief Encode a auth_key struct on a channel 110 | * 111 | * @param system_id ID of this system 112 | * @param component_id ID of this component (e.g. 200 for IMU) 113 | * @param chan The MAVLink channel this message will be sent over 114 | * @param msg The MAVLink message to compress the data into 115 | * @param auth_key C-struct to read the message contents from 116 | */ 117 | static inline uint16_t mavlink_msg_auth_key_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key) 118 | { 119 | return mavlink_msg_auth_key_pack_chan(system_id, component_id, chan, msg, auth_key->key); 120 | } 121 | 122 | /** 123 | * @brief Send a auth_key message 124 | * @param chan MAVLink channel to send the message 125 | * 126 | * @param key key 127 | */ 128 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 129 | 130 | static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key) 131 | { 132 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 133 | char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN]; 134 | 135 | _mav_put_char_array(buf, 0, key, 32); 136 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 137 | #else 138 | mavlink_auth_key_t packet; 139 | 140 | mav_array_memcpy(packet.key, key, sizeof(char)*32); 141 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 142 | #endif 143 | } 144 | 145 | /** 146 | * @brief Send a auth_key message 147 | * @param chan MAVLink channel to send the message 148 | * @param struct The MAVLink struct to serialize 149 | */ 150 | static inline void mavlink_msg_auth_key_send_struct(mavlink_channel_t chan, const mavlink_auth_key_t* auth_key) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | mavlink_msg_auth_key_send(chan, auth_key->key); 154 | #else 155 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)auth_key, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 156 | #endif 157 | } 158 | 159 | #if MAVLINK_MSG_ID_AUTH_KEY_LEN <= MAVLINK_MAX_PAYLOAD_LEN 160 | /* 161 | This variant of _send() can be used to save stack space by re-using 162 | memory from the receive buffer. The caller provides a 163 | mavlink_message_t which is the size of a full mavlink message. This 164 | is usually the receive buffer for the channel, and allows a reply to an 165 | incoming message with minimum stack space usage. 166 | */ 167 | static inline void mavlink_msg_auth_key_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *key) 168 | { 169 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 170 | char *buf = (char *)msgbuf; 171 | 172 | _mav_put_char_array(buf, 0, key, 32); 173 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 174 | #else 175 | mavlink_auth_key_t *packet = (mavlink_auth_key_t *)msgbuf; 176 | 177 | mav_array_memcpy(packet->key, key, sizeof(char)*32); 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC); 179 | #endif 180 | } 181 | #endif 182 | 183 | #endif 184 | 185 | // MESSAGE AUTH_KEY UNPACKING 186 | 187 | 188 | /** 189 | * @brief Get field key from auth_key message 190 | * 191 | * @return key 192 | */ 193 | static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key) 194 | { 195 | return _MAV_RETURN_char_array(msg, key, 32, 0); 196 | } 197 | 198 | /** 199 | * @brief Decode a auth_key message into a struct 200 | * 201 | * @param msg The message to decode 202 | * @param auth_key C-struct to decode the message contents into 203 | */ 204 | static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key) 205 | { 206 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 207 | mavlink_msg_auth_key_get_key(msg, auth_key->key); 208 | #else 209 | uint8_t len = msg->len < MAVLINK_MSG_ID_AUTH_KEY_LEN? msg->len : MAVLINK_MSG_ID_AUTH_KEY_LEN; 210 | memset(auth_key, 0, MAVLINK_MSG_ID_AUTH_KEY_LEN); 211 | memcpy(auth_key, _MAV_PAYLOAD(msg), len); 212 | #endif 213 | } 214 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_camera_trigger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE CAMERA_TRIGGER PACKING 3 | 4 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER 112 5 | 6 | 7 | typedef struct __mavlink_camera_trigger_t { 8 | uint64_t 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.*/ 9 | uint32_t seq; /*< Image frame sequence*/ 10 | } mavlink_camera_trigger_t; 11 | 12 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN 12 13 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN 12 14 | #define MAVLINK_MSG_ID_112_LEN 12 15 | #define MAVLINK_MSG_ID_112_MIN_LEN 12 16 | 17 | #define MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC 174 18 | #define MAVLINK_MSG_ID_112_CRC 174 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_CAMERA_TRIGGER { \ 24 | 112, \ 25 | "CAMERA_TRIGGER", \ 26 | 2, \ 27 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_camera_trigger_t, time_usec) }, \ 28 | { "seq", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_camera_trigger_t, seq) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_CAMERA_TRIGGER { \ 33 | "CAMERA_TRIGGER", \ 34 | 2, \ 35 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_camera_trigger_t, time_usec) }, \ 36 | { "seq", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_camera_trigger_t, seq) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a camera_trigger message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @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. 48 | * @param seq Image frame sequence 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_camera_trigger_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint64_t time_usec, uint32_t seq) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 56 | _mav_put_uint64_t(buf, 0, time_usec); 57 | _mav_put_uint32_t(buf, 8, seq); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 60 | #else 61 | mavlink_camera_trigger_t packet; 62 | packet.time_usec = time_usec; 63 | packet.seq = seq; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_CAMERA_TRIGGER; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a camera_trigger message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @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. 79 | * @param seq Image frame sequence 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_camera_trigger_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint64_t time_usec,uint32_t seq) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 88 | _mav_put_uint64_t(buf, 0, time_usec); 89 | _mav_put_uint32_t(buf, 8, seq); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 92 | #else 93 | mavlink_camera_trigger_t packet; 94 | packet.time_usec = time_usec; 95 | packet.seq = seq; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_CAMERA_TRIGGER; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a camera_trigger struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param camera_trigger C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_camera_trigger_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_camera_trigger_t* camera_trigger) 113 | { 114 | return mavlink_msg_camera_trigger_pack(system_id, component_id, msg, camera_trigger->time_usec, camera_trigger->seq); 115 | } 116 | 117 | /** 118 | * @brief Encode a camera_trigger struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param camera_trigger C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_camera_trigger_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_camera_trigger_t* camera_trigger) 127 | { 128 | return mavlink_msg_camera_trigger_pack_chan(system_id, component_id, chan, msg, camera_trigger->time_usec, camera_trigger->seq); 129 | } 130 | 131 | /** 132 | * @brief Send a camera_trigger message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @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. 136 | * @param seq Image frame sequence 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_camera_trigger_send(mavlink_channel_t chan, uint64_t time_usec, uint32_t seq) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN]; 144 | _mav_put_uint64_t(buf, 0, time_usec); 145 | _mav_put_uint32_t(buf, 8, seq); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 148 | #else 149 | mavlink_camera_trigger_t packet; 150 | packet.time_usec = time_usec; 151 | packet.seq = seq; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)&packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a camera_trigger message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_camera_trigger_send_struct(mavlink_channel_t chan, const mavlink_camera_trigger_t* camera_trigger) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_camera_trigger_send(chan, camera_trigger->time_usec, camera_trigger->seq); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)camera_trigger, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_camera_trigger_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint32_t seq) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint64_t(buf, 0, time_usec); 184 | _mav_put_uint32_t(buf, 8, seq); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, buf, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 187 | #else 188 | mavlink_camera_trigger_t *packet = (mavlink_camera_trigger_t *)msgbuf; 189 | packet->time_usec = time_usec; 190 | packet->seq = seq; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CAMERA_TRIGGER, (const char *)packet, MAVLINK_MSG_ID_CAMERA_TRIGGER_MIN_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN, MAVLINK_MSG_ID_CAMERA_TRIGGER_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE CAMERA_TRIGGER UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field time_usec from camera_trigger message 204 | * 205 | * @return [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. 206 | */ 207 | static inline uint64_t mavlink_msg_camera_trigger_get_time_usec(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint64_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field seq from camera_trigger message 214 | * 215 | * @return Image frame sequence 216 | */ 217 | static inline uint32_t mavlink_msg_camera_trigger_get_seq(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint32_t(msg, 8); 220 | } 221 | 222 | /** 223 | * @brief Decode a camera_trigger message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param camera_trigger C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_camera_trigger_decode(const mavlink_message_t* msg, mavlink_camera_trigger_t* camera_trigger) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | camera_trigger->time_usec = mavlink_msg_camera_trigger_get_time_usec(msg); 232 | camera_trigger->seq = mavlink_msg_camera_trigger_get_seq(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN? msg->len : MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN; 235 | memset(camera_trigger, 0, MAVLINK_MSG_ID_CAMERA_TRIGGER_LEN); 236 | memcpy(camera_trigger, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_current_event_sequence.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE CURRENT_EVENT_SEQUENCE PACKING 3 | 4 | #define MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE 411 5 | 6 | 7 | typedef struct __mavlink_current_event_sequence_t { 8 | uint16_t sequence; /*< Sequence number.*/ 9 | uint8_t flags; /*< Flag bitset.*/ 10 | } mavlink_current_event_sequence_t; 11 | 12 | #define MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN 3 13 | #define MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN 3 14 | #define MAVLINK_MSG_ID_411_LEN 3 15 | #define MAVLINK_MSG_ID_411_MIN_LEN 3 16 | 17 | #define MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC 106 18 | #define MAVLINK_MSG_ID_411_CRC 106 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_CURRENT_EVENT_SEQUENCE { \ 24 | 411, \ 25 | "CURRENT_EVENT_SEQUENCE", \ 26 | 2, \ 27 | { { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_current_event_sequence_t, sequence) }, \ 28 | { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_current_event_sequence_t, flags) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_CURRENT_EVENT_SEQUENCE { \ 33 | "CURRENT_EVENT_SEQUENCE", \ 34 | 2, \ 35 | { { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_current_event_sequence_t, sequence) }, \ 36 | { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_current_event_sequence_t, flags) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a current_event_sequence message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param sequence Sequence number. 48 | * @param flags Flag bitset. 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_current_event_sequence_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint16_t sequence, uint8_t flags) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN]; 56 | _mav_put_uint16_t(buf, 0, sequence); 57 | _mav_put_uint8_t(buf, 2, flags); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); 60 | #else 61 | mavlink_current_event_sequence_t packet; 62 | packet.sequence = sequence; 63 | packet.flags = flags; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a current_event_sequence message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param sequence Sequence number. 79 | * @param flags Flag bitset. 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_current_event_sequence_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint16_t sequence,uint8_t flags) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN]; 88 | _mav_put_uint16_t(buf, 0, sequence); 89 | _mav_put_uint8_t(buf, 2, flags); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); 92 | #else 93 | mavlink_current_event_sequence_t packet; 94 | packet.sequence = sequence; 95 | packet.flags = flags; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a current_event_sequence struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param current_event_sequence C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_current_event_sequence_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_current_event_sequence_t* current_event_sequence) 113 | { 114 | return mavlink_msg_current_event_sequence_pack(system_id, component_id, msg, current_event_sequence->sequence, current_event_sequence->flags); 115 | } 116 | 117 | /** 118 | * @brief Encode a current_event_sequence struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param current_event_sequence C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_current_event_sequence_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_current_event_sequence_t* current_event_sequence) 127 | { 128 | return mavlink_msg_current_event_sequence_pack_chan(system_id, component_id, chan, msg, current_event_sequence->sequence, current_event_sequence->flags); 129 | } 130 | 131 | /** 132 | * @brief Send a current_event_sequence message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param sequence Sequence number. 136 | * @param flags Flag bitset. 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_current_event_sequence_send(mavlink_channel_t chan, uint16_t sequence, uint8_t flags) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN]; 144 | _mav_put_uint16_t(buf, 0, sequence); 145 | _mav_put_uint8_t(buf, 2, flags); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE, buf, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 148 | #else 149 | mavlink_current_event_sequence_t packet; 150 | packet.sequence = sequence; 151 | packet.flags = flags; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE, (const char *)&packet, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a current_event_sequence message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_current_event_sequence_send_struct(mavlink_channel_t chan, const mavlink_current_event_sequence_t* current_event_sequence) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_current_event_sequence_send(chan, current_event_sequence->sequence, current_event_sequence->flags); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE, (const char *)current_event_sequence, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_current_event_sequence_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t sequence, uint8_t flags) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint16_t(buf, 0, sequence); 184 | _mav_put_uint8_t(buf, 2, flags); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE, buf, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 187 | #else 188 | mavlink_current_event_sequence_t *packet = (mavlink_current_event_sequence_t *)msgbuf; 189 | packet->sequence = sequence; 190 | packet->flags = flags; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE, (const char *)packet, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_MIN_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE CURRENT_EVENT_SEQUENCE UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field sequence from current_event_sequence message 204 | * 205 | * @return Sequence number. 206 | */ 207 | static inline uint16_t mavlink_msg_current_event_sequence_get_sequence(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint16_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field flags from current_event_sequence message 214 | * 215 | * @return Flag bitset. 216 | */ 217 | static inline uint8_t mavlink_msg_current_event_sequence_get_flags(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint8_t(msg, 2); 220 | } 221 | 222 | /** 223 | * @brief Decode a current_event_sequence message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param current_event_sequence C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_current_event_sequence_decode(const mavlink_message_t* msg, mavlink_current_event_sequence_t* current_event_sequence) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | current_event_sequence->sequence = mavlink_msg_current_event_sequence_get_sequence(msg); 232 | current_event_sequence->flags = mavlink_msg_current_event_sequence_get_flags(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN? msg->len : MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN; 235 | memset(current_event_sequence, 0, MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE_LEN); 236 | memcpy(current_event_sequence, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE DEBUG PACKING 3 | 4 | #define MAVLINK_MSG_ID_DEBUG 254 5 | 6 | 7 | typedef struct __mavlink_debug_t { 8 | uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/ 9 | float value; /*< DEBUG value*/ 10 | uint8_t ind; /*< index of debug variable*/ 11 | } mavlink_debug_t; 12 | 13 | #define MAVLINK_MSG_ID_DEBUG_LEN 9 14 | #define MAVLINK_MSG_ID_DEBUG_MIN_LEN 9 15 | #define MAVLINK_MSG_ID_254_LEN 9 16 | #define MAVLINK_MSG_ID_254_MIN_LEN 9 17 | 18 | #define MAVLINK_MSG_ID_DEBUG_CRC 46 19 | #define MAVLINK_MSG_ID_254_CRC 46 20 | 21 | 22 | 23 | #if MAVLINK_COMMAND_24BIT 24 | #define MAVLINK_MESSAGE_INFO_DEBUG { \ 25 | 254, \ 26 | "DEBUG", \ 27 | 3, \ 28 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_debug_t, time_boot_ms) }, \ 29 | { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_debug_t, ind) }, \ 30 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_debug_t, value) }, \ 31 | } \ 32 | } 33 | #else 34 | #define MAVLINK_MESSAGE_INFO_DEBUG { \ 35 | "DEBUG", \ 36 | 3, \ 37 | { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_debug_t, time_boot_ms) }, \ 38 | { "ind", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_debug_t, ind) }, \ 39 | { "value", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_debug_t, value) }, \ 40 | } \ 41 | } 42 | #endif 43 | 44 | /** 45 | * @brief Pack a debug message 46 | * @param system_id ID of this system 47 | * @param component_id ID of this component (e.g. 200 for IMU) 48 | * @param msg The MAVLink message to compress the data into 49 | * 50 | * @param time_boot_ms [ms] Timestamp (time since system boot). 51 | * @param ind index of debug variable 52 | * @param value DEBUG value 53 | * @return length of the message in bytes (excluding serial stream start sign) 54 | */ 55 | static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 56 | uint32_t time_boot_ms, uint8_t ind, float value) 57 | { 58 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 59 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 60 | _mav_put_uint32_t(buf, 0, time_boot_ms); 61 | _mav_put_float(buf, 4, value); 62 | _mav_put_uint8_t(buf, 8, ind); 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_LEN); 65 | #else 66 | mavlink_debug_t packet; 67 | packet.time_boot_ms = time_boot_ms; 68 | packet.value = value; 69 | packet.ind = ind; 70 | 71 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_LEN); 72 | #endif 73 | 74 | msg->msgid = MAVLINK_MSG_ID_DEBUG; 75 | 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); 76 | } 77 | 78 | /** 79 | * @brief Pack a debug message on a channel 80 | * @param system_id ID of this system 81 | * @param component_id ID of this component (e.g. 200 for IMU) 82 | * @param chan The MAVLink channel this message will be sent over 83 | * @param msg The MAVLink message to compress the data into 84 | * @param time_boot_ms [ms] Timestamp (time since system boot). 85 | * @param ind index of debug variable 86 | * @param value DEBUG value 87 | * @return length of the message in bytes (excluding serial stream start sign) 88 | */ 89 | static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 90 | mavlink_message_t* msg, 91 | uint32_t time_boot_ms,uint8_t ind,float value) 92 | { 93 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 94 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 95 | _mav_put_uint32_t(buf, 0, time_boot_ms); 96 | _mav_put_float(buf, 4, value); 97 | _mav_put_uint8_t(buf, 8, ind); 98 | 99 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DEBUG_LEN); 100 | #else 101 | mavlink_debug_t packet; 102 | packet.time_boot_ms = time_boot_ms; 103 | packet.value = value; 104 | packet.ind = ind; 105 | 106 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DEBUG_LEN); 107 | #endif 108 | 109 | msg->msgid = MAVLINK_MSG_ID_DEBUG; 110 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 111 | } 112 | 113 | /** 114 | * @brief Encode a debug struct 115 | * 116 | * @param system_id ID of this system 117 | * @param component_id ID of this component (e.g. 200 for IMU) 118 | * @param msg The MAVLink message to compress the data into 119 | * @param debug C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_debug_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_debug_t* debug) 122 | { 123 | return mavlink_msg_debug_pack(system_id, component_id, msg, debug->time_boot_ms, debug->ind, debug->value); 124 | } 125 | 126 | /** 127 | * @brief Encode a debug struct on a channel 128 | * 129 | * @param system_id ID of this system 130 | * @param component_id ID of this component (e.g. 200 for IMU) 131 | * @param chan The MAVLink channel this message will be sent over 132 | * @param msg The MAVLink message to compress the data into 133 | * @param debug C-struct to read the message contents from 134 | */ 135 | static inline uint16_t mavlink_msg_debug_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_debug_t* debug) 136 | { 137 | return mavlink_msg_debug_pack_chan(system_id, component_id, chan, msg, debug->time_boot_ms, debug->ind, debug->value); 138 | } 139 | 140 | /** 141 | * @brief Send a debug message 142 | * @param chan MAVLink channel to send the message 143 | * 144 | * @param time_boot_ms [ms] Timestamp (time since system boot). 145 | * @param ind index of debug variable 146 | * @param value DEBUG value 147 | */ 148 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 149 | 150 | static inline void mavlink_msg_debug_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t ind, float value) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | char buf[MAVLINK_MSG_ID_DEBUG_LEN]; 154 | _mav_put_uint32_t(buf, 0, time_boot_ms); 155 | _mav_put_float(buf, 4, value); 156 | _mav_put_uint8_t(buf, 8, ind); 157 | 158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 159 | #else 160 | mavlink_debug_t packet; 161 | packet.time_boot_ms = time_boot_ms; 162 | packet.value = value; 163 | packet.ind = ind; 164 | 165 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)&packet, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 166 | #endif 167 | } 168 | 169 | /** 170 | * @brief Send a debug message 171 | * @param chan MAVLink channel to send the message 172 | * @param struct The MAVLink struct to serialize 173 | */ 174 | static inline void mavlink_msg_debug_send_struct(mavlink_channel_t chan, const mavlink_debug_t* debug) 175 | { 176 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 177 | mavlink_msg_debug_send(chan, debug->time_boot_ms, debug->ind, debug->value); 178 | #else 179 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)debug, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 180 | #endif 181 | } 182 | 183 | #if MAVLINK_MSG_ID_DEBUG_LEN <= MAVLINK_MAX_PAYLOAD_LEN 184 | /* 185 | This variant of _send() can be used to save stack space by re-using 186 | memory from the receive buffer. The caller provides a 187 | mavlink_message_t which is the size of a full mavlink message. This 188 | is usually the receive buffer for the channel, and allows a reply to an 189 | incoming message with minimum stack space usage. 190 | */ 191 | static inline void mavlink_msg_debug_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t ind, float value) 192 | { 193 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 194 | char *buf = (char *)msgbuf; 195 | _mav_put_uint32_t(buf, 0, time_boot_ms); 196 | _mav_put_float(buf, 4, value); 197 | _mav_put_uint8_t(buf, 8, ind); 198 | 199 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, buf, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 200 | #else 201 | mavlink_debug_t *packet = (mavlink_debug_t *)msgbuf; 202 | packet->time_boot_ms = time_boot_ms; 203 | packet->value = value; 204 | packet->ind = ind; 205 | 206 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DEBUG, (const char *)packet, MAVLINK_MSG_ID_DEBUG_MIN_LEN, MAVLINK_MSG_ID_DEBUG_LEN, MAVLINK_MSG_ID_DEBUG_CRC); 207 | #endif 208 | } 209 | #endif 210 | 211 | #endif 212 | 213 | // MESSAGE DEBUG UNPACKING 214 | 215 | 216 | /** 217 | * @brief Get field time_boot_ms from debug message 218 | * 219 | * @return [ms] Timestamp (time since system boot). 220 | */ 221 | static inline uint32_t mavlink_msg_debug_get_time_boot_ms(const mavlink_message_t* msg) 222 | { 223 | return _MAV_RETURN_uint32_t(msg, 0); 224 | } 225 | 226 | /** 227 | * @brief Get field ind from debug message 228 | * 229 | * @return index of debug variable 230 | */ 231 | static inline uint8_t mavlink_msg_debug_get_ind(const mavlink_message_t* msg) 232 | { 233 | return _MAV_RETURN_uint8_t(msg, 8); 234 | } 235 | 236 | /** 237 | * @brief Get field value from debug message 238 | * 239 | * @return DEBUG value 240 | */ 241 | static inline float mavlink_msg_debug_get_value(const mavlink_message_t* msg) 242 | { 243 | return _MAV_RETURN_float(msg, 4); 244 | } 245 | 246 | /** 247 | * @brief Decode a debug message into a struct 248 | * 249 | * @param msg The message to decode 250 | * @param debug C-struct to decode the message contents into 251 | */ 252 | static inline void mavlink_msg_debug_decode(const mavlink_message_t* msg, mavlink_debug_t* debug) 253 | { 254 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 255 | debug->time_boot_ms = mavlink_msg_debug_get_time_boot_ms(msg); 256 | debug->value = mavlink_msg_debug_get_value(msg); 257 | debug->ind = mavlink_msg_debug_get_ind(msg); 258 | #else 259 | uint8_t len = msg->len < MAVLINK_MSG_ID_DEBUG_LEN? msg->len : MAVLINK_MSG_ID_DEBUG_LEN; 260 | memset(debug, 0, MAVLINK_MSG_ID_DEBUG_LEN); 261 | memcpy(debug, _MAV_PAYLOAD(msg), len); 262 | #endif 263 | } 264 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_encapsulated_data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE ENCAPSULATED_DATA PACKING 3 | 4 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131 5 | 6 | 7 | typedef struct __mavlink_encapsulated_data_t { 8 | uint16_t seqnr; /*< sequence number (starting with 0 on every transmission)*/ 9 | uint8_t data[253]; /*< image data bytes*/ 10 | } mavlink_encapsulated_data_t; 11 | 12 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN 255 13 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN 255 14 | #define MAVLINK_MSG_ID_131_LEN 255 15 | #define MAVLINK_MSG_ID_131_MIN_LEN 255 16 | 17 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223 18 | #define MAVLINK_MSG_ID_131_CRC 223 19 | 20 | #define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \ 24 | 131, \ 25 | "ENCAPSULATED_DATA", \ 26 | 2, \ 27 | { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \ 28 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \ 33 | "ENCAPSULATED_DATA", \ 34 | 2, \ 35 | { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \ 36 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a encapsulated_data message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param seqnr sequence number (starting with 0 on every transmission) 48 | * @param data image data bytes 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint16_t seqnr, const uint8_t *data) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 56 | _mav_put_uint16_t(buf, 0, seqnr); 57 | _mav_put_uint8_t_array(buf, 2, data, 253); 58 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 59 | #else 60 | mavlink_encapsulated_data_t packet; 61 | packet.seqnr = seqnr; 62 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 64 | #endif 65 | 66 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; 67 | 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); 68 | } 69 | 70 | /** 71 | * @brief Pack a encapsulated_data message on a channel 72 | * @param system_id ID of this system 73 | * @param component_id ID of this component (e.g. 200 for IMU) 74 | * @param chan The MAVLink channel this message will be sent over 75 | * @param msg The MAVLink message to compress the data into 76 | * @param seqnr sequence number (starting with 0 on every transmission) 77 | * @param data image data bytes 78 | * @return length of the message in bytes (excluding serial stream start sign) 79 | */ 80 | static inline uint16_t mavlink_msg_encapsulated_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 81 | mavlink_message_t* msg, 82 | uint16_t seqnr,const uint8_t *data) 83 | { 84 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 85 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 86 | _mav_put_uint16_t(buf, 0, seqnr); 87 | _mav_put_uint8_t_array(buf, 2, data, 253); 88 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 89 | #else 90 | mavlink_encapsulated_data_t packet; 91 | packet.seqnr = seqnr; 92 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 93 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 94 | #endif 95 | 96 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; 97 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 98 | } 99 | 100 | /** 101 | * @brief Encode a encapsulated_data struct 102 | * 103 | * @param system_id ID of this system 104 | * @param component_id ID of this component (e.g. 200 for IMU) 105 | * @param msg The MAVLink message to compress the data into 106 | * @param encapsulated_data C-struct to read the message contents from 107 | */ 108 | static inline uint16_t mavlink_msg_encapsulated_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data) 109 | { 110 | return mavlink_msg_encapsulated_data_pack(system_id, component_id, msg, encapsulated_data->seqnr, encapsulated_data->data); 111 | } 112 | 113 | /** 114 | * @brief Encode a encapsulated_data struct on a channel 115 | * 116 | * @param system_id ID of this system 117 | * @param component_id ID of this component (e.g. 200 for IMU) 118 | * @param chan The MAVLink channel this message will be sent over 119 | * @param msg The MAVLink message to compress the data into 120 | * @param encapsulated_data C-struct to read the message contents from 121 | */ 122 | static inline uint16_t mavlink_msg_encapsulated_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data) 123 | { 124 | return mavlink_msg_encapsulated_data_pack_chan(system_id, component_id, chan, msg, encapsulated_data->seqnr, encapsulated_data->data); 125 | } 126 | 127 | /** 128 | * @brief Send a encapsulated_data message 129 | * @param chan MAVLink channel to send the message 130 | * 131 | * @param seqnr sequence number (starting with 0 on every transmission) 132 | * @param data image data bytes 133 | */ 134 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 135 | 136 | static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) 137 | { 138 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 139 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; 140 | _mav_put_uint16_t(buf, 0, seqnr); 141 | _mav_put_uint8_t_array(buf, 2, data, 253); 142 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 143 | #else 144 | mavlink_encapsulated_data_t packet; 145 | packet.seqnr = seqnr; 146 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)&packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 148 | #endif 149 | } 150 | 151 | /** 152 | * @brief Send a encapsulated_data message 153 | * @param chan MAVLink channel to send the message 154 | * @param struct The MAVLink struct to serialize 155 | */ 156 | static inline void mavlink_msg_encapsulated_data_send_struct(mavlink_channel_t chan, const mavlink_encapsulated_data_t* encapsulated_data) 157 | { 158 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 159 | mavlink_msg_encapsulated_data_send(chan, encapsulated_data->seqnr, encapsulated_data->data); 160 | #else 161 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)encapsulated_data, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 162 | #endif 163 | } 164 | 165 | #if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN 166 | /* 167 | This variant of _send() can be used to save stack space by re-using 168 | memory from the receive buffer. The caller provides a 169 | mavlink_message_t which is the size of a full mavlink message. This 170 | is usually the receive buffer for the channel, and allows a reply to an 171 | incoming message with minimum stack space usage. 172 | */ 173 | static inline void mavlink_msg_encapsulated_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) 174 | { 175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 176 | char *buf = (char *)msgbuf; 177 | _mav_put_uint16_t(buf, 0, seqnr); 178 | _mav_put_uint8_t_array(buf, 2, data, 253); 179 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 180 | #else 181 | mavlink_encapsulated_data_t *packet = (mavlink_encapsulated_data_t *)msgbuf; 182 | packet->seqnr = seqnr; 183 | mav_array_memcpy(packet->data, data, sizeof(uint8_t)*253); 184 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); 185 | #endif 186 | } 187 | #endif 188 | 189 | #endif 190 | 191 | // MESSAGE ENCAPSULATED_DATA UNPACKING 192 | 193 | 194 | /** 195 | * @brief Get field seqnr from encapsulated_data message 196 | * 197 | * @return sequence number (starting with 0 on every transmission) 198 | */ 199 | static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t* msg) 200 | { 201 | return _MAV_RETURN_uint16_t(msg, 0); 202 | } 203 | 204 | /** 205 | * @brief Get field data from encapsulated_data message 206 | * 207 | * @return image data bytes 208 | */ 209 | static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t* msg, uint8_t *data) 210 | { 211 | return _MAV_RETURN_uint8_t_array(msg, data, 253, 2); 212 | } 213 | 214 | /** 215 | * @brief Decode a encapsulated_data message into a struct 216 | * 217 | * @param msg The message to decode 218 | * @param encapsulated_data C-struct to decode the message contents into 219 | */ 220 | static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t* msg, mavlink_encapsulated_data_t* encapsulated_data) 221 | { 222 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 223 | encapsulated_data->seqnr = mavlink_msg_encapsulated_data_get_seqnr(msg); 224 | mavlink_msg_encapsulated_data_get_data(msg, encapsulated_data->data); 225 | #else 226 | uint8_t len = msg->len < MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN? msg->len : MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN; 227 | memset(encapsulated_data, 0, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); 228 | memcpy(encapsulated_data, _MAV_PAYLOAD(msg), len); 229 | #endif 230 | } 231 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_log_erase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE LOG_ERASE PACKING 3 | 4 | #define MAVLINK_MSG_ID_LOG_ERASE 121 5 | 6 | 7 | typedef struct __mavlink_log_erase_t { 8 | uint8_t target_system; /*< System ID*/ 9 | uint8_t target_component; /*< Component ID*/ 10 | } mavlink_log_erase_t; 11 | 12 | #define MAVLINK_MSG_ID_LOG_ERASE_LEN 2 13 | #define MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN 2 14 | #define MAVLINK_MSG_ID_121_LEN 2 15 | #define MAVLINK_MSG_ID_121_MIN_LEN 2 16 | 17 | #define MAVLINK_MSG_ID_LOG_ERASE_CRC 237 18 | #define MAVLINK_MSG_ID_121_CRC 237 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_LOG_ERASE { \ 24 | 121, \ 25 | "LOG_ERASE", \ 26 | 2, \ 27 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_erase_t, target_system) }, \ 28 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_erase_t, target_component) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_LOG_ERASE { \ 33 | "LOG_ERASE", \ 34 | 2, \ 35 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_erase_t, target_system) }, \ 36 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_erase_t, target_component) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a log_erase message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param target_system System ID 48 | * @param target_component Component ID 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_log_erase_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint8_t target_system, uint8_t target_component) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 56 | _mav_put_uint8_t(buf, 0, target_system); 57 | _mav_put_uint8_t(buf, 1, target_component); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ERASE_LEN); 60 | #else 61 | mavlink_log_erase_t packet; 62 | packet.target_system = target_system; 63 | packet.target_component = target_component; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ERASE_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_LOG_ERASE; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a log_erase message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param target_system System ID 79 | * @param target_component Component ID 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_log_erase_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint8_t target_system,uint8_t target_component) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 88 | _mav_put_uint8_t(buf, 0, target_system); 89 | _mav_put_uint8_t(buf, 1, target_component); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ERASE_LEN); 92 | #else 93 | mavlink_log_erase_t packet; 94 | packet.target_system = target_system; 95 | packet.target_component = target_component; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ERASE_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_LOG_ERASE; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a log_erase struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param log_erase C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_log_erase_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_erase_t* log_erase) 113 | { 114 | return mavlink_msg_log_erase_pack(system_id, component_id, msg, log_erase->target_system, log_erase->target_component); 115 | } 116 | 117 | /** 118 | * @brief Encode a log_erase struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param log_erase C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_log_erase_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_erase_t* log_erase) 127 | { 128 | return mavlink_msg_log_erase_pack_chan(system_id, component_id, chan, msg, log_erase->target_system, log_erase->target_component); 129 | } 130 | 131 | /** 132 | * @brief Send a log_erase message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param target_system System ID 136 | * @param target_component Component ID 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_log_erase_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_LOG_ERASE_LEN]; 144 | _mav_put_uint8_t(buf, 0, target_system); 145 | _mav_put_uint8_t(buf, 1, target_component); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, buf, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 148 | #else 149 | mavlink_log_erase_t packet; 150 | packet.target_system = target_system; 151 | packet.target_component = target_component; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)&packet, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a log_erase message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_log_erase_send_struct(mavlink_channel_t chan, const mavlink_log_erase_t* log_erase) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_log_erase_send(chan, log_erase->target_system, log_erase->target_component); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)log_erase, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_LOG_ERASE_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_log_erase_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint8_t(buf, 0, target_system); 184 | _mav_put_uint8_t(buf, 1, target_component); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, buf, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 187 | #else 188 | mavlink_log_erase_t *packet = (mavlink_log_erase_t *)msgbuf; 189 | packet->target_system = target_system; 190 | packet->target_component = target_component; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ERASE, (const char *)packet, MAVLINK_MSG_ID_LOG_ERASE_MIN_LEN, MAVLINK_MSG_ID_LOG_ERASE_LEN, MAVLINK_MSG_ID_LOG_ERASE_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE LOG_ERASE UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field target_system from log_erase message 204 | * 205 | * @return System ID 206 | */ 207 | static inline uint8_t mavlink_msg_log_erase_get_target_system(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint8_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field target_component from log_erase message 214 | * 215 | * @return Component ID 216 | */ 217 | static inline uint8_t mavlink_msg_log_erase_get_target_component(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint8_t(msg, 1); 220 | } 221 | 222 | /** 223 | * @brief Decode a log_erase message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param log_erase C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_log_erase_decode(const mavlink_message_t* msg, mavlink_log_erase_t* log_erase) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | log_erase->target_system = mavlink_msg_log_erase_get_target_system(msg); 232 | log_erase->target_component = mavlink_msg_log_erase_get_target_component(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_ERASE_LEN? msg->len : MAVLINK_MSG_ID_LOG_ERASE_LEN; 235 | memset(log_erase, 0, MAVLINK_MSG_ID_LOG_ERASE_LEN); 236 | memcpy(log_erase, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_log_request_end.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE LOG_REQUEST_END PACKING 3 | 4 | #define MAVLINK_MSG_ID_LOG_REQUEST_END 122 5 | 6 | 7 | typedef struct __mavlink_log_request_end_t { 8 | uint8_t target_system; /*< System ID*/ 9 | uint8_t target_component; /*< Component ID*/ 10 | } mavlink_log_request_end_t; 11 | 12 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_LEN 2 13 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN 2 14 | #define MAVLINK_MSG_ID_122_LEN 2 15 | #define MAVLINK_MSG_ID_122_MIN_LEN 2 16 | 17 | #define MAVLINK_MSG_ID_LOG_REQUEST_END_CRC 203 18 | #define MAVLINK_MSG_ID_122_CRC 203 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_LOG_REQUEST_END { \ 24 | 122, \ 25 | "LOG_REQUEST_END", \ 26 | 2, \ 27 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_request_end_t, target_system) }, \ 28 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_request_end_t, target_component) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_LOG_REQUEST_END { \ 33 | "LOG_REQUEST_END", \ 34 | 2, \ 35 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_log_request_end_t, target_system) }, \ 36 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_log_request_end_t, target_component) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a log_request_end message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param target_system System ID 48 | * @param target_component Component ID 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_log_request_end_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint8_t target_system, uint8_t target_component) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 56 | _mav_put_uint8_t(buf, 0, target_system); 57 | _mav_put_uint8_t(buf, 1, target_component); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 60 | #else 61 | mavlink_log_request_end_t packet; 62 | packet.target_system = target_system; 63 | packet.target_component = target_component; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_END; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a log_request_end message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param target_system System ID 79 | * @param target_component Component ID 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_log_request_end_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint8_t target_system,uint8_t target_component) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 88 | _mav_put_uint8_t(buf, 0, target_system); 89 | _mav_put_uint8_t(buf, 1, target_component); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 92 | #else 93 | mavlink_log_request_end_t packet; 94 | packet.target_system = target_system; 95 | packet.target_component = target_component; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_LOG_REQUEST_END; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a log_request_end struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param log_request_end C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_log_request_end_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_request_end_t* log_request_end) 113 | { 114 | return mavlink_msg_log_request_end_pack(system_id, component_id, msg, log_request_end->target_system, log_request_end->target_component); 115 | } 116 | 117 | /** 118 | * @brief Encode a log_request_end struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param log_request_end C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_log_request_end_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_request_end_t* log_request_end) 127 | { 128 | return mavlink_msg_log_request_end_pack_chan(system_id, component_id, chan, msg, log_request_end->target_system, log_request_end->target_component); 129 | } 130 | 131 | /** 132 | * @brief Send a log_request_end message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param target_system System ID 136 | * @param target_component Component ID 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_log_request_end_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_LOG_REQUEST_END_LEN]; 144 | _mav_put_uint8_t(buf, 0, target_system); 145 | _mav_put_uint8_t(buf, 1, target_component); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, buf, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 148 | #else 149 | mavlink_log_request_end_t packet; 150 | packet.target_system = target_system; 151 | packet.target_component = target_component; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)&packet, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a log_request_end message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_log_request_end_send_struct(mavlink_channel_t chan, const mavlink_log_request_end_t* log_request_end) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_log_request_end_send(chan, log_request_end->target_system, log_request_end->target_component); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)log_request_end, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_LOG_REQUEST_END_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_log_request_end_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint8_t(buf, 0, target_system); 184 | _mav_put_uint8_t(buf, 1, target_component); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, buf, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 187 | #else 188 | mavlink_log_request_end_t *packet = (mavlink_log_request_end_t *)msgbuf; 189 | packet->target_system = target_system; 190 | packet->target_component = target_component; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_REQUEST_END, (const char *)packet, MAVLINK_MSG_ID_LOG_REQUEST_END_MIN_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN, MAVLINK_MSG_ID_LOG_REQUEST_END_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE LOG_REQUEST_END UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field target_system from log_request_end message 204 | * 205 | * @return System ID 206 | */ 207 | static inline uint8_t mavlink_msg_log_request_end_get_target_system(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint8_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field target_component from log_request_end message 214 | * 215 | * @return Component ID 216 | */ 217 | static inline uint8_t mavlink_msg_log_request_end_get_target_component(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint8_t(msg, 1); 220 | } 221 | 222 | /** 223 | * @brief Decode a log_request_end message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param log_request_end C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_log_request_end_decode(const mavlink_message_t* msg, mavlink_log_request_end_t* log_request_end) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | log_request_end->target_system = mavlink_msg_log_request_end_get_target_system(msg); 232 | log_request_end->target_component = mavlink_msg_log_request_end_get_target_component(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_REQUEST_END_LEN? msg->len : MAVLINK_MSG_ID_LOG_REQUEST_END_LEN; 235 | memset(log_request_end, 0, MAVLINK_MSG_ID_LOG_REQUEST_END_LEN); 236 | memcpy(log_request_end, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_mission_item_reached.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE MISSION_ITEM_REACHED PACKING 3 | 4 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED 46 5 | 6 | 7 | typedef struct __mavlink_mission_item_reached_t { 8 | uint16_t seq; /*< Sequence*/ 9 | } mavlink_mission_item_reached_t; 10 | 11 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN 2 12 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN 2 13 | #define MAVLINK_MSG_ID_46_LEN 2 14 | #define MAVLINK_MSG_ID_46_MIN_LEN 2 15 | 16 | #define MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC 11 17 | #define MAVLINK_MSG_ID_46_CRC 11 18 | 19 | 20 | 21 | #if MAVLINK_COMMAND_24BIT 22 | #define MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED { \ 23 | 46, \ 24 | "MISSION_ITEM_REACHED", \ 25 | 1, \ 26 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_item_reached_t, seq) }, \ 27 | } \ 28 | } 29 | #else 30 | #define MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED { \ 31 | "MISSION_ITEM_REACHED", \ 32 | 1, \ 33 | { { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_mission_item_reached_t, seq) }, \ 34 | } \ 35 | } 36 | #endif 37 | 38 | /** 39 | * @brief Pack a mission_item_reached message 40 | * @param system_id ID of this system 41 | * @param component_id ID of this component (e.g. 200 for IMU) 42 | * @param msg The MAVLink message to compress the data into 43 | * 44 | * @param seq Sequence 45 | * @return length of the message in bytes (excluding serial stream start sign) 46 | */ 47 | static inline uint16_t mavlink_msg_mission_item_reached_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 48 | uint16_t seq) 49 | { 50 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 51 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 52 | _mav_put_uint16_t(buf, 0, seq); 53 | 54 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 55 | #else 56 | mavlink_mission_item_reached_t packet; 57 | packet.seq = seq; 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 60 | #endif 61 | 62 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; 63 | 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); 64 | } 65 | 66 | /** 67 | * @brief Pack a mission_item_reached message on a channel 68 | * @param system_id ID of this system 69 | * @param component_id ID of this component (e.g. 200 for IMU) 70 | * @param chan The MAVLink channel this message will be sent over 71 | * @param msg The MAVLink message to compress the data into 72 | * @param seq Sequence 73 | * @return length of the message in bytes (excluding serial stream start sign) 74 | */ 75 | static inline uint16_t mavlink_msg_mission_item_reached_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 76 | mavlink_message_t* msg, 77 | uint16_t seq) 78 | { 79 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 80 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 81 | _mav_put_uint16_t(buf, 0, seq); 82 | 83 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 84 | #else 85 | mavlink_mission_item_reached_t packet; 86 | packet.seq = seq; 87 | 88 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 89 | #endif 90 | 91 | msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; 92 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 93 | } 94 | 95 | /** 96 | * @brief Encode a mission_item_reached struct 97 | * 98 | * @param system_id ID of this system 99 | * @param component_id ID of this component (e.g. 200 for IMU) 100 | * @param msg The MAVLink message to compress the data into 101 | * @param mission_item_reached C-struct to read the message contents from 102 | */ 103 | static inline uint16_t mavlink_msg_mission_item_reached_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_item_reached_t* mission_item_reached) 104 | { 105 | return mavlink_msg_mission_item_reached_pack(system_id, component_id, msg, mission_item_reached->seq); 106 | } 107 | 108 | /** 109 | * @brief Encode a mission_item_reached struct on a channel 110 | * 111 | * @param system_id ID of this system 112 | * @param component_id ID of this component (e.g. 200 for IMU) 113 | * @param chan The MAVLink channel this message will be sent over 114 | * @param msg The MAVLink message to compress the data into 115 | * @param mission_item_reached C-struct to read the message contents from 116 | */ 117 | static inline uint16_t mavlink_msg_mission_item_reached_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_item_reached_t* mission_item_reached) 118 | { 119 | return mavlink_msg_mission_item_reached_pack_chan(system_id, component_id, chan, msg, mission_item_reached->seq); 120 | } 121 | 122 | /** 123 | * @brief Send a mission_item_reached message 124 | * @param chan MAVLink channel to send the message 125 | * 126 | * @param seq Sequence 127 | */ 128 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 129 | 130 | static inline void mavlink_msg_mission_item_reached_send(mavlink_channel_t chan, uint16_t seq) 131 | { 132 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 133 | char buf[MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN]; 134 | _mav_put_uint16_t(buf, 0, seq); 135 | 136 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 137 | #else 138 | mavlink_mission_item_reached_t packet; 139 | packet.seq = seq; 140 | 141 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 142 | #endif 143 | } 144 | 145 | /** 146 | * @brief Send a mission_item_reached message 147 | * @param chan MAVLink channel to send the message 148 | * @param struct The MAVLink struct to serialize 149 | */ 150 | static inline void mavlink_msg_mission_item_reached_send_struct(mavlink_channel_t chan, const mavlink_mission_item_reached_t* mission_item_reached) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | mavlink_msg_mission_item_reached_send(chan, mission_item_reached->seq); 154 | #else 155 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)mission_item_reached, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 156 | #endif 157 | } 158 | 159 | #if MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN <= MAVLINK_MAX_PAYLOAD_LEN 160 | /* 161 | This variant of _send() can be used to save stack space by re-using 162 | memory from the receive buffer. The caller provides a 163 | mavlink_message_t which is the size of a full mavlink message. This 164 | is usually the receive buffer for the channel, and allows a reply to an 165 | incoming message with minimum stack space usage. 166 | */ 167 | static inline void mavlink_msg_mission_item_reached_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seq) 168 | { 169 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 170 | char *buf = (char *)msgbuf; 171 | _mav_put_uint16_t(buf, 0, seq); 172 | 173 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, buf, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 174 | #else 175 | mavlink_mission_item_reached_t *packet = (mavlink_mission_item_reached_t *)msgbuf; 176 | packet->seq = seq; 177 | 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM_REACHED, (const char *)packet, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_CRC); 179 | #endif 180 | } 181 | #endif 182 | 183 | #endif 184 | 185 | // MESSAGE MISSION_ITEM_REACHED UNPACKING 186 | 187 | 188 | /** 189 | * @brief Get field seq from mission_item_reached message 190 | * 191 | * @return Sequence 192 | */ 193 | static inline uint16_t mavlink_msg_mission_item_reached_get_seq(const mavlink_message_t* msg) 194 | { 195 | return _MAV_RETURN_uint16_t(msg, 0); 196 | } 197 | 198 | /** 199 | * @brief Decode a mission_item_reached message into a struct 200 | * 201 | * @param msg The message to decode 202 | * @param mission_item_reached C-struct to decode the message contents into 203 | */ 204 | static inline void mavlink_msg_mission_item_reached_decode(const mavlink_message_t* msg, mavlink_mission_item_reached_t* mission_item_reached) 205 | { 206 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 207 | mission_item_reached->seq = mavlink_msg_mission_item_reached_get_seq(msg); 208 | #else 209 | uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN; 210 | memset(mission_item_reached, 0, MAVLINK_MSG_ID_MISSION_ITEM_REACHED_LEN); 211 | memcpy(mission_item_reached, _MAV_PAYLOAD(msg), len); 212 | #endif 213 | } 214 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_param_request_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE PARAM_REQUEST_LIST PACKING 3 | 4 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST 21 5 | 6 | 7 | typedef struct __mavlink_param_request_list_t { 8 | uint8_t target_system; /*< System ID*/ 9 | uint8_t target_component; /*< Component ID*/ 10 | } mavlink_param_request_list_t; 11 | 12 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN 2 13 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN 2 14 | #define MAVLINK_MSG_ID_21_LEN 2 15 | #define MAVLINK_MSG_ID_21_MIN_LEN 2 16 | 17 | #define MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC 159 18 | #define MAVLINK_MSG_ID_21_CRC 159 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST { \ 24 | 21, \ 25 | "PARAM_REQUEST_LIST", \ 26 | 2, \ 27 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_request_list_t, target_system) }, \ 28 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_request_list_t, target_component) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST { \ 33 | "PARAM_REQUEST_LIST", \ 34 | 2, \ 35 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_request_list_t, target_system) }, \ 36 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_request_list_t, target_component) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a param_request_list message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param target_system System ID 48 | * @param target_component Component ID 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_param_request_list_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint8_t target_system, uint8_t target_component) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 56 | _mav_put_uint8_t(buf, 0, target_system); 57 | _mav_put_uint8_t(buf, 1, target_component); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 60 | #else 61 | mavlink_param_request_list_t packet; 62 | packet.target_system = target_system; 63 | packet.target_component = target_component; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a param_request_list message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param target_system System ID 79 | * @param target_component Component ID 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_param_request_list_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint8_t target_system,uint8_t target_component) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 88 | _mav_put_uint8_t(buf, 0, target_system); 89 | _mav_put_uint8_t(buf, 1, target_component); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 92 | #else 93 | mavlink_param_request_list_t packet; 94 | packet.target_system = target_system; 95 | packet.target_component = target_component; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a param_request_list struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param param_request_list C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_param_request_list_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_request_list_t* param_request_list) 113 | { 114 | return mavlink_msg_param_request_list_pack(system_id, component_id, msg, param_request_list->target_system, param_request_list->target_component); 115 | } 116 | 117 | /** 118 | * @brief Encode a param_request_list struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param param_request_list C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_param_request_list_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_request_list_t* param_request_list) 127 | { 128 | return mavlink_msg_param_request_list_pack_chan(system_id, component_id, chan, msg, param_request_list->target_system, param_request_list->target_component); 129 | } 130 | 131 | /** 132 | * @brief Send a param_request_list message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param target_system System ID 136 | * @param target_component Component ID 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_param_request_list_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN]; 144 | _mav_put_uint8_t(buf, 0, target_system); 145 | _mav_put_uint8_t(buf, 1, target_component); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 148 | #else 149 | mavlink_param_request_list_t packet; 150 | packet.target_system = target_system; 151 | packet.target_component = target_component; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)&packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a param_request_list message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_param_request_list_send_struct(mavlink_channel_t chan, const mavlink_param_request_list_t* param_request_list) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_param_request_list_send(chan, param_request_list->target_system, param_request_list->target_component); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)param_request_list, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_param_request_list_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint8_t(buf, 0, target_system); 184 | _mav_put_uint8_t(buf, 1, target_component); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 187 | #else 188 | mavlink_param_request_list_t *packet = (mavlink_param_request_list_t *)msgbuf; 189 | packet->target_system = target_system; 190 | packet->target_component = target_component; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_LIST, (const char *)packet, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE PARAM_REQUEST_LIST UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field target_system from param_request_list message 204 | * 205 | * @return System ID 206 | */ 207 | static inline uint8_t mavlink_msg_param_request_list_get_target_system(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint8_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field target_component from param_request_list message 214 | * 215 | * @return Component ID 216 | */ 217 | static inline uint8_t mavlink_msg_param_request_list_get_target_component(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint8_t(msg, 1); 220 | } 221 | 222 | /** 223 | * @brief Decode a param_request_list message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param param_request_list C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_param_request_list_decode(const mavlink_message_t* msg, mavlink_param_request_list_t* param_request_list) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | param_request_list->target_system = mavlink_msg_param_request_list_get_target_system(msg); 232 | param_request_list->target_component = mavlink_msg_param_request_list_get_target_component(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN? msg->len : MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN; 235 | memset(param_request_list, 0, MAVLINK_MSG_ID_PARAM_REQUEST_LIST_LEN); 236 | memcpy(param_request_list, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_power_status.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE POWER_STATUS PACKING 3 | 4 | #define MAVLINK_MSG_ID_POWER_STATUS 125 5 | 6 | 7 | typedef struct __mavlink_power_status_t { 8 | uint16_t Vcc; /*< [mV] 5V rail voltage.*/ 9 | uint16_t Vservo; /*< [mV] Servo rail voltage.*/ 10 | uint16_t flags; /*< Bitmap of power supply status flags.*/ 11 | } mavlink_power_status_t; 12 | 13 | #define MAVLINK_MSG_ID_POWER_STATUS_LEN 6 14 | #define MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN 6 15 | #define MAVLINK_MSG_ID_125_LEN 6 16 | #define MAVLINK_MSG_ID_125_MIN_LEN 6 17 | 18 | #define MAVLINK_MSG_ID_POWER_STATUS_CRC 203 19 | #define MAVLINK_MSG_ID_125_CRC 203 20 | 21 | 22 | 23 | #if MAVLINK_COMMAND_24BIT 24 | #define MAVLINK_MESSAGE_INFO_POWER_STATUS { \ 25 | 125, \ 26 | "POWER_STATUS", \ 27 | 3, \ 28 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_power_status_t, Vcc) }, \ 29 | { "Vservo", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_power_status_t, Vservo) }, \ 30 | { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_power_status_t, flags) }, \ 31 | } \ 32 | } 33 | #else 34 | #define MAVLINK_MESSAGE_INFO_POWER_STATUS { \ 35 | "POWER_STATUS", \ 36 | 3, \ 37 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_power_status_t, Vcc) }, \ 38 | { "Vservo", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_power_status_t, Vservo) }, \ 39 | { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_power_status_t, flags) }, \ 40 | } \ 41 | } 42 | #endif 43 | 44 | /** 45 | * @brief Pack a power_status message 46 | * @param system_id ID of this system 47 | * @param component_id ID of this component (e.g. 200 for IMU) 48 | * @param msg The MAVLink message to compress the data into 49 | * 50 | * @param Vcc [mV] 5V rail voltage. 51 | * @param Vservo [mV] Servo rail voltage. 52 | * @param flags Bitmap of power supply status flags. 53 | * @return length of the message in bytes (excluding serial stream start sign) 54 | */ 55 | static inline uint16_t mavlink_msg_power_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 56 | uint16_t Vcc, uint16_t Vservo, uint16_t flags) 57 | { 58 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 59 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 60 | _mav_put_uint16_t(buf, 0, Vcc); 61 | _mav_put_uint16_t(buf, 2, Vservo); 62 | _mav_put_uint16_t(buf, 4, flags); 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POWER_STATUS_LEN); 65 | #else 66 | mavlink_power_status_t packet; 67 | packet.Vcc = Vcc; 68 | packet.Vservo = Vservo; 69 | packet.flags = flags; 70 | 71 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POWER_STATUS_LEN); 72 | #endif 73 | 74 | msg->msgid = MAVLINK_MSG_ID_POWER_STATUS; 75 | 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); 76 | } 77 | 78 | /** 79 | * @brief Pack a power_status message on a channel 80 | * @param system_id ID of this system 81 | * @param component_id ID of this component (e.g. 200 for IMU) 82 | * @param chan The MAVLink channel this message will be sent over 83 | * @param msg The MAVLink message to compress the data into 84 | * @param Vcc [mV] 5V rail voltage. 85 | * @param Vservo [mV] Servo rail voltage. 86 | * @param flags Bitmap of power supply status flags. 87 | * @return length of the message in bytes (excluding serial stream start sign) 88 | */ 89 | static inline uint16_t mavlink_msg_power_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 90 | mavlink_message_t* msg, 91 | uint16_t Vcc,uint16_t Vservo,uint16_t flags) 92 | { 93 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 94 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 95 | _mav_put_uint16_t(buf, 0, Vcc); 96 | _mav_put_uint16_t(buf, 2, Vservo); 97 | _mav_put_uint16_t(buf, 4, flags); 98 | 99 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_POWER_STATUS_LEN); 100 | #else 101 | mavlink_power_status_t packet; 102 | packet.Vcc = Vcc; 103 | packet.Vservo = Vservo; 104 | packet.flags = flags; 105 | 106 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_POWER_STATUS_LEN); 107 | #endif 108 | 109 | msg->msgid = MAVLINK_MSG_ID_POWER_STATUS; 110 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 111 | } 112 | 113 | /** 114 | * @brief Encode a power_status struct 115 | * 116 | * @param system_id ID of this system 117 | * @param component_id ID of this component (e.g. 200 for IMU) 118 | * @param msg The MAVLink message to compress the data into 119 | * @param power_status C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_power_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_power_status_t* power_status) 122 | { 123 | return mavlink_msg_power_status_pack(system_id, component_id, msg, power_status->Vcc, power_status->Vservo, power_status->flags); 124 | } 125 | 126 | /** 127 | * @brief Encode a power_status struct on a channel 128 | * 129 | * @param system_id ID of this system 130 | * @param component_id ID of this component (e.g. 200 for IMU) 131 | * @param chan The MAVLink channel this message will be sent over 132 | * @param msg The MAVLink message to compress the data into 133 | * @param power_status C-struct to read the message contents from 134 | */ 135 | static inline uint16_t mavlink_msg_power_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_power_status_t* power_status) 136 | { 137 | return mavlink_msg_power_status_pack_chan(system_id, component_id, chan, msg, power_status->Vcc, power_status->Vservo, power_status->flags); 138 | } 139 | 140 | /** 141 | * @brief Send a power_status message 142 | * @param chan MAVLink channel to send the message 143 | * 144 | * @param Vcc [mV] 5V rail voltage. 145 | * @param Vservo [mV] Servo rail voltage. 146 | * @param flags Bitmap of power supply status flags. 147 | */ 148 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 149 | 150 | static inline void mavlink_msg_power_status_send(mavlink_channel_t chan, uint16_t Vcc, uint16_t Vservo, uint16_t flags) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | char buf[MAVLINK_MSG_ID_POWER_STATUS_LEN]; 154 | _mav_put_uint16_t(buf, 0, Vcc); 155 | _mav_put_uint16_t(buf, 2, Vservo); 156 | _mav_put_uint16_t(buf, 4, flags); 157 | 158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, buf, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 159 | #else 160 | mavlink_power_status_t packet; 161 | packet.Vcc = Vcc; 162 | packet.Vservo = Vservo; 163 | packet.flags = flags; 164 | 165 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)&packet, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 166 | #endif 167 | } 168 | 169 | /** 170 | * @brief Send a power_status message 171 | * @param chan MAVLink channel to send the message 172 | * @param struct The MAVLink struct to serialize 173 | */ 174 | static inline void mavlink_msg_power_status_send_struct(mavlink_channel_t chan, const mavlink_power_status_t* power_status) 175 | { 176 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 177 | mavlink_msg_power_status_send(chan, power_status->Vcc, power_status->Vservo, power_status->flags); 178 | #else 179 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)power_status, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 180 | #endif 181 | } 182 | 183 | #if MAVLINK_MSG_ID_POWER_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN 184 | /* 185 | This variant of _send() can be used to save stack space by re-using 186 | memory from the receive buffer. The caller provides a 187 | mavlink_message_t which is the size of a full mavlink message. This 188 | is usually the receive buffer for the channel, and allows a reply to an 189 | incoming message with minimum stack space usage. 190 | */ 191 | static inline void mavlink_msg_power_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t Vcc, uint16_t Vservo, uint16_t flags) 192 | { 193 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 194 | char *buf = (char *)msgbuf; 195 | _mav_put_uint16_t(buf, 0, Vcc); 196 | _mav_put_uint16_t(buf, 2, Vservo); 197 | _mav_put_uint16_t(buf, 4, flags); 198 | 199 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, buf, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 200 | #else 201 | mavlink_power_status_t *packet = (mavlink_power_status_t *)msgbuf; 202 | packet->Vcc = Vcc; 203 | packet->Vservo = Vservo; 204 | packet->flags = flags; 205 | 206 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_POWER_STATUS, (const char *)packet, MAVLINK_MSG_ID_POWER_STATUS_MIN_LEN, MAVLINK_MSG_ID_POWER_STATUS_LEN, MAVLINK_MSG_ID_POWER_STATUS_CRC); 207 | #endif 208 | } 209 | #endif 210 | 211 | #endif 212 | 213 | // MESSAGE POWER_STATUS UNPACKING 214 | 215 | 216 | /** 217 | * @brief Get field Vcc from power_status message 218 | * 219 | * @return [mV] 5V rail voltage. 220 | */ 221 | static inline uint16_t mavlink_msg_power_status_get_Vcc(const mavlink_message_t* msg) 222 | { 223 | return _MAV_RETURN_uint16_t(msg, 0); 224 | } 225 | 226 | /** 227 | * @brief Get field Vservo from power_status message 228 | * 229 | * @return [mV] Servo rail voltage. 230 | */ 231 | static inline uint16_t mavlink_msg_power_status_get_Vservo(const mavlink_message_t* msg) 232 | { 233 | return _MAV_RETURN_uint16_t(msg, 2); 234 | } 235 | 236 | /** 237 | * @brief Get field flags from power_status message 238 | * 239 | * @return Bitmap of power supply status flags. 240 | */ 241 | static inline uint16_t mavlink_msg_power_status_get_flags(const mavlink_message_t* msg) 242 | { 243 | return _MAV_RETURN_uint16_t(msg, 4); 244 | } 245 | 246 | /** 247 | * @brief Decode a power_status message into a struct 248 | * 249 | * @param msg The message to decode 250 | * @param power_status C-struct to decode the message contents into 251 | */ 252 | static inline void mavlink_msg_power_status_decode(const mavlink_message_t* msg, mavlink_power_status_t* power_status) 253 | { 254 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 255 | power_status->Vcc = mavlink_msg_power_status_get_Vcc(msg); 256 | power_status->Vservo = mavlink_msg_power_status_get_Vservo(msg); 257 | power_status->flags = mavlink_msg_power_status_get_flags(msg); 258 | #else 259 | uint8_t len = msg->len < MAVLINK_MSG_ID_POWER_STATUS_LEN? msg->len : MAVLINK_MSG_ID_POWER_STATUS_LEN; 260 | memset(power_status, 0, MAVLINK_MSG_ID_POWER_STATUS_LEN); 261 | memcpy(power_status, _MAV_PAYLOAD(msg), len); 262 | #endif 263 | } 264 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_raw_rpm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE RAW_RPM PACKING 3 | 4 | #define MAVLINK_MSG_ID_RAW_RPM 339 5 | 6 | 7 | typedef struct __mavlink_raw_rpm_t { 8 | float frequency; /*< [rpm] Indicated rate*/ 9 | uint8_t index; /*< Index of this RPM sensor (0-indexed)*/ 10 | } mavlink_raw_rpm_t; 11 | 12 | #define MAVLINK_MSG_ID_RAW_RPM_LEN 5 13 | #define MAVLINK_MSG_ID_RAW_RPM_MIN_LEN 5 14 | #define MAVLINK_MSG_ID_339_LEN 5 15 | #define MAVLINK_MSG_ID_339_MIN_LEN 5 16 | 17 | #define MAVLINK_MSG_ID_RAW_RPM_CRC 199 18 | #define MAVLINK_MSG_ID_339_CRC 199 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_RAW_RPM { \ 24 | 339, \ 25 | "RAW_RPM", \ 26 | 2, \ 27 | { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_raw_rpm_t, index) }, \ 28 | { "frequency", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_raw_rpm_t, frequency) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_RAW_RPM { \ 33 | "RAW_RPM", \ 34 | 2, \ 35 | { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_raw_rpm_t, index) }, \ 36 | { "frequency", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_raw_rpm_t, frequency) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a raw_rpm message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param index Index of this RPM sensor (0-indexed) 48 | * @param frequency [rpm] Indicated rate 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_raw_rpm_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint8_t index, float frequency) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_RAW_RPM_LEN]; 56 | _mav_put_float(buf, 0, frequency); 57 | _mav_put_uint8_t(buf, 4, index); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_RPM_LEN); 60 | #else 61 | mavlink_raw_rpm_t packet; 62 | packet.frequency = frequency; 63 | packet.index = index; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_RPM_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_RAW_RPM; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a raw_rpm message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param index Index of this RPM sensor (0-indexed) 79 | * @param frequency [rpm] Indicated rate 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_raw_rpm_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint8_t index,float frequency) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_RAW_RPM_LEN]; 88 | _mav_put_float(buf, 0, frequency); 89 | _mav_put_uint8_t(buf, 4, index); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_RPM_LEN); 92 | #else 93 | mavlink_raw_rpm_t packet; 94 | packet.frequency = frequency; 95 | packet.index = index; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_RPM_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_RAW_RPM; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a raw_rpm struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param raw_rpm C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_raw_rpm_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_rpm_t* raw_rpm) 113 | { 114 | return mavlink_msg_raw_rpm_pack(system_id, component_id, msg, raw_rpm->index, raw_rpm->frequency); 115 | } 116 | 117 | /** 118 | * @brief Encode a raw_rpm struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param raw_rpm C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_raw_rpm_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_raw_rpm_t* raw_rpm) 127 | { 128 | return mavlink_msg_raw_rpm_pack_chan(system_id, component_id, chan, msg, raw_rpm->index, raw_rpm->frequency); 129 | } 130 | 131 | /** 132 | * @brief Send a raw_rpm message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param index Index of this RPM sensor (0-indexed) 136 | * @param frequency [rpm] Indicated rate 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_raw_rpm_send(mavlink_channel_t chan, uint8_t index, float frequency) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_RAW_RPM_LEN]; 144 | _mav_put_float(buf, 0, frequency); 145 | _mav_put_uint8_t(buf, 4, index); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, buf, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 148 | #else 149 | mavlink_raw_rpm_t packet; 150 | packet.frequency = frequency; 151 | packet.index = index; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)&packet, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a raw_rpm message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_raw_rpm_send_struct(mavlink_channel_t chan, const mavlink_raw_rpm_t* raw_rpm) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_raw_rpm_send(chan, raw_rpm->index, raw_rpm->frequency); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)raw_rpm, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_RAW_RPM_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_raw_rpm_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t index, float frequency) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_float(buf, 0, frequency); 184 | _mav_put_uint8_t(buf, 4, index); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, buf, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 187 | #else 188 | mavlink_raw_rpm_t *packet = (mavlink_raw_rpm_t *)msgbuf; 189 | packet->frequency = frequency; 190 | packet->index = index; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)packet, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE RAW_RPM UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field index from raw_rpm message 204 | * 205 | * @return Index of this RPM sensor (0-indexed) 206 | */ 207 | static inline uint8_t mavlink_msg_raw_rpm_get_index(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint8_t(msg, 4); 210 | } 211 | 212 | /** 213 | * @brief Get field frequency from raw_rpm message 214 | * 215 | * @return [rpm] Indicated rate 216 | */ 217 | static inline float mavlink_msg_raw_rpm_get_frequency(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_float(msg, 0); 220 | } 221 | 222 | /** 223 | * @brief Decode a raw_rpm message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param raw_rpm C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_raw_rpm_decode(const mavlink_message_t* msg, mavlink_raw_rpm_t* raw_rpm) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | raw_rpm->frequency = mavlink_msg_raw_rpm_get_frequency(msg); 232 | raw_rpm->index = mavlink_msg_raw_rpm_get_index(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_RPM_LEN? msg->len : MAVLINK_MSG_ID_RAW_RPM_LEN; 235 | memset(raw_rpm, 0, MAVLINK_MSG_ID_RAW_RPM_LEN); 236 | memcpy(raw_rpm, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_system_time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE SYSTEM_TIME PACKING 3 | 4 | #define MAVLINK_MSG_ID_SYSTEM_TIME 2 5 | 6 | 7 | typedef struct __mavlink_system_time_t { 8 | uint64_t time_unix_usec; /*< [us] Timestamp (UNIX epoch time).*/ 9 | uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/ 10 | } mavlink_system_time_t; 11 | 12 | #define MAVLINK_MSG_ID_SYSTEM_TIME_LEN 12 13 | #define MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN 12 14 | #define MAVLINK_MSG_ID_2_LEN 12 15 | #define MAVLINK_MSG_ID_2_MIN_LEN 12 16 | 17 | #define MAVLINK_MSG_ID_SYSTEM_TIME_CRC 137 18 | #define MAVLINK_MSG_ID_2_CRC 137 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \ 24 | 2, \ 25 | "SYSTEM_TIME", \ 26 | 2, \ 27 | { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \ 28 | { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_SYSTEM_TIME { \ 33 | "SYSTEM_TIME", \ 34 | 2, \ 35 | { { "time_unix_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_system_time_t, time_unix_usec) }, \ 36 | { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_system_time_t, time_boot_ms) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a system_time message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param time_unix_usec [us] Timestamp (UNIX epoch time). 48 | * @param time_boot_ms [ms] Timestamp (time since system boot). 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | uint64_t time_unix_usec, uint32_t time_boot_ms) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 56 | _mav_put_uint64_t(buf, 0, time_unix_usec); 57 | _mav_put_uint32_t(buf, 8, time_boot_ms); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 60 | #else 61 | mavlink_system_time_t packet; 62 | packet.time_unix_usec = time_unix_usec; 63 | packet.time_boot_ms = time_boot_ms; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a system_time message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param time_unix_usec [us] Timestamp (UNIX epoch time). 79 | * @param time_boot_ms [ms] Timestamp (time since system boot). 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | uint64_t time_unix_usec,uint32_t time_boot_ms) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 88 | _mav_put_uint64_t(buf, 0, time_unix_usec); 89 | _mav_put_uint32_t(buf, 8, time_boot_ms); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 92 | #else 93 | mavlink_system_time_t packet; 94 | packet.time_unix_usec = time_unix_usec; 95 | packet.time_boot_ms = time_boot_ms; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a system_time struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param system_time C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_system_time_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_system_time_t* system_time) 113 | { 114 | return mavlink_msg_system_time_pack(system_id, component_id, msg, system_time->time_unix_usec, system_time->time_boot_ms); 115 | } 116 | 117 | /** 118 | * @brief Encode a system_time struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param system_time C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_system_time_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_system_time_t* system_time) 127 | { 128 | return mavlink_msg_system_time_pack_chan(system_id, component_id, chan, msg, system_time->time_unix_usec, system_time->time_boot_ms); 129 | } 130 | 131 | /** 132 | * @brief Send a system_time message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param time_unix_usec [us] Timestamp (UNIX epoch time). 136 | * @param time_boot_ms [ms] Timestamp (time since system boot). 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_system_time_send(mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_SYSTEM_TIME_LEN]; 144 | _mav_put_uint64_t(buf, 0, time_unix_usec); 145 | _mav_put_uint32_t(buf, 8, time_boot_ms); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 148 | #else 149 | mavlink_system_time_t packet; 150 | packet.time_unix_usec = time_unix_usec; 151 | packet.time_boot_ms = time_boot_ms; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)&packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a system_time message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_system_time_send_struct(mavlink_channel_t chan, const mavlink_system_time_t* system_time) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_system_time_send(chan, system_time->time_unix_usec, system_time->time_boot_ms); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)system_time, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_SYSTEM_TIME_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_system_time_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_unix_usec, uint32_t time_boot_ms) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_uint64_t(buf, 0, time_unix_usec); 184 | _mav_put_uint32_t(buf, 8, time_boot_ms); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, buf, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 187 | #else 188 | mavlink_system_time_t *packet = (mavlink_system_time_t *)msgbuf; 189 | packet->time_unix_usec = time_unix_usec; 190 | packet->time_boot_ms = time_boot_ms; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYSTEM_TIME, (const char *)packet, MAVLINK_MSG_ID_SYSTEM_TIME_MIN_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_LEN, MAVLINK_MSG_ID_SYSTEM_TIME_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE SYSTEM_TIME UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field time_unix_usec from system_time message 204 | * 205 | * @return [us] Timestamp (UNIX epoch time). 206 | */ 207 | static inline uint64_t mavlink_msg_system_time_get_time_unix_usec(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_uint64_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field time_boot_ms from system_time message 214 | * 215 | * @return [ms] Timestamp (time since system boot). 216 | */ 217 | static inline uint32_t mavlink_msg_system_time_get_time_boot_ms(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_uint32_t(msg, 8); 220 | } 221 | 222 | /** 223 | * @brief Decode a system_time message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param system_time C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_system_time_decode(const mavlink_message_t* msg, mavlink_system_time_t* system_time) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | system_time->time_unix_usec = mavlink_msg_system_time_get_time_unix_usec(msg); 232 | system_time->time_boot_ms = mavlink_msg_system_time_get_time_boot_ms(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_SYSTEM_TIME_LEN? msg->len : MAVLINK_MSG_ID_SYSTEM_TIME_LEN; 235 | memset(system_time, 0, MAVLINK_MSG_ID_SYSTEM_TIME_LEN); 236 | memcpy(system_time, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_terrain_check.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE TERRAIN_CHECK PACKING 3 | 4 | #define MAVLINK_MSG_ID_TERRAIN_CHECK 135 5 | 6 | 7 | typedef struct __mavlink_terrain_check_t { 8 | int32_t lat; /*< [degE7] Latitude*/ 9 | int32_t lon; /*< [degE7] Longitude*/ 10 | } mavlink_terrain_check_t; 11 | 12 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_LEN 8 13 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN 8 14 | #define MAVLINK_MSG_ID_135_LEN 8 15 | #define MAVLINK_MSG_ID_135_MIN_LEN 8 16 | 17 | #define MAVLINK_MSG_ID_TERRAIN_CHECK_CRC 203 18 | #define MAVLINK_MSG_ID_135_CRC 203 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_TERRAIN_CHECK { \ 24 | 135, \ 25 | "TERRAIN_CHECK", \ 26 | 2, \ 27 | { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_check_t, lat) }, \ 28 | { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_check_t, lon) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_TERRAIN_CHECK { \ 33 | "TERRAIN_CHECK", \ 34 | 2, \ 35 | { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_check_t, lat) }, \ 36 | { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_check_t, lon) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a terrain_check message 43 | * @param system_id ID of this system 44 | * @param component_id ID of this component (e.g. 200 for IMU) 45 | * @param msg The MAVLink message to compress the data into 46 | * 47 | * @param lat [degE7] Latitude 48 | * @param lon [degE7] Longitude 49 | * @return length of the message in bytes (excluding serial stream start sign) 50 | */ 51 | static inline uint16_t mavlink_msg_terrain_check_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 52 | int32_t lat, int32_t lon) 53 | { 54 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 55 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 56 | _mav_put_int32_t(buf, 0, lat); 57 | _mav_put_int32_t(buf, 4, lon); 58 | 59 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 60 | #else 61 | mavlink_terrain_check_t packet; 62 | packet.lat = lat; 63 | packet.lon = lon; 64 | 65 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_TERRAIN_CHECK; 69 | 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); 70 | } 71 | 72 | /** 73 | * @brief Pack a terrain_check message on a channel 74 | * @param system_id ID of this system 75 | * @param component_id ID of this component (e.g. 200 for IMU) 76 | * @param chan The MAVLink channel this message will be sent over 77 | * @param msg The MAVLink message to compress the data into 78 | * @param lat [degE7] Latitude 79 | * @param lon [degE7] Longitude 80 | * @return length of the message in bytes (excluding serial stream start sign) 81 | */ 82 | static inline uint16_t mavlink_msg_terrain_check_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 83 | mavlink_message_t* msg, 84 | int32_t lat,int32_t lon) 85 | { 86 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 87 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 88 | _mav_put_int32_t(buf, 0, lat); 89 | _mav_put_int32_t(buf, 4, lon); 90 | 91 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 92 | #else 93 | mavlink_terrain_check_t packet; 94 | packet.lat = lat; 95 | packet.lon = lon; 96 | 97 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_TERRAIN_CHECK; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a terrain_check struct 106 | * 107 | * @param system_id ID of this system 108 | * @param component_id ID of this component (e.g. 200 for IMU) 109 | * @param msg The MAVLink message to compress the data into 110 | * @param terrain_check C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_terrain_check_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_check_t* terrain_check) 113 | { 114 | return mavlink_msg_terrain_check_pack(system_id, component_id, msg, terrain_check->lat, terrain_check->lon); 115 | } 116 | 117 | /** 118 | * @brief Encode a terrain_check struct on a channel 119 | * 120 | * @param system_id ID of this system 121 | * @param component_id ID of this component (e.g. 200 for IMU) 122 | * @param chan The MAVLink channel this message will be sent over 123 | * @param msg The MAVLink message to compress the data into 124 | * @param terrain_check C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_terrain_check_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_check_t* terrain_check) 127 | { 128 | return mavlink_msg_terrain_check_pack_chan(system_id, component_id, chan, msg, terrain_check->lat, terrain_check->lon); 129 | } 130 | 131 | /** 132 | * @brief Send a terrain_check message 133 | * @param chan MAVLink channel to send the message 134 | * 135 | * @param lat [degE7] Latitude 136 | * @param lon [degE7] Longitude 137 | */ 138 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 139 | 140 | static inline void mavlink_msg_terrain_check_send(mavlink_channel_t chan, int32_t lat, int32_t lon) 141 | { 142 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 143 | char buf[MAVLINK_MSG_ID_TERRAIN_CHECK_LEN]; 144 | _mav_put_int32_t(buf, 0, lat); 145 | _mav_put_int32_t(buf, 4, lon); 146 | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, buf, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 148 | #else 149 | mavlink_terrain_check_t packet; 150 | packet.lat = lat; 151 | packet.lon = lon; 152 | 153 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a terrain_check message 159 | * @param chan MAVLink channel to send the message 160 | * @param struct The MAVLink struct to serialize 161 | */ 162 | static inline void mavlink_msg_terrain_check_send_struct(mavlink_channel_t chan, const mavlink_terrain_check_t* terrain_check) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_terrain_check_send(chan, terrain_check->lat, terrain_check->lon); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)terrain_check, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_TERRAIN_CHECK_LEN <= MAVLINK_MAX_PAYLOAD_LEN 172 | /* 173 | This variant of _send() can be used to save stack space by re-using 174 | memory from the receive buffer. The caller provides a 175 | mavlink_message_t which is the size of a full mavlink message. This 176 | is usually the receive buffer for the channel, and allows a reply to an 177 | incoming message with minimum stack space usage. 178 | */ 179 | static inline void mavlink_msg_terrain_check_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon) 180 | { 181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 182 | char *buf = (char *)msgbuf; 183 | _mav_put_int32_t(buf, 0, lat); 184 | _mav_put_int32_t(buf, 4, lon); 185 | 186 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, buf, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 187 | #else 188 | mavlink_terrain_check_t *packet = (mavlink_terrain_check_t *)msgbuf; 189 | packet->lat = lat; 190 | packet->lon = lon; 191 | 192 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_CHECK, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_CHECK_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN, MAVLINK_MSG_ID_TERRAIN_CHECK_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE TERRAIN_CHECK UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field lat from terrain_check message 204 | * 205 | * @return [degE7] Latitude 206 | */ 207 | static inline int32_t mavlink_msg_terrain_check_get_lat(const mavlink_message_t* msg) 208 | { 209 | return _MAV_RETURN_int32_t(msg, 0); 210 | } 211 | 212 | /** 213 | * @brief Get field lon from terrain_check message 214 | * 215 | * @return [degE7] Longitude 216 | */ 217 | static inline int32_t mavlink_msg_terrain_check_get_lon(const mavlink_message_t* msg) 218 | { 219 | return _MAV_RETURN_int32_t(msg, 4); 220 | } 221 | 222 | /** 223 | * @brief Decode a terrain_check message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param terrain_check C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_terrain_check_decode(const mavlink_message_t* msg, mavlink_terrain_check_t* terrain_check) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | terrain_check->lat = mavlink_msg_terrain_check_get_lat(msg); 232 | terrain_check->lon = mavlink_msg_terrain_check_get_lon(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_CHECK_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_CHECK_LEN; 235 | memset(terrain_check, 0, MAVLINK_MSG_ID_TERRAIN_CHECK_LEN); 236 | memcpy(terrain_check, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/version.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from common.xml 3 | * @see http://mavlink.org 4 | */ 5 | #pragma once 6 | 7 | #ifndef MAVLINK_VERSION_H 8 | #define MAVLINK_VERSION_H 9 | 10 | #define MAVLINK_BUILD_DATE "Wed Sep 27 2023" 11 | #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" 12 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255 13 | 14 | #endif // MAVLINK_VERSION_H 15 | -------------------------------------------------------------------------------- /mavlink/mavlink_conversions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef MAVLINK_NO_CONVERSION_HELPERS 4 | 5 | /* enable math defines on Windows */ 6 | #ifdef _MSC_VER 7 | #ifndef _USE_MATH_DEFINES 8 | #define _USE_MATH_DEFINES 9 | #endif 10 | #endif 11 | #include 12 | 13 | #ifndef M_PI_2 14 | #define M_PI_2 ((float)asin(1)) 15 | #endif 16 | 17 | /** 18 | * @file mavlink_conversions.h 19 | * 20 | * These conversion functions follow the NASA rotation standards definition file 21 | * available online. 22 | * 23 | * Their intent is to lower the barrier for MAVLink adopters to use gimbal-lock free 24 | * (both rotation matrices, sometimes called DCM, and quaternions are gimbal-lock free) 25 | * rotation representations. Euler angles (roll, pitch, yaw) will be phased out of the 26 | * protocol as widely as possible. 27 | * 28 | * @author James Goppert 29 | * @author Thomas Gubler 30 | */ 31 | 32 | 33 | /** 34 | * Converts a quaternion to a rotation matrix 35 | * 36 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 37 | * @param dcm a 3x3 rotation matrix 38 | */ 39 | MAVLINK_HELPER void mavlink_quaternion_to_dcm(const float quaternion[4], float dcm[3][3]) 40 | { 41 | double a = (double)quaternion[0]; 42 | double b = (double)quaternion[1]; 43 | double c = (double)quaternion[2]; 44 | double d = (double)quaternion[3]; 45 | double aSq = a * a; 46 | double bSq = b * b; 47 | double cSq = c * c; 48 | double dSq = d * d; 49 | dcm[0][0] = aSq + bSq - cSq - dSq; 50 | dcm[0][1] = 2 * (b * c - a * d); 51 | dcm[0][2] = 2 * (a * c + b * d); 52 | dcm[1][0] = 2 * (b * c + a * d); 53 | dcm[1][1] = aSq - bSq + cSq - dSq; 54 | dcm[1][2] = 2 * (c * d - a * b); 55 | dcm[2][0] = 2 * (b * d - a * c); 56 | dcm[2][1] = 2 * (a * b + c * d); 57 | dcm[2][2] = aSq - bSq - cSq + dSq; 58 | } 59 | 60 | 61 | /** 62 | * Converts a rotation matrix to euler angles 63 | * 64 | * @param dcm a 3x3 rotation matrix 65 | * @param roll the roll angle in radians 66 | * @param pitch the pitch angle in radians 67 | * @param yaw the yaw angle in radians 68 | */ 69 | MAVLINK_HELPER void mavlink_dcm_to_euler(const float dcm[3][3], float* roll, float* pitch, float* yaw) 70 | { 71 | float phi, theta, psi; 72 | theta = asinf(-dcm[2][0]); 73 | 74 | if (fabsf(theta - (float)M_PI_2) < 1.0e-3f) { 75 | phi = 0.0f; 76 | psi = (atan2f(dcm[1][2] - dcm[0][1], 77 | dcm[0][2] + dcm[1][1]) + phi); 78 | 79 | } else if (fabsf(theta + (float)M_PI_2) < 1.0e-3f) { 80 | phi = 0.0f; 81 | psi = atan2f(dcm[1][2] - dcm[0][1], 82 | dcm[0][2] + dcm[1][1] - phi); 83 | 84 | } else { 85 | phi = atan2f(dcm[2][1], dcm[2][2]); 86 | psi = atan2f(dcm[1][0], dcm[0][0]); 87 | } 88 | 89 | *roll = phi; 90 | *pitch = theta; 91 | *yaw = psi; 92 | } 93 | 94 | 95 | /** 96 | * Converts a quaternion to euler angles 97 | * 98 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 99 | * @param roll the roll angle in radians 100 | * @param pitch the pitch angle in radians 101 | * @param yaw the yaw angle in radians 102 | */ 103 | MAVLINK_HELPER void mavlink_quaternion_to_euler(const float quaternion[4], float* roll, float* pitch, float* yaw) 104 | { 105 | float dcm[3][3]; 106 | mavlink_quaternion_to_dcm(quaternion, dcm); 107 | mavlink_dcm_to_euler((const float(*)[3])dcm, roll, pitch, yaw); 108 | } 109 | 110 | 111 | /** 112 | * Converts euler angles to a quaternion 113 | * 114 | * @param roll the roll angle in radians 115 | * @param pitch the pitch angle in radians 116 | * @param yaw the yaw angle in radians 117 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 118 | */ 119 | MAVLINK_HELPER void mavlink_euler_to_quaternion(float roll, float pitch, float yaw, float quaternion[4]) 120 | { 121 | float cosPhi_2 = cosf(roll / 2); 122 | float sinPhi_2 = sinf(roll / 2); 123 | float cosTheta_2 = cosf(pitch / 2); 124 | float sinTheta_2 = sinf(pitch / 2); 125 | float cosPsi_2 = cosf(yaw / 2); 126 | float sinPsi_2 = sinf(yaw / 2); 127 | quaternion[0] = (cosPhi_2 * cosTheta_2 * cosPsi_2 + 128 | sinPhi_2 * sinTheta_2 * sinPsi_2); 129 | quaternion[1] = (sinPhi_2 * cosTheta_2 * cosPsi_2 - 130 | cosPhi_2 * sinTheta_2 * sinPsi_2); 131 | quaternion[2] = (cosPhi_2 * sinTheta_2 * cosPsi_2 + 132 | sinPhi_2 * cosTheta_2 * sinPsi_2); 133 | quaternion[3] = (cosPhi_2 * cosTheta_2 * sinPsi_2 - 134 | sinPhi_2 * sinTheta_2 * cosPsi_2); 135 | } 136 | 137 | 138 | /** 139 | * Converts a rotation matrix to a quaternion 140 | * Reference: 141 | * - Shoemake, Quaternions, 142 | * http://www.cs.ucr.edu/~vbz/resources/quatut.pdf 143 | * 144 | * @param dcm a 3x3 rotation matrix 145 | * @param quaternion a [w, x, y, z] ordered quaternion (null-rotation being 1 0 0 0) 146 | */ 147 | MAVLINK_HELPER void mavlink_dcm_to_quaternion(const float dcm[3][3], float quaternion[4]) 148 | { 149 | float tr = dcm[0][0] + dcm[1][1] + dcm[2][2]; 150 | if (tr > 0.0f) { 151 | float s = sqrtf(tr + 1.0f); 152 | quaternion[0] = s * 0.5f; 153 | s = 0.5f / s; 154 | quaternion[1] = (dcm[2][1] - dcm[1][2]) * s; 155 | quaternion[2] = (dcm[0][2] - dcm[2][0]) * s; 156 | quaternion[3] = (dcm[1][0] - dcm[0][1]) * s; 157 | } else { 158 | /* Find maximum diagonal element in dcm 159 | * store index in dcm_i */ 160 | int dcm_i = 0; 161 | int i; 162 | for (i = 1; i < 3; i++) { 163 | if (dcm[i][i] > dcm[dcm_i][dcm_i]) { 164 | dcm_i = i; 165 | } 166 | } 167 | 168 | int dcm_j = (dcm_i + 1) % 3; 169 | int dcm_k = (dcm_i + 2) % 3; 170 | 171 | float s = sqrtf((dcm[dcm_i][dcm_i] - dcm[dcm_j][dcm_j] - 172 | dcm[dcm_k][dcm_k]) + 1.0f); 173 | quaternion[dcm_i + 1] = s * 0.5f; 174 | s = 0.5f / s; 175 | quaternion[dcm_j + 1] = (dcm[dcm_i][dcm_j] + dcm[dcm_j][dcm_i]) * s; 176 | quaternion[dcm_k + 1] = (dcm[dcm_k][dcm_i] + dcm[dcm_i][dcm_k]) * s; 177 | quaternion[0] = (dcm[dcm_k][dcm_j] - dcm[dcm_j][dcm_k]) * s; 178 | } 179 | } 180 | 181 | 182 | /** 183 | * Converts euler angles to a rotation matrix 184 | * 185 | * @param roll the roll angle in radians 186 | * @param pitch the pitch angle in radians 187 | * @param yaw the yaw angle in radians 188 | * @param dcm a 3x3 rotation matrix 189 | */ 190 | MAVLINK_HELPER void mavlink_euler_to_dcm(float roll, float pitch, float yaw, float dcm[3][3]) 191 | { 192 | float cosPhi = cosf(roll); 193 | float sinPhi = sinf(roll); 194 | float cosThe = cosf(pitch); 195 | float sinThe = sinf(pitch); 196 | float cosPsi = cosf(yaw); 197 | float sinPsi = sinf(yaw); 198 | 199 | dcm[0][0] = cosThe * cosPsi; 200 | dcm[0][1] = -cosPhi * sinPsi + sinPhi * sinThe * cosPsi; 201 | dcm[0][2] = sinPhi * sinPsi + cosPhi * sinThe * cosPsi; 202 | 203 | dcm[1][0] = cosThe * sinPsi; 204 | dcm[1][1] = cosPhi * cosPsi + sinPhi * sinThe * sinPsi; 205 | dcm[1][2] = -sinPhi * cosPsi + cosPhi * sinThe * sinPsi; 206 | 207 | dcm[2][0] = -sinThe; 208 | dcm[2][1] = sinPhi * cosThe; 209 | dcm[2][2] = cosPhi * cosThe; 210 | } 211 | 212 | #endif // MAVLINK_NO_CONVERSION_HELPERS 213 | -------------------------------------------------------------------------------- /mavlink/mavlink_get_info.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef MAVLINK_USE_MESSAGE_INFO 4 | #define MAVLINK_HAVE_GET_MESSAGE_INFO 5 | 6 | /* 7 | return the message_info struct for a message 8 | */ 9 | MAVLINK_HELPER const mavlink_message_info_t *mavlink_get_message_info_by_id(uint32_t msgid) 10 | { 11 | static const mavlink_message_info_t mavlink_message_info[] = MAVLINK_MESSAGE_INFO; 12 | /* 13 | use a bisection search to find the right entry. A perfect hash may be better 14 | Note that this assumes the table is sorted with primary key msgid 15 | */ 16 | const uint32_t count = sizeof(mavlink_message_info)/sizeof(mavlink_message_info[0]); 17 | if (count == 0) { 18 | return NULL; 19 | } 20 | uint32_t low=0, high=count-1; 21 | while (low < high) { 22 | uint32_t mid = (low+high)/2; 23 | if (msgid < mavlink_message_info[mid].msgid) { 24 | high = mid; 25 | continue; 26 | } 27 | if (msgid > mavlink_message_info[mid].msgid) { 28 | low = mid+1; 29 | continue; 30 | } 31 | return &mavlink_message_info[mid]; 32 | } 33 | if (mavlink_message_info[low].msgid == msgid) { 34 | return &mavlink_message_info[low]; 35 | } 36 | return NULL; 37 | } 38 | 39 | /* 40 | return the message_info struct for a message 41 | */ 42 | MAVLINK_HELPER const mavlink_message_info_t *mavlink_get_message_info(const mavlink_message_t *msg) 43 | { 44 | return mavlink_get_message_info_by_id(msg->msgid); 45 | } 46 | 47 | /* 48 | return the message_info struct for a message 49 | */ 50 | MAVLINK_HELPER const mavlink_message_info_t *mavlink_get_message_info_by_name(const char *name) 51 | { 52 | static const struct { const char *name; uint32_t msgid; } mavlink_message_names[] = MAVLINK_MESSAGE_NAMES; 53 | /* 54 | use a bisection search to find the right entry. A perfect hash may be better 55 | Note that this assumes the table is sorted with primary key name 56 | */ 57 | const uint32_t count = sizeof(mavlink_message_names)/sizeof(mavlink_message_names[0]); 58 | if (count == 0) { 59 | return NULL; 60 | } 61 | uint32_t low=0, high=count-1; 62 | while (low < high) { 63 | uint32_t mid = (low+high)/2; 64 | int cmp = strcmp(mavlink_message_names[mid].name, name); 65 | if (cmp > 0) { 66 | high = mid; 67 | continue; 68 | } 69 | if (cmp < 0) { 70 | low = mid+1; 71 | continue; 72 | } 73 | low = mid; 74 | break; 75 | } 76 | if (strcmp(mavlink_message_names[low].name, name) == 0) { 77 | return mavlink_get_message_info_by_id(mavlink_message_names[low].msgid); 78 | } 79 | return NULL; 80 | } 81 | #endif // MAVLINK_USE_MESSAGE_INFO 82 | 83 | 84 | -------------------------------------------------------------------------------- /mavlink/mavlink_sha256.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | sha-256 implementation for MAVLink based on Heimdal sources, with 5 | modifications to suit mavlink headers 6 | */ 7 | /* 8 | * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan 9 | * (Royal Institute of Technology, Stockholm, Sweden). 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 19 | * 2. Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in the 21 | * documentation and/or other materials provided with the distribution. 22 | * 23 | * 3. Neither the name of the Institute nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 | * SUCH DAMAGE. 38 | */ 39 | 40 | /* 41 | allow implementation to provide their own sha256 with the same API 42 | */ 43 | #ifndef HAVE_MAVLINK_SHA256 44 | 45 | #ifdef MAVLINK_USE_CXX_NAMESPACE 46 | namespace mavlink { 47 | #endif 48 | 49 | #ifndef MAVLINK_HELPER 50 | #define MAVLINK_HELPER 51 | #endif 52 | 53 | typedef struct { 54 | uint32_t sz[2]; 55 | uint32_t counter[8]; 56 | union { 57 | unsigned char save_bytes[64]; 58 | uint32_t save_u32[16]; 59 | } u; 60 | } mavlink_sha256_ctx; 61 | 62 | #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) 63 | #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) 64 | 65 | #define ROTR(x,n) (((x)>>(n)) | ((x) << (32 - (n)))) 66 | 67 | #define Sigma0(x) (ROTR(x,2) ^ ROTR(x,13) ^ ROTR(x,22)) 68 | #define Sigma1(x) (ROTR(x,6) ^ ROTR(x,11) ^ ROTR(x,25)) 69 | #define sigma0(x) (ROTR(x,7) ^ ROTR(x,18) ^ ((x)>>3)) 70 | #define sigma1(x) (ROTR(x,17) ^ ROTR(x,19) ^ ((x)>>10)) 71 | 72 | static const uint32_t mavlink_sha256_constant_256[64] = { 73 | 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 74 | 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 75 | 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 76 | 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 77 | 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 78 | 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 79 | 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 80 | 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 81 | 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 82 | 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 83 | 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 84 | 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 85 | 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 86 | 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 87 | 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 88 | 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 89 | }; 90 | 91 | MAVLINK_HELPER void mavlink_sha256_init(mavlink_sha256_ctx *m) 92 | { 93 | m->sz[0] = 0; 94 | m->sz[1] = 0; 95 | m->counter[0] = 0x6a09e667; 96 | m->counter[1] = 0xbb67ae85; 97 | m->counter[2] = 0x3c6ef372; 98 | m->counter[3] = 0xa54ff53a; 99 | m->counter[4] = 0x510e527f; 100 | m->counter[5] = 0x9b05688c; 101 | m->counter[6] = 0x1f83d9ab; 102 | m->counter[7] = 0x5be0cd19; 103 | } 104 | 105 | static inline void mavlink_sha256_calc(mavlink_sha256_ctx *m, uint32_t *in) 106 | { 107 | uint32_t AA, BB, CC, DD, EE, FF, GG, HH; 108 | uint32_t data[64]; 109 | int i; 110 | 111 | AA = m->counter[0]; 112 | BB = m->counter[1]; 113 | CC = m->counter[2]; 114 | DD = m->counter[3]; 115 | EE = m->counter[4]; 116 | FF = m->counter[5]; 117 | GG = m->counter[6]; 118 | HH = m->counter[7]; 119 | 120 | for (i = 0; i < 16; ++i) 121 | data[i] = in[i]; 122 | for (i = 16; i < 64; ++i) 123 | data[i] = sigma1(data[i-2]) + data[i-7] + 124 | sigma0(data[i-15]) + data[i - 16]; 125 | 126 | for (i = 0; i < 64; i++) { 127 | uint32_t T1, T2; 128 | 129 | T1 = HH + Sigma1(EE) + Ch(EE, FF, GG) + mavlink_sha256_constant_256[i] + data[i]; 130 | T2 = Sigma0(AA) + Maj(AA,BB,CC); 131 | 132 | HH = GG; 133 | GG = FF; 134 | FF = EE; 135 | EE = DD + T1; 136 | DD = CC; 137 | CC = BB; 138 | BB = AA; 139 | AA = T1 + T2; 140 | } 141 | 142 | m->counter[0] += AA; 143 | m->counter[1] += BB; 144 | m->counter[2] += CC; 145 | m->counter[3] += DD; 146 | m->counter[4] += EE; 147 | m->counter[5] += FF; 148 | m->counter[6] += GG; 149 | m->counter[7] += HH; 150 | } 151 | 152 | MAVLINK_HELPER void mavlink_sha256_update(mavlink_sha256_ctx *m, const void *v, uint32_t len) 153 | { 154 | const unsigned char *p = (const unsigned char *)v; 155 | uint32_t old_sz = m->sz[0]; 156 | uint32_t offset; 157 | 158 | m->sz[0] += len * 8; 159 | if (m->sz[0] < old_sz) 160 | ++m->sz[1]; 161 | offset = (old_sz / 8) % 64; 162 | while(len > 0){ 163 | uint32_t l = 64 - offset; 164 | if (len < l) { 165 | l = len; 166 | } 167 | memcpy(m->u.save_bytes + offset, p, l); 168 | offset += l; 169 | p += l; 170 | len -= l; 171 | if(offset == 64){ 172 | int i; 173 | uint32_t current[16]; 174 | const uint32_t *u = m->u.save_u32; 175 | for (i = 0; i < 16; i++){ 176 | const uint8_t *p1 = (const uint8_t *)&u[i]; 177 | uint8_t *p2 = (uint8_t *)¤t[i]; 178 | p2[0] = p1[3]; 179 | p2[1] = p1[2]; 180 | p2[2] = p1[1]; 181 | p2[3] = p1[0]; 182 | } 183 | mavlink_sha256_calc(m, current); 184 | offset = 0; 185 | } 186 | } 187 | } 188 | 189 | /* 190 | get first 48 bits of final sha256 hash 191 | */ 192 | MAVLINK_HELPER void mavlink_sha256_final_48(mavlink_sha256_ctx *m, uint8_t result[6]) 193 | { 194 | unsigned char zeros[72]; 195 | unsigned offset = (m->sz[0] / 8) % 64; 196 | unsigned int dstart = (120 - offset - 1) % 64 + 1; 197 | uint8_t *p = (uint8_t *)&m->counter[0]; 198 | 199 | *zeros = 0x80; 200 | memset (zeros + 1, 0, sizeof(zeros) - 1); 201 | zeros[dstart+7] = (m->sz[0] >> 0) & 0xff; 202 | zeros[dstart+6] = (m->sz[0] >> 8) & 0xff; 203 | zeros[dstart+5] = (m->sz[0] >> 16) & 0xff; 204 | zeros[dstart+4] = (m->sz[0] >> 24) & 0xff; 205 | zeros[dstart+3] = (m->sz[1] >> 0) & 0xff; 206 | zeros[dstart+2] = (m->sz[1] >> 8) & 0xff; 207 | zeros[dstart+1] = (m->sz[1] >> 16) & 0xff; 208 | zeros[dstart+0] = (m->sz[1] >> 24) & 0xff; 209 | 210 | mavlink_sha256_update(m, zeros, dstart + 8); 211 | 212 | // this ordering makes the result consistent with taking the first 213 | // 6 bytes of more conventional sha256 functions. It assumes 214 | // little-endian ordering of m->counter 215 | result[0] = p[3]; 216 | result[1] = p[2]; 217 | result[2] = p[1]; 218 | result[3] = p[0]; 219 | result[4] = p[7]; 220 | result[5] = p[6]; 221 | } 222 | 223 | // prevent conflicts with users of the header 224 | #undef Ch 225 | #undef ROTR 226 | #undef Sigma0 227 | #undef Sigma1 228 | #undef sigma0 229 | #undef sigma1 230 | 231 | #ifdef MAVLINK_USE_CXX_NAMESPACE 232 | } // namespace mavlink 233 | #endif 234 | 235 | #endif // HAVE_MAVLINK_SHA256 236 | -------------------------------------------------------------------------------- /mavlink/minimal/mavlink.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from minimal.xml 3 | * @see http://mavlink.org 4 | */ 5 | #pragma once 6 | #ifndef MAVLINK_H 7 | #define MAVLINK_H 8 | 9 | #define MAVLINK_PRIMARY_XML_HASH 7866375523044912686 10 | 11 | #ifndef MAVLINK_STX 12 | #define MAVLINK_STX 253 13 | #endif 14 | 15 | #ifndef MAVLINK_ENDIAN 16 | #define MAVLINK_ENDIAN MAVLINK_LITTLE_ENDIAN 17 | #endif 18 | 19 | #ifndef MAVLINK_ALIGNED_FIELDS 20 | #define MAVLINK_ALIGNED_FIELDS 1 21 | #endif 22 | 23 | #ifndef MAVLINK_CRC_EXTRA 24 | #define MAVLINK_CRC_EXTRA 1 25 | #endif 26 | 27 | #ifndef MAVLINK_COMMAND_24BIT 28 | #define MAVLINK_COMMAND_24BIT 1 29 | #endif 30 | 31 | #include "version.h" 32 | #include "minimal.h" 33 | 34 | #endif // MAVLINK_H 35 | -------------------------------------------------------------------------------- /mavlink/minimal/testsuite.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol testsuite generated from minimal.xml 3 | * @see https://mavlink.io/en/ 4 | */ 5 | #pragma once 6 | #ifndef MINIMAL_TESTSUITE_H 7 | #define MINIMAL_TESTSUITE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #ifndef MAVLINK_TEST_ALL 14 | #define MAVLINK_TEST_ALL 15 | 16 | static void mavlink_test_minimal(uint8_t, uint8_t, mavlink_message_t *last_msg); 17 | 18 | static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) 19 | { 20 | 21 | mavlink_test_minimal(system_id, component_id, last_msg); 22 | } 23 | #endif 24 | 25 | 26 | 27 | 28 | static void mavlink_test_heartbeat(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) 29 | { 30 | #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1 31 | mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0); 32 | if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_HEARTBEAT >= 256) { 33 | return; 34 | } 35 | #endif 36 | mavlink_message_t msg; 37 | uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; 38 | uint16_t i; 39 | mavlink_heartbeat_t packet_in = { 40 | 963497464,17,84,151,218,3 41 | }; 42 | mavlink_heartbeat_t packet1, packet2; 43 | memset(&packet1, 0, sizeof(packet1)); 44 | packet1.custom_mode = packet_in.custom_mode; 45 | packet1.type = packet_in.type; 46 | packet1.autopilot = packet_in.autopilot; 47 | packet1.base_mode = packet_in.base_mode; 48 | packet1.system_status = packet_in.system_status; 49 | packet1.mavlink_version = packet_in.mavlink_version; 50 | 51 | 52 | #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1 53 | if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) { 54 | // cope with extensions 55 | memset(MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN); 56 | } 57 | #endif 58 | memset(&packet2, 0, sizeof(packet2)); 59 | mavlink_msg_heartbeat_encode(system_id, component_id, &msg, &packet1); 60 | mavlink_msg_heartbeat_decode(&msg, &packet2); 61 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 62 | 63 | memset(&packet2, 0, sizeof(packet2)); 64 | mavlink_msg_heartbeat_pack(system_id, component_id, &msg , packet1.type , packet1.autopilot , packet1.base_mode , packet1.custom_mode , packet1.system_status ); 65 | mavlink_msg_heartbeat_decode(&msg, &packet2); 66 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 67 | 68 | memset(&packet2, 0, sizeof(packet2)); 69 | mavlink_msg_heartbeat_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.type , packet1.autopilot , packet1.base_mode , packet1.custom_mode , packet1.system_status ); 70 | mavlink_msg_heartbeat_decode(&msg, &packet2); 71 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 72 | 73 | memset(&packet2, 0, sizeof(packet2)); 74 | mavlink_msg_to_send_buffer(buffer, &msg); 75 | for (i=0; iflags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_PROTOCOL_VERSION >= 256) { 97 | return; 98 | } 99 | #endif 100 | mavlink_message_t msg; 101 | uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; 102 | uint16_t i; 103 | mavlink_protocol_version_t packet_in = { 104 | 17235,17339,17443,{ 151, 152, 153, 154, 155, 156, 157, 158 },{ 175, 176, 177, 178, 179, 180, 181, 182 } 105 | }; 106 | mavlink_protocol_version_t packet1, packet2; 107 | memset(&packet1, 0, sizeof(packet1)); 108 | packet1.version = packet_in.version; 109 | packet1.min_version = packet_in.min_version; 110 | packet1.max_version = packet_in.max_version; 111 | 112 | mav_array_memcpy(packet1.spec_version_hash, packet_in.spec_version_hash, sizeof(uint8_t)*8); 113 | mav_array_memcpy(packet1.library_version_hash, packet_in.library_version_hash, sizeof(uint8_t)*8); 114 | 115 | #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1 116 | if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) { 117 | // cope with extensions 118 | memset(MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN); 119 | } 120 | #endif 121 | memset(&packet2, 0, sizeof(packet2)); 122 | mavlink_msg_protocol_version_encode(system_id, component_id, &msg, &packet1); 123 | mavlink_msg_protocol_version_decode(&msg, &packet2); 124 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 125 | 126 | memset(&packet2, 0, sizeof(packet2)); 127 | mavlink_msg_protocol_version_pack(system_id, component_id, &msg , packet1.version , packet1.min_version , packet1.max_version , packet1.spec_version_hash , packet1.library_version_hash ); 128 | mavlink_msg_protocol_version_decode(&msg, &packet2); 129 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 130 | 131 | memset(&packet2, 0, sizeof(packet2)); 132 | mavlink_msg_protocol_version_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.version , packet1.min_version , packet1.max_version , packet1.spec_version_hash , packet1.library_version_hash ); 133 | mavlink_msg_protocol_version_decode(&msg, &packet2); 134 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); 135 | 136 | memset(&packet2, 0, sizeof(packet2)); 137 | mavlink_msg_to_send_buffer(buffer, &msg); 138 | for (i=0; iwidth / 2; 3 | if (osd_vars.osd_mode > 0){ 4 | // Artificial Horizon 5 | int32_t offset_pitch = osd_vars.telemetry_pitch * 4; 6 | int32_t offset_roll = osd_vars.telemetry_roll * 4; 7 | int32_t y_pos_left = ((int32_t)buf->height / 2 - 2 + offset_pitch + offset_roll); 8 | int32_t y_pos_right = ((int32_t)buf->height / 2 - 2 + offset_pitch - offset_roll); 9 | - 10 | for (int i = 0; i < 4; i++) { 11 | if (y_pos_left > 0 && y_pos_left < buf->height && 12 | y_pos_right > 0 && y_pos_right < buf->height) { 13 | //fbg_line(cr, x_center - 180, y_pos_left + i, x_center + 180, y_pos_right + i, 255, 255, 255); 14 | } 15 | } 16 | - 17 | // Vertical Speedometer 18 | int32_t offset_vspeed = osd_vars.telemetry_vspeed * 5; 19 | int32_t y_pos_vspeed = ((int32_t)buf->height / 2 - offset_vspeed); 20 | for (int i = 0; i < 8; i++) { 21 | if (y_pos_vspeed > 0 && y_pos_vspeed < buf->height) { 22 | //fbg_line(cr, x_center + 242 + i, buf->height / 2, x_center + 242 + i, y_pos_vspeed, 255, 255, 255); 23 | } 24 | } 25 | - 26 | for (int i = 0; i < 25; i++) { 27 | uint32_t width = (i == 12) ? 10 : 0; 28 | - 29 | // fbg_line(cr, x_center - 240 - width, 30 | // buf->height / 2 - 120 + i * 10, x_center - 220, 31 | // buf->height / 2 - 120 + i * 10, 255, 255, 255); 32 | // fbg_line(cr, x_center - 240 - width, 33 | // buf->height / 2 - 120 + i * 10 + 1, x_center - 220, 34 | // buf->height / 2 - 120 + i * 10 + 1, 255, 255, 255); 35 | - 36 | // fbg_line(cr, x_center + 220, buf->height / 2 - 120 + i * 10, 37 | // x_center + 240 + width, buf->height / 2 - 120 + i * 10, 255, 255, 255); 38 | // fbg_line(cr, x_center + 220, buf->height / 2 - 120 + i * 10 + 1, 39 | // x_center + 240 + width, buf->height / 2 - 120 + i * 10 + 1, 255, 255, 255); 40 | } 41 | - 42 | // OSD telemetry 43 | sprintf(msg, "ALT:%.00fM", osd_vars.telemetry_altitude); 44 | cairo_move_to(cr, x_center + (20) + 260, buf->height / 2 - 8); 45 | cairo_show_text(cr, msg); 46 | sprintf(msg, "SPD:%.00fKM/H", osd_vars.telemetry_gspeed); 47 | cairo_move_to(cr, x_center - (16 * 3) - 360, buf->height / 2 - 8); 48 | cairo_show_text(cr, msg); 49 | sprintf(msg, "VSPD:%.00fM/S", osd_vars.telemetry_vspeed); 50 | cairo_move_to(cr, x_center + (20) + 260, buf->height / 2 + 22); 51 | cairo_show_text(cr, msg); 52 | } 53 | - 54 | sprintf(msg, "BAT:%.02fV", osd_vars.telemetry_battery / 1000); 55 | cairo_move_to(cr, 40, buf->height - 30); 56 | cairo_show_text(cr, msg); 57 | sprintf(msg, "CONS:%.00fmAh", osd_vars.telemetry_current_consumed); 58 | cairo_move_to(cr, 40, buf->height - 60); 59 | cairo_show_text(cr, msg); 60 | sprintf(msg, "CUR:%.02fA", osd_vars.telemetry_current / 100); 61 | cairo_move_to(cr, 40, buf->height - 90); 62 | cairo_show_text(cr, msg); 63 | sprintf(msg, "THR:%.00f%%", osd_vars.telemetry_throttle); 64 | cairo_move_to(cr, 40, buf->height - 120); 65 | cairo_show_text(cr, msg); 66 | 67 | if (osd_vars.osd_mode > 0){ 68 | sprintf(msg, "SATS:%.00f", osd_vars.telemetry_sats); 69 | cairo_move_to(cr,buf->width - 140, buf->height - 30); 70 | cairo_show_text(cr, msg); 71 | sprintf(msg, "HDG:%.00f", osd_vars.telemetry_hdg); 72 | cairo_move_to(cr,buf->width - 140, buf->height - 120); 73 | cairo_show_text(cr, msg); 74 | sprintf(osd_vars.c1, "%.00f", osd_vars.telemetry_lat); 75 | - 76 | if (osd_vars.telemetry_lat < 10000000) { 77 | insertString(osd_vars.c1, "LAT:0.", 0); 78 | } 79 | - 80 | if (osd_vars.telemetry_lat > 9999999) { 81 | if (numOfChars(osd_vars.c1) == 8) { 82 | insertString(osd_vars.c1, ".", 1); 83 | } else { 84 | insertString(osd_vars.c1, ".", 2); 85 | } 86 | insertString(osd_vars.c1, "LAT:", 0); 87 | } 88 | cairo_move_to(cr, buf->width - 240, buf->height - 90); 89 | cairo_show_text(cr, osd_vars.c1); 90 | - 91 | sprintf(osd_vars.c2, "%.00f", osd_vars.telemetry_lon); 92 | if (osd_vars.telemetry_lon < 10000000) { 93 | insertString(osd_vars.c2, "LON:0.", 0); 94 | } 95 | if (osd_vars.telemetry_lon > 9999999) { 96 | if (numOfChars(osd_vars.c2) == 8) { 97 | insertString(osd_vars.c2, ".", 1); 98 | } else { 99 | insertString(osd_vars.c2, ".", 2); 100 | } 101 | insertString(osd_vars.c2, "LON:", 0); 102 | } 103 | cairo_move_to(cr, buf->width - 240, buf->height - 60); 104 | cairo_show_text(cr, osd_vars.c2); 105 | //sprintf(msg, "PITCH:%.00f", telemetry_pitch); 106 | //cairo_move_to(cr, msg, x_center + 440, buf->height - 140); 107 | //sprintf(msg, "ROLL:%.00f", telemetry_roll); 108 | //cairo_move_to(cr, msg, x_center + 440, buf->height - 170); 109 | sprintf(msg, "DIST:%.03fM", osd_vars.telemetry_distance); 110 | cairo_move_to(cr, x_center - 350, buf->height - 30); 111 | cairo_show_text(cr, msg); 112 | } 113 | 114 | sprintf(msg, "RSSI:%.00f", osd_vars.telemetry_rssi); 115 | cairo_move_to(cr, x_center - 50, buf->height - 30); 116 | cairo_show_text(cr, msg); 117 | - 118 | // Print rate stats 119 | struct timespec current_timestamp; 120 | if (!clock_gettime(CLOCK_MONOTONIC_COARSE, ¤t_timestamp)) { 121 | double interval = getTimeInterval(¤t_timestamp, &last_timestamp); 122 | if (interval > 1) { 123 | last_timestamp = current_timestamp; 124 | rx_rate = ((float)stats_rx_bytes+(((float)stats_rx_bytes*25)/100)) / 1024.0f * 8; 125 | stats_rx_bytes = 0; 126 | } 127 | } 128 | - 129 | uint64_t diff; 130 | struct timespec start, end; 131 | clock_gettime(CLOCK_MONOTONIC, &start); 132 | sleep(1); 133 | clock_gettime(CLOCK_MONOTONIC, &end); 134 | diff = BILLION * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec; 135 | - 136 | char hud_frames_rx[32]; 137 | if (osd_vars.osd_mode > 0){ 138 | cairo_move_to(cr, x_center - strlen(hud_frames_rx) / 2 * 16, 40); 139 | cairo_show_text(cr, hud_frames_rx); 140 | } else { 141 | cairo_move_to(cr, buf->width - 300, buf->height - 60); 142 | cairo_show_text(cr, hud_frames_rx); 143 | sprintf(msg, "TIME:%.2d:%.2d", minutes,seconds); 144 | cairo_move_to(cr, buf->width - 300, buf->height - 90); 145 | cairo_show_text(cr, msg); 146 | if (osd_vars.telemetry_arm > 1700){ 147 | seconds = seconds + diff/1000000000; 148 | } 149 | if(seconds > 59){ 150 | seconds = 0; 151 | ++minutes; 152 | } 153 | if(minutes > 59){ 154 | seconds = 0; 155 | minutes = 0; 156 | } 157 | } 158 | float percent = rx_rate / (1024 * 10); 159 | if (percent > 1) { 160 | percent = 1; 161 | } 162 | - 163 | uint32_t width = (strlen(hud_frames_rx) * 16) * percent; 164 | if (osd_vars.osd_mode > 0){ 165 | cairo_set_source_rgba(cr, 255, 255, 255, 0.8); // R, G, B, A 166 | cairo_rectangle(cr, x_center - strlen(hud_frames_rx) / 2 * 16, 64, width, 8); 167 | } else { 168 | cairo_set_source_rgba(cr, 255, 255, 255, 0.8); // R, G, B, A 169 | cairo_rectangle(cr, buf->width - 300, buf->height - 36, width, 8); 170 | } -------------------------------------------------------------------------------- /osd.h: -------------------------------------------------------------------------------- 1 | #ifndef OSD_H 2 | #define OSD_H 3 | 4 | #include "drm.h" 5 | #include 6 | 7 | // OSD Vars 8 | struct osd_vars { 9 | int plane_zpos; 10 | int refresh_frequency_ms; 11 | 12 | // Video Decoder 13 | bool enable_video; 14 | int current_framerate; 15 | bool enable_latency; 16 | float latency_avg; 17 | float latency_max; 18 | float latency_min; 19 | // Video Feed 20 | int bw_curr; 21 | long long bw_stats[10]; 22 | uint32_t video_width; 23 | uint32_t video_height; 24 | 25 | // Mavlink WFB-ng 26 | bool enable_wfbng; 27 | int8_t wfb_rssi; 28 | uint16_t wfb_errors; 29 | uint16_t wfb_fec_fixed; 30 | int8_t wfb_flags; 31 | 32 | // Mavlink 33 | int enable_telemetry; 34 | int telemetry_level; 35 | float telemetry_altitude; 36 | float telemetry_pitch; 37 | float telemetry_roll; 38 | float telemetry_yaw; 39 | float telemetry_battery; 40 | float telemetry_current; 41 | float telemetry_current_consumed; 42 | double telemetry_lat; 43 | double telemetry_lon; 44 | double telemetry_lat_base; 45 | double telemetry_lon_base; 46 | double telemetry_hdg; 47 | double telemetry_distance; 48 | double s1_double; 49 | double s2_double; 50 | double s3_double; 51 | double s4_double; 52 | float telemetry_sats; 53 | float telemetry_gspeed; 54 | float telemetry_vspeed; 55 | float telemetry_rssi; 56 | float telemetry_throttle; 57 | float telemetry_resolution; 58 | float telemetry_arm; 59 | float armed; 60 | char c1[30]; 61 | char c2[30]; 62 | char s1[30]; 63 | char s2[30]; 64 | char s3[30]; 65 | char s4[30]; 66 | char* ptr; 67 | }; 68 | 69 | extern struct osd_vars osd_vars; 70 | extern int osd_thread_signal; 71 | extern pthread_mutex_t osd_mutex; 72 | 73 | typedef struct { 74 | struct modeset_output *out; 75 | int fd; 76 | } osd_thread_params; 77 | 78 | void *__OSD_THREAD__(void *param); 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /rtp.c: -------------------------------------------------------------------------------- 1 | #include "rtp.h" 2 | #include 3 | #include 4 | 5 | uint16_t rtp_sequence(const rtp_header_t *header) { 6 | return ntohs(header->sequence_number); 7 | } 8 | 9 | uint32_t frames_received = 0; 10 | uint32_t in_nal_size = 0; 11 | 12 | uint8_t* decode_frame(uint8_t* rx_buffer, uint32_t rx_size, 13 | uint32_t header_size, uint8_t* nal_buffer, uint32_t* out_nal_size) { 14 | rx_buffer += header_size; 15 | rx_size -= header_size; 16 | 17 | // Get NAL type 18 | uint8_t fragment_type_avc = rx_buffer[0] & 0x1F; 19 | uint8_t fragment_type_hevc = (rx_buffer[0] >> 1) & 0x3F; 20 | 21 | uint8_t start_bit = 0; 22 | uint8_t end_bit = 0; 23 | uint8_t copy_size = 4; 24 | 25 | if (fragment_type_avc == 28 || fragment_type_hevc == 49) { 26 | if (fragment_type_avc == 28) { 27 | start_bit = rx_buffer[1] & 0x80; 28 | end_bit = rx_buffer[1] & 0x40; 29 | nal_buffer[4] = (rx_buffer[0] & 0xE0) | (rx_buffer[1] & 0x1F); 30 | } else { 31 | start_bit = rx_buffer[2] & 0x80; 32 | end_bit = rx_buffer[2] & 0x40; 33 | nal_buffer[4] = (rx_buffer[0] & 0x81) | (rx_buffer[2] & 0x3F) << 1; 34 | nal_buffer[5] = 1; 35 | copy_size++; 36 | rx_buffer++; 37 | rx_size--; 38 | } 39 | 40 | rx_buffer++; 41 | rx_size--; 42 | 43 | if (start_bit) { 44 | // Write NAL header 45 | nal_buffer[0] = 0; 46 | nal_buffer[1] = 0; 47 | nal_buffer[2] = 0; 48 | nal_buffer[3] = 1; 49 | 50 | // Copy data 51 | memcpy(nal_buffer + copy_size, rx_buffer, rx_size); 52 | in_nal_size = rx_size + copy_size; 53 | } else { 54 | rx_buffer++; 55 | rx_size--; 56 | memcpy(nal_buffer + in_nal_size, rx_buffer, rx_size); 57 | in_nal_size += rx_size; 58 | 59 | if (end_bit) { 60 | *out_nal_size = in_nal_size; 61 | in_nal_size = 0; 62 | frames_received++; 63 | return nal_buffer; 64 | } 65 | } 66 | 67 | return NULL; 68 | } else { 69 | // Write NAL header 70 | nal_buffer[0] = 0; 71 | nal_buffer[1] = 0; 72 | nal_buffer[2] = 0; 73 | nal_buffer[3] = 1; 74 | memcpy(nal_buffer + copy_size, rx_buffer, rx_size); 75 | *out_nal_size = rx_size + copy_size; 76 | in_nal_size = 0; 77 | 78 | // Return NAL 79 | frames_received++; 80 | return nal_buffer; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /rtp.h: -------------------------------------------------------------------------------- 1 | #ifndef RTP_FRAME_H 2 | #define RTP_FRAME_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint8_t version: 2; // RTP version 8 | uint8_t padding: 1; // Padding flag 9 | uint8_t extension: 1; // Extension flag 10 | uint8_t csrc_count: 4; // CSRC count 11 | uint8_t marker: 1; // Marker bit 12 | uint8_t payload_type: 7; // Payload type 13 | uint16_t sequence_number; // Sequence number 14 | uint32_t timestamp; // Timestamp 15 | uint32_t ssrc; // Synchronization source identifier 16 | } rtp_header_t; 17 | 18 | // RTP frame handling. 19 | 20 | uint8_t* decode_frame(uint8_t* rx_buffer, uint32_t rx_size, uint32_t header_size, uint8_t* nal_buffer, uint32_t* out_nal_size); 21 | 22 | uint16_t rtp_sequence(const rtp_header_t *header); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /scheduling_helper.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by https://github.com/Consti10 on 09.04.24. 3 | // https://github.com/OpenHD/FPVue_RK3566/tree/openhd 4 | // 5 | 6 | #ifndef FPVUE_SCHEDULINGHELPER_H 7 | #define FPVUE_SCHEDULINGHELPER_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace SchedulingHelper { 18 | 19 | // Only 'low' in comparison to other realtime tasks 20 | static constexpr int PRIORITY_REALTIME_LOW=30; 21 | static constexpr int PRIORITY_REALTIME_MID=40; 22 | 23 | // this thread should run as close to realtime as possible 24 | // https://youtu.be/NrjXEaTSyrw?t=647 25 | // COMMENT: Please don't ever use 99 for your application, there are some kernel 26 | // threads that run at 99 that are really important So ... lets use 90 for now 27 | static void set_thread_params_max_realtime(const std::string& tag, 28 | const int priority = 90) { 29 | pthread_t target = pthread_self(); 30 | int policy = SCHED_FIFO; 31 | sched_param param{}; 32 | // param.sched_priority = sched_get_priority_max(policy); 33 | param.sched_priority = priority; 34 | auto result = pthread_setschedparam(target, policy, ¶m); 35 | if (result != 0) { 36 | std::stringstream ss; 37 | ss << "Cannot setThreadParamsMaxRealtime " << result; 38 | std::cerr << ss.str() << std::endl; 39 | } else { 40 | std::stringstream ss; 41 | ss << "Changed prio "; 42 | if (!tag.empty()) { 43 | ss << "for " << tag << " "; 44 | } 45 | ss << "to SCHED_FIFO:" << param.sched_priority; 46 | std::cout << ss.str() << std::endl; 47 | } 48 | } 49 | 50 | static bool check_root() { 51 | const auto uid = getuid(); 52 | const bool root = uid ? false : true; 53 | return root; 54 | } 55 | 56 | } // namespace SchedulingHelper 57 | 58 | #endif //FPVUE_SCHEDULINGHELPER_H 59 | -------------------------------------------------------------------------------- /time_util.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by https://github.com/Consti10 on 31.03.24. 3 | // https://github.com/OpenHD/FPVue_RK3566/tree/openhd 4 | // 5 | 6 | 7 | #ifndef FPVUE_TIME_UTIL_H 8 | #define FPVUE_TIME_UTIL_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | /** 15 | * @return milliseconds 16 | */ 17 | uint64_t get_time_ms() { 18 | struct timespec spec; 19 | if (clock_gettime(1, &spec) == -1) { /* 1 is CLOCK_MONOTONIC */ 20 | abort(); 21 | } 22 | return spec.tv_sec * 1000 + spec.tv_nsec / 1e6; 23 | } 24 | 25 | void print_time_ms(const char* tag,uint64_t ms){ 26 | printf("%s %dms\n",tag,(int)ms); 27 | } 28 | 29 | 30 | struct TSAccumulator{ 31 | // In milliseconds 32 | uint64_t min_ms; 33 | uint64_t max_ms; 34 | uint64_t accumulated_ms; 35 | int count; 36 | uint64_t last_print_ms; 37 | }; 38 | 39 | 40 | void accumulate_and_print(const char *tag,uint64_t ms,struct TSAccumulator* tsAccumulator){ 41 | if(ms>tsAccumulator->max_ms){ 42 | tsAccumulator->max_ms=ms; 43 | } 44 | if(msmin_ms){ 45 | tsAccumulator->min_ms=ms; 46 | } 47 | tsAccumulator->accumulated_ms+=ms; 48 | tsAccumulator->count++; 49 | uint64_t elapsed_since_last_print_ms=get_time_ms()- tsAccumulator->last_print_ms; 50 | if(elapsed_since_last_print_ms>1000){ 51 | uint64_t average=tsAccumulator->accumulated_ms/tsAccumulator->count; 52 | printf("%s min:%ld max:%ld avg:%ld (ms)\n",tag,tsAccumulator->min_ms,tsAccumulator->max_ms,average); 53 | tsAccumulator->min_ms=UINT64_MAX; 54 | tsAccumulator->max_ms=0; 55 | tsAccumulator->count=0; 56 | tsAccumulator->accumulated_ms=0; 57 | tsAccumulator->last_print_ms=get_time_ms(); 58 | } 59 | } 60 | 61 | 62 | #endif //FPVUE_TIME_UTIL_H 63 | --------------------------------------------------------------------------------