1 | // MESSAGE LOG_DATA PACKING
|
---|
2 |
|
---|
3 | #define MAVLINK_MSG_ID_LOG_DATA 120
|
---|
4 |
|
---|
5 | typedef struct MAVLINK_PACKED __mavlink_log_data_t
|
---|
6 | {
|
---|
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;
|
---|
12 |
|
---|
13 | #define MAVLINK_MSG_ID_LOG_DATA_LEN 97
|
---|
14 | #define MAVLINK_MSG_ID_LOG_DATA_MIN_LEN 97
|
---|
15 | #define MAVLINK_MSG_ID_120_LEN 97
|
---|
16 | #define MAVLINK_MSG_ID_120_MIN_LEN 97
|
---|
17 |
|
---|
18 | #define MAVLINK_MSG_ID_LOG_DATA_CRC 134
|
---|
19 | #define MAVLINK_MSG_ID_120_CRC 134
|
---|
20 |
|
---|
21 | #define MAVLINK_MSG_LOG_DATA_FIELD_DATA_LEN 90
|
---|
22 |
|
---|
23 | #if MAVLINK_COMMAND_24BIT
|
---|
24 | #define MAVLINK_MESSAGE_INFO_LOG_DATA { \
|
---|
25 | 120, \
|
---|
26 | "LOG_DATA", \
|
---|
27 | 4, \
|
---|
28 | { { "ofs", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_data_t, ofs) }, \
|
---|
29 | { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_log_data_t, id) }, \
|
---|
30 | { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_log_data_t, count) }, \
|
---|
31 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 90, 7, offsetof(mavlink_log_data_t, data) }, \
|
---|
32 | } \
|
---|
33 | }
|
---|
34 | #else
|
---|
35 | #define MAVLINK_MESSAGE_INFO_LOG_DATA { \
|
---|
36 | "LOG_DATA", \
|
---|
37 | 4, \
|
---|
38 | { { "ofs", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_log_data_t, ofs) }, \
|
---|
39 | { "id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_log_data_t, id) }, \
|
---|
40 | { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_log_data_t, count) }, \
|
---|
41 | { "data", NULL, MAVLINK_TYPE_UINT8_T, 90, 7, offsetof(mavlink_log_data_t, data) }, \
|
---|
42 | } \
|
---|
43 | }
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * @brief Pack a log_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 id Log id (from LOG_ENTRY reply)
|
---|
53 | * @param ofs Offset into the log
|
---|
54 | * @param count Number of bytes (zero for end of log)
|
---|
55 | * @param data log data
|
---|
56 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
57 | */
|
---|
58 | static inline uint16_t mavlink_msg_log_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
|
---|
59 | uint16_t id, uint32_t ofs, uint8_t count, const uint8_t *data)
|
---|
60 | {
|
---|
61 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
62 | char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
|
---|
63 | _mav_put_uint32_t(buf, 0, ofs);
|
---|
64 | _mav_put_uint16_t(buf, 4, id);
|
---|
65 | _mav_put_uint8_t(buf, 6, count);
|
---|
66 | _mav_put_uint8_t_array(buf, 7, data, 90);
|
---|
67 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
|
---|
68 | #else
|
---|
69 | mavlink_log_data_t packet;
|
---|
70 | packet.ofs = ofs;
|
---|
71 | packet.id = id;
|
---|
72 | packet.count = count;
|
---|
73 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
|
---|
74 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | msg->msgid = MAVLINK_MSG_ID_LOG_DATA;
|
---|
78 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
79 | }
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * @brief Pack a log_data message on a channel
|
---|
83 | * @param system_id ID of this system
|
---|
84 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
85 | * @param chan The MAVLink channel this message will be sent over
|
---|
86 | * @param msg The MAVLink message to compress the data into
|
---|
87 | * @param id Log id (from LOG_ENTRY reply)
|
---|
88 | * @param ofs Offset into the log
|
---|
89 | * @param count Number of bytes (zero for end of log)
|
---|
90 | * @param data log data
|
---|
91 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
92 | */
|
---|
93 | static inline uint16_t mavlink_msg_log_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
|
---|
94 | mavlink_message_t* msg,
|
---|
95 | uint16_t id,uint32_t ofs,uint8_t count,const uint8_t *data)
|
---|
96 | {
|
---|
97 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
98 | char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
|
---|
99 | _mav_put_uint32_t(buf, 0, ofs);
|
---|
100 | _mav_put_uint16_t(buf, 4, id);
|
---|
101 | _mav_put_uint8_t(buf, 6, count);
|
---|
102 | _mav_put_uint8_t_array(buf, 7, data, 90);
|
---|
103 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOG_DATA_LEN);
|
---|
104 | #else
|
---|
105 | mavlink_log_data_t packet;
|
---|
106 | packet.ofs = ofs;
|
---|
107 | packet.id = id;
|
---|
108 | packet.count = count;
|
---|
109 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
|
---|
110 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOG_DATA_LEN);
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | msg->msgid = MAVLINK_MSG_ID_LOG_DATA;
|
---|
114 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
115 | }
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * @brief Encode a log_data struct
|
---|
119 | *
|
---|
120 | * @param system_id ID of this system
|
---|
121 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
122 | * @param msg The MAVLink message to compress the data into
|
---|
123 | * @param log_data C-struct to read the message contents from
|
---|
124 | */
|
---|
125 | 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)
|
---|
126 | {
|
---|
127 | return mavlink_msg_log_data_pack(system_id, component_id, msg, log_data->id, log_data->ofs, log_data->count, log_data->data);
|
---|
128 | }
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * @brief Encode a log_data struct on a channel
|
---|
132 | *
|
---|
133 | * @param system_id ID of this system
|
---|
134 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
135 | * @param chan The MAVLink channel this message will be sent over
|
---|
136 | * @param msg The MAVLink message to compress the data into
|
---|
137 | * @param log_data C-struct to read the message contents from
|
---|
138 | */
|
---|
139 | 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)
|
---|
140 | {
|
---|
141 | 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);
|
---|
142 | }
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * @brief Send a log_data message
|
---|
146 | * @param chan MAVLink channel to send the message
|
---|
147 | *
|
---|
148 | * @param id Log id (from LOG_ENTRY reply)
|
---|
149 | * @param ofs Offset into the log
|
---|
150 | * @param count Number of bytes (zero for end of log)
|
---|
151 | * @param data log data
|
---|
152 | */
|
---|
153 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
---|
154 |
|
---|
155 | 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)
|
---|
156 | {
|
---|
157 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
158 | char buf[MAVLINK_MSG_ID_LOG_DATA_LEN];
|
---|
159 | _mav_put_uint32_t(buf, 0, ofs);
|
---|
160 | _mav_put_uint16_t(buf, 4, id);
|
---|
161 | _mav_put_uint8_t(buf, 6, count);
|
---|
162 | _mav_put_uint8_t_array(buf, 7, data, 90);
|
---|
163 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
164 | #else
|
---|
165 | mavlink_log_data_t packet;
|
---|
166 | packet.ofs = ofs;
|
---|
167 | packet.id = id;
|
---|
168 | packet.count = count;
|
---|
169 | mav_array_memcpy(packet.data, data, sizeof(uint8_t)*90);
|
---|
170 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)&packet, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
171 | #endif
|
---|
172 | }
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * @brief Send a log_data message
|
---|
176 | * @param chan MAVLink channel to send the message
|
---|
177 | * @param struct The MAVLink struct to serialize
|
---|
178 | */
|
---|
179 | static inline void mavlink_msg_log_data_send_struct(mavlink_channel_t chan, const mavlink_log_data_t* log_data)
|
---|
180 | {
|
---|
181 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
182 | mavlink_msg_log_data_send(chan, log_data->id, log_data->ofs, log_data->count, log_data->data);
|
---|
183 | #else
|
---|
184 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)log_data, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
185 | #endif
|
---|
186 | }
|
---|
187 |
|
---|
188 | #if MAVLINK_MSG_ID_LOG_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
|
---|
189 | /*
|
---|
190 | This varient of _send() can be used to save stack space by re-using
|
---|
191 | memory from the receive buffer. The caller provides a
|
---|
192 | mavlink_message_t which is the size of a full mavlink message. This
|
---|
193 | is usually the receive buffer for the channel, and allows a reply to an
|
---|
194 | incoming message with minimum stack space usage.
|
---|
195 | */
|
---|
196 | 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)
|
---|
197 | {
|
---|
198 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
199 | char *buf = (char *)msgbuf;
|
---|
200 | _mav_put_uint32_t(buf, 0, ofs);
|
---|
201 | _mav_put_uint16_t(buf, 4, id);
|
---|
202 | _mav_put_uint8_t(buf, 6, count);
|
---|
203 | _mav_put_uint8_t_array(buf, 7, data, 90);
|
---|
204 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, buf, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
205 | #else
|
---|
206 | mavlink_log_data_t *packet = (mavlink_log_data_t *)msgbuf;
|
---|
207 | packet->ofs = ofs;
|
---|
208 | packet->id = id;
|
---|
209 | packet->count = count;
|
---|
210 | mav_array_memcpy(packet->data, data, sizeof(uint8_t)*90);
|
---|
211 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOG_DATA, (const char *)packet, MAVLINK_MSG_ID_LOG_DATA_MIN_LEN, MAVLINK_MSG_ID_LOG_DATA_LEN, MAVLINK_MSG_ID_LOG_DATA_CRC);
|
---|
212 | #endif
|
---|
213 | }
|
---|
214 | #endif
|
---|
215 |
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | // MESSAGE LOG_DATA UNPACKING
|
---|
219 |
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * @brief Get field id from log_data message
|
---|
223 | *
|
---|
224 | * @return Log id (from LOG_ENTRY reply)
|
---|
225 | */
|
---|
226 | static inline uint16_t mavlink_msg_log_data_get_id(const mavlink_message_t* msg)
|
---|
227 | {
|
---|
228 | return _MAV_RETURN_uint16_t(msg, 4);
|
---|
229 | }
|
---|
230 |
|
---|
231 | /**
|
---|
232 | * @brief Get field ofs from log_data message
|
---|
233 | *
|
---|
234 | * @return Offset into the log
|
---|
235 | */
|
---|
236 | static inline uint32_t mavlink_msg_log_data_get_ofs(const mavlink_message_t* msg)
|
---|
237 | {
|
---|
238 | return _MAV_RETURN_uint32_t(msg, 0);
|
---|
239 | }
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * @brief Get field count from log_data message
|
---|
243 | *
|
---|
244 | * @return Number of bytes (zero for end of log)
|
---|
245 | */
|
---|
246 | static inline uint8_t mavlink_msg_log_data_get_count(const mavlink_message_t* msg)
|
---|
247 | {
|
---|
248 | return _MAV_RETURN_uint8_t(msg, 6);
|
---|
249 | }
|
---|
250 |
|
---|
251 | /**
|
---|
252 | * @brief Get field data from log_data message
|
---|
253 | *
|
---|
254 | * @return log data
|
---|
255 | */
|
---|
256 | static inline uint16_t mavlink_msg_log_data_get_data(const mavlink_message_t* msg, uint8_t *data)
|
---|
257 | {
|
---|
258 | return _MAV_RETURN_uint8_t_array(msg, data, 90, 7);
|
---|
259 | }
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * @brief Decode a log_data message into a struct
|
---|
263 | *
|
---|
264 | * @param msg The message to decode
|
---|
265 | * @param log_data C-struct to decode the message contents into
|
---|
266 | */
|
---|
267 | static inline void mavlink_msg_log_data_decode(const mavlink_message_t* msg, mavlink_log_data_t* log_data)
|
---|
268 | {
|
---|
269 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
270 | log_data->ofs = mavlink_msg_log_data_get_ofs(msg);
|
---|
271 | log_data->id = mavlink_msg_log_data_get_id(msg);
|
---|
272 | log_data->count = mavlink_msg_log_data_get_count(msg);
|
---|
273 | mavlink_msg_log_data_get_data(msg, log_data->data);
|
---|
274 | #else
|
---|
275 | uint8_t len = msg->len < MAVLINK_MSG_ID_LOG_DATA_LEN? msg->len : MAVLINK_MSG_ID_LOG_DATA_LEN;
|
---|
276 | memset(log_data, 0, MAVLINK_MSG_ID_LOG_DATA_LEN);
|
---|
277 | memcpy(log_data, _MAV_PAYLOAD(msg), len);
|
---|
278 | #endif
|
---|
279 | }
|
---|