1 // MESSAGE ENCAPSULATED_DATA PACKING
3 #define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131
5 typedef struct __mavlink_encapsulated_data_t
7 uint16_t seqnr
; ///< sequence number (starting with 0 on every transmission)
8 uint8_t data
[253]; ///< image data bytes
9 } mavlink_encapsulated_data_t
;
11 #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN 255
12 #define MAVLINK_MSG_ID_131_LEN 255
14 #define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223
15 #define MAVLINK_MSG_ID_131_CRC 223
17 #define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253
19 #define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \
20 "ENCAPSULATED_DATA", \
22 { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \
23 { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \
29 * @brief Pack a encapsulated_data message
30 * @param system_id ID of this system
31 * @param component_id ID of this component (e.g. 200 for IMU)
32 * @param msg The MAVLink message to compress the data into
34 * @param seqnr sequence number (starting with 0 on every transmission)
35 * @param data image data bytes
36 * @return length of the message in bytes (excluding serial stream start sign)
38 static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
39 uint16_t seqnr
, const uint8_t *data
)
41 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
42 char buf
[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
];
43 _mav_put_uint16_t(buf
, 0, seqnr
);
44 _mav_put_uint8_t_array(buf
, 2, data
, 253);
45 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
47 mavlink_encapsulated_data_t packet
;
49 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*253);
50 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
53 msg
->msgid
= MAVLINK_MSG_ID_ENCAPSULATED_DATA
;
55 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC
);
57 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
62 * @brief Pack a encapsulated_data message on a channel
63 * @param system_id ID of this system
64 * @param component_id ID of this component (e.g. 200 for IMU)
65 * @param chan The MAVLink channel this message will be sent over
66 * @param msg The MAVLink message to compress the data into
67 * @param seqnr sequence number (starting with 0 on every transmission)
68 * @param data image data bytes
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_encapsulated_data_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
72 mavlink_message_t
* msg
,
73 uint16_t seqnr
,const uint8_t *data
)
75 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
76 char buf
[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
];
77 _mav_put_uint16_t(buf
, 0, seqnr
);
78 _mav_put_uint8_t_array(buf
, 2, data
, 253);
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
81 mavlink_encapsulated_data_t packet
;
83 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*253);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
87 msg
->msgid
= MAVLINK_MSG_ID_ENCAPSULATED_DATA
;
89 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC
);
91 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
96 * @brief Encode a encapsulated_data struct
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 encapsulated_data C-struct to read the message contents from
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
)
105 return mavlink_msg_encapsulated_data_pack(system_id
, component_id
, msg
, encapsulated_data
->seqnr
, encapsulated_data
->data
);
109 * @brief Encode a encapsulated_data struct on a channel
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 encapsulated_data C-struct to read the message contents from
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
)
119 return mavlink_msg_encapsulated_data_pack_chan(system_id
, component_id
, chan
, msg
, encapsulated_data
->seqnr
, encapsulated_data
->data
);
123 * @brief Send a encapsulated_data message
124 * @param chan MAVLink channel to send the message
126 * @param seqnr sequence number (starting with 0 on every transmission)
127 * @param data image data bytes
129 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
131 static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan
, uint16_t seqnr
, const uint8_t *data
)
133 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
134 char buf
[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
];
135 _mav_put_uint16_t(buf
, 0, seqnr
);
136 _mav_put_uint8_t_array(buf
, 2, data
, 253);
137 #if MAVLINK_CRC_EXTRA
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
);
140 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA
, buf
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
143 mavlink_encapsulated_data_t packet
;
144 packet
.seqnr
= seqnr
;
145 mav_array_memcpy(packet
.data
, data
, sizeof(uint8_t)*253);
146 #if MAVLINK_CRC_EXTRA
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
);
149 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA
, (const char *)&packet
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
154 #if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
156 This varient of _send() can be used to save stack space by re-using
157 memory from the receive buffer. The caller provides a
158 mavlink_message_t which is the size of a full mavlink message. This
159 is usually the receive buffer for the channel, and allows a reply to an
160 incoming message with minimum stack space usage.
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
)
164 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 char *buf
= (char *)msgbuf
;
166 _mav_put_uint16_t(buf
, 0, seqnr
);
167 _mav_put_uint8_t_array(buf
, 2, data
, 253);
168 #if MAVLINK_CRC_EXTRA
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
);
171 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA
, buf
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
174 mavlink_encapsulated_data_t
*packet
= (mavlink_encapsulated_data_t
*)msgbuf
;
175 packet
->seqnr
= seqnr
;
176 mav_array_memcpy(packet
->data
, data
, sizeof(uint8_t)*253);
177 #if MAVLINK_CRC_EXTRA
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
);
180 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ENCAPSULATED_DATA
, (const char *)packet
, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);
188 // MESSAGE ENCAPSULATED_DATA UNPACKING
192 * @brief Get field seqnr from encapsulated_data message
194 * @return sequence number (starting with 0 on every transmission)
196 static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t
* msg
)
198 return _MAV_RETURN_uint16_t(msg
, 0);
202 * @brief Get field data from encapsulated_data message
204 * @return image data bytes
206 static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t
* msg
, uint8_t *data
)
208 return _MAV_RETURN_uint8_t_array(msg
, data
, 253, 2);
212 * @brief Decode a encapsulated_data message into a struct
214 * @param msg The message to decode
215 * @param encapsulated_data C-struct to decode the message contents into
217 static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t
* msg
, mavlink_encapsulated_data_t
* encapsulated_data
)
219 #if MAVLINK_NEED_BYTE_SWAP
220 encapsulated_data
->seqnr
= mavlink_msg_encapsulated_data_get_seqnr(msg
);
221 mavlink_msg_encapsulated_data_get_data(msg
, encapsulated_data
->data
);
223 memcpy(encapsulated_data
, _MAV_PAYLOAD(msg
), MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN
);