RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_v2_extension.h
1#pragma once
2// MESSAGE V2_EXTENSION PACKING
3
4#define MAVLINK_MSG_ID_V2_EXTENSION 248
5
6MAVPACKED(
7typedef 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/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 is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any 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;
14
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
19
20#define MAVLINK_MSG_ID_V2_EXTENSION_CRC 8
21#define MAVLINK_MSG_ID_248_CRC 8
22
23#define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 249
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
27 248, \
28 "V2_EXTENSION", \
29 5, \
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) }, \
35 } \
36}
37#else
38#define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
39 "V2_EXTENSION", \
40 5, \
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) }, \
46 } \
47}
48#endif
49
50/**
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
55 *
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/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 is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any 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)
62 */
63static 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)
65{
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);
74#else
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);
82#endif
83
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);
86}
87
88/**
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/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 is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any 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)
100 */
101static 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)
104{
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);
113#else
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);
121#endif
122
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);
125}
126
127/**
128 * @brief Encode a v2_extension struct
129 *
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
134 */
135static 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)
136{
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);
138}
139
140/**
141 * @brief Encode a v2_extension struct on a channel
142 *
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
148 */
149static 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)
150{
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);
152}
153
154/**
155 * @brief Send a v2_extension message
156 * @param chan MAVLink channel to send the message
157 *
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/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 is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
163 */
164#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
165
166static 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)
167{
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);
176#else
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);
184#endif
185}
186
187/**
188 * @brief Send a v2_extension message
189 * @param chan MAVLink channel to send the message
190 * @param struct The MAVLink struct to serialize
191 */
192static inline void mavlink_msg_v2_extension_send_struct(mavlink_channel_t chan, const mavlink_v2_extension_t* v2_extension)
193{
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);
196#else
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);
198#endif
199}
200
201#if MAVLINK_MSG_ID_V2_EXTENSION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
202/*
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.
208 */
209static 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)
210{
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);
219#else
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);
227#endif
228}
229#endif
230
231#endif
232
233// MESSAGE V2_EXTENSION UNPACKING
234
235
236/**
237 * @brief Get field target_network from v2_extension message
238 *
239 * @return Network ID (0 for broadcast)
240 */
241static inline uint8_t mavlink_msg_v2_extension_get_target_network(const mavlink_message_t* msg)
242{
243 return _MAV_RETURN_uint8_t(msg, 2);
244}
245
246/**
247 * @brief Get field target_system from v2_extension message
248 *
249 * @return System ID (0 for broadcast)
250 */
251static inline uint8_t mavlink_msg_v2_extension_get_target_system(const mavlink_message_t* msg)
252{
253 return _MAV_RETURN_uint8_t(msg, 3);
254}
255
256/**
257 * @brief Get field target_component from v2_extension message
258 *
259 * @return Component ID (0 for broadcast)
260 */
261static inline uint8_t mavlink_msg_v2_extension_get_target_component(const mavlink_message_t* msg)
262{
263 return _MAV_RETURN_uint8_t(msg, 4);
264}
265
266/**
267 * @brief Get field message_type from v2_extension message
268 *
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/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.
270 */
271static inline uint16_t mavlink_msg_v2_extension_get_message_type(const mavlink_message_t* msg)
272{
273 return _MAV_RETURN_uint16_t(msg, 0);
274}
275
276/**
277 * @brief Get field payload from v2_extension message
278 *
279 * @return Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
280 */
281static inline uint16_t mavlink_msg_v2_extension_get_payload(const mavlink_message_t* msg, uint8_t *payload)
282{
283 return _MAV_RETURN_uint8_t_array(msg, payload, 249, 5);
284}
285
286/**
287 * @brief Decode a v2_extension message into a struct
288 *
289 * @param msg The message to decode
290 * @param v2_extension C-struct to decode the message contents into
291 */
292static inline void mavlink_msg_v2_extension_decode(const mavlink_message_t* msg, mavlink_v2_extension_t* v2_extension)
293{
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);
300#else
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);
304#endif
305}