[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_file_transfer_protocol.h
blob07b5a3ef647815038004290eaf3ee057f52f277b
1 #pragma once
2 // MESSAGE FILE_TRANSFER_PROTOCOL PACKING
4 #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL 110
6 MAVPACKED(
7 typedef struct __mavlink_file_transfer_protocol_t {
8 uint8_t target_network; /*< Network ID (0 for broadcast)*/
9 uint8_t target_system; /*< System ID (0 for broadcast)*/
10 uint8_t target_component; /*< Component ID (0 for broadcast)*/
11 uint8_t payload[251]; /*< Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.*/
12 }) mavlink_file_transfer_protocol_t;
14 #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN 254
15 #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN 254
16 #define MAVLINK_MSG_ID_110_LEN 254
17 #define MAVLINK_MSG_ID_110_MIN_LEN 254
19 #define MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC 84
20 #define MAVLINK_MSG_ID_110_CRC 84
22 #define MAVLINK_MSG_FILE_TRANSFER_PROTOCOL_FIELD_PAYLOAD_LEN 251
24 #if MAVLINK_COMMAND_24BIT
25 #define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_PROTOCOL { \
26 110, \
27 "FILE_TRANSFER_PROTOCOL", \
28 4, \
29 { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_file_transfer_protocol_t, target_network) }, \
30 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_file_transfer_protocol_t, target_system) }, \
31 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_file_transfer_protocol_t, target_component) }, \
32 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 251, 3, offsetof(mavlink_file_transfer_protocol_t, payload) }, \
33 } \
35 #else
36 #define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_PROTOCOL { \
37 "FILE_TRANSFER_PROTOCOL", \
38 4, \
39 { { "target_network", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_file_transfer_protocol_t, target_network) }, \
40 { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_file_transfer_protocol_t, target_system) }, \
41 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_file_transfer_protocol_t, target_component) }, \
42 { "payload", NULL, MAVLINK_TYPE_UINT8_T, 251, 3, offsetof(mavlink_file_transfer_protocol_t, payload) }, \
43 } \
45 #endif
47 /**
48 * @brief Pack a file_transfer_protocol message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
53 * @param target_network Network ID (0 for broadcast)
54 * @param target_system System ID (0 for broadcast)
55 * @param target_component Component ID (0 for broadcast)
56 * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
57 * @return length of the message in bytes (excluding serial stream start sign)
59 static inline uint16_t mavlink_msg_file_transfer_protocol_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
64 _mav_put_uint8_t(buf, 0, target_network);
65 _mav_put_uint8_t(buf, 1, target_system);
66 _mav_put_uint8_t(buf, 2, target_component);
67 _mav_put_uint8_t_array(buf, 3, payload, 251);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
69 #else
70 mavlink_file_transfer_protocol_t packet;
71 packet.target_network = target_network;
72 packet.target_system = target_system;
73 packet.target_component = target_component;
74 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
76 #endif
78 msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL;
79 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
82 /**
83 * @brief Pack a file_transfer_protocol message on a channel
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param chan The MAVLink channel this message will be sent over
87 * @param msg The MAVLink message to compress the data into
88 * @param target_network Network ID (0 for broadcast)
89 * @param target_system System ID (0 for broadcast)
90 * @param target_component Component ID (0 for broadcast)
91 * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
92 * @return length of the message in bytes (excluding serial stream start sign)
94 static inline uint16_t mavlink_msg_file_transfer_protocol_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
95 mavlink_message_t* msg,
96 uint8_t target_network,uint8_t target_system,uint8_t target_component,const uint8_t *payload)
98 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
100 _mav_put_uint8_t(buf, 0, target_network);
101 _mav_put_uint8_t(buf, 1, target_system);
102 _mav_put_uint8_t(buf, 2, target_component);
103 _mav_put_uint8_t_array(buf, 3, payload, 251);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
105 #else
106 mavlink_file_transfer_protocol_t packet;
107 packet.target_network = target_network;
108 packet.target_system = target_system;
109 packet.target_component = target_component;
110 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
112 #endif
114 msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL;
115 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
119 * @brief Encode a file_transfer_protocol struct
121 * @param system_id ID of this system
122 * @param component_id ID of this component (e.g. 200 for IMU)
123 * @param msg The MAVLink message to compress the data into
124 * @param file_transfer_protocol C-struct to read the message contents from
126 static inline uint16_t mavlink_msg_file_transfer_protocol_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
128 return mavlink_msg_file_transfer_protocol_pack(system_id, component_id, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
132 * @brief Encode a file_transfer_protocol struct on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @param file_transfer_protocol C-struct to read the message contents from
140 static inline uint16_t mavlink_msg_file_transfer_protocol_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
142 return mavlink_msg_file_transfer_protocol_pack_chan(system_id, component_id, chan, msg, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
146 * @brief Send a file_transfer_protocol message
147 * @param chan MAVLink channel to send the message
149 * @param target_network Network ID (0 for broadcast)
150 * @param target_system System ID (0 for broadcast)
151 * @param target_component Component ID (0 for broadcast)
152 * @param payload Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
154 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
156 static inline void mavlink_msg_file_transfer_protocol_send(mavlink_channel_t chan, uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 char buf[MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN];
160 _mav_put_uint8_t(buf, 0, target_network);
161 _mav_put_uint8_t(buf, 1, target_system);
162 _mav_put_uint8_t(buf, 2, target_component);
163 _mav_put_uint8_t_array(buf, 3, payload, 251);
164 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
165 #else
166 mavlink_file_transfer_protocol_t packet;
167 packet.target_network = target_network;
168 packet.target_system = target_system;
169 packet.target_component = target_component;
170 mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*251);
171 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)&packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
172 #endif
176 * @brief Send a file_transfer_protocol message
177 * @param chan MAVLink channel to send the message
178 * @param struct The MAVLink struct to serialize
180 static inline void mavlink_msg_file_transfer_protocol_send_struct(mavlink_channel_t chan, const mavlink_file_transfer_protocol_t* file_transfer_protocol)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 mavlink_msg_file_transfer_protocol_send(chan, file_transfer_protocol->target_network, file_transfer_protocol->target_system, file_transfer_protocol->target_component, file_transfer_protocol->payload);
184 #else
185 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)file_transfer_protocol, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
186 #endif
189 #if MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
191 This varient of _send() can be used to save stack space by re-using
192 memory from the receive buffer. The caller provides a
193 mavlink_message_t which is the size of a full mavlink message. This
194 is usually the receive buffer for the channel, and allows a reply to an
195 incoming message with minimum stack space usage.
197 static inline void mavlink_msg_file_transfer_protocol_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_network, uint8_t target_system, uint8_t target_component, const uint8_t *payload)
199 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char *buf = (char *)msgbuf;
201 _mav_put_uint8_t(buf, 0, target_network);
202 _mav_put_uint8_t(buf, 1, target_system);
203 _mav_put_uint8_t(buf, 2, target_component);
204 _mav_put_uint8_t_array(buf, 3, payload, 251);
205 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, buf, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
206 #else
207 mavlink_file_transfer_protocol_t *packet = (mavlink_file_transfer_protocol_t *)msgbuf;
208 packet->target_network = target_network;
209 packet->target_system = target_system;
210 packet->target_component = target_component;
211 mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*251);
212 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL, (const char *)packet, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_MIN_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_CRC);
213 #endif
215 #endif
217 #endif
219 // MESSAGE FILE_TRANSFER_PROTOCOL UNPACKING
223 * @brief Get field target_network from file_transfer_protocol message
225 * @return Network ID (0 for broadcast)
227 static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_network(const mavlink_message_t* msg)
229 return _MAV_RETURN_uint8_t(msg, 0);
233 * @brief Get field target_system from file_transfer_protocol message
235 * @return System ID (0 for broadcast)
237 static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_system(const mavlink_message_t* msg)
239 return _MAV_RETURN_uint8_t(msg, 1);
243 * @brief Get field target_component from file_transfer_protocol message
245 * @return Component ID (0 for broadcast)
247 static inline uint8_t mavlink_msg_file_transfer_protocol_get_target_component(const mavlink_message_t* msg)
249 return _MAV_RETURN_uint8_t(msg, 2);
253 * @brief Get field payload from file_transfer_protocol message
255 * @return Variable length payload. The length is defined by the remaining message length when subtracting the header and other fields. The entire content of this block is opaque unless you understand any the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the mavlink specification.
257 static inline uint16_t mavlink_msg_file_transfer_protocol_get_payload(const mavlink_message_t* msg, uint8_t *payload)
259 return _MAV_RETURN_uint8_t_array(msg, payload, 251, 3);
263 * @brief Decode a file_transfer_protocol message into a struct
265 * @param msg The message to decode
266 * @param file_transfer_protocol C-struct to decode the message contents into
268 static inline void mavlink_msg_file_transfer_protocol_decode(const mavlink_message_t* msg, mavlink_file_transfer_protocol_t* file_transfer_protocol)
270 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
271 file_transfer_protocol->target_network = mavlink_msg_file_transfer_protocol_get_target_network(msg);
272 file_transfer_protocol->target_system = mavlink_msg_file_transfer_protocol_get_target_system(msg);
273 file_transfer_protocol->target_component = mavlink_msg_file_transfer_protocol_get_target_component(msg);
274 mavlink_msg_file_transfer_protocol_get_payload(msg, file_transfer_protocol->payload);
275 #else
276 uint8_t len = msg->len < MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN? msg->len : MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN;
277 memset(file_transfer_protocol, 0, MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL_LEN);
278 memcpy(file_transfer_protocol, _MAV_PAYLOAD(msg), len);
279 #endif