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.

330 lines
15 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE LOGGING_DATA PACKING
  3. #define MAVLINK_MSG_ID_LOGGING_DATA 266
  4. MAVPACKED(
  5. typedef struct __mavlink_logging_data_t {
  6. uint16_t sequence; /*< sequence number (can wrap)*/
  7. uint8_t target_system; /*< system ID of the target*/
  8. uint8_t target_component; /*< component ID of the target*/
  9. uint8_t length; /*< [bytes] data length*/
  10. uint8_t first_message_offset; /*< [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to 255 if no start exists).*/
  11. uint8_t data[249]; /*< logged data*/
  12. }) mavlink_logging_data_t;
  13. #define MAVLINK_MSG_ID_LOGGING_DATA_LEN 255
  14. #define MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN 255
  15. #define MAVLINK_MSG_ID_266_LEN 255
  16. #define MAVLINK_MSG_ID_266_MIN_LEN 255
  17. #define MAVLINK_MSG_ID_LOGGING_DATA_CRC 193
  18. #define MAVLINK_MSG_ID_266_CRC 193
  19. #define MAVLINK_MSG_LOGGING_DATA_FIELD_DATA_LEN 249
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_LOGGING_DATA { \
  22. 266, \
  23. "LOGGING_DATA", \
  24. 6, \
  25. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_logging_data_t, target_system) }, \
  26. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_logging_data_t, target_component) }, \
  27. { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_logging_data_t, sequence) }, \
  28. { "length", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_logging_data_t, length) }, \
  29. { "first_message_offset", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_logging_data_t, first_message_offset) }, \
  30. { "data", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_logging_data_t, data) }, \
  31. } \
  32. }
  33. #else
  34. #define MAVLINK_MESSAGE_INFO_LOGGING_DATA { \
  35. "LOGGING_DATA", \
  36. 6, \
  37. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_logging_data_t, target_system) }, \
  38. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_logging_data_t, target_component) }, \
  39. { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_logging_data_t, sequence) }, \
  40. { "length", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_logging_data_t, length) }, \
  41. { "first_message_offset", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_logging_data_t, first_message_offset) }, \
  42. { "data", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_logging_data_t, data) }, \
  43. } \
  44. }
  45. #endif
  46. /**
  47. * @brief Pack a logging_data message
  48. * @param system_id ID of this system
  49. * @param component_id ID of this component (e.g. 200 for IMU)
  50. * @param msg The MAVLink message to compress the data into
  51. *
  52. * @param target_system system ID of the target
  53. * @param target_component component ID of the target
  54. * @param sequence sequence number (can wrap)
  55. * @param length [bytes] data length
  56. * @param first_message_offset [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to 255 if no start exists).
  57. * @param data logged data
  58. * @return length of the message in bytes (excluding serial stream start sign)
  59. */
  60. static inline uint16_t mavlink_msg_logging_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  61. uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data)
  62. {
  63. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  64. char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
  65. _mav_put_uint16_t(buf, 0, sequence);
  66. _mav_put_uint8_t(buf, 2, target_system);
  67. _mav_put_uint8_t(buf, 3, target_component);
  68. _mav_put_uint8_t(buf, 4, length);
  69. _mav_put_uint8_t(buf, 5, first_message_offset);
  70. _mav_put_uint8_t_array(buf, 6, data, 249);
  71. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
  72. #else
  73. mavlink_logging_data_t packet;
  74. packet.sequence = sequence;
  75. packet.target_system = target_system;
  76. packet.target_component = target_component;
  77. packet.length = length;
  78. packet.first_message_offset = first_message_offset;
  79. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
  80. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
  81. #endif
  82. msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA;
  83. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  84. }
  85. /**
  86. * @brief Pack a logging_data message on a channel
  87. * @param system_id ID of this system
  88. * @param component_id ID of this component (e.g. 200 for IMU)
  89. * @param chan The MAVLink channel this message will be sent over
  90. * @param msg The MAVLink message to compress the data into
  91. * @param target_system system ID of the target
  92. * @param target_component component ID of the target
  93. * @param sequence sequence number (can wrap)
  94. * @param length [bytes] data length
  95. * @param first_message_offset [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to 255 if no start exists).
  96. * @param data logged data
  97. * @return length of the message in bytes (excluding serial stream start sign)
  98. */
  99. static inline uint16_t mavlink_msg_logging_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  100. mavlink_message_t* msg,
  101. uint8_t target_system,uint8_t target_component,uint16_t sequence,uint8_t length,uint8_t first_message_offset,const uint8_t *data)
  102. {
  103. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  104. char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
  105. _mav_put_uint16_t(buf, 0, sequence);
  106. _mav_put_uint8_t(buf, 2, target_system);
  107. _mav_put_uint8_t(buf, 3, target_component);
  108. _mav_put_uint8_t(buf, 4, length);
  109. _mav_put_uint8_t(buf, 5, first_message_offset);
  110. _mav_put_uint8_t_array(buf, 6, data, 249);
  111. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
  112. #else
  113. mavlink_logging_data_t packet;
  114. packet.sequence = sequence;
  115. packet.target_system = target_system;
  116. packet.target_component = target_component;
  117. packet.length = length;
  118. packet.first_message_offset = first_message_offset;
  119. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
  120. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
  121. #endif
  122. msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA;
  123. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  124. }
  125. /**
  126. * @brief Encode a logging_data struct
  127. *
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param msg The MAVLink message to compress the data into
  131. * @param logging_data C-struct to read the message contents from
  132. */
  133. static inline uint16_t mavlink_msg_logging_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_logging_data_t* logging_data)
  134. {
  135. return mavlink_msg_logging_data_pack(system_id, component_id, msg, logging_data->target_system, logging_data->target_component, logging_data->sequence, logging_data->length, logging_data->first_message_offset, logging_data->data);
  136. }
  137. /**
  138. * @brief Encode a logging_data struct on a channel
  139. *
  140. * @param system_id ID of this system
  141. * @param component_id ID of this component (e.g. 200 for IMU)
  142. * @param chan The MAVLink channel this message will be sent over
  143. * @param msg The MAVLink message to compress the data into
  144. * @param logging_data C-struct to read the message contents from
  145. */
  146. static inline uint16_t mavlink_msg_logging_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_logging_data_t* logging_data)
  147. {
  148. return mavlink_msg_logging_data_pack_chan(system_id, component_id, chan, msg, logging_data->target_system, logging_data->target_component, logging_data->sequence, logging_data->length, logging_data->first_message_offset, logging_data->data);
  149. }
  150. /**
  151. * @brief Send a logging_data message
  152. * @param chan MAVLink channel to send the message
  153. *
  154. * @param target_system system ID of the target
  155. * @param target_component component ID of the target
  156. * @param sequence sequence number (can wrap)
  157. * @param length [bytes] data length
  158. * @param first_message_offset [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to 255 if no start exists).
  159. * @param data logged data
  160. */
  161. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  162. static inline void mavlink_msg_logging_data_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data)
  163. {
  164. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  165. char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
  166. _mav_put_uint16_t(buf, 0, sequence);
  167. _mav_put_uint8_t(buf, 2, target_system);
  168. _mav_put_uint8_t(buf, 3, target_component);
  169. _mav_put_uint8_t(buf, 4, length);
  170. _mav_put_uint8_t(buf, 5, first_message_offset);
  171. _mav_put_uint8_t_array(buf, 6, data, 249);
  172. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOGGING_DATA, buf, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  173. #else
  174. mavlink_logging_data_t packet;
  175. packet.sequence = sequence;
  176. packet.target_system = target_system;
  177. packet.target_component = target_component;
  178. packet.length = length;
  179. packet.first_message_offset = first_message_offset;
  180. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOGGING_DATA, (const char *)&packet, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  182. #endif
  183. }
  184. /**
  185. * @brief Send a logging_data message
  186. * @param chan MAVLink channel to send the message
  187. * @param struct The MAVLink struct to serialize
  188. */
  189. static inline void mavlink_msg_logging_data_send_struct(mavlink_channel_t chan, const mavlink_logging_data_t* logging_data)
  190. {
  191. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  192. mavlink_msg_logging_data_send(chan, logging_data->target_system, logging_data->target_component, logging_data->sequence, logging_data->length, logging_data->first_message_offset, logging_data->data);
  193. #else
  194. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOGGING_DATA, (const char *)logging_data, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  195. #endif
  196. }
  197. #if MAVLINK_MSG_ID_LOGGING_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  198. /*
  199. This varient of _send() can be used to save stack space by re-using
  200. memory from the receive buffer. The caller provides a
  201. mavlink_message_t which is the size of a full mavlink message. This
  202. is usually the receive buffer for the channel, and allows a reply to an
  203. incoming message with minimum stack space usage.
  204. */
  205. static inline void mavlink_msg_logging_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data)
  206. {
  207. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  208. char *buf = (char *)msgbuf;
  209. _mav_put_uint16_t(buf, 0, sequence);
  210. _mav_put_uint8_t(buf, 2, target_system);
  211. _mav_put_uint8_t(buf, 3, target_component);
  212. _mav_put_uint8_t(buf, 4, length);
  213. _mav_put_uint8_t(buf, 5, first_message_offset);
  214. _mav_put_uint8_t_array(buf, 6, data, 249);
  215. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOGGING_DATA, buf, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  216. #else
  217. mavlink_logging_data_t *packet = (mavlink_logging_data_t *)msgbuf;
  218. packet->sequence = sequence;
  219. packet->target_system = target_system;
  220. packet->target_component = target_component;
  221. packet->length = length;
  222. packet->first_message_offset = first_message_offset;
  223. mav_array_memcpy(packet->data, data, sizeof(uint8_t)*249);
  224. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOGGING_DATA, (const char *)packet, MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN, MAVLINK_MSG_ID_LOGGING_DATA_LEN, MAVLINK_MSG_ID_LOGGING_DATA_CRC);
  225. #endif
  226. }
  227. #endif
  228. #endif
  229. // MESSAGE LOGGING_DATA UNPACKING
  230. /**
  231. * @brief Get field target_system from logging_data message
  232. *
  233. * @return system ID of the target
  234. */
  235. static inline uint8_t mavlink_msg_logging_data_get_target_system(const mavlink_message_t* msg)
  236. {
  237. return _MAV_RETURN_uint8_t(msg, 2);
  238. }
  239. /**
  240. * @brief Get field target_component from logging_data message
  241. *
  242. * @return component ID of the target
  243. */
  244. static inline uint8_t mavlink_msg_logging_data_get_target_component(const mavlink_message_t* msg)
  245. {
  246. return _MAV_RETURN_uint8_t(msg, 3);
  247. }
  248. /**
  249. * @brief Get field sequence from logging_data message
  250. *
  251. * @return sequence number (can wrap)
  252. */
  253. static inline uint16_t mavlink_msg_logging_data_get_sequence(const mavlink_message_t* msg)
  254. {
  255. return _MAV_RETURN_uint16_t(msg, 0);
  256. }
  257. /**
  258. * @brief Get field length from logging_data message
  259. *
  260. * @return [bytes] data length
  261. */
  262. static inline uint8_t mavlink_msg_logging_data_get_length(const mavlink_message_t* msg)
  263. {
  264. return _MAV_RETURN_uint8_t(msg, 4);
  265. }
  266. /**
  267. * @brief Get field first_message_offset from logging_data message
  268. *
  269. * @return [bytes] offset into data where first message starts. This can be used for recovery, when a previous message got lost (set to 255 if no start exists).
  270. */
  271. static inline uint8_t mavlink_msg_logging_data_get_first_message_offset(const mavlink_message_t* msg)
  272. {
  273. return _MAV_RETURN_uint8_t(msg, 5);
  274. }
  275. /**
  276. * @brief Get field data from logging_data message
  277. *
  278. * @return logged data
  279. */
  280. static inline uint16_t mavlink_msg_logging_data_get_data(const mavlink_message_t* msg, uint8_t *data)
  281. {
  282. return _MAV_RETURN_uint8_t_array(msg, data, 249, 6);
  283. }
  284. /**
  285. * @brief Decode a logging_data message into a struct
  286. *
  287. * @param msg The message to decode
  288. * @param logging_data C-struct to decode the message contents into
  289. */
  290. static inline void mavlink_msg_logging_data_decode(const mavlink_message_t* msg, mavlink_logging_data_t* logging_data)
  291. {
  292. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  293. logging_data->sequence = mavlink_msg_logging_data_get_sequence(msg);
  294. logging_data->target_system = mavlink_msg_logging_data_get_target_system(msg);
  295. logging_data->target_component = mavlink_msg_logging_data_get_target_component(msg);
  296. logging_data->length = mavlink_msg_logging_data_get_length(msg);
  297. logging_data->first_message_offset = mavlink_msg_logging_data_get_first_message_offset(msg);
  298. mavlink_msg_logging_data_get_data(msg, logging_data->data);
  299. #else
  300. uint8_t len = msg->len < MAVLINK_MSG_ID_LOGGING_DATA_LEN? msg->len : MAVLINK_MSG_ID_LOGGING_DATA_LEN;
  301. memset(logging_data, 0, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
  302. memcpy(logging_data, _MAV_PAYLOAD(msg), len);
  303. #endif
  304. }