/libs/mavlink/include/mavlink/v1.0/common/mavlink_msg_mission_ack.h

https://gitlab.com/fsgdez/apm_planner · C Header · 257 lines · 148 code · 32 blank · 77 comment · 4 complexity · 48306804fbb526b44d170379d51957a0 MD5 · raw file

  1. // MESSAGE MISSION_ACK PACKING
  2. #define MAVLINK_MSG_ID_MISSION_ACK 47
  3. typedef struct __mavlink_mission_ack_t
  4. {
  5. uint8_t target_system; ///< System ID
  6. uint8_t target_component; ///< Component ID
  7. uint8_t type; ///< See MAV_MISSION_RESULT enum
  8. } mavlink_mission_ack_t;
  9. #define MAVLINK_MSG_ID_MISSION_ACK_LEN 3
  10. #define MAVLINK_MSG_ID_47_LEN 3
  11. #define MAVLINK_MSG_ID_MISSION_ACK_CRC 153
  12. #define MAVLINK_MSG_ID_47_CRC 153
  13. #define MAVLINK_MESSAGE_INFO_MISSION_ACK { \
  14. "MISSION_ACK", \
  15. 3, \
  16. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) }, \
  17. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) }, \
  18. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) }, \
  19. } \
  20. }
  21. /**
  22. * @brief Pack a mission_ack message
  23. * @param system_id ID of this system
  24. * @param component_id ID of this component (e.g. 200 for IMU)
  25. * @param msg The MAVLink message to compress the data into
  26. *
  27. * @param target_system System ID
  28. * @param target_component Component ID
  29. * @param type See MAV_MISSION_RESULT enum
  30. * @return length of the message in bytes (excluding serial stream start sign)
  31. */
  32. static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  33. uint8_t target_system, uint8_t target_component, uint8_t type)
  34. {
  35. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  36. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  37. _mav_put_uint8_t(buf, 0, target_system);
  38. _mav_put_uint8_t(buf, 1, target_component);
  39. _mav_put_uint8_t(buf, 2, type);
  40. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  41. #else
  42. mavlink_mission_ack_t packet;
  43. packet.target_system = target_system;
  44. packet.target_component = target_component;
  45. packet.type = type;
  46. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  47. #endif
  48. msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
  49. #if MAVLINK_CRC_EXTRA
  50. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  51. #else
  52. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  53. #endif
  54. }
  55. /**
  56. * @brief Pack a mission_ack message on a channel
  57. * @param system_id ID of this system
  58. * @param component_id ID of this component (e.g. 200 for IMU)
  59. * @param chan The MAVLink channel this message will be sent over
  60. * @param msg The MAVLink message to compress the data into
  61. * @param target_system System ID
  62. * @param target_component Component ID
  63. * @param type See MAV_MISSION_RESULT enum
  64. * @return length of the message in bytes (excluding serial stream start sign)
  65. */
  66. static inline uint16_t mavlink_msg_mission_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  67. mavlink_message_t* msg,
  68. uint8_t target_system,uint8_t target_component,uint8_t type)
  69. {
  70. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  71. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  72. _mav_put_uint8_t(buf, 0, target_system);
  73. _mav_put_uint8_t(buf, 1, target_component);
  74. _mav_put_uint8_t(buf, 2, type);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  76. #else
  77. mavlink_mission_ack_t packet;
  78. packet.target_system = target_system;
  79. packet.target_component = target_component;
  80. packet.type = type;
  81. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  82. #endif
  83. msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
  84. #if MAVLINK_CRC_EXTRA
  85. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  86. #else
  87. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  88. #endif
  89. }
  90. /**
  91. * @brief Encode a mission_ack struct
  92. *
  93. * @param system_id ID of this system
  94. * @param component_id ID of this component (e.g. 200 for IMU)
  95. * @param msg The MAVLink message to compress the data into
  96. * @param mission_ack C-struct to read the message contents from
  97. */
  98. static inline uint16_t mavlink_msg_mission_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack)
  99. {
  100. return mavlink_msg_mission_ack_pack(system_id, component_id, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type);
  101. }
  102. /**
  103. * @brief Encode a mission_ack struct on a channel
  104. *
  105. * @param system_id ID of this system
  106. * @param component_id ID of this component (e.g. 200 for IMU)
  107. * @param chan The MAVLink channel this message will be sent over
  108. * @param msg The MAVLink message to compress the data into
  109. * @param mission_ack C-struct to read the message contents from
  110. */
  111. static inline uint16_t mavlink_msg_mission_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_ack_t* mission_ack)
  112. {
  113. return mavlink_msg_mission_ack_pack_chan(system_id, component_id, chan, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type);
  114. }
  115. /**
  116. * @brief Send a mission_ack message
  117. * @param chan MAVLink channel to send the message
  118. *
  119. * @param target_system System ID
  120. * @param target_component Component ID
  121. * @param type See MAV_MISSION_RESULT enum
  122. */
  123. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  124. static inline void mavlink_msg_mission_ack_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type)
  125. {
  126. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  127. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  128. _mav_put_uint8_t(buf, 0, target_system);
  129. _mav_put_uint8_t(buf, 1, target_component);
  130. _mav_put_uint8_t(buf, 2, type);
  131. #if MAVLINK_CRC_EXTRA
  132. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  133. #else
  134. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  135. #endif
  136. #else
  137. mavlink_mission_ack_t packet;
  138. packet.target_system = target_system;
  139. packet.target_component = target_component;
  140. packet.type = type;
  141. #if MAVLINK_CRC_EXTRA
  142. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  143. #else
  144. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  145. #endif
  146. #endif
  147. }
  148. #if MAVLINK_MSG_ID_MISSION_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  149. /*
  150. This varient of _send() can be used to save stack space by re-using
  151. memory from the receive buffer. The caller provides a
  152. mavlink_message_t which is the size of a full mavlink message. This
  153. is usually the receive buffer for the channel, and allows a reply to an
  154. incoming message with minimum stack space usage.
  155. */
  156. static inline void mavlink_msg_mission_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type)
  157. {
  158. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  159. char *buf = (char *)msgbuf;
  160. _mav_put_uint8_t(buf, 0, target_system);
  161. _mav_put_uint8_t(buf, 1, target_component);
  162. _mav_put_uint8_t(buf, 2, type);
  163. #if MAVLINK_CRC_EXTRA
  164. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  165. #else
  166. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  167. #endif
  168. #else
  169. mavlink_mission_ack_t *packet = (mavlink_mission_ack_t *)msgbuf;
  170. packet->target_system = target_system;
  171. packet->target_component = target_component;
  172. packet->type = type;
  173. #if MAVLINK_CRC_EXTRA
  174. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)packet, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  175. #else
  176. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  177. #endif
  178. #endif
  179. }
  180. #endif
  181. #endif
  182. // MESSAGE MISSION_ACK UNPACKING
  183. /**
  184. * @brief Get field target_system from mission_ack message
  185. *
  186. * @return System ID
  187. */
  188. static inline uint8_t mavlink_msg_mission_ack_get_target_system(const mavlink_message_t* msg)
  189. {
  190. return _MAV_RETURN_uint8_t(msg, 0);
  191. }
  192. /**
  193. * @brief Get field target_component from mission_ack message
  194. *
  195. * @return Component ID
  196. */
  197. static inline uint8_t mavlink_msg_mission_ack_get_target_component(const mavlink_message_t* msg)
  198. {
  199. return _MAV_RETURN_uint8_t(msg, 1);
  200. }
  201. /**
  202. * @brief Get field type from mission_ack message
  203. *
  204. * @return See MAV_MISSION_RESULT enum
  205. */
  206. static inline uint8_t mavlink_msg_mission_ack_get_type(const mavlink_message_t* msg)
  207. {
  208. return _MAV_RETURN_uint8_t(msg, 2);
  209. }
  210. /**
  211. * @brief Decode a mission_ack message into a struct
  212. *
  213. * @param msg The message to decode
  214. * @param mission_ack C-struct to decode the message contents into
  215. */
  216. static inline void mavlink_msg_mission_ack_decode(const mavlink_message_t* msg, mavlink_mission_ack_t* mission_ack)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP
  219. mission_ack->target_system = mavlink_msg_mission_ack_get_target_system(msg);
  220. mission_ack->target_component = mavlink_msg_mission_ack_get_target_component(msg);
  221. mission_ack->type = mavlink_msg_mission_ack_get_type(msg);
  222. #else
  223. memcpy(mission_ack, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_MISSION_ACK_LEN);
  224. #endif
  225. }