source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_v2_extension.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 17.3 KB
Line 
1// MESSAGE V2_EXTENSION PACKING
2
3#define MAVLINK_MSG_ID_V2_EXTENSION 248
4
5typedef struct MAVLINK_PACKED __mavlink_v2_extension_t
6{
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;
13
14#define MAVLINK_MSG_ID_V2_EXTENSION_LEN 254
15#define MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN 254
16#define MAVLINK_MSG_ID_248_LEN 254
17#define MAVLINK_MSG_ID_248_MIN_LEN 254
18
19#define MAVLINK_MSG_ID_V2_EXTENSION_CRC 8
20#define MAVLINK_MSG_ID_248_CRC 8
21
22#define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 249
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
26 248, \
27 "V2_EXTENSION", \
28 5, \
29 { { "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, message_type) }, \
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 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 5, offsetof(mavlink_v2_extension_t, payload) }, \
34 } \
35}
36#else
37#define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
38 "V2_EXTENSION", \
39 5, \
40 { { "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, message_type) }, \
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 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 5, offsetof(mavlink_v2_extension_t, payload) }, \
45 } \
46}
47#endif
48
49/**
50 * @brief Pack a v2_extension message
51 * @param system_id ID of this system
52 * @param component_id ID of this component (e.g. 200 for IMU)
53 * @param msg The MAVLink message to compress the data into
54 *
55 * @param target_network Network ID (0 for broadcast)
56 * @param target_system System ID (0 for broadcast)
57 * @param target_component Component ID (0 for broadcast)
58 * @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.
59 * @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.
60 * @return length of the message in bytes (excluding serial stream start sign)
61 */
62static inline uint16_t mavlink_msg_v2_extension_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63 uint8_t target_network, uint8_t target_system, uint8_t target_component, uint16_t message_type, const uint8_t *payload)
64{
65#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
67 _mav_put_uint16_t(buf, 0, message_type);
68 _mav_put_uint8_t(buf, 2, target_network);
69 _mav_put_uint8_t(buf, 3, target_system);
70 _mav_put_uint8_t(buf, 4, target_component);
71 _mav_put_uint8_t_array(buf, 5, payload, 249);
72 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
73#else
74 mavlink_v2_extension_t packet;
75 packet.message_type = message_type;
76 packet.target_network = target_network;
77 packet.target_system = target_system;
78 packet.target_component = target_component;
79 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
80 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
81#endif
82
83 msg->msgid = MAVLINK_MSG_ID_V2_EXTENSION;
84 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);
85}
86
87/**
88 * @brief Pack a v2_extension message on a channel
89 * @param system_id ID of this system
90 * @param component_id ID of this component (e.g. 200 for IMU)
91 * @param chan The MAVLink channel this message will be sent over
92 * @param msg The MAVLink message to compress the data into
93 * @param target_network Network ID (0 for broadcast)
94 * @param target_system System ID (0 for broadcast)
95 * @param target_component Component ID (0 for broadcast)
96 * @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.
97 * @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.
98 * @return length of the message in bytes (excluding serial stream start sign)
99 */
100static inline uint16_t mavlink_msg_v2_extension_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
101 mavlink_message_t* msg,
102 uint8_t target_network,uint8_t target_system,uint8_t target_component,uint16_t message_type,const uint8_t *payload)
103{
104#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
105 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
106 _mav_put_uint16_t(buf, 0, message_type);
107 _mav_put_uint8_t(buf, 2, target_network);
108 _mav_put_uint8_t(buf, 3, target_system);
109 _mav_put_uint8_t(buf, 4, target_component);
110 _mav_put_uint8_t_array(buf, 5, payload, 249);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
112#else
113 mavlink_v2_extension_t packet;
114 packet.message_type = message_type;
115 packet.target_network = target_network;
116 packet.target_system = target_system;
117 packet.target_component = target_component;
118 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
120#endif
121
122 msg->msgid = MAVLINK_MSG_ID_V2_EXTENSION;
123 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);
124}
125
126/**
127 * @brief Encode a v2_extension struct
128 *
129 * @param system_id ID of this system
130 * @param component_id ID of this component (e.g. 200 for IMU)
131 * @param msg The MAVLink message to compress the data into
132 * @param v2_extension C-struct to read the message contents from
133 */
134static 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)
135{
136 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);
137}
138
139/**
140 * @brief Encode a v2_extension struct on a channel
141 *
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param chan The MAVLink channel this message will be sent over
145 * @param msg The MAVLink message to compress the data into
146 * @param v2_extension C-struct to read the message contents from
147 */
148static 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)
149{
150 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);
151}
152
153/**
154 * @brief Send a v2_extension message
155 * @param chan MAVLink channel to send the message
156 *
157 * @param target_network Network ID (0 for broadcast)
158 * @param target_system System ID (0 for broadcast)
159 * @param target_component Component ID (0 for broadcast)
160 * @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.
161 * @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.
162 */
163#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
164
165static 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)
166{
167#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
168 char buf[MAVLINK_MSG_ID_V2_EXTENSION_LEN];
169 _mav_put_uint16_t(buf, 0, message_type);
170 _mav_put_uint8_t(buf, 2, target_network);
171 _mav_put_uint8_t(buf, 3, target_system);
172 _mav_put_uint8_t(buf, 4, target_component);
173 _mav_put_uint8_t_array(buf, 5, payload, 249);
174 _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);
175#else
176 mavlink_v2_extension_t packet;
177 packet.message_type = message_type;
178 packet.target_network = target_network;
179 packet.target_system = target_system;
180 packet.target_component = target_component;
181 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
182 _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);
183#endif
184}
185
186/**
187 * @brief Send a v2_extension message
188 * @param chan MAVLink channel to send the message
189 * @param struct The MAVLink struct to serialize
190 */
191static inline void mavlink_msg_v2_extension_send_struct(mavlink_channel_t chan, const mavlink_v2_extension_t* v2_extension)
192{
193#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 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);
195#else
196 _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);
197#endif
198}
199
200#if MAVLINK_MSG_ID_V2_EXTENSION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
201/*
202 This varient of _send() can be used to save stack space by re-using
203 memory from the receive buffer. The caller provides a
204 mavlink_message_t which is the size of a full mavlink message. This
205 is usually the receive buffer for the channel, and allows a reply to an
206 incoming message with minimum stack space usage.
207 */
208static 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)
209{
210#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
211 char *buf = (char *)msgbuf;
212 _mav_put_uint16_t(buf, 0, message_type);
213 _mav_put_uint8_t(buf, 2, target_network);
214 _mav_put_uint8_t(buf, 3, target_system);
215 _mav_put_uint8_t(buf, 4, target_component);
216 _mav_put_uint8_t_array(buf, 5, payload, 249);
217 _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);
218#else
219 mavlink_v2_extension_t *packet = (mavlink_v2_extension_t *)msgbuf;
220 packet->message_type = message_type;
221 packet->target_network = target_network;
222 packet->target_system = target_system;
223 packet->target_component = target_component;
224 mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*249);
225 _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);
226#endif
227}
228#endif
229
230#endif
231
232// MESSAGE V2_EXTENSION UNPACKING
233
234
235/**
236 * @brief Get field target_network from v2_extension message
237 *
238 * @return Network ID (0 for broadcast)
239 */
240static inline uint8_t mavlink_msg_v2_extension_get_target_network(const mavlink_message_t* msg)
241{
242 return _MAV_RETURN_uint8_t(msg, 2);
243}
244
245/**
246 * @brief Get field target_system from v2_extension message
247 *
248 * @return System ID (0 for broadcast)
249 */
250static inline uint8_t mavlink_msg_v2_extension_get_target_system(const mavlink_message_t* msg)
251{
252 return _MAV_RETURN_uint8_t(msg, 3);
253}
254
255/**
256 * @brief Get field target_component from v2_extension message
257 *
258 * @return Component ID (0 for broadcast)
259 */
260static inline uint8_t mavlink_msg_v2_extension_get_target_component(const mavlink_message_t* msg)
261{
262 return _MAV_RETURN_uint8_t(msg, 4);
263}
264
265/**
266 * @brief Get field message_type from v2_extension message
267 *
268 * @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.
269 */
270static inline uint16_t mavlink_msg_v2_extension_get_message_type(const mavlink_message_t* msg)
271{
272 return _MAV_RETURN_uint16_t(msg, 0);
273}
274
275/**
276 * @brief Get field payload from v2_extension message
277 *
278 * @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.
279 */
280static inline uint16_t mavlink_msg_v2_extension_get_payload(const mavlink_message_t* msg, uint8_t *payload)
281{
282 return _MAV_RETURN_uint8_t_array(msg, payload, 249, 5);
283}
284
285/**
286 * @brief Decode a v2_extension message into a struct
287 *
288 * @param msg The message to decode
289 * @param v2_extension C-struct to decode the message contents into
290 */
291static inline void mavlink_msg_v2_extension_decode(const mavlink_message_t* msg, mavlink_v2_extension_t* v2_extension)
292{
293#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
294 v2_extension->message_type = mavlink_msg_v2_extension_get_message_type(msg);
295 v2_extension->target_network = mavlink_msg_v2_extension_get_target_network(msg);
296 v2_extension->target_system = mavlink_msg_v2_extension_get_target_system(msg);
297 v2_extension->target_component = mavlink_msg_v2_extension_get_target_component(msg);
298 mavlink_msg_v2_extension_get_payload(msg, v2_extension->payload);
299#else
300 uint8_t len = msg->len < MAVLINK_MSG_ID_V2_EXTENSION_LEN? msg->len : MAVLINK_MSG_ID_V2_EXTENSION_LEN;
301 memset(v2_extension, 0, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
302 memcpy(v2_extension, _MAV_PAYLOAD(msg), len);
303#endif
304}
Note: See TracBrowser for help on using the repository browser.