2 // MESSAGE ENCAPSULATED_DATA PACKING
4 #define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131
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
;
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
17 #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223
18 #define MAVLINK_MSG_ID_131_CRC 223
20 #define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253
22 #if MAVLINK_COMMAND_24BIT
23 #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \
25 "ENCAPSULATED_DATA", \
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) }, \
32 #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \
33 "ENCAPSULATED_DATA", \
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) }, \
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
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)
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
)
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
);
60 mavlink_encapsulated_data_t packet
;
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
);
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
);
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)
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
)
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
);
90 mavlink_encapsulated_data_t packet
;
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
);
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
);
101 * @brief Encode a encapsulated_data struct
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
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
)
110 return mavlink_msg_encapsulated_data_pack(system_id
, component_id
, msg
, encapsulated_data
->seqnr
, encapsulated_data
->data
);
114 * @brief Encode a encapsulated_data struct on a channel
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
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
)
124 return mavlink_msg_encapsulated_data_pack_chan(system_id
, component_id
, chan
, msg
, encapsulated_data
->seqnr
, encapsulated_data
->data
);
128 * @brief Send a encapsulated_data message
129 * @param chan MAVLink channel to send the message
131 * @param seqnr sequence number (starting with 0 on every transmission)
132 * @param data image data bytes
134 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
136 static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan
, uint16_t seqnr
, const uint8_t *data
)
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
);
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
);
152 * @brief Send a encapsulated_data message
153 * @param chan MAVLink channel to send the message
154 * @param struct The MAVLink struct to serialize
156 static inline void mavlink_msg_encapsulated_data_send_struct(mavlink_channel_t chan
, const mavlink_encapsulated_data_t
* encapsulated_data
)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 mavlink_msg_encapsulated_data_send(chan
, encapsulated_data
->seqnr
, encapsulated_data
->data
);
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
);
165 #if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
167 This varient 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.
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
)
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
);
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
);
191 // MESSAGE ENCAPSULATED_DATA UNPACKING
195 * @brief Get field seqnr from encapsulated_data message
197 * @return sequence number (starting with 0 on every transmission)
199 static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t
* msg
)
201 return _MAV_RETURN_uint16_t(msg
, 0);
205 * @brief Get field data from encapsulated_data message
207 * @return image data bytes
209 static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t
* msg
, uint8_t *data
)
211 return _MAV_RETURN_uint8_t_array(msg
, data
, 253, 2);
215 * @brief Decode a encapsulated_data message into a struct
217 * @param msg The message to decode
218 * @param encapsulated_data C-struct to decode the message contents into
220 static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t
* msg
, mavlink_encapsulated_data_t
* encapsulated_data
)
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
);
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
);