source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_encapsulated_data.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 9.5 KB
Line 
1// MESSAGE ENCAPSULATED_DATA PACKING
2
3#define MAVLINK_MSG_ID_ENCAPSULATED_DATA 131
4
5typedef struct MAVLINK_PACKED __mavlink_encapsulated_data_t
6{
7 uint16_t seqnr; /*< sequence number (starting with 0 on every transmission)*/
8 uint8_t data[253]; /*< image data bytes*/
9} mavlink_encapsulated_data_t;
10
11#define MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN 255
12#define MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN 255
13#define MAVLINK_MSG_ID_131_LEN 255
14#define MAVLINK_MSG_ID_131_MIN_LEN 255
15
16#define MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC 223
17#define MAVLINK_MSG_ID_131_CRC 223
18
19#define MAVLINK_MSG_ENCAPSULATED_DATA_FIELD_DATA_LEN 253
20
21#if MAVLINK_COMMAND_24BIT
22#define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \
23 131, \
24 "ENCAPSULATED_DATA", \
25 2, \
26 { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \
27 { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \
28 } \
29}
30#else
31#define MAVLINK_MESSAGE_INFO_ENCAPSULATED_DATA { \
32 "ENCAPSULATED_DATA", \
33 2, \
34 { { "seqnr", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_encapsulated_data_t, seqnr) }, \
35 { "data", NULL, MAVLINK_TYPE_UINT8_T, 253, 2, offsetof(mavlink_encapsulated_data_t, data) }, \
36 } \
37}
38#endif
39
40/**
41 * @brief Pack a encapsulated_data message
42 * @param system_id ID of this system
43 * @param component_id ID of this component (e.g. 200 for IMU)
44 * @param msg The MAVLink message to compress the data into
45 *
46 * @param seqnr sequence number (starting with 0 on every transmission)
47 * @param data image data bytes
48 * @return length of the message in bytes (excluding serial stream start sign)
49 */
50static inline uint16_t mavlink_msg_encapsulated_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51 uint16_t seqnr, const uint8_t *data)
52{
53#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
54 char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN];
55 _mav_put_uint16_t(buf, 0, seqnr);
56 _mav_put_uint8_t_array(buf, 2, data, 253);
57 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN);
58#else
59 mavlink_encapsulated_data_t packet;
60 packet.seqnr = seqnr;
61 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253);
62 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN);
63#endif
64
65 msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA;
66 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
67}
68
69/**
70 * @brief Pack a encapsulated_data message on a channel
71 * @param system_id ID of this system
72 * @param component_id ID of this component (e.g. 200 for IMU)
73 * @param chan The MAVLink channel this message will be sent over
74 * @param msg The MAVLink message to compress the data into
75 * @param seqnr sequence number (starting with 0 on every transmission)
76 * @param data image data bytes
77 * @return length of the message in bytes (excluding serial stream start sign)
78 */
79static inline uint16_t mavlink_msg_encapsulated_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
80 mavlink_message_t* msg,
81 uint16_t seqnr,const uint8_t *data)
82{
83#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
84 char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN];
85 _mav_put_uint16_t(buf, 0, seqnr);
86 _mav_put_uint8_t_array(buf, 2, data, 253);
87 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN);
88#else
89 mavlink_encapsulated_data_t packet;
90 packet.seqnr = seqnr;
91 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253);
92 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN);
93#endif
94
95 msg->msgid = MAVLINK_MSG_ID_ENCAPSULATED_DATA;
96 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
97}
98
99/**
100 * @brief Encode a encapsulated_data struct
101 *
102 * @param system_id ID of this system
103 * @param component_id ID of this component (e.g. 200 for IMU)
104 * @param msg The MAVLink message to compress the data into
105 * @param encapsulated_data C-struct to read the message contents from
106 */
107static inline uint16_t mavlink_msg_encapsulated_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data)
108{
109 return mavlink_msg_encapsulated_data_pack(system_id, component_id, msg, encapsulated_data->seqnr, encapsulated_data->data);
110}
111
112/**
113 * @brief Encode a encapsulated_data struct on a channel
114 *
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 encapsulated_data C-struct to read the message contents from
120 */
121static inline uint16_t mavlink_msg_encapsulated_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_encapsulated_data_t* encapsulated_data)
122{
123 return mavlink_msg_encapsulated_data_pack_chan(system_id, component_id, chan, msg, encapsulated_data->seqnr, encapsulated_data->data);
124}
125
126/**
127 * @brief Send a encapsulated_data message
128 * @param chan MAVLink channel to send the message
129 *
130 * @param seqnr sequence number (starting with 0 on every transmission)
131 * @param data image data bytes
132 */
133#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
134
135static inline void mavlink_msg_encapsulated_data_send(mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data)
136{
137#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
138 char buf[MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN];
139 _mav_put_uint16_t(buf, 0, seqnr);
140 _mav_put_uint8_t_array(buf, 2, data, 253);
141 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
142#else
143 mavlink_encapsulated_data_t packet;
144 packet.seqnr = seqnr;
145 mav_array_memcpy(packet.data, data, sizeof(uint8_t)*253);
146 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)&packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
147#endif
148}
149
150/**
151 * @brief Send a encapsulated_data message
152 * @param chan MAVLink channel to send the message
153 * @param struct The MAVLink struct to serialize
154 */
155static inline void mavlink_msg_encapsulated_data_send_struct(mavlink_channel_t chan, const mavlink_encapsulated_data_t* encapsulated_data)
156{
157#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
158 mavlink_msg_encapsulated_data_send(chan, encapsulated_data->seqnr, encapsulated_data->data);
159#else
160 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)encapsulated_data, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
161#endif
162}
163
164#if MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
165/*
166 This varient of _send() can be used to save stack space by re-using
167 memory from the receive buffer. The caller provides a
168 mavlink_message_t which is the size of a full mavlink message. This
169 is usually the receive buffer for the channel, and allows a reply to an
170 incoming message with minimum stack space usage.
171 */
172static inline void mavlink_msg_encapsulated_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t seqnr, const uint8_t *data)
173{
174#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
175 char *buf = (char *)msgbuf;
176 _mav_put_uint16_t(buf, 0, seqnr);
177 _mav_put_uint8_t_array(buf, 2, data, 253);
178 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, buf, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
179#else
180 mavlink_encapsulated_data_t *packet = (mavlink_encapsulated_data_t *)msgbuf;
181 packet->seqnr = seqnr;
182 mav_array_memcpy(packet->data, data, sizeof(uint8_t)*253);
183 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ENCAPSULATED_DATA, (const char *)packet, MAVLINK_MSG_ID_ENCAPSULATED_DATA_MIN_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN, MAVLINK_MSG_ID_ENCAPSULATED_DATA_CRC);
184#endif
185}
186#endif
187
188#endif
189
190// MESSAGE ENCAPSULATED_DATA UNPACKING
191
192
193/**
194 * @brief Get field seqnr from encapsulated_data message
195 *
196 * @return sequence number (starting with 0 on every transmission)
197 */
198static inline uint16_t mavlink_msg_encapsulated_data_get_seqnr(const mavlink_message_t* msg)
199{
200 return _MAV_RETURN_uint16_t(msg, 0);
201}
202
203/**
204 * @brief Get field data from encapsulated_data message
205 *
206 * @return image data bytes
207 */
208static inline uint16_t mavlink_msg_encapsulated_data_get_data(const mavlink_message_t* msg, uint8_t *data)
209{
210 return _MAV_RETURN_uint8_t_array(msg, data, 253, 2);
211}
212
213/**
214 * @brief Decode a encapsulated_data message into a struct
215 *
216 * @param msg The message to decode
217 * @param encapsulated_data C-struct to decode the message contents into
218 */
219static inline void mavlink_msg_encapsulated_data_decode(const mavlink_message_t* msg, mavlink_encapsulated_data_t* encapsulated_data)
220{
221#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
222 encapsulated_data->seqnr = mavlink_msg_encapsulated_data_get_seqnr(msg);
223 mavlink_msg_encapsulated_data_get_data(msg, encapsulated_data->data);
224#else
225 uint8_t len = msg->len < MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN? msg->len : MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN;
226 memset(encapsulated_data, 0, MAVLINK_MSG_ID_ENCAPSULATED_DATA_LEN);
227 memcpy(encapsulated_data, _MAV_PAYLOAD(msg), len);
228#endif
229}
Note: See TracBrowser for help on using the repository browser.