Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mavlink F429ZI_LCD_demo
Fork of mavlink_bridge by
mavlink/v10/common/mavlink_msg_encapsulated_data.h@0:28183cc7963f, 2015-11-24 (annotated)
- Committer:
- bhepp
- Date:
- Tue Nov 24 16:41:11 2015 +0000
- Revision:
- 0:28183cc7963f
Mavlink bridge for Mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhepp | 0:28183cc7963f | 1 | // MESSAGE ENCAPSULATED_DATA PACKING |
bhepp | 0:28183cc7963f | 2 | |
bhepp | 0:28183cc7963f | 3 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131 |
bhepp | 0:28183cc7963f | 4 | |
bhepp | 0:28183cc7963f | 5 | typedef struct __mavlink_encapsulated_data_t |
bhepp | 0:28183cc7963f | 6 | { |
bhepp | 0:28183cc7963f | 7 | uint16_t seqnr; /*< sequence number (starting with 0 on every transmission)*/ |
bhepp | 0:28183cc7963f | 8 | uint8_t data[253]; /*< image data bytes*/ |
bhepp | 0:28183cc7963f | 9 | } mavlink_encapsulated_data_t; |
bhepp | 0:28183cc7963f | 10 | |
bhepp | 0:28183cc7963f | 11 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN 255 |
bhepp | 0:28183cc7963f | 12 | #define MAVLINK_MSG_ID_131_LEN 255 |
bhepp | 0:28183cc7963f | 13 | |
bhepp | 0:28183cc7963f | 14 | #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223 |
bhepp | 0:28183cc7963f | 15 | #define MAVLINK_MSG_ID_131_CRC 223 |
bhepp | 0:28183cc7963f | 16 | |
bhepp | 0:28183cc7963f | 17 | #define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253 |
bhepp | 0:28183cc7963f | 18 | |
bhepp | 0:28183cc7963f | 19 | #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \ |
bhepp | 0:28183cc7963f | 20 | "ENCAPSULATED_DATA", \ |
bhepp | 0:28183cc7963f | 21 | 2, \ |
bhepp | 0:28183cc7963f | 22 | { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \ |
bhepp | 0:28183cc7963f | 23 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \ |
bhepp | 0:28183cc7963f | 24 | } \ |
bhepp | 0:28183cc7963f | 25 | } |
bhepp | 0:28183cc7963f | 26 | |
bhepp | 0:28183cc7963f | 27 | |
bhepp | 0:28183cc7963f | 28 | /** |
bhepp | 0:28183cc7963f | 29 | * @brief Pack a encapsulated_data message |
bhepp | 0:28183cc7963f | 30 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 31 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 32 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 33 | * |
bhepp | 0:28183cc7963f | 34 | * @param seqnr sequence number (starting with 0 on every transmission) |
bhepp | 0:28183cc7963f | 35 | * @param data image data bytes |
bhepp | 0:28183cc7963f | 36 | * @return length of the message in bytes (excluding serial stream start sign) |
bhepp | 0:28183cc7963f | 37 | */ |
bhepp | 0:28183cc7963f | 38 | static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
bhepp | 0:28183cc7963f | 39 | uint16_t seqnr, const uint8_t *data) |
bhepp | 0:28183cc7963f | 40 | { |
bhepp | 0:28183cc7963f | 41 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 42 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; |
bhepp | 0:28183cc7963f | 43 | _mav_put_uint16_t(buf, 0, seqnr); |
bhepp | 0:28183cc7963f | 44 | _mav_put_uint8_t_array(buf, 2, data, 253); |
bhepp | 0:28183cc7963f | 45 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 46 | #else |
bhepp | 0:28183cc7963f | 47 | mavlink_encapsulated_data_t packet; |
bhepp | 0:28183cc7963f | 48 | packet.seqnr = seqnr; |
bhepp | 0:28183cc7963f | 49 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); |
bhepp | 0:28183cc7963f | 50 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 51 | #endif |
bhepp | 0:28183cc7963f | 52 | |
bhepp | 0:28183cc7963f | 53 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; |
bhepp | 0:28183cc7963f | 54 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 55 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 56 | #else |
bhepp | 0:28183cc7963f | 57 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 58 | #endif |
bhepp | 0:28183cc7963f | 59 | } |
bhepp | 0:28183cc7963f | 60 | |
bhepp | 0:28183cc7963f | 61 | /** |
bhepp | 0:28183cc7963f | 62 | * @brief Pack a encapsulated_data message on a channel |
bhepp | 0:28183cc7963f | 63 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 64 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 65 | * @param chan The MAVLink channel this message will be sent over |
bhepp | 0:28183cc7963f | 66 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 67 | * @param seqnr sequence number (starting with 0 on every transmission) |
bhepp | 0:28183cc7963f | 68 | * @param data image data bytes |
bhepp | 0:28183cc7963f | 69 | * @return length of the message in bytes (excluding serial stream start sign) |
bhepp | 0:28183cc7963f | 70 | */ |
bhepp | 0:28183cc7963f | 71 | static inline uint16_t mavlink_msg_encapsulated_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
bhepp | 0:28183cc7963f | 72 | mavlink_message_t* msg, |
bhepp | 0:28183cc7963f | 73 | uint16_t seqnr,const uint8_t *data) |
bhepp | 0:28183cc7963f | 74 | { |
bhepp | 0:28183cc7963f | 75 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 76 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; |
bhepp | 0:28183cc7963f | 77 | _mav_put_uint16_t(buf, 0, seqnr); |
bhepp | 0:28183cc7963f | 78 | _mav_put_uint8_t_array(buf, 2, data, 253); |
bhepp | 0:28183cc7963f | 79 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 80 | #else |
bhepp | 0:28183cc7963f | 81 | mavlink_encapsulated_data_t packet; |
bhepp | 0:28183cc7963f | 82 | packet.seqnr = seqnr; |
bhepp | 0:28183cc7963f | 83 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); |
bhepp | 0:28183cc7963f | 84 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 85 | #endif |
bhepp | 0:28183cc7963f | 86 | |
bhepp | 0:28183cc7963f | 87 | msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA; |
bhepp | 0:28183cc7963f | 88 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 89 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 90 | #else |
bhepp | 0:28183cc7963f | 91 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 92 | #endif |
bhepp | 0:28183cc7963f | 93 | } |
bhepp | 0:28183cc7963f | 94 | |
bhepp | 0:28183cc7963f | 95 | /** |
bhepp | 0:28183cc7963f | 96 | * @brief Encode a encapsulated_data struct |
bhepp | 0:28183cc7963f | 97 | * |
bhepp | 0:28183cc7963f | 98 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 99 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 100 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 101 | * @param encapsulated_data C-struct to read the message contents from |
bhepp | 0:28183cc7963f | 102 | */ |
bhepp | 0:28183cc7963f | 103 | 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) |
bhepp | 0:28183cc7963f | 104 | { |
bhepp | 0:28183cc7963f | 105 | return mavlink_msg_encapsulated_data_pack(system_id, component_id, msg, encapsulated_data->seqnr, encapsulated_data->data); |
bhepp | 0:28183cc7963f | 106 | } |
bhepp | 0:28183cc7963f | 107 | |
bhepp | 0:28183cc7963f | 108 | /** |
bhepp | 0:28183cc7963f | 109 | * @brief Encode a encapsulated_data struct on a channel |
bhepp | 0:28183cc7963f | 110 | * |
bhepp | 0:28183cc7963f | 111 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 112 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 113 | * @param chan The MAVLink channel this message will be sent over |
bhepp | 0:28183cc7963f | 114 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 115 | * @param encapsulated_data C-struct to read the message contents from |
bhepp | 0:28183cc7963f | 116 | */ |
bhepp | 0:28183cc7963f | 117 | 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) |
bhepp | 0:28183cc7963f | 118 | { |
bhepp | 0:28183cc7963f | 119 | return mavlink_msg_encapsulated_data_pack_chan(system_id, component_id, chan, msg, encapsulated_data->seqnr, encapsulated_data->data); |
bhepp | 0:28183cc7963f | 120 | } |
bhepp | 0:28183cc7963f | 121 | |
bhepp | 0:28183cc7963f | 122 | /** |
bhepp | 0:28183cc7963f | 123 | * @brief Send a encapsulated_data message |
bhepp | 0:28183cc7963f | 124 | * @param chan MAVLink channel to send the message |
bhepp | 0:28183cc7963f | 125 | * |
bhepp | 0:28183cc7963f | 126 | * @param seqnr sequence number (starting with 0 on every transmission) |
bhepp | 0:28183cc7963f | 127 | * @param data image data bytes |
bhepp | 0:28183cc7963f | 128 | */ |
bhepp | 0:28183cc7963f | 129 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
bhepp | 0:28183cc7963f | 130 | |
bhepp | 0:28183cc7963f | 131 | static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) |
bhepp | 0:28183cc7963f | 132 | { |
bhepp | 0:28183cc7963f | 133 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 134 | char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN]; |
bhepp | 0:28183cc7963f | 135 | _mav_put_uint16_t(buf, 0, seqnr); |
bhepp | 0:28183cc7963f | 136 | _mav_put_uint8_t_array(buf, 2, data, 253); |
bhepp | 0:28183cc7963f | 137 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 138 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 139 | #else |
bhepp | 0:28183cc7963f | 140 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 141 | #endif |
bhepp | 0:28183cc7963f | 142 | #else |
bhepp | 0:28183cc7963f | 143 | mavlink_encapsulated_data_t packet; |
bhepp | 0:28183cc7963f | 144 | packet.seqnr = seqnr; |
bhepp | 0:28183cc7963f | 145 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253); |
bhepp | 0:28183cc7963f | 146 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 147 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)&packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 148 | #else |
bhepp | 0:28183cc7963f | 149 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)&packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 150 | #endif |
bhepp | 0:28183cc7963f | 151 | #endif |
bhepp | 0:28183cc7963f | 152 | } |
bhepp | 0:28183cc7963f | 153 | |
bhepp | 0:28183cc7963f | 154 | #if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN |
bhepp | 0:28183cc7963f | 155 | /* |
bhepp | 0:28183cc7963f | 156 | This varient of _send() can be used to save stack space by re-using |
bhepp | 0:28183cc7963f | 157 | memory from the receive buffer. The caller provides a |
bhepp | 0:28183cc7963f | 158 | mavlink_message_t which is the size of a full mavlink message. This |
bhepp | 0:28183cc7963f | 159 | is usually the receive buffer for the channel, and allows a reply to an |
bhepp | 0:28183cc7963f | 160 | incoming message with minimum stack space usage. |
bhepp | 0:28183cc7963f | 161 | */ |
bhepp | 0:28183cc7963f | 162 | static inline void mavlink_msg_encapsulated_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data) |
bhepp | 0:28183cc7963f | 163 | { |
bhepp | 0:28183cc7963f | 164 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 165 | char *buf = (char *)msgbuf; |
bhepp | 0:28183cc7963f | 166 | _mav_put_uint16_t(buf, 0, seqnr); |
bhepp | 0:28183cc7963f | 167 | _mav_put_uint8_t_array(buf, 2, data, 253); |
bhepp | 0:28183cc7963f | 168 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 169 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 170 | #else |
bhepp | 0:28183cc7963f | 171 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 172 | #endif |
bhepp | 0:28183cc7963f | 173 | #else |
bhepp | 0:28183cc7963f | 174 | mavlink_encapsulated_data_t *packet = (mavlink_encapsulated_data_t *)msgbuf; |
bhepp | 0:28183cc7963f | 175 | packet->seqnr = seqnr; |
bhepp | 0:28183cc7963f | 176 | mav_array_memcpy(packet->data, data, sizeof(uint8_t)*253); |
bhepp | 0:28183cc7963f | 177 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC); |
bhepp | 0:28183cc7963f | 179 | #else |
bhepp | 0:28183cc7963f | 180 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 181 | #endif |
bhepp | 0:28183cc7963f | 182 | #endif |
bhepp | 0:28183cc7963f | 183 | } |
bhepp | 0:28183cc7963f | 184 | #endif |
bhepp | 0:28183cc7963f | 185 | |
bhepp | 0:28183cc7963f | 186 | #endif |
bhepp | 0:28183cc7963f | 187 | |
bhepp | 0:28183cc7963f | 188 | // MESSAGE ENCAPSULATED_DATA UNPACKING |
bhepp | 0:28183cc7963f | 189 | |
bhepp | 0:28183cc7963f | 190 | |
bhepp | 0:28183cc7963f | 191 | /** |
bhepp | 0:28183cc7963f | 192 | * @brief Get field seqnr from encapsulated_data message |
bhepp | 0:28183cc7963f | 193 | * |
bhepp | 0:28183cc7963f | 194 | * @return sequence number (starting with 0 on every transmission) |
bhepp | 0:28183cc7963f | 195 | */ |
bhepp | 0:28183cc7963f | 196 | static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 197 | { |
bhepp | 0:28183cc7963f | 198 | return _MAV_RETURN_uint16_t(msg, 0); |
bhepp | 0:28183cc7963f | 199 | } |
bhepp | 0:28183cc7963f | 200 | |
bhepp | 0:28183cc7963f | 201 | /** |
bhepp | 0:28183cc7963f | 202 | * @brief Get field data from encapsulated_data message |
bhepp | 0:28183cc7963f | 203 | * |
bhepp | 0:28183cc7963f | 204 | * @return image data bytes |
bhepp | 0:28183cc7963f | 205 | */ |
bhepp | 0:28183cc7963f | 206 | static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t* msg, uint8_t *data) |
bhepp | 0:28183cc7963f | 207 | { |
bhepp | 0:28183cc7963f | 208 | return _MAV_RETURN_uint8_t_array(msg, data, 253, 2); |
bhepp | 0:28183cc7963f | 209 | } |
bhepp | 0:28183cc7963f | 210 | |
bhepp | 0:28183cc7963f | 211 | /** |
bhepp | 0:28183cc7963f | 212 | * @brief Decode a encapsulated_data message into a struct |
bhepp | 0:28183cc7963f | 213 | * |
bhepp | 0:28183cc7963f | 214 | * @param msg The message to decode |
bhepp | 0:28183cc7963f | 215 | * @param encapsulated_data C-struct to decode the message contents into |
bhepp | 0:28183cc7963f | 216 | */ |
bhepp | 0:28183cc7963f | 217 | static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t* msg, mavlink_encapsulated_data_t* encapsulated_data) |
bhepp | 0:28183cc7963f | 218 | { |
bhepp | 0:28183cc7963f | 219 | #if MAVLINK_NEED_BYTE_SWAP |
bhepp | 0:28183cc7963f | 220 | encapsulated_data->seqnr = mavlink_msg_encapsulated_data_get_seqnr(msg); |
bhepp | 0:28183cc7963f | 221 | mavlink_msg_encapsulated_data_get_data(msg, encapsulated_data->data); |
bhepp | 0:28183cc7963f | 222 | #else |
bhepp | 0:28183cc7963f | 223 | memcpy(encapsulated_data, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN); |
bhepp | 0:28183cc7963f | 224 | #endif |
bhepp | 0:28183cc7963f | 225 | } |