Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_v2_extension.h
blob59a0ba093f2143eb08784167d263551a959dea77
1 // MESSAGE V2_EXTENSION PACKING
3 #define MAVLINK_MSG_ID_V2_EXTENSION 248
5 typedef struct __mavlink_v2_extension_t
7 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.
8 uint8_t target_network; ///< Network ID (0 for broadcast)
9 uint8_t target_system; ///< System ID (0 for broadcast)
10 uint8_t target_component; ///< Component ID (0 for broadcast)
11 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.
12 } mavlink_v2_extension_t;
14 #define MAVLINK_MSG_ID_V2_EXTENSION_LEN 254
15 #define MAVLINK_MSG_ID_248_LEN 254
17 #define MAVLINK_MSG_ID_V2_EXTENSION_CRC 8
18 #define MAVLINK_MSG_ID_248_CRC 8
20 #define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 249
22 #define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
23 "V2_EXTENSION", \
24 5, \
25 { { "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, message_type) }, \
26 { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_v2_extension_t, target_network) }, \
27 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_v2_extension_t, target_system) }, \
28 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_v2_extension_t, target_component) }, \
29 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 5, offsetof(mavlink_v2_extension_t, payload) }, \
30 } \
34 /**
35 * @brief Pack a v2_extension message
36 * @param system_id ID of this system
37 * @param component_id ID of this component (e.g. 200 for IMU)
38 * @param msg The MAVLink message to compress the data into
40 * @param target_network Network ID (0 for broadcast)
41 * @param target_system System ID (0 for broadcast)
42 * @param target_component Component ID (0 for broadcast)
43 * @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.
44 * @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.
45 * @return length of the message in bytes (excluding serial stream start sign)
47 static inline uint16_t mavlink_msg_v2_extension_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
48 uint8_t target_network, uint8_t target_system, uint8_t target_component, uint16_t message_type, const uint8_t *payload)
50 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
51 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
52 _mav_put_uint16_t(buf, 0, message_type);
53 _mav_put_uint8_t(buf, 2, target_network);
54 _mav_put_uint8_t(buf, 3, target_system);
55 _mav_put_uint8_t(buf, 4, target_component);
56 _mav_put_uint8_t_array(buf, 5, payload, 249);
57 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
58 #else
59 mavlink_v2_extension_t packet;
60 packet.message_type = message_type;
61 packet.target_network = target_network;
62 packet.target_system = target_system;
63 packet.target_component = target_component;
64 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
66 #endif
68 msg->msgid = MAVLINK_MSG_ID_V2_EXTENSION;
69 #if MAVLINK_CRC_EXTRA
70 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
71 #else
72 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
73 #endif
76 /**
77 * @brief Pack a v2_extension message on a channel
78 * @param system_id ID of this system
79 * @param component_id ID of this component (e.g. 200 for IMU)
80 * @param chan The MAVLink channel this message will be sent over
81 * @param msg The MAVLink message to compress the data into
82 * @param target_network Network ID (0 for broadcast)
83 * @param target_system System ID (0 for broadcast)
84 * @param target_component Component ID (0 for broadcast)
85 * @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.
86 * @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.
87 * @return length of the message in bytes (excluding serial stream start sign)
89 static inline uint16_t mavlink_msg_v2_extension_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
90 mavlink_message_t* msg,
91 uint8_t target_network,uint8_t target_system,uint8_t target_component,uint16_t message_type,const uint8_t *payload)
93 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
94 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
95 _mav_put_uint16_t(buf, 0, message_type);
96 _mav_put_uint8_t(buf, 2, target_network);
97 _mav_put_uint8_t(buf, 3, target_system);
98 _mav_put_uint8_t(buf, 4, target_component);
99 _mav_put_uint8_t_array(buf, 5, payload, 249);
100 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
101 #else
102 mavlink_v2_extension_t packet;
103 packet.message_type = message_type;
104 packet.target_network = target_network;
105 packet.target_system = target_system;
106 packet.target_component = target_component;
107 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
109 #endif
111 msg->msgid = MAVLINK_MSG_ID_V2_EXTENSION;
112 #if MAVLINK_CRC_EXTRA
113 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
114 #else
115 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
116 #endif
120 * @brief Encode a v2_extension struct
122 * @param system_id ID of this system
123 * @param component_id ID of this component (e.g. 200 for IMU)
124 * @param msg The MAVLink message to compress the data into
125 * @param v2_extension C-struct to read the message contents from
127 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)
129 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);
133 * @brief Encode a v2_extension struct on a channel
135 * @param system_id ID of this system
136 * @param component_id ID of this component (e.g. 200 for IMU)
137 * @param chan The MAVLink channel this message will be sent over
138 * @param msg The MAVLink message to compress the data into
139 * @param v2_extension C-struct to read the message contents from
141 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)
143 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);
147 * @brief Send a v2_extension message
148 * @param chan MAVLink channel to send the message
150 * @param target_network Network ID (0 for broadcast)
151 * @param target_system System ID (0 for broadcast)
152 * @param target_component Component ID (0 for broadcast)
153 * @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.
154 * @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.
156 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
158 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)
160 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
161 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
162 _mav_put_uint16_t(buf, 0, message_type);
163 _mav_put_uint8_t(buf, 2, target_network);
164 _mav_put_uint8_t(buf, 3, target_system);
165 _mav_put_uint8_t(buf, 4, target_component);
166 _mav_put_uint8_t_array(buf, 5, payload, 249);
167 #if MAVLINK_CRC_EXTRA
168 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
169 #else
170 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
171 #endif
172 #else
173 mavlink_v2_extension_t packet;
174 packet.message_type = message_type;
175 packet.target_network = target_network;
176 packet.target_system = target_system;
177 packet.target_component = target_component;
178 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
179 #if MAVLINK_CRC_EXTRA
180 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)&packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
181 #else
182 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)&packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
183 #endif
184 #endif
187 #if MAVLINK_MSG_ID_V2_EXTENSION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
189 This varient of _send() can be used to save stack space by re-using
190 memory from the receive buffer. The caller provides a
191 mavlink_message_t which is the size of a full mavlink message. This
192 is usually the receive buffer for the channel, and allows a reply to an
193 incoming message with minimum stack space usage.
195 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)
197 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
198 char *buf = (char *)msgbuf;
199 _mav_put_uint16_t(buf, 0, message_type);
200 _mav_put_uint8_t(buf, 2, target_network);
201 _mav_put_uint8_t(buf, 3, target_system);
202 _mav_put_uint8_t(buf, 4, target_component);
203 _mav_put_uint8_t_array(buf, 5, payload, 249);
204 #if MAVLINK_CRC_EXTRA
205 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
206 #else
207 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
208 #endif
209 #else
210 mavlink_v2_extension_t *packet = (mavlink_v2_extension_t *)msgbuf;
211 packet->message_type = message_type;
212 packet->target_network = target_network;
213 packet->target_system = target_system;
214 packet->target_component = target_component;
215 mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*249);
216 #if MAVLINK_CRC_EXTRA
217 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
218 #else
219 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
220 #endif
221 #endif
223 #endif
225 #endif
227 // MESSAGE V2_EXTENSION UNPACKING
231 * @brief Get field target_network from v2_extension message
233 * @return Network ID (0 for broadcast)
235 static inline uint8_t mavlink_msg_v2_extension_get_target_network(const mavlink_message_t* msg)
237 return _MAV_RETURN_uint8_t(msg, 2);
241 * @brief Get field target_system from v2_extension message
243 * @return System ID (0 for broadcast)
245 static inline uint8_t mavlink_msg_v2_extension_get_target_system(const mavlink_message_t* msg)
247 return _MAV_RETURN_uint8_t(msg, 3);
251 * @brief Get field target_component from v2_extension message
253 * @return Component ID (0 for broadcast)
255 static inline uint8_t mavlink_msg_v2_extension_get_target_component(const mavlink_message_t* msg)
257 return _MAV_RETURN_uint8_t(msg, 4);
261 * @brief Get field message_type from v2_extension message
263 * @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.
265 static inline uint16_t mavlink_msg_v2_extension_get_message_type(const mavlink_message_t* msg)
267 return _MAV_RETURN_uint16_t(msg, 0);
271 * @brief Get field payload from v2_extension message
273 * @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.
275 static inline uint16_t mavlink_msg_v2_extension_get_payload(const mavlink_message_t* msg, uint8_t *payload)
277 return _MAV_RETURN_uint8_t_array(msg, payload, 249, 5);
281 * @brief Decode a v2_extension message into a struct
283 * @param msg The message to decode
284 * @param v2_extension C-struct to decode the message contents into
286 static inline void mavlink_msg_v2_extension_decode(const mavlink_message_t* msg, mavlink_v2_extension_t* v2_extension)
288 #if MAVLINK_NEED_BYTE_SWAP
289 v2_extension->message_type = mavlink_msg_v2_extension_get_message_type(msg);
290 v2_extension->target_network = mavlink_msg_v2_extension_get_target_network(msg);
291 v2_extension->target_system = mavlink_msg_v2_extension_get_target_system(msg);
292 v2_extension->target_component = mavlink_msg_v2_extension_get_target_component(msg);
293 mavlink_msg_v2_extension_get_payload(msg, v2_extension->payload);
294 #else
295 memcpy(v2_extension, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_V2_EXTENSION_LEN);
296 #endif