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.

313 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE FENCE_STATUS PACKING
  3. #define MAVLINK_MSG_ID_FENCE_STATUS 162
  4. MAVPACKED(
  5. typedef struct __mavlink_fence_status_t {
  6. uint32_t breach_time; /*< [ms] Time (since boot) of last breach.*/
  7. uint16_t breach_count; /*< Number of fence breaches.*/
  8. uint8_t breach_status; /*< Breach status (0 if currently inside fence, 1 if outside).*/
  9. uint8_t breach_type; /*< Last breach type.*/
  10. uint8_t breach_mitigation; /*< Active action to prevent fence breach*/
  11. }) mavlink_fence_status_t;
  12. #define MAVLINK_MSG_ID_FENCE_STATUS_LEN 9
  13. #define MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN 8
  14. #define MAVLINK_MSG_ID_162_LEN 9
  15. #define MAVLINK_MSG_ID_162_MIN_LEN 8
  16. #define MAVLINK_MSG_ID_FENCE_STATUS_CRC 189
  17. #define MAVLINK_MSG_ID_162_CRC 189
  18. #if MAVLINK_COMMAND_24BIT
  19. #define MAVLINK_MESSAGE_INFO_FENCE_STATUS { \
  20. 162, \
  21. "FENCE_STATUS", \
  22. 5, \
  23. { { "breach_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_fence_status_t, breach_status) }, \
  24. { "breach_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_fence_status_t, breach_count) }, \
  25. { "breach_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_fence_status_t, breach_type) }, \
  26. { "breach_time", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_fence_status_t, breach_time) }, \
  27. { "breach_mitigation", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_status_t, breach_mitigation) }, \
  28. } \
  29. }
  30. #else
  31. #define MAVLINK_MESSAGE_INFO_FENCE_STATUS { \
  32. "FENCE_STATUS", \
  33. 5, \
  34. { { "breach_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_fence_status_t, breach_status) }, \
  35. { "breach_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_fence_status_t, breach_count) }, \
  36. { "breach_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_fence_status_t, breach_type) }, \
  37. { "breach_time", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_fence_status_t, breach_time) }, \
  38. { "breach_mitigation", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_status_t, breach_mitigation) }, \
  39. } \
  40. }
  41. #endif
  42. /**
  43. * @brief Pack a fence_status message
  44. * @param system_id ID of this system
  45. * @param component_id ID of this component (e.g. 200 for IMU)
  46. * @param msg The MAVLink message to compress the data into
  47. *
  48. * @param breach_status Breach status (0 if currently inside fence, 1 if outside).
  49. * @param breach_count Number of fence breaches.
  50. * @param breach_type Last breach type.
  51. * @param breach_time [ms] Time (since boot) of last breach.
  52. * @param breach_mitigation Active action to prevent fence breach
  53. * @return length of the message in bytes (excluding serial stream start sign)
  54. */
  55. static inline uint16_t mavlink_msg_fence_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  56. uint8_t breach_status, uint16_t breach_count, uint8_t breach_type, uint32_t breach_time, uint8_t breach_mitigation)
  57. {
  58. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  59. char buf[MAVLINK_MSG_ID_FENCE_STATUS_LEN];
  60. _mav_put_uint32_t(buf, 0, breach_time);
  61. _mav_put_uint16_t(buf, 4, breach_count);
  62. _mav_put_uint8_t(buf, 6, breach_status);
  63. _mav_put_uint8_t(buf, 7, breach_type);
  64. _mav_put_uint8_t(buf, 8, breach_mitigation);
  65. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_STATUS_LEN);
  66. #else
  67. mavlink_fence_status_t packet;
  68. packet.breach_time = breach_time;
  69. packet.breach_count = breach_count;
  70. packet.breach_status = breach_status;
  71. packet.breach_type = breach_type;
  72. packet.breach_mitigation = breach_mitigation;
  73. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_STATUS_LEN);
  74. #endif
  75. msg->msgid = MAVLINK_MSG_ID_FENCE_STATUS;
  76. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  77. }
  78. /**
  79. * @brief Pack a fence_status message on a channel
  80. * @param system_id ID of this system
  81. * @param component_id ID of this component (e.g. 200 for IMU)
  82. * @param chan The MAVLink channel this message will be sent over
  83. * @param msg The MAVLink message to compress the data into
  84. * @param breach_status Breach status (0 if currently inside fence, 1 if outside).
  85. * @param breach_count Number of fence breaches.
  86. * @param breach_type Last breach type.
  87. * @param breach_time [ms] Time (since boot) of last breach.
  88. * @param breach_mitigation Active action to prevent fence breach
  89. * @return length of the message in bytes (excluding serial stream start sign)
  90. */
  91. static inline uint16_t mavlink_msg_fence_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  92. mavlink_message_t* msg,
  93. uint8_t breach_status,uint16_t breach_count,uint8_t breach_type,uint32_t breach_time,uint8_t breach_mitigation)
  94. {
  95. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  96. char buf[MAVLINK_MSG_ID_FENCE_STATUS_LEN];
  97. _mav_put_uint32_t(buf, 0, breach_time);
  98. _mav_put_uint16_t(buf, 4, breach_count);
  99. _mav_put_uint8_t(buf, 6, breach_status);
  100. _mav_put_uint8_t(buf, 7, breach_type);
  101. _mav_put_uint8_t(buf, 8, breach_mitigation);
  102. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_STATUS_LEN);
  103. #else
  104. mavlink_fence_status_t packet;
  105. packet.breach_time = breach_time;
  106. packet.breach_count = breach_count;
  107. packet.breach_status = breach_status;
  108. packet.breach_type = breach_type;
  109. packet.breach_mitigation = breach_mitigation;
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_STATUS_LEN);
  111. #endif
  112. msg->msgid = MAVLINK_MSG_ID_FENCE_STATUS;
  113. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  114. }
  115. /**
  116. * @brief Encode a fence_status struct
  117. *
  118. * @param system_id ID of this system
  119. * @param component_id ID of this component (e.g. 200 for IMU)
  120. * @param msg The MAVLink message to compress the data into
  121. * @param fence_status C-struct to read the message contents from
  122. */
  123. static inline uint16_t mavlink_msg_fence_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_fence_status_t* fence_status)
  124. {
  125. return mavlink_msg_fence_status_pack(system_id, component_id, msg, fence_status->breach_status, fence_status->breach_count, fence_status->breach_type, fence_status->breach_time, fence_status->breach_mitigation);
  126. }
  127. /**
  128. * @brief Encode a fence_status struct on a channel
  129. *
  130. * @param system_id ID of this system
  131. * @param component_id ID of this component (e.g. 200 for IMU)
  132. * @param chan The MAVLink channel this message will be sent over
  133. * @param msg The MAVLink message to compress the data into
  134. * @param fence_status C-struct to read the message contents from
  135. */
  136. static inline uint16_t mavlink_msg_fence_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_fence_status_t* fence_status)
  137. {
  138. return mavlink_msg_fence_status_pack_chan(system_id, component_id, chan, msg, fence_status->breach_status, fence_status->breach_count, fence_status->breach_type, fence_status->breach_time, fence_status->breach_mitigation);
  139. }
  140. /**
  141. * @brief Send a fence_status message
  142. * @param chan MAVLink channel to send the message
  143. *
  144. * @param breach_status Breach status (0 if currently inside fence, 1 if outside).
  145. * @param breach_count Number of fence breaches.
  146. * @param breach_type Last breach type.
  147. * @param breach_time [ms] Time (since boot) of last breach.
  148. * @param breach_mitigation Active action to prevent fence breach
  149. */
  150. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  151. static inline void mavlink_msg_fence_status_send(mavlink_channel_t chan, uint8_t breach_status, uint16_t breach_count, uint8_t breach_type, uint32_t breach_time, uint8_t breach_mitigation)
  152. {
  153. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  154. char buf[MAVLINK_MSG_ID_FENCE_STATUS_LEN];
  155. _mav_put_uint32_t(buf, 0, breach_time);
  156. _mav_put_uint16_t(buf, 4, breach_count);
  157. _mav_put_uint8_t(buf, 6, breach_status);
  158. _mav_put_uint8_t(buf, 7, breach_type);
  159. _mav_put_uint8_t(buf, 8, breach_mitigation);
  160. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_STATUS, buf, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  161. #else
  162. mavlink_fence_status_t packet;
  163. packet.breach_time = breach_time;
  164. packet.breach_count = breach_count;
  165. packet.breach_status = breach_status;
  166. packet.breach_type = breach_type;
  167. packet.breach_mitigation = breach_mitigation;
  168. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_STATUS, (const char *)&packet, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  169. #endif
  170. }
  171. /**
  172. * @brief Send a fence_status message
  173. * @param chan MAVLink channel to send the message
  174. * @param struct The MAVLink struct to serialize
  175. */
  176. static inline void mavlink_msg_fence_status_send_struct(mavlink_channel_t chan, const mavlink_fence_status_t* fence_status)
  177. {
  178. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  179. mavlink_msg_fence_status_send(chan, fence_status->breach_status, fence_status->breach_count, fence_status->breach_type, fence_status->breach_time, fence_status->breach_mitigation);
  180. #else
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_STATUS, (const char *)fence_status, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  182. #endif
  183. }
  184. #if MAVLINK_MSG_ID_FENCE_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  185. /*
  186. This varient of _send() can be used to save stack space by re-using
  187. memory from the receive buffer. The caller provides a
  188. mavlink_message_t which is the size of a full mavlink message. This
  189. is usually the receive buffer for the channel, and allows a reply to an
  190. incoming message with minimum stack space usage.
  191. */
  192. static inline void mavlink_msg_fence_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t breach_status, uint16_t breach_count, uint8_t breach_type, uint32_t breach_time, uint8_t breach_mitigation)
  193. {
  194. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  195. char *buf = (char *)msgbuf;
  196. _mav_put_uint32_t(buf, 0, breach_time);
  197. _mav_put_uint16_t(buf, 4, breach_count);
  198. _mav_put_uint8_t(buf, 6, breach_status);
  199. _mav_put_uint8_t(buf, 7, breach_type);
  200. _mav_put_uint8_t(buf, 8, breach_mitigation);
  201. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_STATUS, buf, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  202. #else
  203. mavlink_fence_status_t *packet = (mavlink_fence_status_t *)msgbuf;
  204. packet->breach_time = breach_time;
  205. packet->breach_count = breach_count;
  206. packet->breach_status = breach_status;
  207. packet->breach_type = breach_type;
  208. packet->breach_mitigation = breach_mitigation;
  209. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_STATUS, (const char *)packet, MAVLINK_MSG_ID_FENCE_STATUS_MIN_LEN, MAVLINK_MSG_ID_FENCE_STATUS_LEN, MAVLINK_MSG_ID_FENCE_STATUS_CRC);
  210. #endif
  211. }
  212. #endif
  213. #endif
  214. // MESSAGE FENCE_STATUS UNPACKING
  215. /**
  216. * @brief Get field breach_status from fence_status message
  217. *
  218. * @return Breach status (0 if currently inside fence, 1 if outside).
  219. */
  220. static inline uint8_t mavlink_msg_fence_status_get_breach_status(const mavlink_message_t* msg)
  221. {
  222. return _MAV_RETURN_uint8_t(msg, 6);
  223. }
  224. /**
  225. * @brief Get field breach_count from fence_status message
  226. *
  227. * @return Number of fence breaches.
  228. */
  229. static inline uint16_t mavlink_msg_fence_status_get_breach_count(const mavlink_message_t* msg)
  230. {
  231. return _MAV_RETURN_uint16_t(msg, 4);
  232. }
  233. /**
  234. * @brief Get field breach_type from fence_status message
  235. *
  236. * @return Last breach type.
  237. */
  238. static inline uint8_t mavlink_msg_fence_status_get_breach_type(const mavlink_message_t* msg)
  239. {
  240. return _MAV_RETURN_uint8_t(msg, 7);
  241. }
  242. /**
  243. * @brief Get field breach_time from fence_status message
  244. *
  245. * @return [ms] Time (since boot) of last breach.
  246. */
  247. static inline uint32_t mavlink_msg_fence_status_get_breach_time(const mavlink_message_t* msg)
  248. {
  249. return _MAV_RETURN_uint32_t(msg, 0);
  250. }
  251. /**
  252. * @brief Get field breach_mitigation from fence_status message
  253. *
  254. * @return Active action to prevent fence breach
  255. */
  256. static inline uint8_t mavlink_msg_fence_status_get_breach_mitigation(const mavlink_message_t* msg)
  257. {
  258. return _MAV_RETURN_uint8_t(msg, 8);
  259. }
  260. /**
  261. * @brief Decode a fence_status message into a struct
  262. *
  263. * @param msg The message to decode
  264. * @param fence_status C-struct to decode the message contents into
  265. */
  266. static inline void mavlink_msg_fence_status_decode(const mavlink_message_t* msg, mavlink_fence_status_t* fence_status)
  267. {
  268. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  269. fence_status->breach_time = mavlink_msg_fence_status_get_breach_time(msg);
  270. fence_status->breach_count = mavlink_msg_fence_status_get_breach_count(msg);
  271. fence_status->breach_status = mavlink_msg_fence_status_get_breach_status(msg);
  272. fence_status->breach_type = mavlink_msg_fence_status_get_breach_type(msg);
  273. fence_status->breach_mitigation = mavlink_msg_fence_status_get_breach_mitigation(msg);
  274. #else
  275. uint8_t len = msg->len < MAVLINK_MSG_ID_FENCE_STATUS_LEN? msg->len : MAVLINK_MSG_ID_FENCE_STATUS_LEN;
  276. memset(fence_status, 0, MAVLINK_MSG_ID_FENCE_STATUS_LEN);
  277. memcpy(fence_status, _MAV_PAYLOAD(msg), len);
  278. #endif
  279. }