Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_logging_data.h
blobc9bf0559ded90b27ed8f537d2700da2f5136a12f
1 #pragma once
2 // MESSAGE LOGGING_DATA PACKING
4 #define MAVLINK_MSG_ID_LOGGING_DATA 266
7 typedef struct __mavlink_logging_data_t {
8 uint16_t sequence; /*< sequence number (can wrap)*/
9 uint8_t target_system; /*< system ID of the target*/
10 uint8_t target_component; /*< component ID of the target*/
11 uint8_t length; /*< [bytes] data length*/
12 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).*/
13 uint8_t data[249]; /*< logged data*/
14 } mavlink_logging_data_t;
16 #define MAVLINK_MSG_ID_LOGGING_DATA_LEN 255
17 #define MAVLINK_MSG_ID_LOGGING_DATA_MIN_LEN 255
18 #define MAVLINK_MSG_ID_266_LEN 255
19 #define MAVLINK_MSG_ID_266_MIN_LEN 255
21 #define MAVLINK_MSG_ID_LOGGING_DATA_CRC 193
22 #define MAVLINK_MSG_ID_266_CRC 193
24 #define MAVLINK_MSG_LOGGING_DATA_FIELD_DATA_LEN 249
26 #if MAVLINK_COMMAND_24BIT
27 #define MAVLINK_MESSAGE_INFO_LOGGING_DATA { \
28 266, \
29 "LOGGING_DATA", \
30 6, \
31 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_logging_data_t, target_system) }, \
32 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_logging_data_t, target_component) }, \
33 { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_logging_data_t, sequence) }, \
34 { "length", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_logging_data_t, length) }, \
35 { "first_message_offset", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_logging_data_t, first_message_offset) }, \
36 { "data", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_logging_data_t, data) }, \
37 } \
39 #else
40 #define MAVLINK_MESSAGE_INFO_LOGGING_DATA { \
41 "LOGGING_DATA", \
42 6, \
43 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_logging_data_t, target_system) }, \
44 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_logging_data_t, target_component) }, \
45 { "sequence", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_logging_data_t, sequence) }, \
46 { "length", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_logging_data_t, length) }, \
47 { "first_message_offset", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_logging_data_t, first_message_offset) }, \
48 { "data", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_logging_data_t, data) }, \
49 } \
51 #endif
53 /**
54 * @brief Pack a logging_data message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
59 * @param target_system system ID of the target
60 * @param target_component component ID of the target
61 * @param sequence sequence number (can wrap)
62 * @param length [bytes] data length
63 * @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).
64 * @param data logged data
65 * @return length of the message in bytes (excluding serial stream start sign)
67 static inline uint16_t mavlink_msg_logging_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t length, uint8_t first_message_offset, const uint8_t *data)
70 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
72 _mav_put_uint16_t(buf, 0, sequence);
73 _mav_put_uint8_t(buf, 2, target_system);
74 _mav_put_uint8_t(buf, 3, target_component);
75 _mav_put_uint8_t(buf, 4, length);
76 _mav_put_uint8_t(buf, 5, first_message_offset);
77 _mav_put_uint8_t_array(buf, 6, data, 249);
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
79 #else
80 mavlink_logging_data_t packet;
81 packet.sequence = sequence;
82 packet.target_system = target_system;
83 packet.target_component = target_component;
84 packet.length = length;
85 packet.first_message_offset = first_message_offset;
86 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
88 #endif
90 msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA;
91 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);
94 /**
95 * @brief Pack a logging_data message on a channel
96 * @param system_id ID of this system
97 * @param component_id ID of this component (e.g. 200 for IMU)
98 * @param chan The MAVLink channel this message will be sent over
99 * @param msg The MAVLink message to compress the data into
100 * @param target_system system ID of the target
101 * @param target_component component ID of the target
102 * @param sequence sequence number (can wrap)
103 * @param length [bytes] data length
104 * @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).
105 * @param data logged data
106 * @return length of the message in bytes (excluding serial stream start sign)
108 static inline uint16_t mavlink_msg_logging_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
109 mavlink_message_t* msg,
110 uint8_t target_system,uint8_t target_component,uint16_t sequence,uint8_t length,uint8_t first_message_offset,const uint8_t *data)
112 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
113 char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
114 _mav_put_uint16_t(buf, 0, sequence);
115 _mav_put_uint8_t(buf, 2, target_system);
116 _mav_put_uint8_t(buf, 3, target_component);
117 _mav_put_uint8_t(buf, 4, length);
118 _mav_put_uint8_t(buf, 5, first_message_offset);
119 _mav_put_uint8_t_array(buf, 6, data, 249);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
121 #else
122 mavlink_logging_data_t packet;
123 packet.sequence = sequence;
124 packet.target_system = target_system;
125 packet.target_component = target_component;
126 packet.length = length;
127 packet.first_message_offset = first_message_offset;
128 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
130 #endif
132 msg->msgid = MAVLINK_MSG_ID_LOGGING_DATA;
133 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);
137 * @brief Encode a logging_data struct
139 * @param system_id ID of this system
140 * @param component_id ID of this component (e.g. 200 for IMU)
141 * @param msg The MAVLink message to compress the data into
142 * @param logging_data C-struct to read the message contents from
144 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)
146 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);
150 * @brief Encode a logging_data struct on a channel
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param chan The MAVLink channel this message will be sent over
155 * @param msg The MAVLink message to compress the data into
156 * @param logging_data C-struct to read the message contents from
158 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)
160 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);
164 * @brief Send a logging_data message
165 * @param chan MAVLink channel to send the message
167 * @param target_system system ID of the target
168 * @param target_component component ID of the target
169 * @param sequence sequence number (can wrap)
170 * @param length [bytes] data length
171 * @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).
172 * @param data logged data
174 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
176 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)
178 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
179 char buf[MAVLINK_MSG_ID_LOGGING_DATA_LEN];
180 _mav_put_uint16_t(buf, 0, sequence);
181 _mav_put_uint8_t(buf, 2, target_system);
182 _mav_put_uint8_t(buf, 3, target_component);
183 _mav_put_uint8_t(buf, 4, length);
184 _mav_put_uint8_t(buf, 5, first_message_offset);
185 _mav_put_uint8_t_array(buf, 6, data, 249);
186 _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);
187 #else
188 mavlink_logging_data_t packet;
189 packet.sequence = sequence;
190 packet.target_system = target_system;
191 packet.target_component = target_component;
192 packet.length = length;
193 packet.first_message_offset = first_message_offset;
194 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*249);
195 _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);
196 #endif
200 * @brief Send a logging_data message
201 * @param chan MAVLink channel to send the message
202 * @param struct The MAVLink struct to serialize
204 static inline void mavlink_msg_logging_data_send_struct(mavlink_channel_t chan, const mavlink_logging_data_t* logging_data)
206 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
207 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);
208 #else
209 _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);
210 #endif
213 #if MAVLINK_MSG_ID_LOGGING_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
215 This varient of _send() can be used to save stack space by re-using
216 memory from the receive buffer. The caller provides a
217 mavlink_message_t which is the size of a full mavlink message. This
218 is usually the receive buffer for the channel, and allows a reply to an
219 incoming message with minimum stack space usage.
221 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)
223 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
224 char *buf = (char *)msgbuf;
225 _mav_put_uint16_t(buf, 0, sequence);
226 _mav_put_uint8_t(buf, 2, target_system);
227 _mav_put_uint8_t(buf, 3, target_component);
228 _mav_put_uint8_t(buf, 4, length);
229 _mav_put_uint8_t(buf, 5, first_message_offset);
230 _mav_put_uint8_t_array(buf, 6, data, 249);
231 _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);
232 #else
233 mavlink_logging_data_t *packet = (mavlink_logging_data_t *)msgbuf;
234 packet->sequence = sequence;
235 packet->target_system = target_system;
236 packet->target_component = target_component;
237 packet->length = length;
238 packet->first_message_offset = first_message_offset;
239 mav_array_memcpy(packet->data, data, sizeof(uint8_t)*249);
240 _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);
241 #endif
243 #endif
245 #endif
247 // MESSAGE LOGGING_DATA UNPACKING
251 * @brief Get field target_system from logging_data message
253 * @return system ID of the target
255 static inline uint8_t mavlink_msg_logging_data_get_target_system(const mavlink_message_t* msg)
257 return _MAV_RETURN_uint8_t(msg, 2);
261 * @brief Get field target_component from logging_data message
263 * @return component ID of the target
265 static inline uint8_t mavlink_msg_logging_data_get_target_component(const mavlink_message_t* msg)
267 return _MAV_RETURN_uint8_t(msg, 3);
271 * @brief Get field sequence from logging_data message
273 * @return sequence number (can wrap)
275 static inline uint16_t mavlink_msg_logging_data_get_sequence(const mavlink_message_t* msg)
277 return _MAV_RETURN_uint16_t(msg, 0);
281 * @brief Get field length from logging_data message
283 * @return [bytes] data length
285 static inline uint8_t mavlink_msg_logging_data_get_length(const mavlink_message_t* msg)
287 return _MAV_RETURN_uint8_t(msg, 4);
291 * @brief Get field first_message_offset from logging_data message
293 * @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).
295 static inline uint8_t mavlink_msg_logging_data_get_first_message_offset(const mavlink_message_t* msg)
297 return _MAV_RETURN_uint8_t(msg, 5);
301 * @brief Get field data from logging_data message
303 * @return logged data
305 static inline uint16_t mavlink_msg_logging_data_get_data(const mavlink_message_t* msg, uint8_t *data)
307 return _MAV_RETURN_uint8_t_array(msg, data, 249, 6);
311 * @brief Decode a logging_data message into a struct
313 * @param msg The message to decode
314 * @param logging_data C-struct to decode the message contents into
316 static inline void mavlink_msg_logging_data_decode(const mavlink_message_t* msg, mavlink_logging_data_t* logging_data)
318 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
319 logging_data->sequence = mavlink_msg_logging_data_get_sequence(msg);
320 logging_data->target_system = mavlink_msg_logging_data_get_target_system(msg);
321 logging_data->target_component = mavlink_msg_logging_data_get_target_component(msg);
322 logging_data->length = mavlink_msg_logging_data_get_length(msg);
323 logging_data->first_message_offset = mavlink_msg_logging_data_get_first_message_offset(msg);
324 mavlink_msg_logging_data_get_data(msg, logging_data->data);
325 #else
326 uint8_t len = msg->len < MAVLINK_MSG_ID_LOGGING_DATA_LEN? msg->len : MAVLINK_MSG_ID_LOGGING_DATA_LEN;
327 memset(logging_data, 0, MAVLINK_MSG_ID_LOGGING_DATA_LEN);
328 memcpy(logging_data, _MAV_PAYLOAD(msg), len);
329 #endif