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

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