RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_storage_information.h
1#pragma once
2// MESSAGE STORAGE_INFORMATION PACKING
3
4#define MAVLINK_MSG_ID_STORAGE_INFORMATION 261
5
6MAVPACKED(
7typedef struct __mavlink_storage_information_t {
8 uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/
9 float total_capacity; /*< Total capacity in MiB*/
10 float used_capacity; /*< Used capacity in MiB*/
11 float available_capacity; /*< Available capacity in MiB*/
12 float read_speed; /*< Read speed in MiB/s*/
13 float write_speed; /*< Write speed in MiB/s*/
14 uint8_t storage_id; /*< Storage ID (1 for first, 2 for second, etc.)*/
15 uint8_t storage_count; /*< Number of storage devices*/
16 uint8_t status; /*< Status of storage (0 not available, 1 unformatted, 2 formatted)*/
17}) mavlink_storage_information_t;
18
19#define MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN 27
20#define MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN 27
21#define MAVLINK_MSG_ID_261_LEN 27
22#define MAVLINK_MSG_ID_261_MIN_LEN 27
23
24#define MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC 179
25#define MAVLINK_MSG_ID_261_CRC 179
26
27
28
29#if MAVLINK_COMMAND_24BIT
30#define MAVLINK_MESSAGE_INFO_STORAGE_INFORMATION { \
31 261, \
32 "STORAGE_INFORMATION", \
33 9, \
34 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_storage_information_t, time_boot_ms) }, \
35 { "storage_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_storage_information_t, storage_id) }, \
36 { "storage_count", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_storage_information_t, storage_count) }, \
37 { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_storage_information_t, status) }, \
38 { "total_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_storage_information_t, total_capacity) }, \
39 { "used_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_storage_information_t, used_capacity) }, \
40 { "available_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_storage_information_t, available_capacity) }, \
41 { "read_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_storage_information_t, read_speed) }, \
42 { "write_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_storage_information_t, write_speed) }, \
43 } \
44}
45#else
46#define MAVLINK_MESSAGE_INFO_STORAGE_INFORMATION { \
47 "STORAGE_INFORMATION", \
48 9, \
49 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_storage_information_t, time_boot_ms) }, \
50 { "storage_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_storage_information_t, storage_id) }, \
51 { "storage_count", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_storage_information_t, storage_count) }, \
52 { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_storage_information_t, status) }, \
53 { "total_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_storage_information_t, total_capacity) }, \
54 { "used_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_storage_information_t, used_capacity) }, \
55 { "available_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_storage_information_t, available_capacity) }, \
56 { "read_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_storage_information_t, read_speed) }, \
57 { "write_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_storage_information_t, write_speed) }, \
58 } \
59}
60#endif
61
62/**
63 * @brief Pack a storage_information message
64 * @param system_id ID of this system
65 * @param component_id ID of this component (e.g. 200 for IMU)
66 * @param msg The MAVLink message to compress the data into
67 *
68 * @param time_boot_ms Timestamp (milliseconds since system boot)
69 * @param storage_id Storage ID (1 for first, 2 for second, etc.)
70 * @param storage_count Number of storage devices
71 * @param status Status of storage (0 not available, 1 unformatted, 2 formatted)
72 * @param total_capacity Total capacity in MiB
73 * @param used_capacity Used capacity in MiB
74 * @param available_capacity Available capacity in MiB
75 * @param read_speed Read speed in MiB/s
76 * @param write_speed Write speed in MiB/s
77 * @return length of the message in bytes (excluding serial stream start sign)
78 */
79static inline uint16_t mavlink_msg_storage_information_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
80 uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed)
81{
82#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
83 char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
84 _mav_put_uint32_t(buf, 0, time_boot_ms);
85 _mav_put_float(buf, 4, total_capacity);
86 _mav_put_float(buf, 8, used_capacity);
87 _mav_put_float(buf, 12, available_capacity);
88 _mav_put_float(buf, 16, read_speed);
89 _mav_put_float(buf, 20, write_speed);
90 _mav_put_uint8_t(buf, 24, storage_id);
91 _mav_put_uint8_t(buf, 25, storage_count);
92 _mav_put_uint8_t(buf, 26, status);
93
94 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
95#else
96 mavlink_storage_information_t packet;
97 packet.time_boot_ms = time_boot_ms;
98 packet.total_capacity = total_capacity;
99 packet.used_capacity = used_capacity;
100 packet.available_capacity = available_capacity;
101 packet.read_speed = read_speed;
102 packet.write_speed = write_speed;
103 packet.storage_id = storage_id;
104 packet.storage_count = storage_count;
105 packet.status = status;
106
107 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
108#endif
109
110 msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION;
111 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
112}
113
114/**
115 * @brief Pack a storage_information message on a channel
116 * @param system_id ID of this system
117 * @param component_id ID of this component (e.g. 200 for IMU)
118 * @param chan The MAVLink channel this message will be sent over
119 * @param msg The MAVLink message to compress the data into
120 * @param time_boot_ms Timestamp (milliseconds since system boot)
121 * @param storage_id Storage ID (1 for first, 2 for second, etc.)
122 * @param storage_count Number of storage devices
123 * @param status Status of storage (0 not available, 1 unformatted, 2 formatted)
124 * @param total_capacity Total capacity in MiB
125 * @param used_capacity Used capacity in MiB
126 * @param available_capacity Available capacity in MiB
127 * @param read_speed Read speed in MiB/s
128 * @param write_speed Write speed in MiB/s
129 * @return length of the message in bytes (excluding serial stream start sign)
130 */
131static inline uint16_t mavlink_msg_storage_information_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
132 mavlink_message_t* msg,
133 uint32_t time_boot_ms,uint8_t storage_id,uint8_t storage_count,uint8_t status,float total_capacity,float used_capacity,float available_capacity,float read_speed,float write_speed)
134{
135#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
136 char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
137 _mav_put_uint32_t(buf, 0, time_boot_ms);
138 _mav_put_float(buf, 4, total_capacity);
139 _mav_put_float(buf, 8, used_capacity);
140 _mav_put_float(buf, 12, available_capacity);
141 _mav_put_float(buf, 16, read_speed);
142 _mav_put_float(buf, 20, write_speed);
143 _mav_put_uint8_t(buf, 24, storage_id);
144 _mav_put_uint8_t(buf, 25, storage_count);
145 _mav_put_uint8_t(buf, 26, status);
146
147 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
148#else
149 mavlink_storage_information_t packet;
150 packet.time_boot_ms = time_boot_ms;
151 packet.total_capacity = total_capacity;
152 packet.used_capacity = used_capacity;
153 packet.available_capacity = available_capacity;
154 packet.read_speed = read_speed;
155 packet.write_speed = write_speed;
156 packet.storage_id = storage_id;
157 packet.storage_count = storage_count;
158 packet.status = status;
159
160 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
161#endif
162
163 msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION;
164 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
165}
166
167/**
168 * @brief Encode a storage_information struct
169 *
170 * @param system_id ID of this system
171 * @param component_id ID of this component (e.g. 200 for IMU)
172 * @param msg The MAVLink message to compress the data into
173 * @param storage_information C-struct to read the message contents from
174 */
175static inline uint16_t mavlink_msg_storage_information_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information)
176{
177 return mavlink_msg_storage_information_pack(system_id, component_id, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed);
178}
179
180/**
181 * @brief Encode a storage_information struct on a channel
182 *
183 * @param system_id ID of this system
184 * @param component_id ID of this component (e.g. 200 for IMU)
185 * @param chan The MAVLink channel this message will be sent over
186 * @param msg The MAVLink message to compress the data into
187 * @param storage_information C-struct to read the message contents from
188 */
189static inline uint16_t mavlink_msg_storage_information_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information)
190{
191 return mavlink_msg_storage_information_pack_chan(system_id, component_id, chan, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed);
192}
193
194/**
195 * @brief Send a storage_information message
196 * @param chan MAVLink channel to send the message
197 *
198 * @param time_boot_ms Timestamp (milliseconds since system boot)
199 * @param storage_id Storage ID (1 for first, 2 for second, etc.)
200 * @param storage_count Number of storage devices
201 * @param status Status of storage (0 not available, 1 unformatted, 2 formatted)
202 * @param total_capacity Total capacity in MiB
203 * @param used_capacity Used capacity in MiB
204 * @param available_capacity Available capacity in MiB
205 * @param read_speed Read speed in MiB/s
206 * @param write_speed Write speed in MiB/s
207 */
208#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
209
210static inline void mavlink_msg_storage_information_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
214 _mav_put_uint32_t(buf, 0, time_boot_ms);
215 _mav_put_float(buf, 4, total_capacity);
216 _mav_put_float(buf, 8, used_capacity);
217 _mav_put_float(buf, 12, available_capacity);
218 _mav_put_float(buf, 16, read_speed);
219 _mav_put_float(buf, 20, write_speed);
220 _mav_put_uint8_t(buf, 24, storage_id);
221 _mav_put_uint8_t(buf, 25, storage_count);
222 _mav_put_uint8_t(buf, 26, status);
223
224 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
225#else
226 mavlink_storage_information_t packet;
227 packet.time_boot_ms = time_boot_ms;
228 packet.total_capacity = total_capacity;
229 packet.used_capacity = used_capacity;
230 packet.available_capacity = available_capacity;
231 packet.read_speed = read_speed;
232 packet.write_speed = write_speed;
233 packet.storage_id = storage_id;
234 packet.storage_count = storage_count;
235 packet.status = status;
236
237 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)&packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
238#endif
239}
240
241/**
242 * @brief Send a storage_information message
243 * @param chan MAVLink channel to send the message
244 * @param struct The MAVLink struct to serialize
245 */
246static inline void mavlink_msg_storage_information_send_struct(mavlink_channel_t chan, const mavlink_storage_information_t* storage_information)
247{
248#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
249 mavlink_msg_storage_information_send(chan, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed);
250#else
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)storage_information, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
252#endif
253}
254
255#if MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
256/*
257 This varient of _send() can be used to save stack space by re-using
258 memory from the receive buffer. The caller provides a
259 mavlink_message_t which is the size of a full mavlink message. This
260 is usually the receive buffer for the channel, and allows a reply to an
261 incoming message with minimum stack space usage.
262 */
263static inline void mavlink_msg_storage_information_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed)
264{
265#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
266 char *buf = (char *)msgbuf;
267 _mav_put_uint32_t(buf, 0, time_boot_ms);
268 _mav_put_float(buf, 4, total_capacity);
269 _mav_put_float(buf, 8, used_capacity);
270 _mav_put_float(buf, 12, available_capacity);
271 _mav_put_float(buf, 16, read_speed);
272 _mav_put_float(buf, 20, write_speed);
273 _mav_put_uint8_t(buf, 24, storage_id);
274 _mav_put_uint8_t(buf, 25, storage_count);
275 _mav_put_uint8_t(buf, 26, status);
276
277 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
278#else
279 mavlink_storage_information_t *packet = (mavlink_storage_information_t *)msgbuf;
280 packet->time_boot_ms = time_boot_ms;
281 packet->total_capacity = total_capacity;
282 packet->used_capacity = used_capacity;
283 packet->available_capacity = available_capacity;
284 packet->read_speed = read_speed;
285 packet->write_speed = write_speed;
286 packet->storage_id = storage_id;
287 packet->storage_count = storage_count;
288 packet->status = status;
289
290 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
291#endif
292}
293#endif
294
295#endif
296
297// MESSAGE STORAGE_INFORMATION UNPACKING
298
299
300/**
301 * @brief Get field time_boot_ms from storage_information message
302 *
303 * @return Timestamp (milliseconds since system boot)
304 */
305static inline uint32_t mavlink_msg_storage_information_get_time_boot_ms(const mavlink_message_t* msg)
306{
307 return _MAV_RETURN_uint32_t(msg, 0);
308}
309
310/**
311 * @brief Get field storage_id from storage_information message
312 *
313 * @return Storage ID (1 for first, 2 for second, etc.)
314 */
315static inline uint8_t mavlink_msg_storage_information_get_storage_id(const mavlink_message_t* msg)
316{
317 return _MAV_RETURN_uint8_t(msg, 24);
318}
319
320/**
321 * @brief Get field storage_count from storage_information message
322 *
323 * @return Number of storage devices
324 */
325static inline uint8_t mavlink_msg_storage_information_get_storage_count(const mavlink_message_t* msg)
326{
327 return _MAV_RETURN_uint8_t(msg, 25);
328}
329
330/**
331 * @brief Get field status from storage_information message
332 *
333 * @return Status of storage (0 not available, 1 unformatted, 2 formatted)
334 */
335static inline uint8_t mavlink_msg_storage_information_get_status(const mavlink_message_t* msg)
336{
337 return _MAV_RETURN_uint8_t(msg, 26);
338}
339
340/**
341 * @brief Get field total_capacity from storage_information message
342 *
343 * @return Total capacity in MiB
344 */
345static inline float mavlink_msg_storage_information_get_total_capacity(const mavlink_message_t* msg)
346{
347 return _MAV_RETURN_float(msg, 4);
348}
349
350/**
351 * @brief Get field used_capacity from storage_information message
352 *
353 * @return Used capacity in MiB
354 */
355static inline float mavlink_msg_storage_information_get_used_capacity(const mavlink_message_t* msg)
356{
357 return _MAV_RETURN_float(msg, 8);
358}
359
360/**
361 * @brief Get field available_capacity from storage_information message
362 *
363 * @return Available capacity in MiB
364 */
365static inline float mavlink_msg_storage_information_get_available_capacity(const mavlink_message_t* msg)
366{
367 return _MAV_RETURN_float(msg, 12);
368}
369
370/**
371 * @brief Get field read_speed from storage_information message
372 *
373 * @return Read speed in MiB/s
374 */
375static inline float mavlink_msg_storage_information_get_read_speed(const mavlink_message_t* msg)
376{
377 return _MAV_RETURN_float(msg, 16);
378}
379
380/**
381 * @brief Get field write_speed from storage_information message
382 *
383 * @return Write speed in MiB/s
384 */
385static inline float mavlink_msg_storage_information_get_write_speed(const mavlink_message_t* msg)
386{
387 return _MAV_RETURN_float(msg, 20);
388}
389
390/**
391 * @brief Decode a storage_information message into a struct
392 *
393 * @param msg The message to decode
394 * @param storage_information C-struct to decode the message contents into
395 */
396static inline void mavlink_msg_storage_information_decode(const mavlink_message_t* msg, mavlink_storage_information_t* storage_information)
397{
398#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
399 storage_information->time_boot_ms = mavlink_msg_storage_information_get_time_boot_ms(msg);
400 storage_information->total_capacity = mavlink_msg_storage_information_get_total_capacity(msg);
401 storage_information->used_capacity = mavlink_msg_storage_information_get_used_capacity(msg);
402 storage_information->available_capacity = mavlink_msg_storage_information_get_available_capacity(msg);
403 storage_information->read_speed = mavlink_msg_storage_information_get_read_speed(msg);
404 storage_information->write_speed = mavlink_msg_storage_information_get_write_speed(msg);
405 storage_information->storage_id = mavlink_msg_storage_information_get_storage_id(msg);
406 storage_information->storage_count = mavlink_msg_storage_information_get_storage_count(msg);
407 storage_information->status = mavlink_msg_storage_information_get_status(msg);
408#else
409 uint8_t len = msg->len < MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN? msg->len : MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN;
410 memset(storage_information, 0, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
411 memcpy(storage_information, _MAV_PAYLOAD(msg), len);
412#endif
413}