Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_log_data.h
blob48641f3eb0ebeb37f7ba8c420d5f9027460456d1
1 // MESSAGE LOG_DATA PACKING
3 #define MAVLINK_MSG_ID_LOG_DATA 120
5 typedef struct __mavlink_log_data_t
7 uint32_t ofs; ///< Offset into the log
8 uint16_t id; ///< Log id (from LOG_ENTRY reply)
9 uint8_t count; ///< Number of bytes (zero for end of log)
10 uint8_t data[90]; ///< log data
11 } mavlink_log_data_t;
13 #define MAVLINK_MSG_ID_LOG_DATA_LEN 97
14 #define MAVLINK_MSG_ID_120_LEN 97
16 #define MAVLINK_MSG_ID_LOG_DATA_CRC 134
17 #define MAVLINK_MSG_ID_120_CRC 134
19 #define MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN 90
21 #define MAVLINK_MESSAGE_INFO_LOG_DATA { \
22 "LOG_DATA", \
23 4, \
24 { { "ofs", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_data_t, ofs) }, \
25 { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_log_data_t, id) }, \
26 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_log_data_t, count) }, \
27 { "data", NULL, MAVLINK_TYPE_UINT8_T, 90, 7, offsetof(mavlink_log_data_t, data) }, \
28 } \
32 /**
33 * @brief Pack a log_data message
34 * @param system_id ID of this system
35 * @param component_id ID of this component (e.g. 200 for IMU)
36 * @param msg The MAVLink message to compress the data into
38 * @param id Log id (from LOG_ENTRY reply)
39 * @param ofs Offset into the log
40 * @param count Number of bytes (zero for end of log)
41 * @param data log data
42 * @return length of the message in bytes (excluding serial stream start sign)
44 static inline uint16_t mavlink_msg_log_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
45 uint16_t id, uint32_t ofs, uint8_t count, const uint8_t *data)
47 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
48 char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
49 _mav_put_uint32_t(buf, 0, ofs);
50 _mav_put_uint16_t(buf, 4, id);
51 _mav_put_uint8_t(buf, 6, count);
52 _mav_put_uint8_t_array(buf, 7, data, 90);
53 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
54 #else
55 mavlink_log_data_t packet;
56 packet.ofs = ofs;
57 packet.id = id;
58 packet.count = count;
59 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
60 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
61 #endif
63 msg->msgid = MAVLINK_MSG_ID_LOG_DATA;
64 #if MAVLINK_CRC_EXTRA
65 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
66 #else
67 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_DATA_LEN);
68 #endif
71 /**
72 * @brief Pack a log_data message on a channel
73 * @param system_id ID of this system
74 * @param component_id ID of this component (e.g. 200 for IMU)
75 * @param chan The MAVLink channel this message will be sent over
76 * @param msg The MAVLink message to compress the data into
77 * @param id Log id (from LOG_ENTRY reply)
78 * @param ofs Offset into the log
79 * @param count Number of bytes (zero for end of log)
80 * @param data log data
81 * @return length of the message in bytes (excluding serial stream start sign)
83 static inline uint16_t mavlink_msg_log_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
84 mavlink_message_t* msg,
85 uint16_t id,uint32_t ofs,uint8_t count,const uint8_t *data)
87 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
89 _mav_put_uint32_t(buf, 0, ofs);
90 _mav_put_uint16_t(buf, 4, id);
91 _mav_put_uint8_t(buf, 6, count);
92 _mav_put_uint8_t_array(buf, 7, data, 90);
93 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
94 #else
95 mavlink_log_data_t packet;
96 packet.ofs = ofs;
97 packet.id = id;
98 packet.count = count;
99 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
100 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
101 #endif
103 msg->msgid = MAVLINK_MSG_ID_LOG_DATA;
104 #if MAVLINK_CRC_EXTRA
105 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
106 #else
107 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_DATA_LEN);
108 #endif
112 * @brief Encode a log_data struct
114 * @param system_id ID of this system
115 * @param component_id ID of this component (e.g. 200 for IMU)
116 * @param msg The MAVLink message to compress the data into
117 * @param log_data C-struct to read the message contents from
119 static inline uint16_t mavlink_msg_log_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_log_data_t* log_data)
121 return mavlink_msg_log_data_pack(system_id, component_id, msg, log_data->id, log_data->ofs, log_data->count, log_data->data);
125 * @brief Encode a log_data struct on a channel
127 * @param system_id ID of this system
128 * @param component_id ID of this component (e.g. 200 for IMU)
129 * @param chan The MAVLink channel this message will be sent over
130 * @param msg The MAVLink message to compress the data into
131 * @param log_data C-struct to read the message contents from
133 static inline uint16_t mavlink_msg_log_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_log_data_t* log_data)
135 return mavlink_msg_log_data_pack_chan(system_id, component_id, chan, msg, log_data->id, log_data->ofs, log_data->count, log_data->data);
139 * @brief Send a log_data message
140 * @param chan MAVLink channel to send the message
142 * @param id Log id (from LOG_ENTRY reply)
143 * @param ofs Offset into the log
144 * @param count Number of bytes (zero for end of log)
145 * @param data log data
147 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
149 static inline void mavlink_msg_log_data_send(mavlink_channel_t chan, uint16_t id, uint32_t ofs, uint8_t count, const uint8_t *data)
151 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
152 char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
153 _mav_put_uint32_t(buf, 0, ofs);
154 _mav_put_uint16_t(buf, 4, id);
155 _mav_put_uint8_t(buf, 6, count);
156 _mav_put_uint8_t_array(buf, 7, data, 90);
157 #if MAVLINK_CRC_EXTRA
158 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
159 #else
160 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
161 #endif
162 #else
163 mavlink_log_data_t packet;
164 packet.ofs = ofs;
165 packet.id = id;
166 packet.count = count;
167 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
168 #if MAVLINK_CRC_EXTRA
169 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)&packet, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
170 #else
171 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)&packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
172 #endif
173 #endif
176 #if MAVLINK_MSG_ID_LOG_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
178 This varient of _send() can be used to save stack space by re-using
179 memory from the receive buffer. The caller provides a
180 mavlink_message_t which is the size of a full mavlink message. This
181 is usually the receive buffer for the channel, and allows a reply to an
182 incoming message with minimum stack space usage.
184 static inline void mavlink_msg_log_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t id, uint32_t ofs, uint8_t count, const uint8_t *data)
186 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
187 char *buf = (char *)msgbuf;
188 _mav_put_uint32_t(buf, 0, ofs);
189 _mav_put_uint16_t(buf, 4, id);
190 _mav_put_uint8_t(buf, 6, count);
191 _mav_put_uint8_t_array(buf, 7, data, 90);
192 #if MAVLINK_CRC_EXTRA
193 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
194 #else
195 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
196 #endif
197 #else
198 mavlink_log_data_t *packet = (mavlink_log_data_t *)msgbuf;
199 packet->ofs = ofs;
200 packet->id = id;
201 packet->count = count;
202 mav_array_memcpy(packet->data, data, sizeof(uint8_t)*90);
203 #if MAVLINK_CRC_EXTRA
204 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)packet, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
205 #else
206 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
207 #endif
208 #endif
210 #endif
212 #endif
214 // MESSAGE LOG_DATA UNPACKING
218 * @brief Get field id from log_data message
220 * @return Log id (from LOG_ENTRY reply)
222 static inline uint16_t mavlink_msg_log_data_get_id(const mavlink_message_t* msg)
224 return _MAV_RETURN_uint16_t(msg, 4);
228 * @brief Get field ofs from log_data message
230 * @return Offset into the log
232 static inline uint32_t mavlink_msg_log_data_get_ofs(const mavlink_message_t* msg)
234 return _MAV_RETURN_uint32_t(msg, 0);
238 * @brief Get field count from log_data message
240 * @return Number of bytes (zero for end of log)
242 static inline uint8_t mavlink_msg_log_data_get_count(const mavlink_message_t* msg)
244 return _MAV_RETURN_uint8_t(msg, 6);
248 * @brief Get field data from log_data message
250 * @return log data
252 static inline uint16_t mavlink_msg_log_data_get_data(const mavlink_message_t* msg, uint8_t *data)
254 return _MAV_RETURN_uint8_t_array(msg, data, 90, 7);
258 * @brief Decode a log_data message into a struct
260 * @param msg The message to decode
261 * @param log_data C-struct to decode the message contents into
263 static inline void mavlink_msg_log_data_decode(const mavlink_message_t* msg, mavlink_log_data_t* log_data)
265 #if MAVLINK_NEED_BYTE_SWAP
266 log_data->ofs = mavlink_msg_log_data_get_ofs(msg);
267 log_data->id = mavlink_msg_log_data_get_id(msg);
268 log_data->count = mavlink_msg_log_data_get_count(msg);
269 mavlink_msg_log_data_get_data(msg, log_data->data);
270 #else
271 memcpy(log_data, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_LOG_DATA_LEN);
272 #endif