You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

281 lines
12 KiB

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