Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_play_tune_v2.h
blobc47d6e6a8a7af40a096e524b5cd5b36b8395c04d
1 #pragma once
2 // MESSAGE PLAY_TUNE_V2 PACKING
4 #define MAVLINK_MSG_ID_PLAY_TUNE_V2 400
7 typedef struct __mavlink_play_tune_v2_t {
8 uint32_t format; /*< Tune format*/
9 uint8_t target_system; /*< System ID*/
10 uint8_t target_component; /*< Component ID*/
11 char tune[248]; /*< Tune definition as a NULL-terminated string.*/
12 } mavlink_play_tune_v2_t;
14 #define MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN 254
15 #define MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN 254
16 #define MAVLINK_MSG_ID_400_LEN 254
17 #define MAVLINK_MSG_ID_400_MIN_LEN 254
19 #define MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC 110
20 #define MAVLINK_MSG_ID_400_CRC 110
22 #define MAVLINK_MSG_PLAY_TUNE_V2_FIELD_TUNE_LEN 248
24 #if MAVLINK_COMMAND_24BIT
25 #define MAVLINK_MESSAGE_INFO_PLAY_TUNE_V2 { \
26 400, \
27 "PLAY_TUNE_V2", \
28 4, \
29 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_play_tune_v2_t, target_system) }, \
30 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_play_tune_v2_t, target_component) }, \
31 { "format", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_play_tune_v2_t, format) }, \
32 { "tune", NULL, MAVLINK_TYPE_CHAR, 248, 6, offsetof(mavlink_play_tune_v2_t, tune) }, \
33 } \
35 #else
36 #define MAVLINK_MESSAGE_INFO_PLAY_TUNE_V2 { \
37 "PLAY_TUNE_V2", \
38 4, \
39 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_play_tune_v2_t, target_system) }, \
40 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_play_tune_v2_t, target_component) }, \
41 { "format", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_play_tune_v2_t, format) }, \
42 { "tune", NULL, MAVLINK_TYPE_CHAR, 248, 6, offsetof(mavlink_play_tune_v2_t, tune) }, \
43 } \
45 #endif
47 /**
48 * @brief Pack a play_tune_v2 message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
53 * @param target_system System ID
54 * @param target_component Component ID
55 * @param format Tune format
56 * @param tune Tune definition as a NULL-terminated string.
57 * @return length of the message in bytes (excluding serial stream start sign)
59 static inline uint16_t mavlink_msg_play_tune_v2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint8_t target_system, uint8_t target_component, uint32_t format, const char *tune)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
64 _mav_put_uint32_t(buf, 0, format);
65 _mav_put_uint8_t(buf, 4, target_system);
66 _mav_put_uint8_t(buf, 5, target_component);
67 _mav_put_char_array(buf, 6, tune, 248);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
69 #else
70 mavlink_play_tune_v2_t packet;
71 packet.format = format;
72 packet.target_system = target_system;
73 packet.target_component = target_component;
74 mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
76 #endif
78 msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE_V2;
79 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
82 /**
83 * @brief Pack a play_tune_v2 message on a channel
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param chan The MAVLink channel this message will be sent over
87 * @param msg The MAVLink message to compress the data into
88 * @param target_system System ID
89 * @param target_component Component ID
90 * @param format Tune format
91 * @param tune Tune definition as a NULL-terminated string.
92 * @return length of the message in bytes (excluding serial stream start sign)
94 static inline uint16_t mavlink_msg_play_tune_v2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
95 mavlink_message_t* msg,
96 uint8_t target_system,uint8_t target_component,uint32_t format,const char *tune)
98 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
100 _mav_put_uint32_t(buf, 0, format);
101 _mav_put_uint8_t(buf, 4, target_system);
102 _mav_put_uint8_t(buf, 5, target_component);
103 _mav_put_char_array(buf, 6, tune, 248);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
105 #else
106 mavlink_play_tune_v2_t packet;
107 packet.format = format;
108 packet.target_system = target_system;
109 packet.target_component = target_component;
110 mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
112 #endif
114 msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE_V2;
115 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
119 * @brief Encode a play_tune_v2 struct
121 * @param system_id ID of this system
122 * @param component_id ID of this component (e.g. 200 for IMU)
123 * @param msg The MAVLink message to compress the data into
124 * @param play_tune_v2 C-struct to read the message contents from
126 static inline uint16_t mavlink_msg_play_tune_v2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_play_tune_v2_t* play_tune_v2)
128 return mavlink_msg_play_tune_v2_pack(system_id, component_id, msg, play_tune_v2->target_system, play_tune_v2->target_component, play_tune_v2->format, play_tune_v2->tune);
132 * @brief Encode a play_tune_v2 struct on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @param play_tune_v2 C-struct to read the message contents from
140 static inline uint16_t mavlink_msg_play_tune_v2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_play_tune_v2_t* play_tune_v2)
142 return mavlink_msg_play_tune_v2_pack_chan(system_id, component_id, chan, msg, play_tune_v2->target_system, play_tune_v2->target_component, play_tune_v2->format, play_tune_v2->tune);
146 * @brief Send a play_tune_v2 message
147 * @param chan MAVLink channel to send the message
149 * @param target_system System ID
150 * @param target_component Component ID
151 * @param format Tune format
152 * @param tune Tune definition as a NULL-terminated string.
154 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
156 static inline void mavlink_msg_play_tune_v2_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint32_t format, const char *tune)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
160 _mav_put_uint32_t(buf, 0, format);
161 _mav_put_uint8_t(buf, 4, target_system);
162 _mav_put_uint8_t(buf, 5, target_component);
163 _mav_put_char_array(buf, 6, tune, 248);
164 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE_V2, buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
165 #else
166 mavlink_play_tune_v2_t packet;
167 packet.format = format;
168 packet.target_system = target_system;
169 packet.target_component = target_component;
170 mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
171 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE_V2, (const char *)&packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
172 #endif
176 * @brief Send a play_tune_v2 message
177 * @param chan MAVLink channel to send the message
178 * @param struct The MAVLink struct to serialize
180 static inline void mavlink_msg_play_tune_v2_send_struct(mavlink_channel_t chan, const mavlink_play_tune_v2_t* play_tune_v2)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 mavlink_msg_play_tune_v2_send(chan, play_tune_v2->target_system, play_tune_v2->target_component, play_tune_v2->format, play_tune_v2->tune);
184 #else
185 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE_V2, (const char *)play_tune_v2, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
186 #endif
189 #if MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
191 This varient of _send() can be used to save stack space by re-using
192 memory from the receive buffer. The caller provides a
193 mavlink_message_t which is the size of a full mavlink message. This
194 is usually the receive buffer for the channel, and allows a reply to an
195 incoming message with minimum stack space usage.
197 static inline void mavlink_msg_play_tune_v2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint32_t format, const char *tune)
199 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char *buf = (char *)msgbuf;
201 _mav_put_uint32_t(buf, 0, format);
202 _mav_put_uint8_t(buf, 4, target_system);
203 _mav_put_uint8_t(buf, 5, target_component);
204 _mav_put_char_array(buf, 6, tune, 248);
205 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE_V2, buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
206 #else
207 mavlink_play_tune_v2_t *packet = (mavlink_play_tune_v2_t *)msgbuf;
208 packet->format = format;
209 packet->target_system = target_system;
210 packet->target_component = target_component;
211 mav_array_memcpy(packet->tune, tune, sizeof(char)*248);
212 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE_V2, (const char *)packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN, MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC);
213 #endif
215 #endif
217 #endif
219 // MESSAGE PLAY_TUNE_V2 UNPACKING
223 * @brief Get field target_system from play_tune_v2 message
225 * @return System ID
227 static inline uint8_t mavlink_msg_play_tune_v2_get_target_system(const mavlink_message_t* msg)
229 return _MAV_RETURN_uint8_t(msg, 4);
233 * @brief Get field target_component from play_tune_v2 message
235 * @return Component ID
237 static inline uint8_t mavlink_msg_play_tune_v2_get_target_component(const mavlink_message_t* msg)
239 return _MAV_RETURN_uint8_t(msg, 5);
243 * @brief Get field format from play_tune_v2 message
245 * @return Tune format
247 static inline uint32_t mavlink_msg_play_tune_v2_get_format(const mavlink_message_t* msg)
249 return _MAV_RETURN_uint32_t(msg, 0);
253 * @brief Get field tune from play_tune_v2 message
255 * @return Tune definition as a NULL-terminated string.
257 static inline uint16_t mavlink_msg_play_tune_v2_get_tune(const mavlink_message_t* msg, char *tune)
259 return _MAV_RETURN_char_array(msg, tune, 248, 6);
263 * @brief Decode a play_tune_v2 message into a struct
265 * @param msg The message to decode
266 * @param play_tune_v2 C-struct to decode the message contents into
268 static inline void mavlink_msg_play_tune_v2_decode(const mavlink_message_t* msg, mavlink_play_tune_v2_t* play_tune_v2)
270 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
271 play_tune_v2->format = mavlink_msg_play_tune_v2_get_format(msg);
272 play_tune_v2->target_system = mavlink_msg_play_tune_v2_get_target_system(msg);
273 play_tune_v2->target_component = mavlink_msg_play_tune_v2_get_target_component(msg);
274 mavlink_msg_play_tune_v2_get_tune(msg, play_tune_v2->tune);
275 #else
276 uint8_t len = msg->len < MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN? msg->len : MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN;
277 memset(play_tune_v2, 0, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
278 memcpy(play_tune_v2, _MAV_PAYLOAD(msg), len);
279 #endif