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.

338 lines
16 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE COMMAND_ACK PACKING
  3. #define MAVLINK_MSG_ID_COMMAND_ACK 77
  4. MAVPACKED(
  5. typedef struct __mavlink_command_ack_t {
  6. uint16_t command; /*< Command ID (of acknowledged command).*/
  7. uint8_t result; /*< Result of command.*/
  8. uint8_t progress; /*< WIP: Also used as result_param1, it can be set with a enum containing the errors reasons of why the command was denied or the progress percentage or 255 if unknown the progress when result is MAV_RESULT_IN_PROGRESS.*/
  9. int32_t result_param2; /*< WIP: Additional parameter of the result, example: which parameter of MAV_CMD_NAV_WAYPOINT caused it to be denied.*/
  10. uint8_t target_system; /*< WIP: System which requested the command to be executed*/
  11. uint8_t target_component; /*< WIP: Component which requested the command to be executed*/
  12. }) mavlink_command_ack_t;
  13. #define MAVLINK_MSG_ID_COMMAND_ACK_LEN 10
  14. #define MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN 3
  15. #define MAVLINK_MSG_ID_77_LEN 10
  16. #define MAVLINK_MSG_ID_77_MIN_LEN 3
  17. #define MAVLINK_MSG_ID_COMMAND_ACK_CRC 143
  18. #define MAVLINK_MSG_ID_77_CRC 143
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
  21. 77, \
  22. "COMMAND_ACK", \
  23. 6, \
  24. { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
  25. { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
  26. { "progress", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_ack_t, progress) }, \
  27. { "result_param2", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_command_ack_t, result_param2) }, \
  28. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_command_ack_t, target_system) }, \
  29. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_command_ack_t, target_component) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_COMMAND_ACK { \
  34. "COMMAND_ACK", \
  35. 6, \
  36. { { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_ack_t, command) }, \
  37. { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_ack_t, result) }, \
  38. { "progress", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_ack_t, progress) }, \
  39. { "result_param2", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_command_ack_t, result_param2) }, \
  40. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_command_ack_t, target_system) }, \
  41. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_command_ack_t, target_component) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a command_ack message
  47. * @param system_id ID of this system
  48. * @param component_id ID of this component (e.g. 200 for IMU)
  49. * @param msg The MAVLink message to compress the data into
  50. *
  51. * @param command Command ID (of acknowledged command).
  52. * @param result Result of command.
  53. * @param progress WIP: Also used as result_param1, it can be set with a enum containing the errors reasons of why the command was denied or the progress percentage or 255 if unknown the progress when result is MAV_RESULT_IN_PROGRESS.
  54. * @param result_param2 WIP: Additional parameter of the result, example: which parameter of MAV_CMD_NAV_WAYPOINT caused it to be denied.
  55. * @param target_system WIP: System which requested the command to be executed
  56. * @param target_component WIP: Component which requested the command to be executed
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. uint16_t command, uint8_t result, uint8_t progress, int32_t result_param2, uint8_t target_system, uint8_t target_component)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
  64. _mav_put_uint16_t(buf, 0, command);
  65. _mav_put_uint8_t(buf, 2, result);
  66. _mav_put_uint8_t(buf, 3, progress);
  67. _mav_put_int32_t(buf, 4, result_param2);
  68. _mav_put_uint8_t(buf, 8, target_system);
  69. _mav_put_uint8_t(buf, 9, target_component);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
  71. #else
  72. mavlink_command_ack_t packet;
  73. packet.command = command;
  74. packet.result = result;
  75. packet.progress = progress;
  76. packet.result_param2 = result_param2;
  77. packet.target_system = target_system;
  78. packet.target_component = target_component;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  83. }
  84. /**
  85. * @brief Pack a command_ack message on a channel
  86. * @param system_id ID of this system
  87. * @param component_id ID of this component (e.g. 200 for IMU)
  88. * @param chan The MAVLink channel this message will be sent over
  89. * @param msg The MAVLink message to compress the data into
  90. * @param command Command ID (of acknowledged command).
  91. * @param result Result of command.
  92. * @param progress WIP: Also used as result_param1, it can be set with a enum containing the errors reasons of why the command was denied or the progress percentage or 255 if unknown the progress when result is MAV_RESULT_IN_PROGRESS.
  93. * @param result_param2 WIP: Additional parameter of the result, example: which parameter of MAV_CMD_NAV_WAYPOINT caused it to be denied.
  94. * @param target_system WIP: System which requested the command to be executed
  95. * @param target_component WIP: Component which requested the command to be executed
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. uint16_t command,uint8_t result,uint8_t progress,int32_t result_param2,uint8_t target_system,uint8_t target_component)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
  104. _mav_put_uint16_t(buf, 0, command);
  105. _mav_put_uint8_t(buf, 2, result);
  106. _mav_put_uint8_t(buf, 3, progress);
  107. _mav_put_int32_t(buf, 4, result_param2);
  108. _mav_put_uint8_t(buf, 8, target_system);
  109. _mav_put_uint8_t(buf, 9, target_component);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
  111. #else
  112. mavlink_command_ack_t packet;
  113. packet.command = command;
  114. packet.result = result;
  115. packet.progress = progress;
  116. packet.result_param2 = result_param2;
  117. packet.target_system = target_system;
  118. packet.target_component = target_component;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  123. }
  124. /**
  125. * @brief Encode a command_ack struct
  126. *
  127. * @param system_id ID of this system
  128. * @param component_id ID of this component (e.g. 200 for IMU)
  129. * @param msg The MAVLink message to compress the data into
  130. * @param command_ack C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_command_ack_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack)
  133. {
  134. return mavlink_msg_command_ack_pack(system_id, component_id, msg, command_ack->command, command_ack->result, command_ack->progress, command_ack->result_param2, command_ack->target_system, command_ack->target_component);
  135. }
  136. /**
  137. * @brief Encode a command_ack struct on a channel
  138. *
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param chan The MAVLink channel this message will be sent over
  142. * @param msg The MAVLink message to compress the data into
  143. * @param command_ack C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_command_ack_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_command_ack_t* command_ack)
  146. {
  147. return mavlink_msg_command_ack_pack_chan(system_id, component_id, chan, msg, command_ack->command, command_ack->result, command_ack->progress, command_ack->result_param2, command_ack->target_system, command_ack->target_component);
  148. }
  149. /**
  150. * @brief Send a command_ack message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param command Command ID (of acknowledged command).
  154. * @param result Result of command.
  155. * @param progress WIP: Also used as result_param1, it can be set with a enum containing the errors reasons of why the command was denied or the progress percentage or 255 if unknown the progress when result is MAV_RESULT_IN_PROGRESS.
  156. * @param result_param2 WIP: Additional parameter of the result, example: which parameter of MAV_CMD_NAV_WAYPOINT caused it to be denied.
  157. * @param target_system WIP: System which requested the command to be executed
  158. * @param target_component WIP: Component which requested the command to be executed
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_command_ack_send(mavlink_channel_t chan, uint16_t command, uint8_t result, uint8_t progress, int32_t result_param2, uint8_t target_system, uint8_t target_component)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_COMMAND_ACK_LEN];
  165. _mav_put_uint16_t(buf, 0, command);
  166. _mav_put_uint8_t(buf, 2, result);
  167. _mav_put_uint8_t(buf, 3, progress);
  168. _mav_put_int32_t(buf, 4, result_param2);
  169. _mav_put_uint8_t(buf, 8, target_system);
  170. _mav_put_uint8_t(buf, 9, target_component);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  172. #else
  173. mavlink_command_ack_t packet;
  174. packet.command = command;
  175. packet.result = result;
  176. packet.progress = progress;
  177. packet.result_param2 = result_param2;
  178. packet.target_system = target_system;
  179. packet.target_component = target_component;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)&packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a command_ack message
  185. * @param chan MAVLink channel to send the message
  186. * @param struct The MAVLink struct to serialize
  187. */
  188. static inline void mavlink_msg_command_ack_send_struct(mavlink_channel_t chan, const mavlink_command_ack_t* command_ack)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_command_ack_send(chan, command_ack->command, command_ack->result, command_ack->progress, command_ack->result_param2, command_ack->target_system, command_ack->target_component);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)command_ack, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_COMMAND_ACK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  197. /*
  198. This varient of _send() can be used to save stack space by re-using
  199. memory from the receive buffer. The caller provides a
  200. mavlink_message_t which is the size of a full mavlink message. This
  201. is usually the receive buffer for the channel, and allows a reply to an
  202. incoming message with minimum stack space usage.
  203. */
  204. static inline void mavlink_msg_command_ack_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t command, uint8_t result, uint8_t progress, int32_t result_param2, uint8_t target_system, uint8_t target_component)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_uint16_t(buf, 0, command);
  209. _mav_put_uint8_t(buf, 2, result);
  210. _mav_put_uint8_t(buf, 3, progress);
  211. _mav_put_int32_t(buf, 4, result_param2);
  212. _mav_put_uint8_t(buf, 8, target_system);
  213. _mav_put_uint8_t(buf, 9, target_component);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, buf, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  215. #else
  216. mavlink_command_ack_t *packet = (mavlink_command_ack_t *)msgbuf;
  217. packet->command = command;
  218. packet->result = result;
  219. packet->progress = progress;
  220. packet->result_param2 = result_param2;
  221. packet->target_system = target_system;
  222. packet->target_component = target_component;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_ACK, (const char *)packet, MAVLINK_MSG_ID_COMMAND_ACK_MIN_LEN, MAVLINK_MSG_ID_COMMAND_ACK_LEN, MAVLINK_MSG_ID_COMMAND_ACK_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE COMMAND_ACK UNPACKING
  229. /**
  230. * @brief Get field command from command_ack message
  231. *
  232. * @return Command ID (of acknowledged command).
  233. */
  234. static inline uint16_t mavlink_msg_command_ack_get_command(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_uint16_t(msg, 0);
  237. }
  238. /**
  239. * @brief Get field result from command_ack message
  240. *
  241. * @return Result of command.
  242. */
  243. static inline uint8_t mavlink_msg_command_ack_get_result(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_uint8_t(msg, 2);
  246. }
  247. /**
  248. * @brief Get field progress from command_ack message
  249. *
  250. * @return WIP: Also used as result_param1, it can be set with a enum containing the errors reasons of why the command was denied or the progress percentage or 255 if unknown the progress when result is MAV_RESULT_IN_PROGRESS.
  251. */
  252. static inline uint8_t mavlink_msg_command_ack_get_progress(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_uint8_t(msg, 3);
  255. }
  256. /**
  257. * @brief Get field result_param2 from command_ack message
  258. *
  259. * @return WIP: Additional parameter of the result, example: which parameter of MAV_CMD_NAV_WAYPOINT caused it to be denied.
  260. */
  261. static inline int32_t mavlink_msg_command_ack_get_result_param2(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_int32_t(msg, 4);
  264. }
  265. /**
  266. * @brief Get field target_system from command_ack message
  267. *
  268. * @return WIP: System which requested the command to be executed
  269. */
  270. static inline uint8_t mavlink_msg_command_ack_get_target_system(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_uint8_t(msg, 8);
  273. }
  274. /**
  275. * @brief Get field target_component from command_ack message
  276. *
  277. * @return WIP: Component which requested the command to be executed
  278. */
  279. static inline uint8_t mavlink_msg_command_ack_get_target_component(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_uint8_t(msg, 9);
  282. }
  283. /**
  284. * @brief Decode a command_ack message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param command_ack C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_command_ack_decode(const mavlink_message_t* msg, mavlink_command_ack_t* command_ack)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. command_ack->command = mavlink_msg_command_ack_get_command(msg);
  293. command_ack->result = mavlink_msg_command_ack_get_result(msg);
  294. command_ack->progress = mavlink_msg_command_ack_get_progress(msg);
  295. command_ack->result_param2 = mavlink_msg_command_ack_get_result_param2(msg);
  296. command_ack->target_system = mavlink_msg_command_ack_get_target_system(msg);
  297. command_ack->target_component = mavlink_msg_command_ack_get_target_component(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_COMMAND_ACK_LEN? msg->len : MAVLINK_MSG_ID_COMMAND_ACK_LEN;
  300. memset(command_ack, 0, MAVLINK_MSG_ID_COMMAND_ACK_LEN);
  301. memcpy(command_ack, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }