mavlink_msg_command_cancel.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #pragma once
  2. // MESSAGE COMMAND_CANCEL PACKING
  3. #define MAVLINK_MSG_ID_COMMAND_CANCEL 80
  4. typedef struct __mavlink_command_cancel_t {
  5. uint16_t command; /*< Command ID (of command to cancel).*/
  6. uint8_t target_system; /*< System executing long running command. Should not be broadcast (0).*/
  7. uint8_t target_component; /*< Component executing long running command.*/
  8. } mavlink_command_cancel_t;
  9. #define MAVLINK_MSG_ID_COMMAND_CANCEL_LEN 4
  10. #define MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN 4
  11. #define MAVLINK_MSG_ID_80_LEN 4
  12. #define MAVLINK_MSG_ID_80_MIN_LEN 4
  13. #define MAVLINK_MSG_ID_COMMAND_CANCEL_CRC 14
  14. #define MAVLINK_MSG_ID_80_CRC 14
  15. #if MAVLINK_COMMAND_24BIT
  16. #define MAVLINK_MESSAGE_INFO_COMMAND_CANCEL { \
  17. 80, \
  18. "COMMAND_CANCEL", \
  19. 3, \
  20. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_cancel_t, target_system) }, \
  21. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_cancel_t, target_component) }, \
  22. { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_cancel_t, command) }, \
  23. } \
  24. }
  25. #else
  26. #define MAVLINK_MESSAGE_INFO_COMMAND_CANCEL { \
  27. "COMMAND_CANCEL", \
  28. 3, \
  29. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_command_cancel_t, target_system) }, \
  30. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_command_cancel_t, target_component) }, \
  31. { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_command_cancel_t, command) }, \
  32. } \
  33. }
  34. #endif
  35. /**
  36. * @brief Pack a command_cancel message
  37. * @param system_id ID of this system
  38. * @param component_id ID of this component (e.g. 200 for IMU)
  39. * @param msg The MAVLink message to compress the data into
  40. *
  41. * @param target_system System executing long running command. Should not be broadcast (0).
  42. * @param target_component Component executing long running command.
  43. * @param command Command ID (of command to cancel).
  44. * @return length of the message in bytes (excluding serial stream start sign)
  45. */
  46. MAVLINK_WIP
  47. static inline uint16_t mavlink_msg_command_cancel_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  48. uint8_t target_system, uint8_t target_component, uint16_t command)
  49. {
  50. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  51. char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN];
  52. _mav_put_uint16_t(buf, 0, command);
  53. _mav_put_uint8_t(buf, 2, target_system);
  54. _mav_put_uint8_t(buf, 3, target_component);
  55. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  56. #else
  57. mavlink_command_cancel_t packet;
  58. packet.command = command;
  59. packet.target_system = target_system;
  60. packet.target_component = target_component;
  61. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  62. #endif
  63. msg->msgid = MAVLINK_MSG_ID_COMMAND_CANCEL;
  64. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  65. }
  66. /**
  67. * @brief Pack a command_cancel message
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param status MAVLink status structure
  71. * @param msg The MAVLink message to compress the data into
  72. *
  73. * @param target_system System executing long running command. Should not be broadcast (0).
  74. * @param target_component Component executing long running command.
  75. * @param command Command ID (of command to cancel).
  76. * @return length of the message in bytes (excluding serial stream start sign)
  77. */
  78. static inline uint16_t mavlink_msg_command_cancel_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  79. uint8_t target_system, uint8_t target_component, uint16_t command)
  80. {
  81. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  82. char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN];
  83. _mav_put_uint16_t(buf, 0, command);
  84. _mav_put_uint8_t(buf, 2, target_system);
  85. _mav_put_uint8_t(buf, 3, target_component);
  86. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  87. #else
  88. mavlink_command_cancel_t packet;
  89. packet.command = command;
  90. packet.target_system = target_system;
  91. packet.target_component = target_component;
  92. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  93. #endif
  94. msg->msgid = MAVLINK_MSG_ID_COMMAND_CANCEL;
  95. #if MAVLINK_CRC_EXTRA
  96. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  97. #else
  98. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  99. #endif
  100. }
  101. /**
  102. * @brief Pack a command_cancel message on a channel
  103. * @param system_id ID of this system
  104. * @param component_id ID of this component (e.g. 200 for IMU)
  105. * @param chan The MAVLink channel this message will be sent over
  106. * @param msg The MAVLink message to compress the data into
  107. * @param target_system System executing long running command. Should not be broadcast (0).
  108. * @param target_component Component executing long running command.
  109. * @param command Command ID (of command to cancel).
  110. * @return length of the message in bytes (excluding serial stream start sign)
  111. */
  112. MAVLINK_WIP
  113. static inline uint16_t mavlink_msg_command_cancel_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  114. mavlink_message_t* msg,
  115. uint8_t target_system,uint8_t target_component,uint16_t command)
  116. {
  117. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  118. char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN];
  119. _mav_put_uint16_t(buf, 0, command);
  120. _mav_put_uint8_t(buf, 2, target_system);
  121. _mav_put_uint8_t(buf, 3, target_component);
  122. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  123. #else
  124. mavlink_command_cancel_t packet;
  125. packet.command = command;
  126. packet.target_system = target_system;
  127. packet.target_component = target_component;
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_COMMAND_CANCEL;
  131. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  132. }
  133. /**
  134. * @brief Encode a command_cancel struct
  135. *
  136. * @param system_id ID of this system
  137. * @param component_id ID of this component (e.g. 200 for IMU)
  138. * @param msg The MAVLink message to compress the data into
  139. * @param command_cancel C-struct to read the message contents from
  140. */
  141. MAVLINK_WIP
  142. static inline uint16_t mavlink_msg_command_cancel_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
  143. {
  144. return mavlink_msg_command_cancel_pack(system_id, component_id, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
  145. }
  146. /**
  147. * @brief Encode a command_cancel struct on a channel
  148. *
  149. * @param system_id ID of this system
  150. * @param component_id ID of this component (e.g. 200 for IMU)
  151. * @param chan The MAVLink channel this message will be sent over
  152. * @param msg The MAVLink message to compress the data into
  153. * @param command_cancel C-struct to read the message contents from
  154. */
  155. MAVLINK_WIP
  156. static inline uint16_t mavlink_msg_command_cancel_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
  157. {
  158. return mavlink_msg_command_cancel_pack_chan(system_id, component_id, chan, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
  159. }
  160. /**
  161. * @brief Encode a command_cancel struct with provided status structure
  162. *
  163. * @param system_id ID of this system
  164. * @param component_id ID of this component (e.g. 200 for IMU)
  165. * @param status MAVLink status structure
  166. * @param msg The MAVLink message to compress the data into
  167. * @param command_cancel C-struct to read the message contents from
  168. */
  169. static inline uint16_t mavlink_msg_command_cancel_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_command_cancel_t* command_cancel)
  170. {
  171. return mavlink_msg_command_cancel_pack_status(system_id, component_id, _status, msg, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
  172. }
  173. /**
  174. * @brief Send a command_cancel message
  175. * @param chan MAVLink channel to send the message
  176. *
  177. * @param target_system System executing long running command. Should not be broadcast (0).
  178. * @param target_component Component executing long running command.
  179. * @param command Command ID (of command to cancel).
  180. */
  181. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  182. MAVLINK_WIP
  183. static inline void mavlink_msg_command_cancel_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t command)
  184. {
  185. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  186. char buf[MAVLINK_MSG_ID_COMMAND_CANCEL_LEN];
  187. _mav_put_uint16_t(buf, 0, command);
  188. _mav_put_uint8_t(buf, 2, target_system);
  189. _mav_put_uint8_t(buf, 3, target_component);
  190. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, buf, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  191. #else
  192. mavlink_command_cancel_t packet;
  193. packet.command = command;
  194. packet.target_system = target_system;
  195. packet.target_component = target_component;
  196. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)&packet, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  197. #endif
  198. }
  199. /**
  200. * @brief Send a command_cancel message
  201. * @param chan MAVLink channel to send the message
  202. * @param struct The MAVLink struct to serialize
  203. */
  204. MAVLINK_WIP
  205. static inline void mavlink_msg_command_cancel_send_struct(mavlink_channel_t chan, const mavlink_command_cancel_t* command_cancel)
  206. {
  207. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  208. mavlink_msg_command_cancel_send(chan, command_cancel->target_system, command_cancel->target_component, command_cancel->command);
  209. #else
  210. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)command_cancel, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  211. #endif
  212. }
  213. #if MAVLINK_MSG_ID_COMMAND_CANCEL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  214. /*
  215. This variant of _send() can be used to save stack space by reusing
  216. memory from the receive buffer. The caller provides a
  217. mavlink_message_t which is the size of a full mavlink message. This
  218. is usually the receive buffer for the channel, and allows a reply to an
  219. incoming message with minimum stack space usage.
  220. */
  221. MAVLINK_WIP
  222. static inline void mavlink_msg_command_cancel_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t command)
  223. {
  224. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  225. char *buf = (char *)msgbuf;
  226. _mav_put_uint16_t(buf, 0, command);
  227. _mav_put_uint8_t(buf, 2, target_system);
  228. _mav_put_uint8_t(buf, 3, target_component);
  229. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, buf, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  230. #else
  231. mavlink_command_cancel_t *packet = (mavlink_command_cancel_t *)msgbuf;
  232. packet->command = command;
  233. packet->target_system = target_system;
  234. packet->target_component = target_component;
  235. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMMAND_CANCEL, (const char *)packet, MAVLINK_MSG_ID_COMMAND_CANCEL_MIN_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN, MAVLINK_MSG_ID_COMMAND_CANCEL_CRC);
  236. #endif
  237. }
  238. #endif
  239. #endif
  240. // MESSAGE COMMAND_CANCEL UNPACKING
  241. /**
  242. * @brief Get field target_system from command_cancel message
  243. *
  244. * @return System executing long running command. Should not be broadcast (0).
  245. */
  246. MAVLINK_WIP
  247. static inline uint8_t mavlink_msg_command_cancel_get_target_system(const mavlink_message_t* msg)
  248. {
  249. return _MAV_RETURN_uint8_t(msg, 2);
  250. }
  251. /**
  252. * @brief Get field target_component from command_cancel message
  253. *
  254. * @return Component executing long running command.
  255. */
  256. MAVLINK_WIP
  257. static inline uint8_t mavlink_msg_command_cancel_get_target_component(const mavlink_message_t* msg)
  258. {
  259. return _MAV_RETURN_uint8_t(msg, 3);
  260. }
  261. /**
  262. * @brief Get field command from command_cancel message
  263. *
  264. * @return Command ID (of command to cancel).
  265. */
  266. MAVLINK_WIP
  267. static inline uint16_t mavlink_msg_command_cancel_get_command(const mavlink_message_t* msg)
  268. {
  269. return _MAV_RETURN_uint16_t(msg, 0);
  270. }
  271. /**
  272. * @brief Decode a command_cancel message into a struct
  273. *
  274. * @param msg The message to decode
  275. * @param command_cancel C-struct to decode the message contents into
  276. */
  277. MAVLINK_WIP
  278. static inline void mavlink_msg_command_cancel_decode(const mavlink_message_t* msg, mavlink_command_cancel_t* command_cancel)
  279. {
  280. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  281. command_cancel->command = mavlink_msg_command_cancel_get_command(msg);
  282. command_cancel->target_system = mavlink_msg_command_cancel_get_target_system(msg);
  283. command_cancel->target_component = mavlink_msg_command_cancel_get_target_component(msg);
  284. #else
  285. uint8_t len = msg->len < MAVLINK_MSG_ID_COMMAND_CANCEL_LEN? msg->len : MAVLINK_MSG_ID_COMMAND_CANCEL_LEN;
  286. memset(command_cancel, 0, MAVLINK_MSG_ID_COMMAND_CANCEL_LEN);
  287. memcpy(command_cancel, _MAV_PAYLOAD(msg), len);
  288. #endif
  289. }