Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_available_modes.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE AVAILABLE_MODES PACKING
3
4#define MAVLINK_MSG_ID_AVAILABLE_MODES 435
5
6
8 uint32_t custom_mode; /*< A bitfield for use for autopilot-specific flags*/
9 uint32_t properties; /*< Mode properties.*/
10 uint8_t number_modes; /*< The total number of available modes for the current vehicle type.*/
11 uint8_t mode_index; /*< The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.*/
12 uint8_t standard_mode; /*< Standard mode.*/
13 char mode_name[35]; /*< Name of custom mode, with null termination character. Should be omitted for standard modes.*/
14} mavlink_available_modes_t;
15
16#define MAVLINK_MSG_ID_AVAILABLE_MODES_LEN 46
17#define MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN 46
18#define MAVLINK_MSG_ID_435_LEN 46
19#define MAVLINK_MSG_ID_435_MIN_LEN 46
20
21#define MAVLINK_MSG_ID_AVAILABLE_MODES_CRC 134
22#define MAVLINK_MSG_ID_435_CRC 134
23
24#define MAVLINK_MSG_AVAILABLE_MODES_FIELD_MODE_NAME_LEN 35
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_AVAILABLE_MODES {
28 435,
29 "AVAILABLE_MODES",
30 6,
31 { { "number_modes", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_available_modes_t, number_modes) },
32 { "mode_index", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_available_modes_t, mode_index) },
33 { "standard_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_available_modes_t, standard_mode) },
34 { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_available_modes_t, custom_mode) },
35 { "properties", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_available_modes_t, properties) },
36 { "mode_name", NULL, MAVLINK_TYPE_CHAR, 35, 11, offsetof(mavlink_available_modes_t, mode_name) },
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_AVAILABLE_MODES {
41 "AVAILABLE_MODES",
42 6,
43 { { "number_modes", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_available_modes_t, number_modes) },
44 { "mode_index", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_available_modes_t, mode_index) },
45 { "standard_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_available_modes_t, standard_mode) },
46 { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_available_modes_t, custom_mode) },
47 { "properties", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_available_modes_t, properties) },
48 { "mode_name", NULL, MAVLINK_TYPE_CHAR, 35, 11, offsetof(mavlink_available_modes_t, mode_name) },
49 } \
50}
51#endif
52
53/**
54 * @brief Pack a available_modes message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
58 *
59 * @param number_modes The total number of available modes for the current vehicle type.
60 * @param mode_index The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.
61 * @param standard_mode Standard mode.
62 * @param custom_mode A bitfield for use for autopilot-specific flags
63 * @param properties Mode properties.
64 * @param mode_name Name of custom mode, with null termination character. Should be omitted for standard modes.
65 * @return length of the message in bytes (excluding serial stream start sign)
66 */
67static inline uint16_t mavlink_msg_available_modes_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 uint8_t number_modes, uint8_t mode_index, uint8_t standard_mode, uint32_t custom_mode, uint32_t properties, const char *mode_name)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
72 _mav_put_uint32_t(buf, 0, custom_mode);
73 _mav_put_uint32_t(buf, 4, properties);
74 _mav_put_uint8_t(buf, 8, number_modes);
75 _mav_put_uint8_t(buf, 9, mode_index);
76 _mav_put_uint8_t(buf, 10, standard_mode);
77 _mav_put_char_array(buf, 11, mode_name, 35);
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
79#else
80 mavlink_available_modes_t packet;
81 packet.custom_mode = custom_mode;
82 packet.properties = properties;
83 packet.number_modes = number_modes;
84 packet.mode_index = mode_index;
85 packet.standard_mode = standard_mode;
86 mav_array_memcpy(packet.mode_name, mode_name, sizeof(char)*35);
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
88#endif
89
91 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
92}
93
94/**
95 * @brief Pack a available_modes message
96 * @param system_id ID of this system
97 * @param component_id ID of this component (e.g. 200 for IMU)
98 * @param status MAVLink status structure
99 * @param msg The MAVLink message to compress the data into
100 *
101 * @param number_modes The total number of available modes for the current vehicle type.
102 * @param mode_index The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.
103 * @param standard_mode Standard mode.
104 * @param custom_mode A bitfield for use for autopilot-specific flags
105 * @param properties Mode properties.
106 * @param mode_name Name of custom mode, with null termination character. Should be omitted for standard modes.
107 * @return length of the message in bytes (excluding serial stream start sign)
108 */
109static inline uint16_t mavlink_msg_available_modes_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
110 uint8_t number_modes, uint8_t mode_index, uint8_t standard_mode, uint32_t custom_mode, uint32_t properties, const char *mode_name)
111{
112#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114 _mav_put_uint32_t(buf, 0, custom_mode);
115 _mav_put_uint32_t(buf, 4, properties);
116 _mav_put_uint8_t(buf, 8, number_modes);
117 _mav_put_uint8_t(buf, 9, mode_index);
118 _mav_put_uint8_t(buf, 10, standard_mode);
119 _mav_put_char_array(buf, 11, mode_name, 35);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
121#else
122 mavlink_available_modes_t packet;
123 packet.custom_mode = custom_mode;
124 packet.properties = properties;
125 packet.number_modes = number_modes;
126 packet.mode_index = mode_index;
127 packet.standard_mode = standard_mode;
128 mav_array_memcpy(packet.mode_name, mode_name, sizeof(char)*35);
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
130#endif
131
133#if MAVLINK_CRC_EXTRA
134 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
135#else
136 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
137#endif
138}
139
140/**
141 * @brief Pack a available_modes message on a channel
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 number_modes The total number of available modes for the current vehicle type.
147 * @param mode_index The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.
148 * @param standard_mode Standard mode.
149 * @param custom_mode A bitfield for use for autopilot-specific flags
150 * @param properties Mode properties.
151 * @param mode_name Name of custom mode, with null termination character. Should be omitted for standard modes.
152 * @return length of the message in bytes (excluding serial stream start sign)
153 */
154static inline uint16_t mavlink_msg_available_modes_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
155 mavlink_message_t* msg,
156 uint8_t number_modes,uint8_t mode_index,uint8_t standard_mode,uint32_t custom_mode,uint32_t properties,const char *mode_name)
157{
158#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
160 _mav_put_uint32_t(buf, 0, custom_mode);
161 _mav_put_uint32_t(buf, 4, properties);
162 _mav_put_uint8_t(buf, 8, number_modes);
163 _mav_put_uint8_t(buf, 9, mode_index);
164 _mav_put_uint8_t(buf, 10, standard_mode);
165 _mav_put_char_array(buf, 11, mode_name, 35);
166 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
167#else
168 mavlink_available_modes_t packet;
169 packet.custom_mode = custom_mode;
170 packet.properties = properties;
171 packet.number_modes = number_modes;
172 packet.mode_index = mode_index;
173 packet.standard_mode = standard_mode;
174 mav_array_memcpy(packet.mode_name, mode_name, sizeof(char)*35);
175 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
176#endif
177
179 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
180}
181
182/**
183 * @brief Encode a available_modes struct
184 *
185 * @param system_id ID of this system
186 * @param component_id ID of this component (e.g. 200 for IMU)
187 * @param msg The MAVLink message to compress the data into
188 * @param available_modes C-struct to read the message contents from
189 */
190static inline uint16_t mavlink_msg_available_modes_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_available_modes_t* available_modes)
191{
192 return mavlink_msg_available_modes_pack(system_id, component_id, msg, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name);
193}
194
195/**
196 * @brief Encode a available_modes struct on a channel
197 *
198 * @param system_id ID of this system
199 * @param component_id ID of this component (e.g. 200 for IMU)
200 * @param chan The MAVLink channel this message will be sent over
201 * @param msg The MAVLink message to compress the data into
202 * @param available_modes C-struct to read the message contents from
203 */
204static inline uint16_t mavlink_msg_available_modes_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_available_modes_t* available_modes)
205{
206 return mavlink_msg_available_modes_pack_chan(system_id, component_id, chan, msg, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name);
207}
208
209/**
210 * @brief Encode a available_modes struct with provided status structure
211 *
212 * @param system_id ID of this system
213 * @param component_id ID of this component (e.g. 200 for IMU)
214 * @param status MAVLink status structure
215 * @param msg The MAVLink message to compress the data into
216 * @param available_modes C-struct to read the message contents from
217 */
218static inline uint16_t mavlink_msg_available_modes_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_available_modes_t* available_modes)
219{
220 return mavlink_msg_available_modes_pack_status(system_id, component_id, _status, msg, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name);
221}
222
223/**
224 * @brief Send a available_modes message
225 * @param chan MAVLink channel to send the message
226 *
227 * @param number_modes The total number of available modes for the current vehicle type.
228 * @param mode_index The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.
229 * @param standard_mode Standard mode.
230 * @param custom_mode A bitfield for use for autopilot-specific flags
231 * @param properties Mode properties.
232 * @param mode_name Name of custom mode, with null termination character. Should be omitted for standard modes.
233 */
234#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
235
236static inline void mavlink_msg_available_modes_send(mavlink_channel_t chan, uint8_t number_modes, uint8_t mode_index, uint8_t standard_mode, uint32_t custom_mode, uint32_t properties, const char *mode_name)
237{
238#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
239 char buf[MAVLINK_MSG_ID_AVAILABLE_MODES_LEN];
240 _mav_put_uint32_t(buf, 0, custom_mode);
241 _mav_put_uint32_t(buf, 4, properties);
242 _mav_put_uint8_t(buf, 8, number_modes);
243 _mav_put_uint8_t(buf, 9, mode_index);
244 _mav_put_uint8_t(buf, 10, standard_mode);
245 _mav_put_char_array(buf, 11, mode_name, 35);
246 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AVAILABLE_MODES, buf, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
247#else
248 mavlink_available_modes_t packet;
249 packet.custom_mode = custom_mode;
250 packet.properties = properties;
251 packet.number_modes = number_modes;
252 packet.mode_index = mode_index;
253 packet.standard_mode = standard_mode;
254 mav_array_memcpy(packet.mode_name, mode_name, sizeof(char)*35);
255 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AVAILABLE_MODES, (const char *)&packet, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
256#endif
257}
258
259/**
260 * @brief Send a available_modes message
261 * @param chan MAVLink channel to send the message
262 * @param struct The MAVLink struct to serialize
263 */
264static inline void mavlink_msg_available_modes_send_struct(mavlink_channel_t chan, const mavlink_available_modes_t* available_modes)
265{
266#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
267 mavlink_msg_available_modes_send(chan, available_modes->number_modes, available_modes->mode_index, available_modes->standard_mode, available_modes->custom_mode, available_modes->properties, available_modes->mode_name);
268#else
269 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AVAILABLE_MODES, (const char *)available_modes, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
270#endif
271}
272
273#if MAVLINK_MSG_ID_AVAILABLE_MODES_LEN <= MAVLINK_MAX_PAYLOAD_LEN
274/*
275 This variant of _send() can be used to save stack space by reusing
276 memory from the receive buffer. The caller provides a
277 mavlink_message_t which is the size of a full mavlink message. This
278 is usually the receive buffer for the channel, and allows a reply to an
279 incoming message with minimum stack space usage.
280 */
281static inline void mavlink_msg_available_modes_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t number_modes, uint8_t mode_index, uint8_t standard_mode, uint32_t custom_mode, uint32_t properties, const char *mode_name)
282{
283#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
284 char *buf = (char *)msgbuf;
285 _mav_put_uint32_t(buf, 0, custom_mode);
286 _mav_put_uint32_t(buf, 4, properties);
287 _mav_put_uint8_t(buf, 8, number_modes);
288 _mav_put_uint8_t(buf, 9, mode_index);
289 _mav_put_uint8_t(buf, 10, standard_mode);
290 _mav_put_char_array(buf, 11, mode_name, 35);
291 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AVAILABLE_MODES, buf, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
292#else
293 mavlink_available_modes_t *packet = (mavlink_available_modes_t *)msgbuf;
294 packet->custom_mode = custom_mode;
295 packet->properties = properties;
296 packet->number_modes = number_modes;
297 packet->mode_index = mode_index;
298 packet->standard_mode = standard_mode;
299 mav_array_memcpy(packet->mode_name, mode_name, sizeof(char)*35);
300 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AVAILABLE_MODES, (const char *)packet, MAVLINK_MSG_ID_AVAILABLE_MODES_MIN_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN, MAVLINK_MSG_ID_AVAILABLE_MODES_CRC);
301#endif
302}
303#endif
304
305#endif
306
307// MESSAGE AVAILABLE_MODES UNPACKING
308
309
310/**
311 * @brief Get field number_modes from available_modes message
312 *
313 * @return The total number of available modes for the current vehicle type.
314 */
315static inline uint8_t mavlink_msg_available_modes_get_number_modes(const mavlink_message_t* msg)
316{
317 return _MAV_RETURN_uint8_t(msg, 8);
318}
319
320/**
321 * @brief Get field mode_index from available_modes message
322 *
323 * @return The current mode index within number_modes, indexed from 1. The index is not guaranteed to be persistent, and may change between reboots or if the set of modes change.
324 */
325static inline uint8_t mavlink_msg_available_modes_get_mode_index(const mavlink_message_t* msg)
326{
327 return _MAV_RETURN_uint8_t(msg, 9);
328}
329
330/**
331 * @brief Get field standard_mode from available_modes message
332 *
333 * @return Standard mode.
334 */
335static inline uint8_t mavlink_msg_available_modes_get_standard_mode(const mavlink_message_t* msg)
336{
337 return _MAV_RETURN_uint8_t(msg, 10);
338}
339
340/**
341 * @brief Get field custom_mode from available_modes message
342 *
343 * @return A bitfield for use for autopilot-specific flags
344 */
345static inline uint32_t mavlink_msg_available_modes_get_custom_mode(const mavlink_message_t* msg)
346{
347 return _MAV_RETURN_uint32_t(msg, 0);
348}
349
350/**
351 * @brief Get field properties from available_modes message
352 *
353 * @return Mode properties.
354 */
355static inline uint32_t mavlink_msg_available_modes_get_properties(const mavlink_message_t* msg)
356{
357 return _MAV_RETURN_uint32_t(msg, 4);
358}
359
360/**
361 * @brief Get field mode_name from available_modes message
362 *
363 * @return Name of custom mode, with null termination character. Should be omitted for standard modes.
364 */
365static inline uint16_t mavlink_msg_available_modes_get_mode_name(const mavlink_message_t* msg, char *mode_name)
366{
367 return _MAV_RETURN_char_array(msg, mode_name, 35, 11);
368}
369
370/**
371 * @brief Decode a available_modes message into a struct
372 *
373 * @param msg The message to decode
374 * @param available_modes C-struct to decode the message contents into
375 */
376static inline void mavlink_msg_available_modes_decode(const mavlink_message_t* msg, mavlink_available_modes_t* available_modes)
377{
378#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
379 available_modes->custom_mode = mavlink_msg_available_modes_get_custom_mode(msg);
380 available_modes->properties = mavlink_msg_available_modes_get_properties(msg);
381 available_modes->number_modes = mavlink_msg_available_modes_get_number_modes(msg);
382 available_modes->mode_index = mavlink_msg_available_modes_get_mode_index(msg);
383 available_modes->standard_mode = mavlink_msg_available_modes_get_standard_mode(msg);
384 mavlink_msg_available_modes_get_mode_name(msg, available_modes->mode_name);
385#else
386 uint8_t len = msg->len < MAVLINK_MSG_ID_AVAILABLE_MODES_LEN? msg->len : MAVLINK_MSG_ID_AVAILABLE_MODES_LEN;
387 memset(available_modes, 0, MAVLINK_MSG_ID_AVAILABLE_MODES_LEN);
388 memcpy(available_modes, _MAV_PAYLOAD(msg), len);
389#endif
390}