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.

263 lines
10 KiB

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