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
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE FENCE_POINT PACKING
  3. #define MAVLINK_MSG_ID_FENCE_POINT 160
  4. MAVPACKED(
  5. typedef struct __mavlink_fence_point_t {
  6. float lat; /*< [deg] Latitude of point.*/
  7. float lng; /*< [deg] Longitude of point.*/
  8. uint8_t target_system; /*< System ID.*/
  9. uint8_t target_component; /*< Component ID.*/
  10. uint8_t idx; /*< Point index (first point is 1, 0 is for return point).*/
  11. uint8_t count; /*< Total number of points (for sanity checking).*/
  12. }) mavlink_fence_point_t;
  13. #define MAVLINK_MSG_ID_FENCE_POINT_LEN 12
  14. #define MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN 12
  15. #define MAVLINK_MSG_ID_160_LEN 12
  16. #define MAVLINK_MSG_ID_160_MIN_LEN 12
  17. #define MAVLINK_MSG_ID_FENCE_POINT_CRC 78
  18. #define MAVLINK_MSG_ID_160_CRC 78
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_FENCE_POINT { \
  21. 160, \
  22. "FENCE_POINT", \
  23. 6, \
  24. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_point_t, target_system) }, \
  25. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_fence_point_t, target_component) }, \
  26. { "idx", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_fence_point_t, idx) }, \
  27. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_fence_point_t, count) }, \
  28. { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_fence_point_t, lat) }, \
  29. { "lng", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_fence_point_t, lng) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_FENCE_POINT { \
  34. "FENCE_POINT", \
  35. 6, \
  36. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_point_t, target_system) }, \
  37. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_fence_point_t, target_component) }, \
  38. { "idx", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_fence_point_t, idx) }, \
  39. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_fence_point_t, count) }, \
  40. { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_fence_point_t, lat) }, \
  41. { "lng", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_fence_point_t, lng) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a fence_point 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 target_system System ID.
  52. * @param target_component Component ID.
  53. * @param idx Point index (first point is 1, 0 is for return point).
  54. * @param count Total number of points (for sanity checking).
  55. * @param lat [deg] Latitude of point.
  56. * @param lng [deg] Longitude of point.
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_fence_point_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
  64. _mav_put_float(buf, 0, lat);
  65. _mav_put_float(buf, 4, lng);
  66. _mav_put_uint8_t(buf, 8, target_system);
  67. _mav_put_uint8_t(buf, 9, target_component);
  68. _mav_put_uint8_t(buf, 10, idx);
  69. _mav_put_uint8_t(buf, 11, count);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_POINT_LEN);
  71. #else
  72. mavlink_fence_point_t packet;
  73. packet.lat = lat;
  74. packet.lng = lng;
  75. packet.target_system = target_system;
  76. packet.target_component = target_component;
  77. packet.idx = idx;
  78. packet.count = count;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_POINT_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_FENCE_POINT;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  83. }
  84. /**
  85. * @brief Pack a fence_point 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 target_system System ID.
  91. * @param target_component Component ID.
  92. * @param idx Point index (first point is 1, 0 is for return point).
  93. * @param count Total number of points (for sanity checking).
  94. * @param lat [deg] Latitude of point.
  95. * @param lng [deg] Longitude of point.
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_fence_point_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. uint8_t target_system,uint8_t target_component,uint8_t idx,uint8_t count,float lat,float lng)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
  104. _mav_put_float(buf, 0, lat);
  105. _mav_put_float(buf, 4, lng);
  106. _mav_put_uint8_t(buf, 8, target_system);
  107. _mav_put_uint8_t(buf, 9, target_component);
  108. _mav_put_uint8_t(buf, 10, idx);
  109. _mav_put_uint8_t(buf, 11, count);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_POINT_LEN);
  111. #else
  112. mavlink_fence_point_t packet;
  113. packet.lat = lat;
  114. packet.lng = lng;
  115. packet.target_system = target_system;
  116. packet.target_component = target_component;
  117. packet.idx = idx;
  118. packet.count = count;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_POINT_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_FENCE_POINT;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  123. }
  124. /**
  125. * @brief Encode a fence_point 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 fence_point C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_fence_point_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_fence_point_t* fence_point)
  133. {
  134. return mavlink_msg_fence_point_pack(system_id, component_id, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
  135. }
  136. /**
  137. * @brief Encode a fence_point 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 fence_point C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_fence_point_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_fence_point_t* fence_point)
  146. {
  147. return mavlink_msg_fence_point_pack_chan(system_id, component_id, chan, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
  148. }
  149. /**
  150. * @brief Send a fence_point message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param target_system System ID.
  154. * @param target_component Component ID.
  155. * @param idx Point index (first point is 1, 0 is for return point).
  156. * @param count Total number of points (for sanity checking).
  157. * @param lat [deg] Latitude of point.
  158. * @param lng [deg] Longitude of point.
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_fence_point_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
  165. _mav_put_float(buf, 0, lat);
  166. _mav_put_float(buf, 4, lng);
  167. _mav_put_uint8_t(buf, 8, target_system);
  168. _mav_put_uint8_t(buf, 9, target_component);
  169. _mav_put_uint8_t(buf, 10, idx);
  170. _mav_put_uint8_t(buf, 11, count);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, buf, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  172. #else
  173. mavlink_fence_point_t packet;
  174. packet.lat = lat;
  175. packet.lng = lng;
  176. packet.target_system = target_system;
  177. packet.target_component = target_component;
  178. packet.idx = idx;
  179. packet.count = count;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)&packet, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a fence_point 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_fence_point_send_struct(mavlink_channel_t chan, const mavlink_fence_point_t* fence_point)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_fence_point_send(chan, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)fence_point, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_FENCE_POINT_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_fence_point_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_float(buf, 0, lat);
  209. _mav_put_float(buf, 4, lng);
  210. _mav_put_uint8_t(buf, 8, target_system);
  211. _mav_put_uint8_t(buf, 9, target_component);
  212. _mav_put_uint8_t(buf, 10, idx);
  213. _mav_put_uint8_t(buf, 11, count);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, buf, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  215. #else
  216. mavlink_fence_point_t *packet = (mavlink_fence_point_t *)msgbuf;
  217. packet->lat = lat;
  218. packet->lng = lng;
  219. packet->target_system = target_system;
  220. packet->target_component = target_component;
  221. packet->idx = idx;
  222. packet->count = count;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)packet, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE FENCE_POINT UNPACKING
  229. /**
  230. * @brief Get field target_system from fence_point message
  231. *
  232. * @return System ID.
  233. */
  234. static inline uint8_t mavlink_msg_fence_point_get_target_system(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_uint8_t(msg, 8);
  237. }
  238. /**
  239. * @brief Get field target_component from fence_point message
  240. *
  241. * @return Component ID.
  242. */
  243. static inline uint8_t mavlink_msg_fence_point_get_target_component(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_uint8_t(msg, 9);
  246. }
  247. /**
  248. * @brief Get field idx from fence_point message
  249. *
  250. * @return Point index (first point is 1, 0 is for return point).
  251. */
  252. static inline uint8_t mavlink_msg_fence_point_get_idx(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_uint8_t(msg, 10);
  255. }
  256. /**
  257. * @brief Get field count from fence_point message
  258. *
  259. * @return Total number of points (for sanity checking).
  260. */
  261. static inline uint8_t mavlink_msg_fence_point_get_count(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_uint8_t(msg, 11);
  264. }
  265. /**
  266. * @brief Get field lat from fence_point message
  267. *
  268. * @return [deg] Latitude of point.
  269. */
  270. static inline float mavlink_msg_fence_point_get_lat(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_float(msg, 0);
  273. }
  274. /**
  275. * @brief Get field lng from fence_point message
  276. *
  277. * @return [deg] Longitude of point.
  278. */
  279. static inline float mavlink_msg_fence_point_get_lng(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_float(msg, 4);
  282. }
  283. /**
  284. * @brief Decode a fence_point message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param fence_point C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_fence_point_decode(const mavlink_message_t* msg, mavlink_fence_point_t* fence_point)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. fence_point->lat = mavlink_msg_fence_point_get_lat(msg);
  293. fence_point->lng = mavlink_msg_fence_point_get_lng(msg);
  294. fence_point->target_system = mavlink_msg_fence_point_get_target_system(msg);
  295. fence_point->target_component = mavlink_msg_fence_point_get_target_component(msg);
  296. fence_point->idx = mavlink_msg_fence_point_get_idx(msg);
  297. fence_point->count = mavlink_msg_fence_point_get_count(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_FENCE_POINT_LEN? msg->len : MAVLINK_MSG_ID_FENCE_POINT_LEN;
  300. memset(fence_point, 0, MAVLINK_MSG_ID_FENCE_POINT_LEN);
  301. memcpy(fence_point, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }