before merging master
[inav.git] / lib / main / MAVLink / common / mavlink_msg_play_tune.h
blobc318448e240aae9826f72c02778ad34924c9c166
1 #pragma once
2 // MESSAGE PLAY_TUNE PACKING
4 #define MAVLINK_MSG_ID_PLAY_TUNE 258
7 typedef struct __mavlink_play_tune_t {
8 uint8_t target_system; /*< System ID*/
9 uint8_t target_component; /*< Component ID*/
10 char tune[30]; /*< tune in board specific format*/
11 char tune2[200]; /*< tune extension (appended to tune)*/
12 } mavlink_play_tune_t;
14 #define MAVLINK_MSG_ID_PLAY_TUNE_LEN 232
15 #define MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN 32
16 #define MAVLINK_MSG_ID_258_LEN 232
17 #define MAVLINK_MSG_ID_258_MIN_LEN 32
19 #define MAVLINK_MSG_ID_PLAY_TUNE_CRC 187
20 #define MAVLINK_MSG_ID_258_CRC 187
22 #define MAVLINK_MSG_PLAY_TUNE_FIELD_TUNE_LEN 30
23 #define MAVLINK_MSG_PLAY_TUNE_FIELD_TUNE2_LEN 200
25 #if MAVLINK_COMMAND_24BIT
26 #define MAVLINK_MESSAGE_INFO_PLAY_TUNE { \
27 258, \
28 "PLAY_TUNE", \
29 4, \
30 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_play_tune_t, target_system) }, \
31 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_play_tune_t, target_component) }, \
32 { "tune", NULL, MAVLINK_TYPE_CHAR, 30, 2, offsetof(mavlink_play_tune_t, tune) }, \
33 { "tune2", NULL, MAVLINK_TYPE_CHAR, 200, 32, offsetof(mavlink_play_tune_t, tune2) }, \
34 } \
36 #else
37 #define MAVLINK_MESSAGE_INFO_PLAY_TUNE { \
38 "PLAY_TUNE", \
39 4, \
40 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_play_tune_t, target_system) }, \
41 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_play_tune_t, target_component) }, \
42 { "tune", NULL, MAVLINK_TYPE_CHAR, 30, 2, offsetof(mavlink_play_tune_t, tune) }, \
43 { "tune2", NULL, MAVLINK_TYPE_CHAR, 200, 32, offsetof(mavlink_play_tune_t, tune2) }, \
44 } \
46 #endif
48 /**
49 * @brief Pack a play_tune message
50 * @param system_id ID of this system
51 * @param component_id ID of this component (e.g. 200 for IMU)
52 * @param msg The MAVLink message to compress the data into
54 * @param target_system System ID
55 * @param target_component Component ID
56 * @param tune tune in board specific format
57 * @param tune2 tune extension (appended to tune)
58 * @return length of the message in bytes (excluding serial stream start sign)
60 static inline uint16_t mavlink_msg_play_tune_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
61 uint8_t target_system, uint8_t target_component, const char *tune, const char *tune2)
63 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
64 char buf[MAVLINK_MSG_ID_PLAY_TUNE_LEN];
65 _mav_put_uint8_t(buf, 0, target_system);
66 _mav_put_uint8_t(buf, 1, target_component);
67 _mav_put_char_array(buf, 2, tune, 30);
68 _mav_put_char_array(buf, 32, tune2, 200);
69 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_LEN);
70 #else
71 mavlink_play_tune_t packet;
72 packet.target_system = target_system;
73 packet.target_component = target_component;
74 mav_array_memcpy(packet.tune, tune, sizeof(char)*30);
75 mav_array_memcpy(packet.tune2, tune2, sizeof(char)*200);
76 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_LEN);
77 #endif
79 msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE;
80 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
83 /**
84 * @brief Pack a play_tune message on a channel
85 * @param system_id ID of this system
86 * @param component_id ID of this component (e.g. 200 for IMU)
87 * @param chan The MAVLink channel this message will be sent over
88 * @param msg The MAVLink message to compress the data into
89 * @param target_system System ID
90 * @param target_component Component ID
91 * @param tune tune in board specific format
92 * @param tune2 tune extension (appended to tune)
93 * @return length of the message in bytes (excluding serial stream start sign)
95 static inline uint16_t mavlink_msg_play_tune_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
96 mavlink_message_t* msg,
97 uint8_t target_system,uint8_t target_component,const char *tune,const char *tune2)
99 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
100 char buf[MAVLINK_MSG_ID_PLAY_TUNE_LEN];
101 _mav_put_uint8_t(buf, 0, target_system);
102 _mav_put_uint8_t(buf, 1, target_component);
103 _mav_put_char_array(buf, 2, tune, 30);
104 _mav_put_char_array(buf, 32, tune2, 200);
105 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_LEN);
106 #else
107 mavlink_play_tune_t packet;
108 packet.target_system = target_system;
109 packet.target_component = target_component;
110 mav_array_memcpy(packet.tune, tune, sizeof(char)*30);
111 mav_array_memcpy(packet.tune2, tune2, sizeof(char)*200);
112 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_LEN);
113 #endif
115 msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE;
116 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
120 * @brief Encode a play_tune 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 play_tune C-struct to read the message contents from
127 static inline uint16_t mavlink_msg_play_tune_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_play_tune_t* play_tune)
129 return mavlink_msg_play_tune_pack(system_id, component_id, msg, play_tune->target_system, play_tune->target_component, play_tune->tune, play_tune->tune2);
133 * @brief Encode a play_tune 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 play_tune C-struct to read the message contents from
141 static inline uint16_t mavlink_msg_play_tune_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_play_tune_t* play_tune)
143 return mavlink_msg_play_tune_pack_chan(system_id, component_id, chan, msg, play_tune->target_system, play_tune->target_component, play_tune->tune, play_tune->tune2);
147 * @brief Send a play_tune message
148 * @param chan MAVLink channel to send the message
150 * @param target_system System ID
151 * @param target_component Component ID
152 * @param tune tune in board specific format
153 * @param tune2 tune extension (appended to tune)
155 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
157 static inline void mavlink_msg_play_tune_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *tune, const char *tune2)
159 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
160 char buf[MAVLINK_MSG_ID_PLAY_TUNE_LEN];
161 _mav_put_uint8_t(buf, 0, target_system);
162 _mav_put_uint8_t(buf, 1, target_component);
163 _mav_put_char_array(buf, 2, tune, 30);
164 _mav_put_char_array(buf, 32, tune2, 200);
165 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE, buf, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
166 #else
167 mavlink_play_tune_t packet;
168 packet.target_system = target_system;
169 packet.target_component = target_component;
170 mav_array_memcpy(packet.tune, tune, sizeof(char)*30);
171 mav_array_memcpy(packet.tune2, tune2, sizeof(char)*200);
172 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE, (const char *)&packet, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
173 #endif
177 * @brief Send a play_tune message
178 * @param chan MAVLink channel to send the message
179 * @param struct The MAVLink struct to serialize
181 static inline void mavlink_msg_play_tune_send_struct(mavlink_channel_t chan, const mavlink_play_tune_t* play_tune)
183 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
184 mavlink_msg_play_tune_send(chan, play_tune->target_system, play_tune->target_component, play_tune->tune, play_tune->tune2);
185 #else
186 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE, (const char *)play_tune, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
187 #endif
190 #if MAVLINK_MSG_ID_PLAY_TUNE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
192 This varient of _send() can be used to save stack space by re-using
193 memory from the receive buffer. The caller provides a
194 mavlink_message_t which is the size of a full mavlink message. This
195 is usually the receive buffer for the channel, and allows a reply to an
196 incoming message with minimum stack space usage.
198 static inline void mavlink_msg_play_tune_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *tune, const char *tune2)
200 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
201 char *buf = (char *)msgbuf;
202 _mav_put_uint8_t(buf, 0, target_system);
203 _mav_put_uint8_t(buf, 1, target_component);
204 _mav_put_char_array(buf, 2, tune, 30);
205 _mav_put_char_array(buf, 32, tune2, 200);
206 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE, buf, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
207 #else
208 mavlink_play_tune_t *packet = (mavlink_play_tune_t *)msgbuf;
209 packet->target_system = target_system;
210 packet->target_component = target_component;
211 mav_array_memcpy(packet->tune, tune, sizeof(char)*30);
212 mav_array_memcpy(packet->tune2, tune2, sizeof(char)*200);
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PLAY_TUNE, (const char *)packet, MAVLINK_MSG_ID_PLAY_TUNE_MIN_LEN, MAVLINK_MSG_ID_PLAY_TUNE_LEN, MAVLINK_MSG_ID_PLAY_TUNE_CRC);
214 #endif
216 #endif
218 #endif
220 // MESSAGE PLAY_TUNE UNPACKING
224 * @brief Get field target_system from play_tune message
226 * @return System ID
228 static inline uint8_t mavlink_msg_play_tune_get_target_system(const mavlink_message_t* msg)
230 return _MAV_RETURN_uint8_t(msg, 0);
234 * @brief Get field target_component from play_tune message
236 * @return Component ID
238 static inline uint8_t mavlink_msg_play_tune_get_target_component(const mavlink_message_t* msg)
240 return _MAV_RETURN_uint8_t(msg, 1);
244 * @brief Get field tune from play_tune message
246 * @return tune in board specific format
248 static inline uint16_t mavlink_msg_play_tune_get_tune(const mavlink_message_t* msg, char *tune)
250 return _MAV_RETURN_char_array(msg, tune, 30, 2);
254 * @brief Get field tune2 from play_tune message
256 * @return tune extension (appended to tune)
258 static inline uint16_t mavlink_msg_play_tune_get_tune2(const mavlink_message_t* msg, char *tune2)
260 return _MAV_RETURN_char_array(msg, tune2, 200, 32);
264 * @brief Decode a play_tune message into a struct
266 * @param msg The message to decode
267 * @param play_tune C-struct to decode the message contents into
269 static inline void mavlink_msg_play_tune_decode(const mavlink_message_t* msg, mavlink_play_tune_t* play_tune)
271 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
272 play_tune->target_system = mavlink_msg_play_tune_get_target_system(msg);
273 play_tune->target_component = mavlink_msg_play_tune_get_target_component(msg);
274 mavlink_msg_play_tune_get_tune(msg, play_tune->tune);
275 mavlink_msg_play_tune_get_tune2(msg, play_tune->tune2);
276 #else
277 uint8_t len = msg->len < MAVLINK_MSG_ID_PLAY_TUNE_LEN? msg->len : MAVLINK_MSG_ID_PLAY_TUNE_LEN;
278 memset(play_tune, 0, MAVLINK_MSG_ID_PLAY_TUNE_LEN);
279 memcpy(play_tune, _MAV_PAYLOAD(msg), len);
280 #endif