Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_component_metadata.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE COMPONENT_METADATA PACKING
3
4#define MAVLINK_MSG_ID_COMPONENT_METADATA 397
5
6
8 uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
9 uint32_t file_crc; /*< CRC32 of the general metadata file.*/
10 char uri[100]; /*< MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.*/
11} mavlink_component_metadata_t;
12
13#define MAVLINK_MSG_ID_COMPONENT_METADATA_LEN 108
14#define MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN 108
15#define MAVLINK_MSG_ID_397_LEN 108
16#define MAVLINK_MSG_ID_397_MIN_LEN 108
17
18#define MAVLINK_MSG_ID_COMPONENT_METADATA_CRC 182
19#define MAVLINK_MSG_ID_397_CRC 182
20
21#define MAVLINK_MSG_COMPONENT_METADATA_FIELD_URI_LEN 100
22
23#if MAVLINK_COMMAND_24BIT
24#define MAVLINK_MESSAGE_INFO_COMPONENT_METADATA {
25 397,
26 "COMPONENT_METADATA",
27 3,
28 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_component_metadata_t, time_boot_ms) },
29 { "file_crc", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_component_metadata_t, file_crc) },
30 { "uri", NULL, MAVLINK_TYPE_CHAR, 100, 8, offsetof(mavlink_component_metadata_t, uri) },
31 } \
32}
33#else
34#define MAVLINK_MESSAGE_INFO_COMPONENT_METADATA {
35 "COMPONENT_METADATA",
36 3,
37 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_component_metadata_t, time_boot_ms) },
38 { "file_crc", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_component_metadata_t, file_crc) },
39 { "uri", NULL, MAVLINK_TYPE_CHAR, 100, 8, offsetof(mavlink_component_metadata_t, uri) },
40 } \
41}
42#endif
43
44/**
45 * @brief Pack a component_metadata message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
49 *
50 * @param time_boot_ms [ms] Timestamp (time since system boot).
51 * @param file_crc CRC32 of the general metadata file.
52 * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
53 * @return length of the message in bytes (excluding serial stream start sign)
54 */
55static inline uint16_t mavlink_msg_component_metadata_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
56 uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
57{
58#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 _mav_put_uint32_t(buf, 0, time_boot_ms);
61 _mav_put_uint32_t(buf, 4, file_crc);
62 _mav_put_char_array(buf, 8, uri, 100);
63 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
64#else
65 mavlink_component_metadata_t packet;
66 packet.time_boot_ms = time_boot_ms;
67 packet.file_crc = file_crc;
68 mav_array_memcpy(packet.uri, uri, sizeof(char)*100);
69 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
70#endif
71
74}
75
76/**
77 * @brief Pack a component_metadata message
78 * @param system_id ID of this system
79 * @param component_id ID of this component (e.g. 200 for IMU)
80 * @param status MAVLink status structure
81 * @param msg The MAVLink message to compress the data into
82 *
83 * @param time_boot_ms [ms] Timestamp (time since system boot).
84 * @param file_crc CRC32 of the general metadata file.
85 * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
86 * @return length of the message in bytes (excluding serial stream start sign)
87 */
88static inline uint16_t mavlink_msg_component_metadata_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
89 uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
90{
91#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
93 _mav_put_uint32_t(buf, 0, time_boot_ms);
94 _mav_put_uint32_t(buf, 4, file_crc);
95 _mav_put_char_array(buf, 8, uri, 100);
96 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
97#else
98 mavlink_component_metadata_t packet;
99 packet.time_boot_ms = time_boot_ms;
100 packet.file_crc = file_crc;
101 mav_array_memcpy(packet.uri, uri, sizeof(char)*100);
102 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
103#endif
104
106#if MAVLINK_CRC_EXTRA
107 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
108#else
109 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
110#endif
111}
112
113/**
114 * @brief Pack a component_metadata message on a channel
115 * @param system_id ID of this system
116 * @param component_id ID of this component (e.g. 200 for IMU)
117 * @param chan The MAVLink channel this message will be sent over
118 * @param msg The MAVLink message to compress the data into
119 * @param time_boot_ms [ms] Timestamp (time since system boot).
120 * @param file_crc CRC32 of the general metadata file.
121 * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
122 * @return length of the message in bytes (excluding serial stream start sign)
123 */
124static inline uint16_t mavlink_msg_component_metadata_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
125 mavlink_message_t* msg,
126 uint32_t time_boot_ms,uint32_t file_crc,const char *uri)
127{
128#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
130 _mav_put_uint32_t(buf, 0, time_boot_ms);
131 _mav_put_uint32_t(buf, 4, file_crc);
132 _mav_put_char_array(buf, 8, uri, 100);
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
134#else
135 mavlink_component_metadata_t packet;
136 packet.time_boot_ms = time_boot_ms;
137 packet.file_crc = file_crc;
138 mav_array_memcpy(packet.uri, uri, sizeof(char)*100);
139 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
140#endif
141
143 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
144}
145
146/**
147 * @brief Encode a component_metadata struct
148 *
149 * @param system_id ID of this system
150 * @param component_id ID of this component (e.g. 200 for IMU)
151 * @param msg The MAVLink message to compress the data into
152 * @param component_metadata C-struct to read the message contents from
153 */
154static inline uint16_t mavlink_msg_component_metadata_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
155{
156 return mavlink_msg_component_metadata_pack(system_id, component_id, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
157}
158
159/**
160 * @brief Encode a component_metadata struct on a channel
161 *
162 * @param system_id ID of this system
163 * @param component_id ID of this component (e.g. 200 for IMU)
164 * @param chan The MAVLink channel this message will be sent over
165 * @param msg The MAVLink message to compress the data into
166 * @param component_metadata C-struct to read the message contents from
167 */
168static inline uint16_t mavlink_msg_component_metadata_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
169{
170 return mavlink_msg_component_metadata_pack_chan(system_id, component_id, chan, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
171}
172
173/**
174 * @brief Encode a component_metadata struct with provided status structure
175 *
176 * @param system_id ID of this system
177 * @param component_id ID of this component (e.g. 200 for IMU)
178 * @param status MAVLink status structure
179 * @param msg The MAVLink message to compress the data into
180 * @param component_metadata C-struct to read the message contents from
181 */
182static inline uint16_t mavlink_msg_component_metadata_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
183{
184 return mavlink_msg_component_metadata_pack_status(system_id, component_id, _status, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
185}
186
187/**
188 * @brief Send a component_metadata message
189 * @param chan MAVLink channel to send the message
190 *
191 * @param time_boot_ms [ms] Timestamp (time since system boot).
192 * @param file_crc CRC32 of the general metadata file.
193 * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
194 */
195#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
196
197static inline void mavlink_msg_component_metadata_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
198{
199#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN];
201 _mav_put_uint32_t(buf, 0, time_boot_ms);
202 _mav_put_uint32_t(buf, 4, file_crc);
203 _mav_put_char_array(buf, 8, uri, 100);
204 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, buf, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
205#else
206 mavlink_component_metadata_t packet;
207 packet.time_boot_ms = time_boot_ms;
208 packet.file_crc = file_crc;
209 mav_array_memcpy(packet.uri, uri, sizeof(char)*100);
210 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)&packet, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
211#endif
212}
213
214/**
215 * @brief Send a component_metadata message
216 * @param chan MAVLink channel to send the message
217 * @param struct The MAVLink struct to serialize
218 */
219static inline void mavlink_msg_component_metadata_send_struct(mavlink_channel_t chan, const mavlink_component_metadata_t* component_metadata)
220{
221#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
222 mavlink_msg_component_metadata_send(chan, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
223#else
224 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)component_metadata, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
225#endif
226}
227
228#if MAVLINK_MSG_ID_COMPONENT_METADATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
229/*
230 This variant of _send() can be used to save stack space by reusing
231 memory from the receive buffer. The caller provides a
232 mavlink_message_t which is the size of a full mavlink message. This
233 is usually the receive buffer for the channel, and allows a reply to an
234 incoming message with minimum stack space usage.
235 */
236static inline void mavlink_msg_component_metadata_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
237{
238#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
239 char *buf = (char *)msgbuf;
240 _mav_put_uint32_t(buf, 0, time_boot_ms);
241 _mav_put_uint32_t(buf, 4, file_crc);
242 _mav_put_char_array(buf, 8, uri, 100);
243 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, buf, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
244#else
245 mavlink_component_metadata_t *packet = (mavlink_component_metadata_t *)msgbuf;
246 packet->time_boot_ms = time_boot_ms;
247 packet->file_crc = file_crc;
248 mav_array_memcpy(packet->uri, uri, sizeof(char)*100);
249 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)packet, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
250#endif
251}
252#endif
253
254#endif
255
256// MESSAGE COMPONENT_METADATA UNPACKING
257
258
259/**
260 * @brief Get field time_boot_ms from component_metadata message
261 *
262 * @return [ms] Timestamp (time since system boot).
263 */
264static inline uint32_t mavlink_msg_component_metadata_get_time_boot_ms(const mavlink_message_t* msg)
265{
266 return _MAV_RETURN_uint32_t(msg, 0);
267}
268
269/**
270 * @brief Get field file_crc from component_metadata message
271 *
272 * @return CRC32 of the general metadata file.
273 */
274static inline uint32_t mavlink_msg_component_metadata_get_file_crc(const mavlink_message_t* msg)
275{
276 return _MAV_RETURN_uint32_t(msg, 4);
277}
278
279/**
280 * @brief Get field uri from component_metadata message
281 *
282 * @return MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
283 */
284static inline uint16_t mavlink_msg_component_metadata_get_uri(const mavlink_message_t* msg, char *uri)
285{
286 return _MAV_RETURN_char_array(msg, uri, 100, 8);
287}
288
289/**
290 * @brief Decode a component_metadata message into a struct
291 *
292 * @param msg The message to decode
293 * @param component_metadata C-struct to decode the message contents into
294 */
295static inline void mavlink_msg_component_metadata_decode(const mavlink_message_t* msg, mavlink_component_metadata_t* component_metadata)
296{
297#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
298 component_metadata->time_boot_ms = mavlink_msg_component_metadata_get_time_boot_ms(msg);
299 component_metadata->file_crc = mavlink_msg_component_metadata_get_file_crc(msg);
300 mavlink_msg_component_metadata_get_uri(msg, component_metadata->uri);
301#else
302 uint8_t len = msg->len < MAVLINK_MSG_ID_COMPONENT_METADATA_LEN? msg->len : MAVLINK_MSG_ID_COMPONENT_METADATA_LEN;
303 memset(component_metadata, 0, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
304 memcpy(component_metadata, _MAV_PAYLOAD(msg), len);
305#endif
306}