mavlink_msg_play_tune_v2.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #pragma once
  2. // MESSAGE PLAY_TUNE_V2 PACKING
  3. #define MAVLINK_MSG_ID_PLAY_TUNE_V2 400
  4. typedef struct __mavlink_play_tune_v2_t {
  5. uint32_t format; /*< Tune format*/
  6. uint8_t target_system; /*< System ID*/
  7. uint8_t target_component; /*< Component ID*/
  8. char tune[248]; /*< Tune definition as a NULL-terminated string.*/
  9. } mavlink_play_tune_v2_t;
  10. #define MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN 254
  11. #define MAVLINK_MSG_ID_PLAY_TUNE_V2_MIN_LEN 254
  12. #define MAVLINK_MSG_ID_400_LEN 254
  13. #define MAVLINK_MSG_ID_400_MIN_LEN 254
  14. #define MAVLINK_MSG_ID_PLAY_TUNE_V2_CRC 110
  15. #define MAVLINK_MSG_ID_400_CRC 110
  16. #define MAVLINK_MSG_PLAY_TUNE_V2_FIELD_TUNE_LEN 248
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_PLAY_TUNE_V2 { \
  19. 400, \
  20. "PLAY_TUNE_V2", \
  21. 4, \
  22. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_play_tune_v2_t, target_system) }, \
  23. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_play_tune_v2_t, target_component) }, \
  24. { "format", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_play_tune_v2_t, format) }, \
  25. { "tune", NULL, MAVLINK_TYPE_CHAR, 248, 6, offsetof(mavlink_play_tune_v2_t, tune) }, \
  26. } \
  27. }
  28. #else
  29. #define MAVLINK_MESSAGE_INFO_PLAY_TUNE_V2 { \
  30. "PLAY_TUNE_V2", \
  31. 4, \
  32. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_play_tune_v2_t, target_system) }, \
  33. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_play_tune_v2_t, target_component) }, \
  34. { "format", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_play_tune_v2_t, format) }, \
  35. { "tune", NULL, MAVLINK_TYPE_CHAR, 248, 6, offsetof(mavlink_play_tune_v2_t, tune) }, \
  36. } \
  37. }
  38. #endif
  39. /**
  40. * @brief Pack a play_tune_v2 message
  41. * @param system_id ID of this system
  42. * @param component_id ID of this component (e.g. 200 for IMU)
  43. * @param msg The MAVLink message to compress the data into
  44. *
  45. * @param target_system System ID
  46. * @param target_component Component ID
  47. * @param format Tune format
  48. * @param tune Tune definition as a NULL-terminated string.
  49. * @return length of the message in bytes (excluding serial stream start sign)
  50. */
  51. static inline uint16_t mavlink_msg_play_tune_v2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  52. uint8_t target_system, uint8_t target_component, uint32_t format, const char *tune)
  53. {
  54. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  55. char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
  56. _mav_put_uint32_t(buf, 0, format);
  57. _mav_put_uint8_t(buf, 4, target_system);
  58. _mav_put_uint8_t(buf, 5, target_component);
  59. _mav_put_char_array(buf, 6, tune, 248);
  60. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
  61. #else
  62. mavlink_play_tune_v2_t packet;
  63. packet.format = format;
  64. packet.target_system = target_system;
  65. packet.target_component = target_component;
  66. mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
  67. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
  68. #endif
  69. msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE_V2;
  70. 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);
  71. }
  72. /**
  73. * @brief Pack a play_tune_v2 message on a channel
  74. * @param system_id ID of this system
  75. * @param component_id ID of this component (e.g. 200 for IMU)
  76. * @param chan The MAVLink channel this message will be sent over
  77. * @param msg The MAVLink message to compress the data into
  78. * @param target_system System ID
  79. * @param target_component Component ID
  80. * @param format Tune format
  81. * @param tune Tune definition as a NULL-terminated string.
  82. * @return length of the message in bytes (excluding serial stream start sign)
  83. */
  84. static inline uint16_t mavlink_msg_play_tune_v2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  85. mavlink_message_t* msg,
  86. uint8_t target_system,uint8_t target_component,uint32_t format,const char *tune)
  87. {
  88. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  89. char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
  90. _mav_put_uint32_t(buf, 0, format);
  91. _mav_put_uint8_t(buf, 4, target_system);
  92. _mav_put_uint8_t(buf, 5, target_component);
  93. _mav_put_char_array(buf, 6, tune, 248);
  94. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
  95. #else
  96. mavlink_play_tune_v2_t packet;
  97. packet.format = format;
  98. packet.target_system = target_system;
  99. packet.target_component = target_component;
  100. mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
  101. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
  102. #endif
  103. msg->msgid = MAVLINK_MSG_ID_PLAY_TUNE_V2;
  104. 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);
  105. }
  106. /**
  107. * @brief Encode a play_tune_v2 struct
  108. *
  109. * @param system_id ID of this system
  110. * @param component_id ID of this component (e.g. 200 for IMU)
  111. * @param msg The MAVLink message to compress the data into
  112. * @param play_tune_v2 C-struct to read the message contents from
  113. */
  114. 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)
  115. {
  116. 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);
  117. }
  118. /**
  119. * @brief Encode a play_tune_v2 struct on a channel
  120. *
  121. * @param system_id ID of this system
  122. * @param component_id ID of this component (e.g. 200 for IMU)
  123. * @param chan The MAVLink channel this message will be sent over
  124. * @param msg The MAVLink message to compress the data into
  125. * @param play_tune_v2 C-struct to read the message contents from
  126. */
  127. 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)
  128. {
  129. 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);
  130. }
  131. /**
  132. * @brief Send a play_tune_v2 message
  133. * @param chan MAVLink channel to send the message
  134. *
  135. * @param target_system System ID
  136. * @param target_component Component ID
  137. * @param format Tune format
  138. * @param tune Tune definition as a NULL-terminated string.
  139. */
  140. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  141. 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)
  142. {
  143. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  144. char buf[MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN];
  145. _mav_put_uint32_t(buf, 0, format);
  146. _mav_put_uint8_t(buf, 4, target_system);
  147. _mav_put_uint8_t(buf, 5, target_component);
  148. _mav_put_char_array(buf, 6, tune, 248);
  149. _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);
  150. #else
  151. mavlink_play_tune_v2_t packet;
  152. packet.format = format;
  153. packet.target_system = target_system;
  154. packet.target_component = target_component;
  155. mav_array_memcpy(packet.tune, tune, sizeof(char)*248);
  156. _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);
  157. #endif
  158. }
  159. /**
  160. * @brief Send a play_tune_v2 message
  161. * @param chan MAVLink channel to send the message
  162. * @param struct The MAVLink struct to serialize
  163. */
  164. static inline void mavlink_msg_play_tune_v2_send_struct(mavlink_channel_t chan, const mavlink_play_tune_v2_t* play_tune_v2)
  165. {
  166. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  167. 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);
  168. #else
  169. _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);
  170. #endif
  171. }
  172. #if MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  173. /*
  174. This variant of _send() can be used to save stack space by re-using
  175. memory from the receive buffer. The caller provides a
  176. mavlink_message_t which is the size of a full mavlink message. This
  177. is usually the receive buffer for the channel, and allows a reply to an
  178. incoming message with minimum stack space usage.
  179. */
  180. 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)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char *buf = (char *)msgbuf;
  184. _mav_put_uint32_t(buf, 0, format);
  185. _mav_put_uint8_t(buf, 4, target_system);
  186. _mav_put_uint8_t(buf, 5, target_component);
  187. _mav_put_char_array(buf, 6, tune, 248);
  188. _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);
  189. #else
  190. mavlink_play_tune_v2_t *packet = (mavlink_play_tune_v2_t *)msgbuf;
  191. packet->format = format;
  192. packet->target_system = target_system;
  193. packet->target_component = target_component;
  194. mav_array_memcpy(packet->tune, tune, sizeof(char)*248);
  195. _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);
  196. #endif
  197. }
  198. #endif
  199. #endif
  200. // MESSAGE PLAY_TUNE_V2 UNPACKING
  201. /**
  202. * @brief Get field target_system from play_tune_v2 message
  203. *
  204. * @return System ID
  205. */
  206. static inline uint8_t mavlink_msg_play_tune_v2_get_target_system(const mavlink_message_t* msg)
  207. {
  208. return _MAV_RETURN_uint8_t(msg, 4);
  209. }
  210. /**
  211. * @brief Get field target_component from play_tune_v2 message
  212. *
  213. * @return Component ID
  214. */
  215. static inline uint8_t mavlink_msg_play_tune_v2_get_target_component(const mavlink_message_t* msg)
  216. {
  217. return _MAV_RETURN_uint8_t(msg, 5);
  218. }
  219. /**
  220. * @brief Get field format from play_tune_v2 message
  221. *
  222. * @return Tune format
  223. */
  224. static inline uint32_t mavlink_msg_play_tune_v2_get_format(const mavlink_message_t* msg)
  225. {
  226. return _MAV_RETURN_uint32_t(msg, 0);
  227. }
  228. /**
  229. * @brief Get field tune from play_tune_v2 message
  230. *
  231. * @return Tune definition as a NULL-terminated string.
  232. */
  233. static inline uint16_t mavlink_msg_play_tune_v2_get_tune(const mavlink_message_t* msg, char *tune)
  234. {
  235. return _MAV_RETURN_char_array(msg, tune, 248, 6);
  236. }
  237. /**
  238. * @brief Decode a play_tune_v2 message into a struct
  239. *
  240. * @param msg The message to decode
  241. * @param play_tune_v2 C-struct to decode the message contents into
  242. */
  243. static inline void mavlink_msg_play_tune_v2_decode(const mavlink_message_t* msg, mavlink_play_tune_v2_t* play_tune_v2)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. play_tune_v2->format = mavlink_msg_play_tune_v2_get_format(msg);
  247. play_tune_v2->target_system = mavlink_msg_play_tune_v2_get_target_system(msg);
  248. play_tune_v2->target_component = mavlink_msg_play_tune_v2_get_target_component(msg);
  249. mavlink_msg_play_tune_v2_get_tune(msg, play_tune_v2->tune);
  250. #else
  251. uint8_t len = msg->len < MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN? msg->len : MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN;
  252. memset(play_tune_v2, 0, MAVLINK_MSG_ID_PLAY_TUNE_V2_LEN);
  253. memcpy(play_tune_v2, _MAV_PAYLOAD(msg), len);
  254. #endif
  255. }