Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_log_entry.h
blob3020dc74e6f2f2f4037f0984be94dd29945e797b
1 #pragma once
2 // MESSAGE LOG_ENTRY PACKING
4 #define MAVLINK_MSG_ID_LOG_ENTRY 118
7 typedef struct __mavlink_log_entry_t {
8 uint32_t time_utc; /*< [s] UTC timestamp of log since 1970, or 0 if not available*/
9 uint32_t size; /*< [bytes] Size of the log (may be approximate)*/
10 uint16_t id; /*< Log id*/
11 uint16_t num_logs; /*< Total number of logs*/
12 uint16_t last_log_num; /*< High log number*/
13 } mavlink_log_entry_t;
15 #define MAVLINK_MSG_ID_LOG_ENTRY_LEN 14
16 #define MAVLINK_MSG_ID_LOG_ENTRY_MIN_LEN 14
17 #define MAVLINK_MSG_ID_118_LEN 14
18 #define MAVLINK_MSG_ID_118_MIN_LEN 14
20 #define MAVLINK_MSG_ID_LOG_ENTRY_CRC 56
21 #define MAVLINK_MSG_ID_118_CRC 56
25 #if MAVLINK_COMMAND_24BIT
26 #define MAVLINK_MESSAGE_INFO_LOG_ENTRY { \
27 118, \
28 "LOG_ENTRY", \
29 5, \
30 { { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_log_entry_t, id) }, \
31 { "num_logs", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_log_entry_t, num_logs) }, \
32 { "last_log_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_log_entry_t, last_log_num) }, \
33 { "time_utc", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_entry_t, time_utc) }, \
34 { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_log_entry_t, size) }, \
35 } \
37 #else
38 #define MAVLINK_MESSAGE_INFO_LOG_ENTRY { \
39 "LOG_ENTRY", \
40 5, \
41 { { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_log_entry_t, id) }, \
42 { "num_logs", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_log_entry_t, num_logs) }, \
43 { "last_log_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_log_entry_t, last_log_num) }, \
44 { "time_utc", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_entry_t, time_utc) }, \
45 { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_log_entry_t, size) }, \
46 } \
48 #endif
50 /**
51 * @brief Pack a log_entry message
52 * @param system_id ID of this system
53 * @param component_id ID of this component (e.g. 200 for IMU)
54 * @param msg The MAVLink message to compress the data into
56 * @param id Log id
57 * @param num_logs Total number of logs
58 * @param last_log_num High log number
59 * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
60 * @param size [bytes] Size of the log (may be approximate)
61 * @return length of the message in bytes (excluding serial stream start sign)
63 static inline uint16_t mavlink_msg_log_entry_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
64 uint16_t id, uint16_t num_logs, uint16_t last_log_num, uint32_t time_utc, uint32_t size)
66 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67 char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
68 _mav_put_uint32_t(buf, 0, time_utc);
69 _mav_put_uint32_t(buf, 4, size);
70 _mav_put_uint16_t(buf, 8, id);
71 _mav_put_uint16_t(buf, 10, num_logs);
72 _mav_put_uint16_t(buf, 12, last_log_num);
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
75 #else
76 mavlink_log_entry_t packet;
77 packet.time_utc = time_utc;
78 packet.size = size;
79 packet.id = id;
80 packet.num_logs = num_logs;
81 packet.last_log_num = last_log_num;
83 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
84 #endif
86 msg->msgid = MAVLINK_MSG_ID_LOG_ENTRY;
87 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);
90 /**
91 * @brief Pack a log_entry message on a channel
92 * @param system_id ID of this system
93 * @param component_id ID of this component (e.g. 200 for IMU)
94 * @param chan The MAVLink channel this message will be sent over
95 * @param msg The MAVLink message to compress the data into
96 * @param id Log id
97 * @param num_logs Total number of logs
98 * @param last_log_num High log number
99 * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
100 * @param size [bytes] Size of the log (may be approximate)
101 * @return length of the message in bytes (excluding serial stream start sign)
103 static inline uint16_t mavlink_msg_log_entry_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
104 mavlink_message_t* msg,
105 uint16_t id,uint16_t num_logs,uint16_t last_log_num,uint32_t time_utc,uint32_t size)
107 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
109 _mav_put_uint32_t(buf, 0, time_utc);
110 _mav_put_uint32_t(buf, 4, size);
111 _mav_put_uint16_t(buf, 8, id);
112 _mav_put_uint16_t(buf, 10, num_logs);
113 _mav_put_uint16_t(buf, 12, last_log_num);
115 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
116 #else
117 mavlink_log_entry_t packet;
118 packet.time_utc = time_utc;
119 packet.size = size;
120 packet.id = id;
121 packet.num_logs = num_logs;
122 packet.last_log_num = last_log_num;
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
125 #endif
127 msg->msgid = MAVLINK_MSG_ID_LOG_ENTRY;
128 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);
132 * @brief Encode a log_entry struct
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param msg The MAVLink message to compress the data into
137 * @param log_entry C-struct to read the message contents from
139 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)
141 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);
145 * @brief Encode a log_entry struct on a channel
147 * @param system_id ID of this system
148 * @param component_id ID of this component (e.g. 200 for IMU)
149 * @param chan The MAVLink channel this message will be sent over
150 * @param msg The MAVLink message to compress the data into
151 * @param log_entry C-struct to read the message contents from
153 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)
155 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);
159 * @brief Send a log_entry message
160 * @param chan MAVLink channel to send the message
162 * @param id Log id
163 * @param num_logs Total number of logs
164 * @param last_log_num High log number
165 * @param time_utc [s] UTC timestamp of log since 1970, or 0 if not available
166 * @param size [bytes] Size of the log (may be approximate)
168 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 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)
172 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
173 char buf[MAVLINK_MSG_ID_LOG_ENTRY_LEN];
174 _mav_put_uint32_t(buf, 0, time_utc);
175 _mav_put_uint32_t(buf, 4, size);
176 _mav_put_uint16_t(buf, 8, id);
177 _mav_put_uint16_t(buf, 10, num_logs);
178 _mav_put_uint16_t(buf, 12, last_log_num);
180 _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);
181 #else
182 mavlink_log_entry_t packet;
183 packet.time_utc = time_utc;
184 packet.size = size;
185 packet.id = id;
186 packet.num_logs = num_logs;
187 packet.last_log_num = last_log_num;
189 _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);
190 #endif
194 * @brief Send a log_entry message
195 * @param chan MAVLink channel to send the message
196 * @param struct The MAVLink struct to serialize
198 static inline void mavlink_msg_log_entry_send_struct(mavlink_channel_t chan, const mavlink_log_entry_t* log_entry)
200 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
201 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);
202 #else
203 _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);
204 #endif
207 #if MAVLINK_MSG_ID_LOG_ENTRY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
209 This varient of _send() can be used to save stack space by re-using
210 memory from the receive buffer. The caller provides a
211 mavlink_message_t which is the size of a full mavlink message. This
212 is usually the receive buffer for the channel, and allows a reply to an
213 incoming message with minimum stack space usage.
215 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)
217 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
218 char *buf = (char *)msgbuf;
219 _mav_put_uint32_t(buf, 0, time_utc);
220 _mav_put_uint32_t(buf, 4, size);
221 _mav_put_uint16_t(buf, 8, id);
222 _mav_put_uint16_t(buf, 10, num_logs);
223 _mav_put_uint16_t(buf, 12, last_log_num);
225 _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);
226 #else
227 mavlink_log_entry_t *packet = (mavlink_log_entry_t *)msgbuf;
228 packet->time_utc = time_utc;
229 packet->size = size;
230 packet->id = id;
231 packet->num_logs = num_logs;
232 packet->last_log_num = last_log_num;
234 _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);
235 #endif
237 #endif
239 #endif
241 // MESSAGE LOG_ENTRY UNPACKING
245 * @brief Get field id from log_entry message
247 * @return Log id
249 static inline uint16_t mavlink_msg_log_entry_get_id(const mavlink_message_t* msg)
251 return _MAV_RETURN_uint16_t(msg, 8);
255 * @brief Get field num_logs from log_entry message
257 * @return Total number of logs
259 static inline uint16_t mavlink_msg_log_entry_get_num_logs(const mavlink_message_t* msg)
261 return _MAV_RETURN_uint16_t(msg, 10);
265 * @brief Get field last_log_num from log_entry message
267 * @return High log number
269 static inline uint16_t mavlink_msg_log_entry_get_last_log_num(const mavlink_message_t* msg)
271 return _MAV_RETURN_uint16_t(msg, 12);
275 * @brief Get field time_utc from log_entry message
277 * @return [s] UTC timestamp of log since 1970, or 0 if not available
279 static inline uint32_t mavlink_msg_log_entry_get_time_utc(const mavlink_message_t* msg)
281 return _MAV_RETURN_uint32_t(msg, 0);
285 * @brief Get field size from log_entry message
287 * @return [bytes] Size of the log (may be approximate)
289 static inline uint32_t mavlink_msg_log_entry_get_size(const mavlink_message_t* msg)
291 return _MAV_RETURN_uint32_t(msg, 4);
295 * @brief Decode a log_entry message into a struct
297 * @param msg The message to decode
298 * @param log_entry C-struct to decode the message contents into
300 static inline void mavlink_msg_log_entry_decode(const mavlink_message_t* msg, mavlink_log_entry_t* log_entry)
302 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
303 log_entry->time_utc = mavlink_msg_log_entry_get_time_utc(msg);
304 log_entry->size = mavlink_msg_log_entry_get_size(msg);
305 log_entry->id = mavlink_msg_log_entry_get_id(msg);
306 log_entry->num_logs = mavlink_msg_log_entry_get_num_logs(msg);
307 log_entry->last_log_num = mavlink_msg_log_entry_get_last_log_num(msg);
308 #else
309 uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_ENTRY_LEN? msg->len : MAVLINK_MSG_ID_LOG_ENTRY_LEN;
310 memset(log_entry, 0, MAVLINK_MSG_ID_LOG_ENTRY_LEN);
311 memcpy(log_entry, _MAV_PAYLOAD(msg), len);
312 #endif