mavlink_msg_mission_ack.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. #pragma once
  2. // MESSAGE MISSION_ACK PACKING
  3. #define MAVLINK_MSG_ID_MISSION_ACK 47
  4. typedef struct __mavlink_mission_ack_t {
  5. uint8_t target_system; /*< System ID*/
  6. uint8_t target_component; /*< Component ID*/
  7. uint8_t type; /*< Mission result.*/
  8. uint8_t mission_type; /*< Mission type.*/
  9. uint32_t opaque_id; /*< Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
  10. The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
  11. The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
  12. 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
  13. 0 if plan ids are not supported.
  14. The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
  15. */
  16. } mavlink_mission_ack_t;
  17. #define MAVLINK_MSG_ID_MISSION_ACK_LEN 8
  18. #define MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN 3
  19. #define MAVLINK_MSG_ID_47_LEN 8
  20. #define MAVLINK_MSG_ID_47_MIN_LEN 3
  21. #define MAVLINK_MSG_ID_MISSION_ACK_CRC 153
  22. #define MAVLINK_MSG_ID_47_CRC 153
  23. #if MAVLINK_COMMAND_24BIT
  24. #define MAVLINK_MESSAGE_INFO_MISSION_ACK { \
  25. 47, \
  26. "MISSION_ACK", \
  27. 5, \
  28. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) }, \
  29. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) }, \
  30. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) }, \
  31. { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_ack_t, mission_type) }, \
  32. { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_mission_ack_t, opaque_id) }, \
  33. } \
  34. }
  35. #else
  36. #define MAVLINK_MESSAGE_INFO_MISSION_ACK { \
  37. "MISSION_ACK", \
  38. 5, \
  39. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_mission_ack_t, target_system) }, \
  40. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_mission_ack_t, target_component) }, \
  41. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_mission_ack_t, type) }, \
  42. { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_mission_ack_t, mission_type) }, \
  43. { "opaque_id", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_mission_ack_t, opaque_id) }, \
  44. } \
  45. }
  46. #endif
  47. /**
  48. * @brief Pack a mission_ack 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
  52. *
  53. * @param target_system System ID
  54. * @param target_component Component ID
  55. * @param type Mission result.
  56. * @param mission_type Mission type.
  57. * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
  58. The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
  59. The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
  60. 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
  61. 0 if plan ids are not supported.
  62. The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
  63. * @return length of the message in bytes (excluding serial stream start sign)
  64. */
  65. static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  66. uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
  67. {
  68. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  69. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  70. _mav_put_uint8_t(buf, 0, target_system);
  71. _mav_put_uint8_t(buf, 1, target_component);
  72. _mav_put_uint8_t(buf, 2, type);
  73. _mav_put_uint8_t(buf, 3, mission_type);
  74. _mav_put_uint32_t(buf, 4, opaque_id);
  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. packet.mission_type = mission_type;
  82. packet.opaque_id = opaque_id;
  83. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  84. #endif
  85. msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
  86. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  87. }
  88. /**
  89. * @brief Pack a mission_ack message on a channel
  90. * @param system_id ID of this system
  91. * @param component_id ID of this component (e.g. 200 for IMU)
  92. * @param chan The MAVLink channel this message will be sent over
  93. * @param msg The MAVLink message to compress the data into
  94. * @param target_system System ID
  95. * @param target_component Component ID
  96. * @param type Mission result.
  97. * @param mission_type Mission type.
  98. * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
  99. The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
  100. The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
  101. 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
  102. 0 if plan ids are not supported.
  103. The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
  104. * @return length of the message in bytes (excluding serial stream start sign)
  105. */
  106. static inline uint16_t mavlink_msg_mission_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  107. mavlink_message_t* msg,
  108. uint8_t target_system,uint8_t target_component,uint8_t type,uint8_t mission_type,uint32_t opaque_id)
  109. {
  110. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  111. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  112. _mav_put_uint8_t(buf, 0, target_system);
  113. _mav_put_uint8_t(buf, 1, target_component);
  114. _mav_put_uint8_t(buf, 2, type);
  115. _mav_put_uint8_t(buf, 3, mission_type);
  116. _mav_put_uint32_t(buf, 4, opaque_id);
  117. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  118. #else
  119. mavlink_mission_ack_t packet;
  120. packet.target_system = target_system;
  121. packet.target_component = target_component;
  122. packet.type = type;
  123. packet.mission_type = mission_type;
  124. packet.opaque_id = opaque_id;
  125. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  126. #endif
  127. msg->msgid = MAVLINK_MSG_ID_MISSION_ACK;
  128. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  129. }
  130. /**
  131. * @brief Encode a mission_ack struct
  132. *
  133. * @param system_id ID of this system
  134. * @param component_id ID of this component (e.g. 200 for IMU)
  135. * @param msg The MAVLink message to compress the data into
  136. * @param mission_ack C-struct to read the message contents from
  137. */
  138. 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)
  139. {
  140. return mavlink_msg_mission_ack_pack(system_id, component_id, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
  141. }
  142. /**
  143. * @brief Encode a mission_ack struct on a channel
  144. *
  145. * @param system_id ID of this system
  146. * @param component_id ID of this component (e.g. 200 for IMU)
  147. * @param chan The MAVLink channel this message will be sent over
  148. * @param msg The MAVLink message to compress the data into
  149. * @param mission_ack C-struct to read the message contents from
  150. */
  151. 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)
  152. {
  153. return mavlink_msg_mission_ack_pack_chan(system_id, component_id, chan, msg, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
  154. }
  155. /**
  156. * @brief Send a mission_ack message
  157. * @param chan MAVLink channel to send the message
  158. *
  159. * @param target_system System ID
  160. * @param target_component Component ID
  161. * @param type Mission result.
  162. * @param mission_type Mission type.
  163. * @param opaque_id Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
  164. The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
  165. The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
  166. 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
  167. 0 if plan ids are not supported.
  168. The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
  169. */
  170. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  171. static inline void mavlink_msg_mission_ack_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t type, uint8_t mission_type, uint32_t opaque_id)
  172. {
  173. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  174. char buf[MAVLINK_MSG_ID_MISSION_ACK_LEN];
  175. _mav_put_uint8_t(buf, 0, target_system);
  176. _mav_put_uint8_t(buf, 1, target_component);
  177. _mav_put_uint8_t(buf, 2, type);
  178. _mav_put_uint8_t(buf, 3, mission_type);
  179. _mav_put_uint32_t(buf, 4, opaque_id);
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  181. #else
  182. mavlink_mission_ack_t packet;
  183. packet.target_system = target_system;
  184. packet.target_component = target_component;
  185. packet.type = type;
  186. packet.mission_type = mission_type;
  187. packet.opaque_id = opaque_id;
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  189. #endif
  190. }
  191. /**
  192. * @brief Send a mission_ack message
  193. * @param chan MAVLink channel to send the message
  194. * @param struct The MAVLink struct to serialize
  195. */
  196. static inline void mavlink_msg_mission_ack_send_struct(mavlink_channel_t chan, const mavlink_mission_ack_t* mission_ack)
  197. {
  198. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  199. mavlink_msg_mission_ack_send(chan, mission_ack->target_system, mission_ack->target_component, mission_ack->type, mission_ack->mission_type, mission_ack->opaque_id);
  200. #else
  201. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)mission_ack, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  202. #endif
  203. }
  204. #if MAVLINK_MSG_ID_MISSION_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  205. /*
  206. This variant of _send() can be used to save stack space by re-using
  207. memory from the receive buffer. The caller provides a
  208. mavlink_message_t which is the size of a full mavlink message. This
  209. is usually the receive buffer for the channel, and allows a reply to an
  210. incoming message with minimum stack space usage.
  211. */
  212. 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, uint8_t mission_type, uint32_t opaque_id)
  213. {
  214. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  215. char *buf = (char *)msgbuf;
  216. _mav_put_uint8_t(buf, 0, target_system);
  217. _mav_put_uint8_t(buf, 1, target_component);
  218. _mav_put_uint8_t(buf, 2, type);
  219. _mav_put_uint8_t(buf, 3, mission_type);
  220. _mav_put_uint32_t(buf, 4, opaque_id);
  221. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, buf, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  222. #else
  223. mavlink_mission_ack_t *packet = (mavlink_mission_ack_t *)msgbuf;
  224. packet->target_system = target_system;
  225. packet->target_component = target_component;
  226. packet->type = type;
  227. packet->mission_type = mission_type;
  228. packet->opaque_id = opaque_id;
  229. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ACK, (const char *)packet, MAVLINK_MSG_ID_MISSION_ACK_MIN_LEN, MAVLINK_MSG_ID_MISSION_ACK_LEN, MAVLINK_MSG_ID_MISSION_ACK_CRC);
  230. #endif
  231. }
  232. #endif
  233. #endif
  234. // MESSAGE MISSION_ACK UNPACKING
  235. /**
  236. * @brief Get field target_system from mission_ack message
  237. *
  238. * @return System ID
  239. */
  240. static inline uint8_t mavlink_msg_mission_ack_get_target_system(const mavlink_message_t* msg)
  241. {
  242. return _MAV_RETURN_uint8_t(msg, 0);
  243. }
  244. /**
  245. * @brief Get field target_component from mission_ack message
  246. *
  247. * @return Component ID
  248. */
  249. static inline uint8_t mavlink_msg_mission_ack_get_target_component(const mavlink_message_t* msg)
  250. {
  251. return _MAV_RETURN_uint8_t(msg, 1);
  252. }
  253. /**
  254. * @brief Get field type from mission_ack message
  255. *
  256. * @return Mission result.
  257. */
  258. static inline uint8_t mavlink_msg_mission_ack_get_type(const mavlink_message_t* msg)
  259. {
  260. return _MAV_RETURN_uint8_t(msg, 2);
  261. }
  262. /**
  263. * @brief Get field mission_type from mission_ack message
  264. *
  265. * @return Mission type.
  266. */
  267. static inline uint8_t mavlink_msg_mission_ack_get_mission_type(const mavlink_message_t* msg)
  268. {
  269. return _MAV_RETURN_uint8_t(msg, 3);
  270. }
  271. /**
  272. * @brief Get field opaque_id from mission_ack message
  273. *
  274. * @return Id of new on-vehicle mission, fence, or rally point plan (on upload to vehicle).
  275. The id is calculated and returned by a vehicle when a new plan is uploaded by a GCS.
  276. The only requirement on the id is that it must change when there is any change to the on-vehicle plan type (there is no requirement that the id be globally unique).
  277. 0 on download from the vehicle to the GCS (on download the ID is set in MISSION_COUNT).
  278. 0 if plan ids are not supported.
  279. The current on-vehicle plan ids are streamed in `MISSION_CURRENT`, allowing a GCS to determine if any part of the plan has changed and needs to be re-uploaded.
  280. */
  281. static inline uint32_t mavlink_msg_mission_ack_get_opaque_id(const mavlink_message_t* msg)
  282. {
  283. return _MAV_RETURN_uint32_t(msg, 4);
  284. }
  285. /**
  286. * @brief Decode a mission_ack message into a struct
  287. *
  288. * @param msg The message to decode
  289. * @param mission_ack C-struct to decode the message contents into
  290. */
  291. static inline void mavlink_msg_mission_ack_decode(const mavlink_message_t* msg, mavlink_mission_ack_t* mission_ack)
  292. {
  293. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  294. mission_ack->target_system = mavlink_msg_mission_ack_get_target_system(msg);
  295. mission_ack->target_component = mavlink_msg_mission_ack_get_target_component(msg);
  296. mission_ack->type = mavlink_msg_mission_ack_get_type(msg);
  297. mission_ack->mission_type = mavlink_msg_mission_ack_get_mission_type(msg);
  298. mission_ack->opaque_id = mavlink_msg_mission_ack_get_opaque_id(msg);
  299. #else
  300. uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ACK_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ACK_LEN;
  301. memset(mission_ack, 0, MAVLINK_MSG_ID_MISSION_ACK_LEN);
  302. memcpy(mission_ack, _MAV_PAYLOAD(msg), len);
  303. #endif
  304. }