source: flair-src/trunk/tools/Controller/Mavlink/src/include/common/mavlink_msg_data_transmission_handshake.h @ 88

Last change on this file since 88 was 88, checked in by Sanahuja Guillaume, 5 years ago

m

File size: 17.1 KB
Line 
1// MESSAGE DATA_TRANSMISSION_HANDSHAKE PACKING
2
3#define MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE 130
4
5typedef struct MAVLINK_PACKED __mavlink_data_transmission_handshake_t
6{
7 uint32_t size; /*< total data size in bytes (set on ACK only)*/
8 uint16_t width; /*< Width of a matrix or image*/
9 uint16_t height; /*< Height of a matrix or image*/
10 uint16_t packets; /*< number of packets beeing sent (set on ACK only)*/
11 uint8_t type; /*< type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h)*/
12 uint8_t payload; /*< payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only)*/
13 uint8_t jpg_quality; /*< JPEG quality out of [1,100]*/
14} mavlink_data_transmission_handshake_t;
15
16#define MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN 13
17#define MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN 13
18#define MAVLINK_MSG_ID_130_LEN 13
19#define MAVLINK_MSG_ID_130_MIN_LEN 13
20
21#define MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC 29
22#define MAVLINK_MSG_ID_130_CRC 29
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_DATA_TRANSMISSION_HANDSHAKE { \
28        130, \
29        "DATA_TRANSMISSION_HANDSHAKE", \
30        7, \
31        {  { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_data_transmission_handshake_t, size) }, \
32         { "width", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_data_transmission_handshake_t, width) }, \
33         { "height", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_data_transmission_handshake_t, height) }, \
34         { "packets", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_data_transmission_handshake_t, packets) }, \
35         { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_data_transmission_handshake_t, type) }, \
36         { "payload", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_data_transmission_handshake_t, payload) }, \
37         { "jpg_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_data_transmission_handshake_t, jpg_quality) }, \
38         } \
39}
40#else
41#define MAVLINK_MESSAGE_INFO_DATA_TRANSMISSION_HANDSHAKE { \
42        "DATA_TRANSMISSION_HANDSHAKE", \
43        7, \
44        {  { "size", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_data_transmission_handshake_t, size) }, \
45         { "width", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_data_transmission_handshake_t, width) }, \
46         { "height", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_data_transmission_handshake_t, height) }, \
47         { "packets", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_data_transmission_handshake_t, packets) }, \
48         { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_data_transmission_handshake_t, type) }, \
49         { "payload", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_data_transmission_handshake_t, payload) }, \
50         { "jpg_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_data_transmission_handshake_t, jpg_quality) }, \
51         } \
52}
53#endif
54
55/**
56 * @brief Pack a data_transmission_handshake message
57 * @param system_id ID of this system
58 * @param component_id ID of this component (e.g. 200 for IMU)
59 * @param msg The MAVLink message to compress the data into
60 *
61 * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h)
62 * @param size total data size in bytes (set on ACK only)
63 * @param width Width of a matrix or image
64 * @param height Height of a matrix or image
65 * @param packets number of packets beeing sent (set on ACK only)
66 * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only)
67 * @param jpg_quality JPEG quality out of [1,100]
68 * @return length of the message in bytes (excluding serial stream start sign)
69 */
70static inline uint16_t mavlink_msg_data_transmission_handshake_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
71                                                       uint8_t type, uint32_t size, uint16_t width, uint16_t height, uint16_t packets, uint8_t payload, uint8_t jpg_quality)
72{
73#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
74        char buf[MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN];
75        _mav_put_uint32_t(buf, 0, size);
76        _mav_put_uint16_t(buf, 4, width);
77        _mav_put_uint16_t(buf, 6, height);
78        _mav_put_uint16_t(buf, 8, packets);
79        _mav_put_uint8_t(buf, 10, type);
80        _mav_put_uint8_t(buf, 11, payload);
81        _mav_put_uint8_t(buf, 12, jpg_quality);
82
83        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN);
84#else
85        mavlink_data_transmission_handshake_t packet;
86        packet.size = size;
87        packet.width = width;
88        packet.height = height;
89        packet.packets = packets;
90        packet.type = type;
91        packet.payload = payload;
92        packet.jpg_quality = jpg_quality;
93
94        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN);
95#endif
96
97        msg->msgid = MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE;
98    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
99}
100
101/**
102 * @brief Pack a data_transmission_handshake message on a channel
103 * @param system_id ID of this system
104 * @param component_id ID of this component (e.g. 200 for IMU)
105 * @param chan The MAVLink channel this message will be sent over
106 * @param msg The MAVLink message to compress the data into
107 * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h)
108 * @param size total data size in bytes (set on ACK only)
109 * @param width Width of a matrix or image
110 * @param height Height of a matrix or image
111 * @param packets number of packets beeing sent (set on ACK only)
112 * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only)
113 * @param jpg_quality JPEG quality out of [1,100]
114 * @return length of the message in bytes (excluding serial stream start sign)
115 */
116static inline uint16_t mavlink_msg_data_transmission_handshake_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
117                                                           mavlink_message_t* msg,
118                                                           uint8_t type,uint32_t size,uint16_t width,uint16_t height,uint16_t packets,uint8_t payload,uint8_t jpg_quality)
119{
120#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
121        char buf[MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN];
122        _mav_put_uint32_t(buf, 0, size);
123        _mav_put_uint16_t(buf, 4, width);
124        _mav_put_uint16_t(buf, 6, height);
125        _mav_put_uint16_t(buf, 8, packets);
126        _mav_put_uint8_t(buf, 10, type);
127        _mav_put_uint8_t(buf, 11, payload);
128        _mav_put_uint8_t(buf, 12, jpg_quality);
129
130        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN);
131#else
132        mavlink_data_transmission_handshake_t packet;
133        packet.size = size;
134        packet.width = width;
135        packet.height = height;
136        packet.packets = packets;
137        packet.type = type;
138        packet.payload = payload;
139        packet.jpg_quality = jpg_quality;
140
141        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN);
142#endif
143
144        msg->msgid = MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE;
145    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
146}
147
148/**
149 * @brief Encode a data_transmission_handshake struct
150 *
151 * @param system_id ID of this system
152 * @param component_id ID of this component (e.g. 200 for IMU)
153 * @param msg The MAVLink message to compress the data into
154 * @param data_transmission_handshake C-struct to read the message contents from
155 */
156static inline uint16_t mavlink_msg_data_transmission_handshake_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data_transmission_handshake_t* data_transmission_handshake)
157{
158        return mavlink_msg_data_transmission_handshake_pack(system_id, component_id, msg, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->width, data_transmission_handshake->height, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality);
159}
160
161/**
162 * @brief Encode a data_transmission_handshake struct on a channel
163 *
164 * @param system_id ID of this system
165 * @param component_id ID of this component (e.g. 200 for IMU)
166 * @param chan The MAVLink channel this message will be sent over
167 * @param msg The MAVLink message to compress the data into
168 * @param data_transmission_handshake C-struct to read the message contents from
169 */
170static inline uint16_t mavlink_msg_data_transmission_handshake_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_data_transmission_handshake_t* data_transmission_handshake)
171{
172        return mavlink_msg_data_transmission_handshake_pack_chan(system_id, component_id, chan, msg, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->width, data_transmission_handshake->height, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality);
173}
174
175/**
176 * @brief Send a data_transmission_handshake message
177 * @param chan MAVLink channel to send the message
178 *
179 * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h)
180 * @param size total data size in bytes (set on ACK only)
181 * @param width Width of a matrix or image
182 * @param height Height of a matrix or image
183 * @param packets number of packets beeing sent (set on ACK only)
184 * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only)
185 * @param jpg_quality JPEG quality out of [1,100]
186 */
187#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
188
189static inline void mavlink_msg_data_transmission_handshake_send(mavlink_channel_t chan, uint8_t type, uint32_t size, uint16_t width, uint16_t height, uint16_t packets, uint8_t payload, uint8_t jpg_quality)
190{
191#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
192        char buf[MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN];
193        _mav_put_uint32_t(buf, 0, size);
194        _mav_put_uint16_t(buf, 4, width);
195        _mav_put_uint16_t(buf, 6, height);
196        _mav_put_uint16_t(buf, 8, packets);
197        _mav_put_uint8_t(buf, 10, type);
198        _mav_put_uint8_t(buf, 11, payload);
199        _mav_put_uint8_t(buf, 12, jpg_quality);
200
201    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, buf, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
202#else
203        mavlink_data_transmission_handshake_t packet;
204        packet.size = size;
205        packet.width = width;
206        packet.height = height;
207        packet.packets = packets;
208        packet.type = type;
209        packet.payload = payload;
210        packet.jpg_quality = jpg_quality;
211
212    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, (const char *)&packet, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
213#endif
214}
215
216/**
217 * @brief Send a data_transmission_handshake message
218 * @param chan MAVLink channel to send the message
219 * @param struct The MAVLink struct to serialize
220 */
221static inline void mavlink_msg_data_transmission_handshake_send_struct(mavlink_channel_t chan, const mavlink_data_transmission_handshake_t* data_transmission_handshake)
222{
223#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
224    mavlink_msg_data_transmission_handshake_send(chan, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->width, data_transmission_handshake->height, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality);
225#else
226    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, (const char *)data_transmission_handshake, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
227#endif
228}
229
230#if MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
231/*
232  This varient of _send() can be used to save stack space by re-using
233  memory from the receive buffer.  The caller provides a
234  mavlink_message_t which is the size of a full mavlink message. This
235  is usually the receive buffer for the channel, and allows a reply to an
236  incoming message with minimum stack space usage.
237 */
238static inline void mavlink_msg_data_transmission_handshake_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint8_t type, uint32_t size, uint16_t width, uint16_t height, uint16_t packets, uint8_t payload, uint8_t jpg_quality)
239{
240#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
241        char *buf = (char *)msgbuf;
242        _mav_put_uint32_t(buf, 0, size);
243        _mav_put_uint16_t(buf, 4, width);
244        _mav_put_uint16_t(buf, 6, height);
245        _mav_put_uint16_t(buf, 8, packets);
246        _mav_put_uint8_t(buf, 10, type);
247        _mav_put_uint8_t(buf, 11, payload);
248        _mav_put_uint8_t(buf, 12, jpg_quality);
249
250    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, buf, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
251#else
252        mavlink_data_transmission_handshake_t *packet = (mavlink_data_transmission_handshake_t *)msgbuf;
253        packet->size = size;
254        packet->width = width;
255        packet->height = height;
256        packet->packets = packets;
257        packet->type = type;
258        packet->payload = payload;
259        packet->jpg_quality = jpg_quality;
260
261    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE, (const char *)packet, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_MIN_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_CRC);
262#endif
263}
264#endif
265
266#endif
267
268// MESSAGE DATA_TRANSMISSION_HANDSHAKE UNPACKING
269
270
271/**
272 * @brief Get field type from data_transmission_handshake message
273 *
274 * @return type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h)
275 */
276static inline uint8_t mavlink_msg_data_transmission_handshake_get_type(const mavlink_message_t* msg)
277{
278        return _MAV_RETURN_uint8_t(msg,  10);
279}
280
281/**
282 * @brief Get field size from data_transmission_handshake message
283 *
284 * @return total data size in bytes (set on ACK only)
285 */
286static inline uint32_t mavlink_msg_data_transmission_handshake_get_size(const mavlink_message_t* msg)
287{
288        return _MAV_RETURN_uint32_t(msg,  0);
289}
290
291/**
292 * @brief Get field width from data_transmission_handshake message
293 *
294 * @return Width of a matrix or image
295 */
296static inline uint16_t mavlink_msg_data_transmission_handshake_get_width(const mavlink_message_t* msg)
297{
298        return _MAV_RETURN_uint16_t(msg,  4);
299}
300
301/**
302 * @brief Get field height from data_transmission_handshake message
303 *
304 * @return Height of a matrix or image
305 */
306static inline uint16_t mavlink_msg_data_transmission_handshake_get_height(const mavlink_message_t* msg)
307{
308        return _MAV_RETURN_uint16_t(msg,  6);
309}
310
311/**
312 * @brief Get field packets from data_transmission_handshake message
313 *
314 * @return number of packets beeing sent (set on ACK only)
315 */
316static inline uint16_t mavlink_msg_data_transmission_handshake_get_packets(const mavlink_message_t* msg)
317{
318        return _MAV_RETURN_uint16_t(msg,  8);
319}
320
321/**
322 * @brief Get field payload from data_transmission_handshake message
323 *
324 * @return payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only)
325 */
326static inline uint8_t mavlink_msg_data_transmission_handshake_get_payload(const mavlink_message_t* msg)
327{
328        return _MAV_RETURN_uint8_t(msg,  11);
329}
330
331/**
332 * @brief Get field jpg_quality from data_transmission_handshake message
333 *
334 * @return JPEG quality out of [1,100]
335 */
336static inline uint8_t mavlink_msg_data_transmission_handshake_get_jpg_quality(const mavlink_message_t* msg)
337{
338        return _MAV_RETURN_uint8_t(msg,  12);
339}
340
341/**
342 * @brief Decode a data_transmission_handshake message into a struct
343 *
344 * @param msg The message to decode
345 * @param data_transmission_handshake C-struct to decode the message contents into
346 */
347static inline void mavlink_msg_data_transmission_handshake_decode(const mavlink_message_t* msg, mavlink_data_transmission_handshake_t* data_transmission_handshake)
348{
349#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
350        data_transmission_handshake->size = mavlink_msg_data_transmission_handshake_get_size(msg);
351        data_transmission_handshake->width = mavlink_msg_data_transmission_handshake_get_width(msg);
352        data_transmission_handshake->height = mavlink_msg_data_transmission_handshake_get_height(msg);
353        data_transmission_handshake->packets = mavlink_msg_data_transmission_handshake_get_packets(msg);
354        data_transmission_handshake->type = mavlink_msg_data_transmission_handshake_get_type(msg);
355        data_transmission_handshake->payload = mavlink_msg_data_transmission_handshake_get_payload(msg);
356        data_transmission_handshake->jpg_quality = mavlink_msg_data_transmission_handshake_get_jpg_quality(msg);
357#else
358        uint8_t len = msg->len < MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN? msg->len : MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN;
359        memset(data_transmission_handshake, 0, MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE_LEN);
360        memcpy(data_transmission_handshake, _MAV_PAYLOAD(msg), len);
361#endif
362}
Note: See TracBrowser for help on using the repository browser.