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 DIAGNOSTIC PACKING
  3. #define MAVLINK_MSG_ID_DIAGNOSTIC 173
  4. MAVPACKED(
  5. typedef struct __mavlink_diagnostic_t {
  6. float diagFl1; /*< Diagnostic float 1*/
  7. float diagFl2; /*< Diagnostic float 2*/
  8. float diagFl3; /*< Diagnostic float 3*/
  9. int16_t diagSh1; /*< Diagnostic short 1*/
  10. int16_t diagSh2; /*< Diagnostic short 2*/
  11. int16_t diagSh3; /*< Diagnostic short 3*/
  12. }) mavlink_diagnostic_t;
  13. #define MAVLINK_MSG_ID_DIAGNOSTIC_LEN 18
  14. #define MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN 18
  15. #define MAVLINK_MSG_ID_173_LEN 18
  16. #define MAVLINK_MSG_ID_173_MIN_LEN 18
  17. #define MAVLINK_MSG_ID_DIAGNOSTIC_CRC 2
  18. #define MAVLINK_MSG_ID_173_CRC 2
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_DIAGNOSTIC { \
  21. 173, \
  22. "DIAGNOSTIC", \
  23. 6, \
  24. { { "diagFl1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_diagnostic_t, diagFl1) }, \
  25. { "diagFl2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_diagnostic_t, diagFl2) }, \
  26. { "diagFl3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_diagnostic_t, diagFl3) }, \
  27. { "diagSh1", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_diagnostic_t, diagSh1) }, \
  28. { "diagSh2", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_diagnostic_t, diagSh2) }, \
  29. { "diagSh3", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_diagnostic_t, diagSh3) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_DIAGNOSTIC { \
  34. "DIAGNOSTIC", \
  35. 6, \
  36. { { "diagFl1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_diagnostic_t, diagFl1) }, \
  37. { "diagFl2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_diagnostic_t, diagFl2) }, \
  38. { "diagFl3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_diagnostic_t, diagFl3) }, \
  39. { "diagSh1", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_diagnostic_t, diagSh1) }, \
  40. { "diagSh2", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_diagnostic_t, diagSh2) }, \
  41. { "diagSh3", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_diagnostic_t, diagSh3) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a diagnostic 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 diagFl1 Diagnostic float 1
  52. * @param diagFl2 Diagnostic float 2
  53. * @param diagFl3 Diagnostic float 3
  54. * @param diagSh1 Diagnostic short 1
  55. * @param diagSh2 Diagnostic short 2
  56. * @param diagSh3 Diagnostic short 3
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_diagnostic_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
  64. _mav_put_float(buf, 0, diagFl1);
  65. _mav_put_float(buf, 4, diagFl2);
  66. _mav_put_float(buf, 8, diagFl3);
  67. _mav_put_int16_t(buf, 12, diagSh1);
  68. _mav_put_int16_t(buf, 14, diagSh2);
  69. _mav_put_int16_t(buf, 16, diagSh3);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
  71. #else
  72. mavlink_diagnostic_t packet;
  73. packet.diagFl1 = diagFl1;
  74. packet.diagFl2 = diagFl2;
  75. packet.diagFl3 = diagFl3;
  76. packet.diagSh1 = diagSh1;
  77. packet.diagSh2 = diagSh2;
  78. packet.diagSh3 = diagSh3;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  83. }
  84. /**
  85. * @brief Pack a diagnostic 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 diagFl1 Diagnostic float 1
  91. * @param diagFl2 Diagnostic float 2
  92. * @param diagFl3 Diagnostic float 3
  93. * @param diagSh1 Diagnostic short 1
  94. * @param diagSh2 Diagnostic short 2
  95. * @param diagSh3 Diagnostic short 3
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_diagnostic_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. float diagFl1,float diagFl2,float diagFl3,int16_t diagSh1,int16_t diagSh2,int16_t diagSh3)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
  104. _mav_put_float(buf, 0, diagFl1);
  105. _mav_put_float(buf, 4, diagFl2);
  106. _mav_put_float(buf, 8, diagFl3);
  107. _mav_put_int16_t(buf, 12, diagSh1);
  108. _mav_put_int16_t(buf, 14, diagSh2);
  109. _mav_put_int16_t(buf, 16, diagSh3);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
  111. #else
  112. mavlink_diagnostic_t packet;
  113. packet.diagFl1 = diagFl1;
  114. packet.diagFl2 = diagFl2;
  115. packet.diagFl3 = diagFl3;
  116. packet.diagSh1 = diagSh1;
  117. packet.diagSh2 = diagSh2;
  118. packet.diagSh3 = diagSh3;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_DIAGNOSTIC;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  123. }
  124. /**
  125. * @brief Encode a diagnostic 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 diagnostic C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_diagnostic_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_diagnostic_t* diagnostic)
  133. {
  134. return mavlink_msg_diagnostic_pack(system_id, component_id, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
  135. }
  136. /**
  137. * @brief Encode a diagnostic 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 diagnostic C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_diagnostic_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_diagnostic_t* diagnostic)
  146. {
  147. return mavlink_msg_diagnostic_pack_chan(system_id, component_id, chan, msg, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
  148. }
  149. /**
  150. * @brief Send a diagnostic message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param diagFl1 Diagnostic float 1
  154. * @param diagFl2 Diagnostic float 2
  155. * @param diagFl3 Diagnostic float 3
  156. * @param diagSh1 Diagnostic short 1
  157. * @param diagSh2 Diagnostic short 2
  158. * @param diagSh3 Diagnostic short 3
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_diagnostic_send(mavlink_channel_t chan, float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_DIAGNOSTIC_LEN];
  165. _mav_put_float(buf, 0, diagFl1);
  166. _mav_put_float(buf, 4, diagFl2);
  167. _mav_put_float(buf, 8, diagFl3);
  168. _mav_put_int16_t(buf, 12, diagSh1);
  169. _mav_put_int16_t(buf, 14, diagSh2);
  170. _mav_put_int16_t(buf, 16, diagSh3);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  172. #else
  173. mavlink_diagnostic_t packet;
  174. packet.diagFl1 = diagFl1;
  175. packet.diagFl2 = diagFl2;
  176. packet.diagFl3 = diagFl3;
  177. packet.diagSh1 = diagSh1;
  178. packet.diagSh2 = diagSh2;
  179. packet.diagSh3 = diagSh3;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)&packet, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a diagnostic 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_diagnostic_send_struct(mavlink_channel_t chan, const mavlink_diagnostic_t* diagnostic)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_diagnostic_send(chan, diagnostic->diagFl1, diagnostic->diagFl2, diagnostic->diagFl3, diagnostic->diagSh1, diagnostic->diagSh2, diagnostic->diagSh3);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)diagnostic, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_DIAGNOSTIC_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_diagnostic_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float diagFl1, float diagFl2, float diagFl3, int16_t diagSh1, int16_t diagSh2, int16_t diagSh3)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_float(buf, 0, diagFl1);
  209. _mav_put_float(buf, 4, diagFl2);
  210. _mav_put_float(buf, 8, diagFl3);
  211. _mav_put_int16_t(buf, 12, diagSh1);
  212. _mav_put_int16_t(buf, 14, diagSh2);
  213. _mav_put_int16_t(buf, 16, diagSh3);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, buf, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  215. #else
  216. mavlink_diagnostic_t *packet = (mavlink_diagnostic_t *)msgbuf;
  217. packet->diagFl1 = diagFl1;
  218. packet->diagFl2 = diagFl2;
  219. packet->diagFl3 = diagFl3;
  220. packet->diagSh1 = diagSh1;
  221. packet->diagSh2 = diagSh2;
  222. packet->diagSh3 = diagSh3;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DIAGNOSTIC, (const char *)packet, MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_LEN, MAVLINK_MSG_ID_DIAGNOSTIC_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE DIAGNOSTIC UNPACKING
  229. /**
  230. * @brief Get field diagFl1 from diagnostic message
  231. *
  232. * @return Diagnostic float 1
  233. */
  234. static inline float mavlink_msg_diagnostic_get_diagFl1(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_float(msg, 0);
  237. }
  238. /**
  239. * @brief Get field diagFl2 from diagnostic message
  240. *
  241. * @return Diagnostic float 2
  242. */
  243. static inline float mavlink_msg_diagnostic_get_diagFl2(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_float(msg, 4);
  246. }
  247. /**
  248. * @brief Get field diagFl3 from diagnostic message
  249. *
  250. * @return Diagnostic float 3
  251. */
  252. static inline float mavlink_msg_diagnostic_get_diagFl3(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_float(msg, 8);
  255. }
  256. /**
  257. * @brief Get field diagSh1 from diagnostic message
  258. *
  259. * @return Diagnostic short 1
  260. */
  261. static inline int16_t mavlink_msg_diagnostic_get_diagSh1(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_int16_t(msg, 12);
  264. }
  265. /**
  266. * @brief Get field diagSh2 from diagnostic message
  267. *
  268. * @return Diagnostic short 2
  269. */
  270. static inline int16_t mavlink_msg_diagnostic_get_diagSh2(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_int16_t(msg, 14);
  273. }
  274. /**
  275. * @brief Get field diagSh3 from diagnostic message
  276. *
  277. * @return Diagnostic short 3
  278. */
  279. static inline int16_t mavlink_msg_diagnostic_get_diagSh3(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_int16_t(msg, 16);
  282. }
  283. /**
  284. * @brief Decode a diagnostic message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param diagnostic C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_diagnostic_decode(const mavlink_message_t* msg, mavlink_diagnostic_t* diagnostic)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. diagnostic->diagFl1 = mavlink_msg_diagnostic_get_diagFl1(msg);
  293. diagnostic->diagFl2 = mavlink_msg_diagnostic_get_diagFl2(msg);
  294. diagnostic->diagFl3 = mavlink_msg_diagnostic_get_diagFl3(msg);
  295. diagnostic->diagSh1 = mavlink_msg_diagnostic_get_diagSh1(msg);
  296. diagnostic->diagSh2 = mavlink_msg_diagnostic_get_diagSh2(msg);
  297. diagnostic->diagSh3 = mavlink_msg_diagnostic_get_diagSh3(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_DIAGNOSTIC_LEN? msg->len : MAVLINK_MSG_ID_DIAGNOSTIC_LEN;
  300. memset(diagnostic, 0, MAVLINK_MSG_ID_DIAGNOSTIC_LEN);
  301. memcpy(diagnostic, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }