2 // MESSAGE V2_EXTENSION PACKING
4 #define MAVLINK_MSG_ID_V2_EXTENSION 248
7 typedef struct __mavlink_v2_extension_t
{
8 uint16_t message_type
; /*< A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.*/
9 uint8_t target_network
; /*< Network ID (0 for broadcast)*/
10 uint8_t target_system
; /*< System ID (0 for broadcast)*/
11 uint8_t target_component
; /*< Component ID (0 for broadcast)*/
12 uint8_t payload
[249]; /*< Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.*/
13 } mavlink_v2_extension_t
;
15 #define MAVLINK_MSG_ID_V2_EXTENSION_LEN 254
16 #define MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN 254
17 #define MAVLINK_MSG_ID_248_LEN 254
18 #define MAVLINK_MSG_ID_248_MIN_LEN 254
20 #define MAVLINK_MSG_ID_V2_EXTENSION_CRC 8
21 #define MAVLINK_MSG_ID_248_CRC 8
23 #define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 249
25 #if MAVLINK_COMMAND_24BIT
26 #define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
30 { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_v2_extension_t, target_network) }, \
31 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_v2_extension_t, target_system) }, \
32 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_v2_extension_t, target_component) }, \
33 { "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, message_type) }, \
34 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 5, offsetof(mavlink_v2_extension_t, payload) }, \
38 #define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
41 { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_v2_extension_t, target_network) }, \
42 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_v2_extension_t, target_system) }, \
43 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_v2_extension_t, target_component) }, \
44 { "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, message_type) }, \
45 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 5, offsetof(mavlink_v2_extension_t, payload) }, \
51 * @brief Pack a v2_extension message
52 * @param system_id ID of this system
53 * @param component_id ID of this component (e.g. 200 for IMU)
54 * @param msg The MAVLink message to compress the data into
56 * @param target_network Network ID (0 for broadcast)
57 * @param target_system System ID (0 for broadcast)
58 * @param target_component Component ID (0 for broadcast)
59 * @param message_type A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.
60 * @param payload Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.
61 * @return length of the message in bytes (excluding serial stream start sign)
63 static inline uint16_t mavlink_msg_v2_extension_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
64 uint8_t target_network
, uint8_t target_system
, uint8_t target_component
, uint16_t message_type
, const uint8_t *payload
)
66 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67 char buf
[MAVLINK_MSG_ID_V2_EXTENSION_LEN
];
68 _mav_put_uint16_t(buf
, 0, message_type
);
69 _mav_put_uint8_t(buf
, 2, target_network
);
70 _mav_put_uint8_t(buf
, 3, target_system
);
71 _mav_put_uint8_t(buf
, 4, target_component
);
72 _mav_put_uint8_t_array(buf
, 5, payload
, 249);
73 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
);
75 mavlink_v2_extension_t packet
;
76 packet
.message_type
= message_type
;
77 packet
.target_network
= target_network
;
78 packet
.target_system
= target_system
;
79 packet
.target_component
= target_component
;
80 mav_array_memcpy(packet
.payload
, payload
, sizeof(uint8_t)*249);
81 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
);
84 msg
->msgid
= MAVLINK_MSG_ID_V2_EXTENSION
;
85 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
89 * @brief Pack a v2_extension message on a channel
90 * @param system_id ID of this system
91 * @param component_id ID of this component (e.g. 200 for IMU)
92 * @param chan The MAVLink channel this message will be sent over
93 * @param msg The MAVLink message to compress the data into
94 * @param target_network Network ID (0 for broadcast)
95 * @param target_system System ID (0 for broadcast)
96 * @param target_component Component ID (0 for broadcast)
97 * @param message_type A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.
98 * @param payload Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.
99 * @return length of the message in bytes (excluding serial stream start sign)
101 static inline uint16_t mavlink_msg_v2_extension_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
102 mavlink_message_t
* msg
,
103 uint8_t target_network
,uint8_t target_system
,uint8_t target_component
,uint16_t message_type
,const uint8_t *payload
)
105 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
106 char buf
[MAVLINK_MSG_ID_V2_EXTENSION_LEN
];
107 _mav_put_uint16_t(buf
, 0, message_type
);
108 _mav_put_uint8_t(buf
, 2, target_network
);
109 _mav_put_uint8_t(buf
, 3, target_system
);
110 _mav_put_uint8_t(buf
, 4, target_component
);
111 _mav_put_uint8_t_array(buf
, 5, payload
, 249);
112 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
);
114 mavlink_v2_extension_t packet
;
115 packet
.message_type
= message_type
;
116 packet
.target_network
= target_network
;
117 packet
.target_system
= target_system
;
118 packet
.target_component
= target_component
;
119 mav_array_memcpy(packet
.payload
, payload
, sizeof(uint8_t)*249);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
);
123 msg
->msgid
= MAVLINK_MSG_ID_V2_EXTENSION
;
124 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
128 * @brief Encode a v2_extension struct
130 * @param system_id ID of this system
131 * @param component_id ID of this component (e.g. 200 for IMU)
132 * @param msg The MAVLink message to compress the data into
133 * @param v2_extension C-struct to read the message contents from
135 static inline uint16_t mavlink_msg_v2_extension_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_v2_extension_t
* v2_extension
)
137 return mavlink_msg_v2_extension_pack(system_id
, component_id
, msg
, v2_extension
->target_network
, v2_extension
->target_system
, v2_extension
->target_component
, v2_extension
->message_type
, v2_extension
->payload
);
141 * @brief Encode a v2_extension struct on a channel
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param chan The MAVLink channel this message will be sent over
146 * @param msg The MAVLink message to compress the data into
147 * @param v2_extension C-struct to read the message contents from
149 static inline uint16_t mavlink_msg_v2_extension_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_v2_extension_t
* v2_extension
)
151 return mavlink_msg_v2_extension_pack_chan(system_id
, component_id
, chan
, msg
, v2_extension
->target_network
, v2_extension
->target_system
, v2_extension
->target_component
, v2_extension
->message_type
, v2_extension
->payload
);
155 * @brief Send a v2_extension message
156 * @param chan MAVLink channel to send the message
158 * @param target_network Network ID (0 for broadcast)
159 * @param target_system System ID (0 for broadcast)
160 * @param target_component Component ID (0 for broadcast)
161 * @param message_type A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.
162 * @param payload Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.
164 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
166 static inline void mavlink_msg_v2_extension_send(mavlink_channel_t chan
, uint8_t target_network
, uint8_t target_system
, uint8_t target_component
, uint16_t message_type
, const uint8_t *payload
)
168 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
169 char buf
[MAVLINK_MSG_ID_V2_EXTENSION_LEN
];
170 _mav_put_uint16_t(buf
, 0, message_type
);
171 _mav_put_uint8_t(buf
, 2, target_network
);
172 _mav_put_uint8_t(buf
, 3, target_system
);
173 _mav_put_uint8_t(buf
, 4, target_component
);
174 _mav_put_uint8_t_array(buf
, 5, payload
, 249);
175 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_V2_EXTENSION
, buf
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
177 mavlink_v2_extension_t packet
;
178 packet
.message_type
= message_type
;
179 packet
.target_network
= target_network
;
180 packet
.target_system
= target_system
;
181 packet
.target_component
= target_component
;
182 mav_array_memcpy(packet
.payload
, payload
, sizeof(uint8_t)*249);
183 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_V2_EXTENSION
, (const char *)&packet
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
188 * @brief Send a v2_extension message
189 * @param chan MAVLink channel to send the message
190 * @param struct The MAVLink struct to serialize
192 static inline void mavlink_msg_v2_extension_send_struct(mavlink_channel_t chan
, const mavlink_v2_extension_t
* v2_extension
)
194 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
195 mavlink_msg_v2_extension_send(chan
, v2_extension
->target_network
, v2_extension
->target_system
, v2_extension
->target_component
, v2_extension
->message_type
, v2_extension
->payload
);
197 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_V2_EXTENSION
, (const char *)v2_extension
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
201 #if MAVLINK_MSG_ID_V2_EXTENSION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
203 This varient of _send() can be used to save stack space by re-using
204 memory from the receive buffer. The caller provides a
205 mavlink_message_t which is the size of a full mavlink message. This
206 is usually the receive buffer for the channel, and allows a reply to an
207 incoming message with minimum stack space usage.
209 static inline void mavlink_msg_v2_extension_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint8_t target_network
, uint8_t target_system
, uint8_t target_component
, uint16_t message_type
, const uint8_t *payload
)
211 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
212 char *buf
= (char *)msgbuf
;
213 _mav_put_uint16_t(buf
, 0, message_type
);
214 _mav_put_uint8_t(buf
, 2, target_network
);
215 _mav_put_uint8_t(buf
, 3, target_system
);
216 _mav_put_uint8_t(buf
, 4, target_component
);
217 _mav_put_uint8_t_array(buf
, 5, payload
, 249);
218 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_V2_EXTENSION
, buf
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
220 mavlink_v2_extension_t
*packet
= (mavlink_v2_extension_t
*)msgbuf
;
221 packet
->message_type
= message_type
;
222 packet
->target_network
= target_network
;
223 packet
->target_system
= target_system
;
224 packet
->target_component
= target_component
;
225 mav_array_memcpy(packet
->payload
, payload
, sizeof(uint8_t)*249);
226 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_V2_EXTENSION
, (const char *)packet
, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_LEN
, MAVLINK_MSG_ID_V2_EXTENSION_CRC
);
233 // MESSAGE V2_EXTENSION UNPACKING
237 * @brief Get field target_network from v2_extension message
239 * @return Network ID (0 for broadcast)
241 static inline uint8_t mavlink_msg_v2_extension_get_target_network(const mavlink_message_t
* msg
)
243 return _MAV_RETURN_uint8_t(msg
, 2);
247 * @brief Get field target_system from v2_extension message
249 * @return System ID (0 for broadcast)
251 static inline uint8_t mavlink_msg_v2_extension_get_target_system(const mavlink_message_t
* msg
)
253 return _MAV_RETURN_uint8_t(msg
, 3);
257 * @brief Get field target_component from v2_extension message
259 * @return Component ID (0 for broadcast)
261 static inline uint8_t mavlink_msg_v2_extension_get_target_component(const mavlink_message_t
* msg
)
263 return _MAV_RETURN_uint8_t(msg
, 4);
267 * @brief Get field message_type from v2_extension message
269 * @return A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.
271 static inline uint16_t mavlink_msg_v2_extension_get_message_type(const mavlink_message_t
* msg
)
273 return _MAV_RETURN_uint16_t(msg
, 0);
277 * @brief Get field payload from v2_extension message
279 * @return Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.
281 static inline uint16_t mavlink_msg_v2_extension_get_payload(const mavlink_message_t
* msg
, uint8_t *payload
)
283 return _MAV_RETURN_uint8_t_array(msg
, payload
, 249, 5);
287 * @brief Decode a v2_extension message into a struct
289 * @param msg The message to decode
290 * @param v2_extension C-struct to decode the message contents into
292 static inline void mavlink_msg_v2_extension_decode(const mavlink_message_t
* msg
, mavlink_v2_extension_t
* v2_extension
)
294 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
295 v2_extension
->message_type
= mavlink_msg_v2_extension_get_message_type(msg
);
296 v2_extension
->target_network
= mavlink_msg_v2_extension_get_target_network(msg
);
297 v2_extension
->target_system
= mavlink_msg_v2_extension_get_target_system(msg
);
298 v2_extension
->target_component
= mavlink_msg_v2_extension_get_target_component(msg
);
299 mavlink_msg_v2_extension_get_payload(msg
, v2_extension
->payload
);
301 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_V2_EXTENSION_LEN
? msg
->len
: MAVLINK_MSG_ID_V2_EXTENSION_LEN
;
302 memset(v2_extension
, 0, MAVLINK_MSG_ID_V2_EXTENSION_LEN
);
303 memcpy(v2_extension
, _MAV_PAYLOAD(msg
), len
);