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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE LOG_ENTRY PACKING
  3. #define MAVLINK_MSG_ID_LOG_ENTRY 118
  4. MAVPACKED(
  5. typedef struct __mavlink_log_entry_t {
  6. uint32_t time_utc; /*< [s] UTC timestamp of log since 1970, or 0 if not available*/
  7. uint32_t size; /*< [bytes] Size of the log (may be approximate)*/
  8. uint16_t id; /*< Log id*/
  9. uint16_t num_logs; /*< Total number of logs*/
  10. uint16_t last_log_num; /*< High log number*/
  11. }) mavlink_log_entry_t;
  12. #define MAVLINK_MSG_ID_LOG_ENTRY_LEN 14
  13. #define MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN 14
  14. #define MAVLINK_MSG_ID_118_LEN 14
  15. #define MAVLINK_MSG_ID_118_MIN_LEN 14
  16. #define MAVLINK_MSG_ID_LOG_ENTRY_CRC 56
  17. #define MAVLINK_MSG_ID_118_CRC 56
  18. #if MAVLINK_COMMAND_24BIT
  19. #define MAVLINK_MESSAGE_INFO_LOG_ENTRY { \
  20. 118, \
  21. "LOG_ENTRY", \
  22. 5, \
  23. { { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_log_entry_t, id) }, \
  24. { "num_logs", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_log_entry_t, num_logs) }, \
  25. { "last_log_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_log_entry_t, last_log_num) }, \
  26. { "time_utc", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_entry_t, time_utc) }, \
  27. { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_log_entry_t, size) }, \
  28. } \
  29. }
  30. #else
  31. #define MAVLINK_MESSAGE_INFO_LOG_ENTRY { \
  32. "LOG_ENTRY", \
  33. 5, \
  34. { { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_log_entry_t, id) }, \
  35. { "num_logs", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_log_entry_t, num_logs) }, \
  36. { "last_log_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_log_entry_t, last_log_num) }, \
  37. { "time_utc", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_entry_t, time_utc) }, \
  38. { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_log_entry_t, size) }, \
  39. } \
  40. }
  41. #endif
  42. /**
  43. * @brief Pack a log_entry 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 id Log id
  49. * @param num_logs Total number of logs
  50. * @param last_log_num High log number
  51. * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
  52. * @param size [bytes] Size of the log (may be approximate)
  53. * @return length of the message in bytes (excluding serial stream start sign)
  54. */
  55. static inline uint16_t mavlink_msg_log_entry_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  56. uint16_t id, uint16_t num_logs, uint16_t last_log_num, uint32_t time_utc, uint32_t size)
  57. {
  58. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  59. char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
  60. _mav_put_uint32_t(buf, 0, time_utc);
  61. _mav_put_uint32_t(buf, 4, size);
  62. _mav_put_uint16_t(buf, 8, id);
  63. _mav_put_uint16_t(buf, 10, num_logs);
  64. _mav_put_uint16_t(buf, 12, last_log_num);
  65. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
  66. #else
  67. mavlink_log_entry_t packet;
  68. packet.time_utc = time_utc;
  69. packet.size = size;
  70. packet.id = id;
  71. packet.num_logs = num_logs;
  72. packet.last_log_num = last_log_num;
  73. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
  74. #endif
  75. msg->msgid = MAVLINK_MSG_ID_LOG_ENTRY;
  76. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  77. }
  78. /**
  79. * @brief Pack a log_entry 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 id Log id
  85. * @param num_logs Total number of logs
  86. * @param last_log_num High log number
  87. * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
  88. * @param size [bytes] Size of the log (may be approximate)
  89. * @return length of the message in bytes (excluding serial stream start sign)
  90. */
  91. static inline uint16_t mavlink_msg_log_entry_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  92. mavlink_message_t* msg,
  93. uint16_t id,uint16_t num_logs,uint16_t last_log_num,uint32_t time_utc,uint32_t size)
  94. {
  95. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  96. char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
  97. _mav_put_uint32_t(buf, 0, time_utc);
  98. _mav_put_uint32_t(buf, 4, size);
  99. _mav_put_uint16_t(buf, 8, id);
  100. _mav_put_uint16_t(buf, 10, num_logs);
  101. _mav_put_uint16_t(buf, 12, last_log_num);
  102. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
  103. #else
  104. mavlink_log_entry_t packet;
  105. packet.time_utc = time_utc;
  106. packet.size = size;
  107. packet.id = id;
  108. packet.num_logs = num_logs;
  109. packet.last_log_num = last_log_num;
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
  111. #endif
  112. msg->msgid = MAVLINK_MSG_ID_LOG_ENTRY;
  113. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  114. }
  115. /**
  116. * @brief Encode a log_entry 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 log_entry C-struct to read the message contents from
  122. */
  123. static inline uint16_t mavlink_msg_log_entry_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_entry_t* log_entry)
  124. {
  125. return mavlink_msg_log_entry_pack(system_id, component_id, msg, log_entry->id, log_entry->num_logs, log_entry->last_log_num, log_entry->time_utc, log_entry->size);
  126. }
  127. /**
  128. * @brief Encode a log_entry 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 log_entry C-struct to read the message contents from
  135. */
  136. static inline uint16_t mavlink_msg_log_entry_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_entry_t* log_entry)
  137. {
  138. return mavlink_msg_log_entry_pack_chan(system_id, component_id, chan, msg, log_entry->id, log_entry->num_logs, log_entry->last_log_num, log_entry->time_utc, log_entry->size);
  139. }
  140. /**
  141. * @brief Send a log_entry message
  142. * @param chan MAVLink channel to send the message
  143. *
  144. * @param id Log id
  145. * @param num_logs Total number of logs
  146. * @param last_log_num High log number
  147. * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
  148. * @param size [bytes] Size of the log (may be approximate)
  149. */
  150. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  151. static inline void mavlink_msg_log_entry_send(mavlink_channel_t chan, uint16_t id, uint16_t num_logs, uint16_t last_log_num, uint32_t time_utc, uint32_t size)
  152. {
  153. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  154. char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
  155. _mav_put_uint32_t(buf, 0, time_utc);
  156. _mav_put_uint32_t(buf, 4, size);
  157. _mav_put_uint16_t(buf, 8, id);
  158. _mav_put_uint16_t(buf, 10, num_logs);
  159. _mav_put_uint16_t(buf, 12, last_log_num);
  160. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ENTRY, buf, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  161. #else
  162. mavlink_log_entry_t packet;
  163. packet.time_utc = time_utc;
  164. packet.size = size;
  165. packet.id = id;
  166. packet.num_logs = num_logs;
  167. packet.last_log_num = last_log_num;
  168. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ENTRY, (const char *)&packet, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  169. #endif
  170. }
  171. /**
  172. * @brief Send a log_entry 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_log_entry_send_struct(mavlink_channel_t chan, const mavlink_log_entry_t* log_entry)
  177. {
  178. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  179. mavlink_msg_log_entry_send(chan, log_entry->id, log_entry->num_logs, log_entry->last_log_num, log_entry->time_utc, log_entry->size);
  180. #else
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ENTRY, (const char *)log_entry, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  182. #endif
  183. }
  184. #if MAVLINK_MSG_ID_LOG_ENTRY_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_log_entry_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t id, uint16_t num_logs, uint16_t last_log_num, uint32_t time_utc, uint32_t size)
  193. {
  194. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  195. char *buf = (char *)msgbuf;
  196. _mav_put_uint32_t(buf, 0, time_utc);
  197. _mav_put_uint32_t(buf, 4, size);
  198. _mav_put_uint16_t(buf, 8, id);
  199. _mav_put_uint16_t(buf, 10, num_logs);
  200. _mav_put_uint16_t(buf, 12, last_log_num);
  201. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ENTRY, buf, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  202. #else
  203. mavlink_log_entry_t *packet = (mavlink_log_entry_t *)msgbuf;
  204. packet->time_utc = time_utc;
  205. packet->size = size;
  206. packet->id = id;
  207. packet->num_logs = num_logs;
  208. packet->last_log_num = last_log_num;
  209. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_ENTRY, (const char *)packet, MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN, MAVLINK_MSG_ID_LOG_ENTRY_LEN, MAVLINK_MSG_ID_LOG_ENTRY_CRC);
  210. #endif
  211. }
  212. #endif
  213. #endif
  214. // MESSAGE LOG_ENTRY UNPACKING
  215. /**
  216. * @brief Get field id from log_entry message
  217. *
  218. * @return Log id
  219. */
  220. static inline uint16_t mavlink_msg_log_entry_get_id(const mavlink_message_t* msg)
  221. {
  222. return _MAV_RETURN_uint16_t(msg, 8);
  223. }
  224. /**
  225. * @brief Get field num_logs from log_entry message
  226. *
  227. * @return Total number of logs
  228. */
  229. static inline uint16_t mavlink_msg_log_entry_get_num_logs(const mavlink_message_t* msg)
  230. {
  231. return _MAV_RETURN_uint16_t(msg, 10);
  232. }
  233. /**
  234. * @brief Get field last_log_num from log_entry message
  235. *
  236. * @return High log number
  237. */
  238. static inline uint16_t mavlink_msg_log_entry_get_last_log_num(const mavlink_message_t* msg)
  239. {
  240. return _MAV_RETURN_uint16_t(msg, 12);
  241. }
  242. /**
  243. * @brief Get field time_utc from log_entry message
  244. *
  245. * @return [s] UTC timestamp of log since 1970, or 0 if not available
  246. */
  247. static inline uint32_t mavlink_msg_log_entry_get_time_utc(const mavlink_message_t* msg)
  248. {
  249. return _MAV_RETURN_uint32_t(msg, 0);
  250. }
  251. /**
  252. * @brief Get field size from log_entry message
  253. *
  254. * @return [bytes] Size of the log (may be approximate)
  255. */
  256. static inline uint32_t mavlink_msg_log_entry_get_size(const mavlink_message_t* msg)
  257. {
  258. return _MAV_RETURN_uint32_t(msg, 4);
  259. }
  260. /**
  261. * @brief Decode a log_entry message into a struct
  262. *
  263. * @param msg The message to decode
  264. * @param log_entry C-struct to decode the message contents into
  265. */
  266. static inline void mavlink_msg_log_entry_decode(const mavlink_message_t* msg, mavlink_log_entry_t* log_entry)
  267. {
  268. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  269. log_entry->time_utc = mavlink_msg_log_entry_get_time_utc(msg);
  270. log_entry->size = mavlink_msg_log_entry_get_size(msg);
  271. log_entry->id = mavlink_msg_log_entry_get_id(msg);
  272. log_entry->num_logs = mavlink_msg_log_entry_get_num_logs(msg);
  273. log_entry->last_log_num = mavlink_msg_log_entry_get_last_log_num(msg);
  274. #else
  275. uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_ENTRY_LEN? msg->len : MAVLINK_MSG_ID_LOG_ENTRY_LEN;
  276. memset(log_entry, 0, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
  277. memcpy(log_entry, _MAV_PAYLOAD(msg), len);
  278. #endif
  279. }