├── .gitignore ├── .clang-format ├── Makefile ├── .vscode ├── settings.json ├── tasks.json └── launch.json ├── mavlink ├── common │ ├── version.h │ ├── mavlink.h │ ├── mavlink_msg_auth_key.h │ ├── mavlink_msg_mission_item_reached.h │ ├── mavlink_msg_raw_rpm.h │ ├── mavlink_msg_terrain_check.h │ ├── mavlink_msg_log_erase.h │ ├── mavlink_msg_system_time.h │ ├── mavlink_msg_debug.h │ ├── mavlink_msg_log_request_end.h │ ├── mavlink_msg_encapsulated_data.h │ ├── mavlink_msg_current_event_sequence.h │ ├── mavlink_msg_param_request_list.h │ ├── mavlink_msg_camera_trigger.h │ ├── mavlink_msg_power_status.h │ ├── mavlink_msg_param_ext_request_list.h │ ├── mavlink_msg_set_mode.h │ └── mavlink_msg_data_stream.h ├── minimal │ ├── version.h │ ├── mavlink.h │ └── testsuite.h ├── standard │ ├── version.h │ ├── mavlink.h │ ├── testsuite.h │ └── standard.h ├── mavlink_get_info.h ├── checksum.h ├── mavlink_conversions.h └── mavlink_sha256.h ├── LICENSE ├── channels_imx335.sh ├── README.md └── channels.sh /.gitignore: -------------------------------------------------------------------------------- 1 | mavfwd 2 | tmp/** 3 | notes.txt 4 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | UseTab: Always 3 | IndentWidth: 4 4 | TabWidth: 4 5 | AlignAfterOpenBracket: DontAlign 6 | ColumnLimit: 100 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-O1 -g -fsanitize=address -fno-omit-frame-pointer -Wall -Wno-address-of-packed-member 2 | LDFLAGS=-g -fsanitize=address 3 | LDLIBS=-levent_core 4 | 5 | mavfwd: 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorTheme": "Default High Contrast", 3 | "files.associations": { 4 | "mavlink.h": "c", 5 | "system_error": "c", 6 | "chrono": "c", 7 | "common.h": "c", 8 | "array": "c", 9 | "string": "c", 10 | "string_view": "c" 11 | } 12 | } -------------------------------------------------------------------------------- /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 "Sat Jul 15 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/minimal/version.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from minimal.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 "Sat Jul 15 2023" 11 | #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" 12 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 22 13 | 14 | #endif // MAVLINK_VERSION_H 15 | -------------------------------------------------------------------------------- /mavlink/standard/version.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from standard.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 "Sat Jul 15 2023" 11 | #define MAVLINK_WIRE_PROTOCOL_VERSION "2.0" 12 | #define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 22 13 | 14 | #endif // MAVLINK_VERSION_H 15 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "gcc build", 6 | "type": "shell", 7 | "command": "gcc", 8 | "args": [ 9 | "-g", 10 | "-o", 11 | "${workspaceFolder}/mavfwd", 12 | "${workspaceFolder}/mavfwd.c", 13 | "-levent", 14 | "-levent_core" 15 | ], 16 | "group": { 17 | "kind": "build", 18 | "isDefault": true 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /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 -7157248543085918260 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/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 5090287056522390184 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/standard/mavlink.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol built from standard.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 7747193470092757787 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 "standard.h" 33 | 34 | #endif // MAVLINK_H 35 | -------------------------------------------------------------------------------- /mavlink/standard/testsuite.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol testsuite generated from standard.xml 3 | * @see https://mavlink.io/en/ 4 | */ 5 | #pragma once 6 | #ifndef STANDARD_TESTSUITE_H 7 | #define STANDARD_TESTSUITE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #ifndef MAVLINK_TEST_ALL 14 | #define MAVLINK_TEST_ALL 15 | static void mavlink_test_minimal(uint8_t, uint8_t, mavlink_message_t *last_msg); 16 | static void mavlink_test_standard(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 | mavlink_test_minimal(system_id, component_id, last_msg); 21 | mavlink_test_standard(system_id, component_id, last_msg); 22 | } 23 | #endif 24 | 25 | #include "../minimal/testsuite.h" 26 | 27 | 28 | 29 | static void mavlink_test_standard(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) 30 | { 31 | 32 | } 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif // __cplusplus 37 | #endif // STANDARD_TESTSUITE_H 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 OpenIPC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | 5 | { 6 | "name": "C Debug", 7 | "type": "cppdbg", 8 | "request": "launch", 9 | "program": "${workspaceFolder}/mavfwd", 10 | "args": [ 11 | "--master", 12 | "/dev/ttyUSB0", 13 | "--baudrate", 14 | "115200", 15 | "--out", 16 | "127.0.0.1:14550", 17 | "--in", 18 | "127.0.0.1:0", 19 | "--channel", 20 | "7", 21 | "-a", 22 | "5", 23 | "-f", 24 | "/home/home/", 25 | "--wfb", 26 | " " 27 | 28 | 29 | ], 30 | "stopAtEntry": false, 31 | "cwd": "${workspaceFolder}", 32 | "environment": [], 33 | "externalConsole": false, 34 | "MIMode": "gdb", 35 | "miDebuggerPath": "/usr/bin/gdb", 36 | 37 | "setupCommands": [ 38 | { 39 | "description": "MAVLINk gdb", 40 | "text": "-enable-pretty-printing", 41 | "ignoreFailures": true 42 | } 43 | ], 44 | "preLaunchTask": "gcc build", 45 | "linux": { 46 | "preLaunchTask": "gcc build" 47 | } 48 | 49 | } 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /mavlink/standard/standard.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief MAVLink comm protocol generated from standard.xml 3 | * @see http://mavlink.org 4 | */ 5 | #pragma once 6 | #ifndef MAVLINK_STANDARD_H 7 | #define MAVLINK_STANDARD_H 8 | 9 | #ifndef MAVLINK_H 10 | #error Wrong include order: MAVLINK_STANDARD.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call. 11 | #endif 12 | 13 | #define MAVLINK_STANDARD_XML_HASH 7747193470092757787 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | // MESSAGE LENGTHS AND CRCS 20 | 21 | #ifndef MAVLINK_MESSAGE_LENGTHS 22 | #define MAVLINK_MESSAGE_LENGTHS {} 23 | #endif 24 | 25 | #ifndef MAVLINK_MESSAGE_CRCS 26 | #define MAVLINK_MESSAGE_CRCS {{0, 50, 9, 9, 0, 0, 0}, {300, 217, 22, 22, 0, 0, 0}} 27 | #endif 28 | 29 | #include "../protocol.h" 30 | 31 | #define MAVLINK_ENABLED_STANDARD 32 | 33 | // ENUM DEFINITIONS 34 | 35 | 36 | 37 | // MAVLINK VERSION 38 | 39 | #ifndef MAVLINK_VERSION 40 | #define MAVLINK_VERSION 2 41 | #endif 42 | 43 | #if (MAVLINK_VERSION == 0) 44 | #undef MAVLINK_VERSION 45 | #define MAVLINK_VERSION 2 46 | #endif 47 | 48 | // MESSAGE DEFINITIONS 49 | 50 | 51 | // base include 52 | #include "../minimal/minimal.h" 53 | 54 | 55 | #if MAVLINK_STANDARD_XML_HASH == MAVLINK_PRIMARY_XML_HASH 56 | # define MAVLINK_MESSAGE_INFO {MAVLINK_MESSAGE_INFO_HEARTBEAT, MAVLINK_MESSAGE_INFO_PROTOCOL_VERSION} 57 | # define MAVLINK_MESSAGE_NAMES {{ "HEARTBEAT", 0 }, { "PROTOCOL_VERSION", 300 }} 58 | # if MAVLINK_COMMAND_24BIT 59 | # include "../mavlink_get_info.h" 60 | # endif 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif // __cplusplus 66 | #endif // MAVLINK_STANDARD_H 67 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /channels_imx335.sh: -------------------------------------------------------------------------------- 1 | 2 | echo $1 $2 >>/tmp/channels.log 3 | # 4 | # gk7205v300 IMX335 board 5 | # 6 position switch as defined by ELRS 6 | # Change resolutions in flight 7 | #2000, 1725, 1575, 1425, 1275, 1000 8 | #if [ $1 -eq 7 ]; then 9 | if [ $2 -lt 1050 ]; then 10 | yaml-cli -s .image.contrast 60 11 | yaml-cli -s .image.hue 50 12 | yaml-cli -s .image.saturation 50 13 | yaml-cli -s .image.luminance 50 14 | 15 | yaml-cli -s .video0.bitrate 7000 16 | yaml-cli -s .video0.size 1920x1080 17 | yaml-cli -s .video0.gopSize 1.5 18 | yaml-cli -s .video0.fps 30 19 | yaml-cli -s .isp.sensorConfig /etc/sensors/imx335_i2c_4M.ini 20 | 21 | echo "1920x1080/30fps/7Mb" >/tmp/mavlink.msg 22 | 23 | killall -1 majestic 24 | sleep 1 25 | /etc/gkrcparams --MaxQp 30 --MaxI 2 26 | 27 | elif [ $2 -gt 1250 ] && [ $2 -lt 1300 ]; then 28 | yaml-cli -s .image.contrast 60 29 | yaml-cli -s .image.hue 50 30 | yaml-cli -s .image.saturation 50 31 | yaml-cli -s .image.luminance 50 32 | 33 | yaml-cli -s .video0.bitrate 14000 34 | yaml-cli -s .video0.size 1920x1080 35 | yaml-cli -s .video0.gopSize 1.5 36 | yaml-cli -s .video0.fps 30 37 | yaml-cli -s .isp.sensorConfig /etc/sensors/imx335_i2c_4M.ini 38 | 39 | echo "1920x1080/30fps/14Mb" >/tmp/mavlink.msg 40 | 41 | killall -1 majestic 42 | sleep 1 43 | /etc/gkrcparams --MaxQp 30 --MaxI 2 44 | 45 | elif [ $2 -gt 1400 ] && [ $2 -lt 1450 ]; then 46 | yaml-cli -s .image.contrast 80 47 | yaml-cli -s .image.hue 50 48 | yaml-cli -s .image.saturation 60 49 | yaml-cli -s .image.luminance 60 50 | 51 | yaml-cli -s .video0.bitrate 14000 52 | yaml-cli -s .video0.size 1920x1080 53 | yaml-cli -s .video0.gopSize 1.5 54 | yaml-cli -s .video0.fps 30 55 | yaml-cli -s .isp.sensorConfig /etc/sensors/imx335_i2c_4M.ini 56 | 57 | echo "1920x1080/30fps/14Mb C:80%" >/tmp/mavlink.msg 58 | 59 | killall -1 majestic 60 | sleep 1 61 | /etc/gkrcparams --MaxQp 30 --MaxI 2 62 | 63 | elif [ $2 -gt 1550 ] && [ $2 -lt 1600 ]; then 64 | 65 | yaml-cli -s .image.contrast 80 66 | yaml-cli -s .image.hue 50 67 | yaml-cli -s .image.saturation 60 68 | yaml-cli -s .image.luminance 60 69 | 70 | yaml-cli -s .video0.bitrate 14000 71 | yaml-cli -s .video0.size 1920x1080 72 | yaml-cli -s .video0.gopSize 1.5 73 | yaml-cli -s .video0.fps 30 74 | yaml-cli -s .isp.sensorConfig /etc/sensors/imx335_i2c_4M.ini 75 | 76 | echo "1920x1080/30fps/14Mb C:80%" >/tmp/mavlink.msg 77 | 78 | 79 | killall -1 majestic 80 | sleep 1 81 | /etc/gkrcparams --MaxQp 30 --MaxI 2 82 | 83 | elif [ $2 -gt 1700 ] && [ $2 -lt 1750 ]; then 84 | 85 | yaml-cli -s .image.contrast 60 86 | yaml-cli -s .image.hue 50 87 | yaml-cli -s .image.saturation 50 88 | yaml-cli -s .image.luminance 50 89 | 90 | yaml-cli -s .video0.bitrate 14000 91 | yaml-cli -s .video0.size size: 2592x1520 92 | yaml-cli -s .video0.gopSize 1.5 93 | yaml-cli -d .video0.fps 94 | 95 | 96 | yaml-cli -s .isp.sensorConfig /etc/sensors/5M_imx335.ini 97 | 98 | echo "2592x1520/25fps" >/tmp/mavlink.msg 99 | 100 | killall -1 majestic 101 | sleep 1 102 | /etc/gkrcparams --MaxQp 30 --MaxI 2 103 | 104 | elif [ $2 -gt 1950 ]; then 105 | # emergency 106 | yaml-cli -s .image.contrast 60 107 | yaml-cli -s .image.hue 50 108 | yaml-cli -s .image.saturation 50 109 | yaml-cli -s .image.luminance 50 110 | 111 | yaml-cli -s .video0.bitrate 3000 112 | yaml-cli -s .video0.size 1920x1080 113 | yaml-cli -s .video0.gopSize 1.5 114 | yaml-cli -s .video0.fps 30 115 | yaml-cli -s .isp.sensorConfig /etc/sensors/imx335_i2c_4M.ini 116 | 117 | echo "1920x1080/30fps/3Mb" >/tmp/mavlink.msg 118 | 119 | killall -1 majestic 120 | sleep 1 121 | /etc/gkrcparams --MaxQp 30 --MaxI 2 122 | 123 | else 124 | echo "unknown value" $2 125 | fi 126 | #fi 127 | 128 | 129 | exit 1 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## MAVFWD 2 | 3 | Added stream parsing with official mavlink library. 4 | 5 | **mavfwd** is a utility for broadcasting a mavlink telemetry stream between wifibroadcast and uart devices, for organizing one- or two-way telemetry between UAV and ground station. 6 | 7 | **mavfwd** is included in the OpenIPC FPV firmware as a lighter alternative to mavlink routerd and is usually used on the air part (camera). 8 | 9 | Also, **mavfwd** can monitor the mavlink RC _CHANNELS package, and call the script `channels.sh` (located at /usr/bin or /usr/sbin) passing the channel number and its value to it when changing as $1 and $2 parameters. An example of channels.sh is present. 10 | 11 | This allows for controlling the camera via the Remote Control Transmitter 12 | 13 | ``` 14 | Usage: mavfwd [OPTIONS] 15 | -m --master Local MAVLink master port (%s by default) 16 | -b --baudrate Serial port baudrate (%d by default) 17 | -o --out Remote output port (%s by default) 18 | -i --in Remote input port (%s by default) 19 | -c --channels RC Channel to listen for commands (0 by default) and call channels.sh 20 | -w --wait Delay after each command received(2000ms defaulr) 21 | -a --aggregate Aggregate packets in frames (1 no aggregation, 0 no parsing only raw data forward) (%d by default) 22 | -f --folder Folder for file mavlink.msg (default is current folder) 23 | -p --persist How long a channel value must persist to generate a command - for multiposition switches (0ms default) 24 | -t --temp Inject SoC temperature into telemetry(HiSilicon and SigmaStart supported) 25 | -j --wfb Reports wfb_tx dropped packets as Mavlink messages. wfb_tx console must be redirected to /wfb.log 26 | -v --verbose Display each packet, default not 27 | --help Display this help 28 | ``` 29 | 30 | ### Example : 31 | 32 | ```mavfwd --master /dev/ttyAMA0 --baudrate 115200 --out 192.168.1.20:14550 -c 7 -w 3000 -a 10 -t -f /tmp/``` 33 | 34 | Will read on the first UART with baudrade 115200 and will listen for values in RC channel 7 that come from the Remote Control via Flight Controller. 35 | 36 | Every time the value is changed with more than 5% the bash script `channels.sh {Channel} {Value}` will be started with params. 37 | 38 | The script then can check the Value param (usually between 1000 and 2000) and do the tasks needed - reconfigure encoder, switch IR mode, restart WiFi, change MCS index. etc. 39 | 40 | To protect the system from overloading (when rotating a pot on the Tx ), the script will not be started again for 3000ms. 41 | -p option is useful for rotary switches, where each switch step will generate a command till the desired one is reached. 42 | 43 | In order to avoid this, the channel value must keep its value for a given period in order to be accepted, for example 1000ms. 44 | 45 | This way if you never stay more than a second on a step of the rotary switch while rotating it, only the last one will be accepted. The drawback is the delay this options adds. 46 | 47 | Packets will be aggregated in chunks of 10 into one UDP frame. 48 | 49 | A MAVLINK_MSG_ID_ATTITUDE from the FC will flush the buffer. 50 | 51 | This way the OSD will be updated with the same rate and no lag will be added. 52 | 53 | ` -a 15` : will flush the cached messages into one UDP packet after count of message reaches 15 54 | 55 | ` -a 1024` : will flush the cached messages into one UDP packet total length of all message reaches 1024 bytes 56 | 57 | In both cases the buffer will be flushed if there are at least 3 packets and a MAVLINK_MSG_ID_ATTITUDE is received. 58 | 59 | Temperature will be read from the board and will be injected into the mavlink stream each second via MAVLINK_MSG_ID_RAW_IMU 27 message. 60 | 61 | Option to send text from the cam. The file mavlink.msg in {tempfolder} is monitored and when found, all data from it are send 62 | as plain text message via MAVLINK_MSG_ID_STATUSTEXT 253 to the ground station and the file is deleted. 63 | 64 | ### Sample: 65 | 66 | echo "Huston, this is IPC" >/tmp/mavlink.msg 67 | 68 | killall -usr1 mavfwd # will send text message to ground station even no data are received in the serial port, can be used to test Camera to Ground connection. 69 | 70 | wfb reporting scans /tmp/wfb.log file every second and extract values from "UDP rxq overflow: 2 packets dropped" lines. 71 | 72 | wfb_tx stdout must be redirected to this file, like this : 73 | 74 | ```wfb_tx -p ${stream} -u ${udp_port} -R 512000 -K ${keydir}/${unit}.key -B ${bandwidth} -M ${mcs_index} -S ${stbc} -L ${ldpc} -G ${guard_interval} -k ${fec_k} -n ${fec_n} -T ${pool_timeout} -i ${link_id} -f ${frame_type} ${wlan} 2>&1 | tee -a /tmp/wfb.log &``` 75 | 76 | In order to cross-compile for a specific camera., pull OpenIPC locally and compile it for the desired chipset. 77 | 78 | Assuming it is compiled in ```/home/home/src/openipc```, then **mavfwd** can be compiled and copied to cam with IP 192.168.1.88 like this: 79 | ``` 80 | cp mavfwd.c /home/home/src/openipc/output/build/mavfwd-220d30e118d26008e94445887a03d77ba73c2d29/ 81 | make -C /home/home/src/openipc/output/ mavfwd-rebuild 82 | scp /home/home/src/openipc/output/build/mavfwd-220d30e118d26008e94445887a03d77ba73c2d29/mavfwd root@192.168.1.88:/usr/bin/ 83 | ``` 84 | -------------------------------------------------------------------------------- /channels.sh: -------------------------------------------------------------------------------- 1 | . /etc/wfb.conf 2 | 3 | function set_mcs() { 4 | echo $(date "+%H:%M:%S") " Setting MCS $1" 5 | if [ ${mcs_index} -eq $1 ]; then 6 | echo $(date "+%H:%M:%S") " MCS the same : $1" 7 | else 8 | # echo $(date "+%H:%M:%S") " changing MCS from ${mcs_index} to $1. Hold on!" 9 | echo "Changing MCS from ${mcs_index} to $1. Hold on!" >/tmp/mavlink.msg 10 | # wait to make this transmitted before wfb_tx is killed to change MCS 11 | sleep 0.2 12 | 13 | # wfb_tx will be killed when changing MCS index. 14 | # kill -9 $(pidof wfb_tx) 15 | # telemetry_tx will be killed when changing MCS index only if it tries to inject 16 | kill -9 $(pidof telemetry_tx) 17 | # better not to kill it, since it may call this script again on restart ! 18 | # kill -9 $(pidof mavfwd) 19 | 20 | sed -i 's/^mcs_index=.*/mcs_index='$1'/' /etc/wfb.conf 21 | 22 | wifibroadcast start 23 | 24 | echo $(date "+%H:%M:%S") " wifibroadcast started " 25 | fi 26 | } 27 | 28 | 29 | #for debugging 30 | #echo 'Starting channels.sh ' $1 $2 >>/tmp/channels.log 31 | #echo 'Channels Called' $1 $2 32 | 33 | 34 | #2000, 1725, 1575, 1425, 1275, 1000 35 | # contrast: 45 36 | # hue: 45 37 | # saturation: 40 38 | # luminance: 50 39 | 40 | # 6 position switch as defined by ELRS 41 | #channel 7 42 | #if [ $1 -eq 7 ]; then 43 | if [ $2 -lt 1050 ]; then 44 | yaml-cli -s .image.contrast 70 45 | yaml-cli -s .image.hue 50 46 | yaml-cli -s .image.saturation 50 47 | yaml-cli -s .image.luminance 50 48 | 49 | yaml-cli -s .video0.bitrate 14000 50 | yaml-cli -s .video0.size 1920x1080 51 | yaml-cli -s .video0.gopSize 1.5 52 | yaml-cli -s .video0.fps 60 53 | yaml-cli -s .video0.minQp 12 54 | 55 | yaml-cli -s .isp.exposure 7 56 | 57 | #delibaretely not set 58 | #set_mcs 3 59 | echo "1920x1080/60fps/E7ms" >/tmp/mavlink.msg 60 | 61 | # killall -1 majestic 62 | killall majestic # just in case majestic had started sending long packets 63 | sleep 1 64 | killall -9 majestic 65 | majestic & 66 | echo "Majestic brute force restart" >/tmp/mavlink.msg 67 | 68 | elif [ $2 -gt 1250 ] && [ $2 -lt 1300 ]; then 69 | yaml-cli -s .image.contrast 70 70 | yaml-cli -s .image.hue 50 71 | yaml-cli -s .image.saturation 50 72 | yaml-cli -s .image.luminance 50 73 | yaml-cli -s .image.sharpen 100 74 | yaml-cli -s .image.denoise 0 75 | 76 | yaml-cli -s .video0.bitrate 14000 77 | yaml-cli -s .video0.size 1920x1080 78 | yaml-cli -s .video0.gopSize 1.5 79 | yaml-cli -s .video0.fps 60 80 | yaml-cli -s .video0.minQp 12 81 | 82 | yaml-cli -s .isp.exposure 13 83 | 84 | set_mcs 3 85 | 86 | echo "1920x1080/60fps/E13ms" >/tmp/mavlink.msg 87 | 88 | killall -1 majestic 89 | 90 | elif [ $2 -gt 1400 ] && [ $2 -lt 1450 ]; then 91 | 92 | yaml-cli -s .image.contrast 70 93 | yaml-cli -s .image.hue 55 94 | yaml-cli -s .image.saturation 60 95 | yaml-cli -s .image.luminance 50 96 | yaml-cli -s .image.sharpen 100 97 | yaml-cli -s .image.denoise 0 98 | 99 | yaml-cli -s .video0.bitrate 15000 100 | yaml-cli -s .video0.size 1920x1080 101 | yaml-cli -s .video0.gopSize 1.5 102 | yaml-cli -s .video0.fps 30 103 | yaml-cli -s .video0.minQp 12 104 | 105 | yaml-cli -s .isp.exposure 28 106 | yaml-cli -s .isp.IPQPDelta -5 107 | 108 | set_mcs 3 109 | 110 | echo "1920x1080/30fps/E28ms" >/tmp/mavlink.msg 111 | 112 | killall -1 majestic 113 | 114 | elif [ $2 -gt 1550 ] && [ $2 -lt 1600 ]; then 115 | 116 | yaml-cli -s .image.contrast 70 117 | yaml-cli -s .image.hue 50 118 | yaml-cli -s .image.saturation 50 119 | yaml-cli -s .image.luminance 50 120 | yaml-cli -s .image.sharpen 100 121 | yaml-cli -s .image.denoise 0 122 | 123 | 124 | yaml-cli -s .video0.bitrate 19000 125 | yaml-cli -s .video0.size 1920x1080 126 | yaml-cli -s .video0.gopSize 1.5 127 | yaml-cli -s .video0.fps 60 128 | yaml-cli -s .video0.minQp 12 129 | 130 | yaml-cli -s .isp.exposure 18 131 | 132 | set_mcs 4 133 | 134 | echo "1920x1080/60fps/E18ms" >/tmp/mavlink.msg 135 | 136 | killall -1 majestic 137 | 138 | # elif [ $2 -gt 1550 ] && [ $2 -lt 1600 ]; then 139 | # 140 | # yaml-cli -s .image.contrast 60 141 | # yaml-cli -s .image.hue 50 142 | # yaml-cli -s .image.saturation 50 143 | # yaml-cli -s .image.luminance 50 144 | # 145 | # yaml-cli -s .video0.bitrate 20000 146 | # yaml-cli -s .video0.size 2944x1656 147 | # yaml-cli -s .video0.gopSize 1 148 | # yaml-cli -s .video0.fps 30 149 | # yaml-cli -s .isp.exposure 20 150 | # 151 | # set_mcs 4 152 | # 153 | # echo "2944x1656/30fps/E20/MCS3" >/tmp/mavlink.msg 154 | # 155 | # killall -1 majestic 156 | # 157 | elif [ $2 -gt 1700 ] && [ $2 -lt 1750 ]; then 158 | 159 | yaml-cli -s .image.contrast 60 160 | yaml-cli -s .image.hue 50 161 | yaml-cli -s .image.saturation 50 162 | yaml-cli -s .image.luminance 50 163 | yaml-cli -s .image.sharpen 100 164 | yaml-cli -s .image.denoise 0 165 | 166 | yaml-cli -s .video0.bitrate 21000 167 | yaml-cli -s .video0.size 3200x1800 168 | yaml-cli -s .video0.gopSize 1 169 | yaml-cli -s .video0.fps 30 170 | yaml-cli -s .video0.minQp 12 171 | 172 | yaml-cli -s .isp.exposure 15 173 | 174 | set_mcs 4 175 | 176 | echo "3200x1800/30fps/E30/MCS4" >/tmp/mavlink.msg 177 | 178 | killall -1 majestic 179 | 180 | elif [ $2 -gt 1950 ]; then 181 | 182 | yaml-cli -s .image.contrast 60 183 | yaml-cli -s .image.hue 50 184 | yaml-cli -s .image.saturation 50 185 | yaml-cli -s .image.luminance 50 186 | 187 | yaml-cli -s .video0.bitrate 18000 188 | yaml-cli -s .video0.size 3840x2160 189 | yaml-cli -s .video0.gopSize 1.5 190 | yaml-cli -s .video0.fps 20 191 | yaml-cli -s .video0.qpDelta -8 192 | yaml-cli -s .video0.minQp 30 193 | # yaml-cli -s .video0.minQp 12 194 | # yaml-cli -s .video0.maxQp 48 195 | 196 | yaml-cli -s .isp.exposure 36 197 | # yaml-cli -s .isp.IPQPDelta -8 198 | 199 | set_mcs 4 200 | 201 | echo "3840x2160/20fps/E36/MCS4" >/tmp/mavlink.msg 202 | killall -1 majestic 203 | 204 | else 205 | echo "unknown value" $2 206 | fi 207 | #fi 208 | 209 | 210 | exit 1 211 | -------------------------------------------------------------------------------- /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/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; i>(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/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_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_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_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/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_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_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_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_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_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_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_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_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_param_ext_request_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE PARAM_EXT_REQUEST_LIST PACKING 3 | 4 | #define MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST 321 5 | 6 | 7 | typedef struct __mavlink_param_ext_request_list_t { 8 | uint8_t target_system; /*< System ID*/ 9 | uint8_t target_component; /*< Component ID*/ 10 | } mavlink_param_ext_request_list_t; 11 | 12 | #define MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN 2 13 | #define MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN 2 14 | #define MAVLINK_MSG_ID_321_LEN 2 15 | #define MAVLINK_MSG_ID_321_MIN_LEN 2 16 | 17 | #define MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC 88 18 | #define MAVLINK_MSG_ID_321_CRC 88 19 | 20 | 21 | 22 | #if MAVLINK_COMMAND_24BIT 23 | #define MAVLINK_MESSAGE_INFO_PARAM_EXT_REQUEST_LIST { \ 24 | 321, \ 25 | "PARAM_EXT_REQUEST_LIST", \ 26 | 2, \ 27 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_ext_request_list_t, target_system) }, \ 28 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_ext_request_list_t, target_component) }, \ 29 | } \ 30 | } 31 | #else 32 | #define MAVLINK_MESSAGE_INFO_PARAM_EXT_REQUEST_LIST { \ 33 | "PARAM_EXT_REQUEST_LIST", \ 34 | 2, \ 35 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_param_ext_request_list_t, target_system) }, \ 36 | { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_param_ext_request_list_t, target_component) }, \ 37 | } \ 38 | } 39 | #endif 40 | 41 | /** 42 | * @brief Pack a param_ext_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_ext_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_EXT_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_EXT_REQUEST_LIST_LEN); 60 | #else 61 | mavlink_param_ext_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_EXT_REQUEST_LIST_LEN); 66 | #endif 67 | 68 | msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST; 69 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 70 | } 71 | 72 | /** 73 | * @brief Pack a param_ext_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_ext_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_EXT_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_EXT_REQUEST_LIST_LEN); 92 | #else 93 | mavlink_param_ext_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_EXT_REQUEST_LIST_LEN); 98 | #endif 99 | 100 | msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST; 101 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 102 | } 103 | 104 | /** 105 | * @brief Encode a param_ext_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_ext_request_list C-struct to read the message contents from 111 | */ 112 | static inline uint16_t mavlink_msg_param_ext_request_list_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_ext_request_list_t* param_ext_request_list) 113 | { 114 | return mavlink_msg_param_ext_request_list_pack(system_id, component_id, msg, param_ext_request_list->target_system, param_ext_request_list->target_component); 115 | } 116 | 117 | /** 118 | * @brief Encode a param_ext_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_ext_request_list C-struct to read the message contents from 125 | */ 126 | static inline uint16_t mavlink_msg_param_ext_request_list_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_ext_request_list_t* param_ext_request_list) 127 | { 128 | return mavlink_msg_param_ext_request_list_pack_chan(system_id, component_id, chan, msg, param_ext_request_list->target_system, param_ext_request_list->target_component); 129 | } 130 | 131 | /** 132 | * @brief Send a param_ext_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_ext_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_EXT_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_EXT_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 148 | #else 149 | mavlink_param_ext_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_EXT_REQUEST_LIST, (const char *)&packet, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 154 | #endif 155 | } 156 | 157 | /** 158 | * @brief Send a param_ext_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_ext_request_list_send_struct(mavlink_channel_t chan, const mavlink_param_ext_request_list_t* param_ext_request_list) 163 | { 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 165 | mavlink_msg_param_ext_request_list_send(chan, param_ext_request_list->target_system, param_ext_request_list->target_component); 166 | #else 167 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST, (const char *)param_ext_request_list, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 168 | #endif 169 | } 170 | 171 | #if MAVLINK_MSG_ID_PARAM_EXT_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_ext_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_EXT_REQUEST_LIST, buf, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 187 | #else 188 | mavlink_param_ext_request_list_t *packet = (mavlink_param_ext_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_EXT_REQUEST_LIST, (const char *)packet, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_CRC); 193 | #endif 194 | } 195 | #endif 196 | 197 | #endif 198 | 199 | // MESSAGE PARAM_EXT_REQUEST_LIST UNPACKING 200 | 201 | 202 | /** 203 | * @brief Get field target_system from param_ext_request_list message 204 | * 205 | * @return System ID 206 | */ 207 | static inline uint8_t mavlink_msg_param_ext_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_ext_request_list message 214 | * 215 | * @return Component ID 216 | */ 217 | static inline uint8_t mavlink_msg_param_ext_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_ext_request_list message into a struct 224 | * 225 | * @param msg The message to decode 226 | * @param param_ext_request_list C-struct to decode the message contents into 227 | */ 228 | static inline void mavlink_msg_param_ext_request_list_decode(const mavlink_message_t* msg, mavlink_param_ext_request_list_t* param_ext_request_list) 229 | { 230 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 231 | param_ext_request_list->target_system = mavlink_msg_param_ext_request_list_get_target_system(msg); 232 | param_ext_request_list->target_component = mavlink_msg_param_ext_request_list_get_target_component(msg); 233 | #else 234 | uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN? msg->len : MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN; 235 | memset(param_ext_request_list, 0, MAVLINK_MSG_ID_PARAM_EXT_REQUEST_LIST_LEN); 236 | memcpy(param_ext_request_list, _MAV_PAYLOAD(msg), len); 237 | #endif 238 | } 239 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_set_mode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE SET_MODE PACKING 3 | 4 | #define MAVLINK_MSG_ID_SET_MODE 11 5 | 6 | 7 | typedef struct __mavlink_set_mode_t { 8 | uint32_t custom_mode; /*< The new autopilot-specific mode. This field can be ignored by an autopilot.*/ 9 | uint8_t target_system; /*< The system setting the mode*/ 10 | uint8_t base_mode; /*< The new base mode.*/ 11 | } mavlink_set_mode_t; 12 | 13 | #define MAVLINK_MSG_ID_SET_MODE_LEN 6 14 | #define MAVLINK_MSG_ID_SET_MODE_MIN_LEN 6 15 | #define MAVLINK_MSG_ID_11_LEN 6 16 | #define MAVLINK_MSG_ID_11_MIN_LEN 6 17 | 18 | #define MAVLINK_MSG_ID_SET_MODE_CRC 89 19 | #define MAVLINK_MSG_ID_11_CRC 89 20 | 21 | 22 | 23 | #if MAVLINK_COMMAND_24BIT 24 | #define MAVLINK_MESSAGE_INFO_SET_MODE { \ 25 | 11, \ 26 | "SET_MODE", \ 27 | 3, \ 28 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_set_mode_t, target_system) }, \ 29 | { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_set_mode_t, base_mode) }, \ 30 | { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_mode_t, custom_mode) }, \ 31 | } \ 32 | } 33 | #else 34 | #define MAVLINK_MESSAGE_INFO_SET_MODE { \ 35 | "SET_MODE", \ 36 | 3, \ 37 | { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_set_mode_t, target_system) }, \ 38 | { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_set_mode_t, base_mode) }, \ 39 | { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_mode_t, custom_mode) }, \ 40 | } \ 41 | } 42 | #endif 43 | 44 | /** 45 | * @brief Pack a set_mode 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 target_system The system setting the mode 51 | * @param base_mode The new base mode. 52 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot. 53 | * @return length of the message in bytes (excluding serial stream start sign) 54 | */ 55 | static inline uint16_t mavlink_msg_set_mode_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 56 | uint8_t target_system, uint8_t base_mode, uint32_t custom_mode) 57 | { 58 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 59 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN]; 60 | _mav_put_uint32_t(buf, 0, custom_mode); 61 | _mav_put_uint8_t(buf, 4, target_system); 62 | _mav_put_uint8_t(buf, 5, base_mode); 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MODE_LEN); 65 | #else 66 | mavlink_set_mode_t packet; 67 | packet.custom_mode = custom_mode; 68 | packet.target_system = target_system; 69 | packet.base_mode = base_mode; 70 | 71 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MODE_LEN); 72 | #endif 73 | 74 | msg->msgid = MAVLINK_MSG_ID_SET_MODE; 75 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 76 | } 77 | 78 | /** 79 | * @brief Pack a set_mode 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 target_system The system setting the mode 85 | * @param base_mode The new base mode. 86 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot. 87 | * @return length of the message in bytes (excluding serial stream start sign) 88 | */ 89 | static inline uint16_t mavlink_msg_set_mode_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 90 | mavlink_message_t* msg, 91 | uint8_t target_system,uint8_t base_mode,uint32_t custom_mode) 92 | { 93 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 94 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN]; 95 | _mav_put_uint32_t(buf, 0, custom_mode); 96 | _mav_put_uint8_t(buf, 4, target_system); 97 | _mav_put_uint8_t(buf, 5, base_mode); 98 | 99 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MODE_LEN); 100 | #else 101 | mavlink_set_mode_t packet; 102 | packet.custom_mode = custom_mode; 103 | packet.target_system = target_system; 104 | packet.base_mode = base_mode; 105 | 106 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MODE_LEN); 107 | #endif 108 | 109 | msg->msgid = MAVLINK_MSG_ID_SET_MODE; 110 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 111 | } 112 | 113 | /** 114 | * @brief Encode a set_mode 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 set_mode C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_set_mode_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode) 122 | { 123 | return mavlink_msg_set_mode_pack(system_id, component_id, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode); 124 | } 125 | 126 | /** 127 | * @brief Encode a set_mode 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 set_mode C-struct to read the message contents from 134 | */ 135 | static inline uint16_t mavlink_msg_set_mode_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode) 136 | { 137 | return mavlink_msg_set_mode_pack_chan(system_id, component_id, chan, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode); 138 | } 139 | 140 | /** 141 | * @brief Send a set_mode message 142 | * @param chan MAVLink channel to send the message 143 | * 144 | * @param target_system The system setting the mode 145 | * @param base_mode The new base mode. 146 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot. 147 | */ 148 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 149 | 150 | static inline void mavlink_msg_set_mode_send(mavlink_channel_t chan, uint8_t target_system, uint8_t base_mode, uint32_t custom_mode) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN]; 154 | _mav_put_uint32_t(buf, 0, custom_mode); 155 | _mav_put_uint8_t(buf, 4, target_system); 156 | _mav_put_uint8_t(buf, 5, base_mode); 157 | 158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, buf, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 159 | #else 160 | mavlink_set_mode_t packet; 161 | packet.custom_mode = custom_mode; 162 | packet.target_system = target_system; 163 | packet.base_mode = base_mode; 164 | 165 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)&packet, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 166 | #endif 167 | } 168 | 169 | /** 170 | * @brief Send a set_mode 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_set_mode_send_struct(mavlink_channel_t chan, const mavlink_set_mode_t* set_mode) 175 | { 176 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 177 | mavlink_msg_set_mode_send(chan, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode); 178 | #else 179 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)set_mode, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 180 | #endif 181 | } 182 | 183 | #if MAVLINK_MSG_ID_SET_MODE_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_set_mode_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t base_mode, uint32_t custom_mode) 192 | { 193 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 194 | char *buf = (char *)msgbuf; 195 | _mav_put_uint32_t(buf, 0, custom_mode); 196 | _mav_put_uint8_t(buf, 4, target_system); 197 | _mav_put_uint8_t(buf, 5, base_mode); 198 | 199 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, buf, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 200 | #else 201 | mavlink_set_mode_t *packet = (mavlink_set_mode_t *)msgbuf; 202 | packet->custom_mode = custom_mode; 203 | packet->target_system = target_system; 204 | packet->base_mode = base_mode; 205 | 206 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)packet, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC); 207 | #endif 208 | } 209 | #endif 210 | 211 | #endif 212 | 213 | // MESSAGE SET_MODE UNPACKING 214 | 215 | 216 | /** 217 | * @brief Get field target_system from set_mode message 218 | * 219 | * @return The system setting the mode 220 | */ 221 | static inline uint8_t mavlink_msg_set_mode_get_target_system(const mavlink_message_t* msg) 222 | { 223 | return _MAV_RETURN_uint8_t(msg, 4); 224 | } 225 | 226 | /** 227 | * @brief Get field base_mode from set_mode message 228 | * 229 | * @return The new base mode. 230 | */ 231 | static inline uint8_t mavlink_msg_set_mode_get_base_mode(const mavlink_message_t* msg) 232 | { 233 | return _MAV_RETURN_uint8_t(msg, 5); 234 | } 235 | 236 | /** 237 | * @brief Get field custom_mode from set_mode message 238 | * 239 | * @return The new autopilot-specific mode. This field can be ignored by an autopilot. 240 | */ 241 | static inline uint32_t mavlink_msg_set_mode_get_custom_mode(const mavlink_message_t* msg) 242 | { 243 | return _MAV_RETURN_uint32_t(msg, 0); 244 | } 245 | 246 | /** 247 | * @brief Decode a set_mode message into a struct 248 | * 249 | * @param msg The message to decode 250 | * @param set_mode C-struct to decode the message contents into 251 | */ 252 | static inline void mavlink_msg_set_mode_decode(const mavlink_message_t* msg, mavlink_set_mode_t* set_mode) 253 | { 254 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 255 | set_mode->custom_mode = mavlink_msg_set_mode_get_custom_mode(msg); 256 | set_mode->target_system = mavlink_msg_set_mode_get_target_system(msg); 257 | set_mode->base_mode = mavlink_msg_set_mode_get_base_mode(msg); 258 | #else 259 | uint8_t len = msg->len < MAVLINK_MSG_ID_SET_MODE_LEN? msg->len : MAVLINK_MSG_ID_SET_MODE_LEN; 260 | memset(set_mode, 0, MAVLINK_MSG_ID_SET_MODE_LEN); 261 | memcpy(set_mode, _MAV_PAYLOAD(msg), len); 262 | #endif 263 | } 264 | -------------------------------------------------------------------------------- /mavlink/common/mavlink_msg_data_stream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // MESSAGE DATA_STREAM PACKING 3 | 4 | #define MAVLINK_MSG_ID_DATA_STREAM 67 5 | 6 | 7 | typedef struct __mavlink_data_stream_t { 8 | uint16_t message_rate; /*< [Hz] The message rate*/ 9 | uint8_t stream_id; /*< The ID of the requested data stream*/ 10 | uint8_t on_off; /*< 1 stream is enabled, 0 stream is stopped.*/ 11 | } mavlink_data_stream_t; 12 | 13 | #define MAVLINK_MSG_ID_DATA_STREAM_LEN 4 14 | #define MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN 4 15 | #define MAVLINK_MSG_ID_67_LEN 4 16 | #define MAVLINK_MSG_ID_67_MIN_LEN 4 17 | 18 | #define MAVLINK_MSG_ID_DATA_STREAM_CRC 21 19 | #define MAVLINK_MSG_ID_67_CRC 21 20 | 21 | 22 | 23 | #if MAVLINK_COMMAND_24BIT 24 | #define MAVLINK_MESSAGE_INFO_DATA_STREAM { \ 25 | 67, \ 26 | "DATA_STREAM", \ 27 | 3, \ 28 | { { "stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_data_stream_t, stream_id) }, \ 29 | { "message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_data_stream_t, message_rate) }, \ 30 | { "on_off", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_data_stream_t, on_off) }, \ 31 | } \ 32 | } 33 | #else 34 | #define MAVLINK_MESSAGE_INFO_DATA_STREAM { \ 35 | "DATA_STREAM", \ 36 | 3, \ 37 | { { "stream_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_data_stream_t, stream_id) }, \ 38 | { "message_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_data_stream_t, message_rate) }, \ 39 | { "on_off", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_data_stream_t, on_off) }, \ 40 | } \ 41 | } 42 | #endif 43 | 44 | /** 45 | * @brief Pack a data_stream 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 stream_id The ID of the requested data stream 51 | * @param message_rate [Hz] The message rate 52 | * @param on_off 1 stream is enabled, 0 stream is stopped. 53 | * @return length of the message in bytes (excluding serial stream start sign) 54 | */ 55 | static inline uint16_t mavlink_msg_data_stream_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, 56 | uint8_t stream_id, uint16_t message_rate, uint8_t on_off) 57 | { 58 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 59 | char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN]; 60 | _mav_put_uint16_t(buf, 0, message_rate); 61 | _mav_put_uint8_t(buf, 2, stream_id); 62 | _mav_put_uint8_t(buf, 3, on_off); 63 | 64 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_STREAM_LEN); 65 | #else 66 | mavlink_data_stream_t packet; 67 | packet.message_rate = message_rate; 68 | packet.stream_id = stream_id; 69 | packet.on_off = on_off; 70 | 71 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_STREAM_LEN); 72 | #endif 73 | 74 | msg->msgid = MAVLINK_MSG_ID_DATA_STREAM; 75 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 76 | } 77 | 78 | /** 79 | * @brief Pack a data_stream 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 stream_id The ID of the requested data stream 85 | * @param message_rate [Hz] The message rate 86 | * @param on_off 1 stream is enabled, 0 stream is stopped. 87 | * @return length of the message in bytes (excluding serial stream start sign) 88 | */ 89 | static inline uint16_t mavlink_msg_data_stream_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, 90 | mavlink_message_t* msg, 91 | uint8_t stream_id,uint16_t message_rate,uint8_t on_off) 92 | { 93 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 94 | char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN]; 95 | _mav_put_uint16_t(buf, 0, message_rate); 96 | _mav_put_uint8_t(buf, 2, stream_id); 97 | _mav_put_uint8_t(buf, 3, on_off); 98 | 99 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_STREAM_LEN); 100 | #else 101 | mavlink_data_stream_t packet; 102 | packet.message_rate = message_rate; 103 | packet.stream_id = stream_id; 104 | packet.on_off = on_off; 105 | 106 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_STREAM_LEN); 107 | #endif 108 | 109 | msg->msgid = MAVLINK_MSG_ID_DATA_STREAM; 110 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 111 | } 112 | 113 | /** 114 | * @brief Encode a data_stream 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 data_stream C-struct to read the message contents from 120 | */ 121 | static inline uint16_t mavlink_msg_data_stream_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data_stream_t* data_stream) 122 | { 123 | return mavlink_msg_data_stream_pack(system_id, component_id, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off); 124 | } 125 | 126 | /** 127 | * @brief Encode a data_stream 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 data_stream C-struct to read the message contents from 134 | */ 135 | static inline uint16_t mavlink_msg_data_stream_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_data_stream_t* data_stream) 136 | { 137 | return mavlink_msg_data_stream_pack_chan(system_id, component_id, chan, msg, data_stream->stream_id, data_stream->message_rate, data_stream->on_off); 138 | } 139 | 140 | /** 141 | * @brief Send a data_stream message 142 | * @param chan MAVLink channel to send the message 143 | * 144 | * @param stream_id The ID of the requested data stream 145 | * @param message_rate [Hz] The message rate 146 | * @param on_off 1 stream is enabled, 0 stream is stopped. 147 | */ 148 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 149 | 150 | static inline void mavlink_msg_data_stream_send(mavlink_channel_t chan, uint8_t stream_id, uint16_t message_rate, uint8_t on_off) 151 | { 152 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 153 | char buf[MAVLINK_MSG_ID_DATA_STREAM_LEN]; 154 | _mav_put_uint16_t(buf, 0, message_rate); 155 | _mav_put_uint8_t(buf, 2, stream_id); 156 | _mav_put_uint8_t(buf, 3, on_off); 157 | 158 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 159 | #else 160 | mavlink_data_stream_t packet; 161 | packet.message_rate = message_rate; 162 | packet.stream_id = stream_id; 163 | packet.on_off = on_off; 164 | 165 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)&packet, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 166 | #endif 167 | } 168 | 169 | /** 170 | * @brief Send a data_stream 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_data_stream_send_struct(mavlink_channel_t chan, const mavlink_data_stream_t* data_stream) 175 | { 176 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 177 | mavlink_msg_data_stream_send(chan, data_stream->stream_id, data_stream->message_rate, data_stream->on_off); 178 | #else 179 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)data_stream, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 180 | #endif 181 | } 182 | 183 | #if MAVLINK_MSG_ID_DATA_STREAM_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_data_stream_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t stream_id, uint16_t message_rate, uint8_t on_off) 192 | { 193 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 194 | char *buf = (char *)msgbuf; 195 | _mav_put_uint16_t(buf, 0, message_rate); 196 | _mav_put_uint8_t(buf, 2, stream_id); 197 | _mav_put_uint8_t(buf, 3, on_off); 198 | 199 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, buf, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 200 | #else 201 | mavlink_data_stream_t *packet = (mavlink_data_stream_t *)msgbuf; 202 | packet->message_rate = message_rate; 203 | packet->stream_id = stream_id; 204 | packet->on_off = on_off; 205 | 206 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_STREAM, (const char *)packet, MAVLINK_MSG_ID_DATA_STREAM_MIN_LEN, MAVLINK_MSG_ID_DATA_STREAM_LEN, MAVLINK_MSG_ID_DATA_STREAM_CRC); 207 | #endif 208 | } 209 | #endif 210 | 211 | #endif 212 | 213 | // MESSAGE DATA_STREAM UNPACKING 214 | 215 | 216 | /** 217 | * @brief Get field stream_id from data_stream message 218 | * 219 | * @return The ID of the requested data stream 220 | */ 221 | static inline uint8_t mavlink_msg_data_stream_get_stream_id(const mavlink_message_t* msg) 222 | { 223 | return _MAV_RETURN_uint8_t(msg, 2); 224 | } 225 | 226 | /** 227 | * @brief Get field message_rate from data_stream message 228 | * 229 | * @return [Hz] The message rate 230 | */ 231 | static inline uint16_t mavlink_msg_data_stream_get_message_rate(const mavlink_message_t* msg) 232 | { 233 | return _MAV_RETURN_uint16_t(msg, 0); 234 | } 235 | 236 | /** 237 | * @brief Get field on_off from data_stream message 238 | * 239 | * @return 1 stream is enabled, 0 stream is stopped. 240 | */ 241 | static inline uint8_t mavlink_msg_data_stream_get_on_off(const mavlink_message_t* msg) 242 | { 243 | return _MAV_RETURN_uint8_t(msg, 3); 244 | } 245 | 246 | /** 247 | * @brief Decode a data_stream message into a struct 248 | * 249 | * @param msg The message to decode 250 | * @param data_stream C-struct to decode the message contents into 251 | */ 252 | static inline void mavlink_msg_data_stream_decode(const mavlink_message_t* msg, mavlink_data_stream_t* data_stream) 253 | { 254 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS 255 | data_stream->message_rate = mavlink_msg_data_stream_get_message_rate(msg); 256 | data_stream->stream_id = mavlink_msg_data_stream_get_stream_id(msg); 257 | data_stream->on_off = mavlink_msg_data_stream_get_on_off(msg); 258 | #else 259 | uint8_t len = msg->len < MAVLINK_MSG_ID_DATA_STREAM_LEN? msg->len : MAVLINK_MSG_ID_DATA_STREAM_LEN; 260 | memset(data_stream, 0, MAVLINK_MSG_ID_DATA_STREAM_LEN); 261 | memcpy(data_stream, _MAV_PAYLOAD(msg), len); 262 | #endif 263 | } 264 | --------------------------------------------------------------------------------