source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_terrain_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: 12.3 KB
Line 
1// MESSAGE TERRAIN_DATA PACKING
2
3#define MAVLINK_MSG_ID_TERRAIN_DATA 134
4
5typedef struct MAVLINK_PACKED __mavlink_terrain_data_t
6{
7 int32_t lat; /*< Latitude of SW corner of first grid (degrees *10^7)*/
8 int32_t lon; /*< Longitude of SW corner of first grid (in degrees *10^7)*/
9 uint16_t grid_spacing; /*< Grid spacing in meters*/
10 int16_t data[16]; /*< Terrain data in meters AMSL*/
11 uint8_t gridbit; /*< bit within the terrain request mask*/
12} mavlink_terrain_data_t;
13
14#define MAVLINK_MSG_ID_TERRAIN_DATA_LEN 43
15#define MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN 43
16#define MAVLINK_MSG_ID_134_LEN 43
17#define MAVLINK_MSG_ID_134_MIN_LEN 43
18
19#define MAVLINK_MSG_ID_TERRAIN_DATA_CRC 229
20#define MAVLINK_MSG_ID_134_CRC 229
21
22#define MAVLINK_MSG_TERRAIN_DATA_FIELD_DATA_LEN 16
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
26 134, \
27 "TERRAIN_DATA", \
28 5, \
29 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
30 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
31 { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
32 { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
33 { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
34 } \
35}
36#else
37#define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
38 "TERRAIN_DATA", \
39 5, \
40 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
41 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
42 { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
43 { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
44 { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
45 } \
46}
47#endif
48
49/**
50 * @brief Pack a terrain_data message
51 * @param system_id ID of this system
52 * @param component_id ID of this component (e.g. 200 for IMU)
53 * @param msg The MAVLink message to compress the data into
54 *
55 * @param lat Latitude of SW corner of first grid (degrees *10^7)
56 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
57 * @param grid_spacing Grid spacing in meters
58 * @param gridbit bit within the terrain request mask
59 * @param data Terrain data in meters AMSL
60 * @return length of the message in bytes (excluding serial stream start sign)
61 */
62static inline uint16_t mavlink_msg_terrain_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63 int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
64{
65#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
67 _mav_put_int32_t(buf, 0, lat);
68 _mav_put_int32_t(buf, 4, lon);
69 _mav_put_uint16_t(buf, 8, grid_spacing);
70 _mav_put_uint8_t(buf, 42, gridbit);
71 _mav_put_int16_t_array(buf, 10, data, 16);
72 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
73#else
74 mavlink_terrain_data_t packet;
75 packet.lat = lat;
76 packet.lon = lon;
77 packet.grid_spacing = grid_spacing;
78 packet.gridbit = gridbit;
79 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
80 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
81#endif
82
83 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
84 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
85}
86
87/**
88 * @brief Pack a terrain_data message on a channel
89 * @param system_id ID of this system
90 * @param component_id ID of this component (e.g. 200 for IMU)
91 * @param chan The MAVLink channel this message will be sent over
92 * @param msg The MAVLink message to compress the data into
93 * @param lat Latitude of SW corner of first grid (degrees *10^7)
94 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
95 * @param grid_spacing Grid spacing in meters
96 * @param gridbit bit within the terrain request mask
97 * @param data Terrain data in meters AMSL
98 * @return length of the message in bytes (excluding serial stream start sign)
99 */
100static inline uint16_t mavlink_msg_terrain_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
101 mavlink_message_t* msg,
102 int32_t lat,int32_t lon,uint16_t grid_spacing,uint8_t gridbit,const int16_t *data)
103{
104#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
105 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
106 _mav_put_int32_t(buf, 0, lat);
107 _mav_put_int32_t(buf, 4, lon);
108 _mav_put_uint16_t(buf, 8, grid_spacing);
109 _mav_put_uint8_t(buf, 42, gridbit);
110 _mav_put_int16_t_array(buf, 10, data, 16);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
112#else
113 mavlink_terrain_data_t packet;
114 packet.lat = lat;
115 packet.lon = lon;
116 packet.grid_spacing = grid_spacing;
117 packet.gridbit = gridbit;
118 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
120#endif
121
122 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
123 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
124}
125
126/**
127 * @brief Encode a terrain_data struct
128 *
129 * @param system_id ID of this system
130 * @param component_id ID of this component (e.g. 200 for IMU)
131 * @param msg The MAVLink message to compress the data into
132 * @param terrain_data C-struct to read the message contents from
133 */
134static inline uint16_t mavlink_msg_terrain_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
135{
136 return mavlink_msg_terrain_data_pack(system_id, component_id, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
137}
138
139/**
140 * @brief Encode a terrain_data struct on a channel
141 *
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param chan The MAVLink channel this message will be sent over
145 * @param msg The MAVLink message to compress the data into
146 * @param terrain_data C-struct to read the message contents from
147 */
148static inline uint16_t mavlink_msg_terrain_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
149{
150 return mavlink_msg_terrain_data_pack_chan(system_id, component_id, chan, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
151}
152
153/**
154 * @brief Send a terrain_data message
155 * @param chan MAVLink channel to send the message
156 *
157 * @param lat Latitude of SW corner of first grid (degrees *10^7)
158 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
159 * @param grid_spacing Grid spacing in meters
160 * @param gridbit bit within the terrain request mask
161 * @param data Terrain data in meters AMSL
162 */
163#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
164
165static inline void mavlink_msg_terrain_data_send(mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
166{
167#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
168 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
169 _mav_put_int32_t(buf, 0, lat);
170 _mav_put_int32_t(buf, 4, lon);
171 _mav_put_uint16_t(buf, 8, grid_spacing);
172 _mav_put_uint8_t(buf, 42, gridbit);
173 _mav_put_int16_t_array(buf, 10, data, 16);
174 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
175#else
176 mavlink_terrain_data_t packet;
177 packet.lat = lat;
178 packet.lon = lon;
179 packet.grid_spacing = grid_spacing;
180 packet.gridbit = gridbit;
181 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
182 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
183#endif
184}
185
186/**
187 * @brief Send a terrain_data message
188 * @param chan MAVLink channel to send the message
189 * @param struct The MAVLink struct to serialize
190 */
191static inline void mavlink_msg_terrain_data_send_struct(mavlink_channel_t chan, const mavlink_terrain_data_t* terrain_data)
192{
193#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 mavlink_msg_terrain_data_send(chan, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
195#else
196 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)terrain_data, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
197#endif
198}
199
200#if MAVLINK_MSG_ID_TERRAIN_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
201/*
202 This varient of _send() can be used to save stack space by re-using
203 memory from the receive buffer. The caller provides a
204 mavlink_message_t which is the size of a full mavlink message. This
205 is usually the receive buffer for the channel, and allows a reply to an
206 incoming message with minimum stack space usage.
207 */
208static inline void mavlink_msg_terrain_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
209{
210#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
211 char *buf = (char *)msgbuf;
212 _mav_put_int32_t(buf, 0, lat);
213 _mav_put_int32_t(buf, 4, lon);
214 _mav_put_uint16_t(buf, 8, grid_spacing);
215 _mav_put_uint8_t(buf, 42, gridbit);
216 _mav_put_int16_t_array(buf, 10, data, 16);
217 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
218#else
219 mavlink_terrain_data_t *packet = (mavlink_terrain_data_t *)msgbuf;
220 packet->lat = lat;
221 packet->lon = lon;
222 packet->grid_spacing = grid_spacing;
223 packet->gridbit = gridbit;
224 mav_array_memcpy(packet->data, data, sizeof(int16_t)*16);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
226#endif
227}
228#endif
229
230#endif
231
232// MESSAGE TERRAIN_DATA UNPACKING
233
234
235/**
236 * @brief Get field lat from terrain_data message
237 *
238 * @return Latitude of SW corner of first grid (degrees *10^7)
239 */
240static inline int32_t mavlink_msg_terrain_data_get_lat(const mavlink_message_t* msg)
241{
242 return _MAV_RETURN_int32_t(msg, 0);
243}
244
245/**
246 * @brief Get field lon from terrain_data message
247 *
248 * @return Longitude of SW corner of first grid (in degrees *10^7)
249 */
250static inline int32_t mavlink_msg_terrain_data_get_lon(const mavlink_message_t* msg)
251{
252 return _MAV_RETURN_int32_t(msg, 4);
253}
254
255/**
256 * @brief Get field grid_spacing from terrain_data message
257 *
258 * @return Grid spacing in meters
259 */
260static inline uint16_t mavlink_msg_terrain_data_get_grid_spacing(const mavlink_message_t* msg)
261{
262 return _MAV_RETURN_uint16_t(msg, 8);
263}
264
265/**
266 * @brief Get field gridbit from terrain_data message
267 *
268 * @return bit within the terrain request mask
269 */
270static inline uint8_t mavlink_msg_terrain_data_get_gridbit(const mavlink_message_t* msg)
271{
272 return _MAV_RETURN_uint8_t(msg, 42);
273}
274
275/**
276 * @brief Get field data from terrain_data message
277 *
278 * @return Terrain data in meters AMSL
279 */
280static inline uint16_t mavlink_msg_terrain_data_get_data(const mavlink_message_t* msg, int16_t *data)
281{
282 return _MAV_RETURN_int16_t_array(msg, data, 16, 10);
283}
284
285/**
286 * @brief Decode a terrain_data message into a struct
287 *
288 * @param msg The message to decode
289 * @param terrain_data C-struct to decode the message contents into
290 */
291static inline void mavlink_msg_terrain_data_decode(const mavlink_message_t* msg, mavlink_terrain_data_t* terrain_data)
292{
293#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
294 terrain_data->lat = mavlink_msg_terrain_data_get_lat(msg);
295 terrain_data->lon = mavlink_msg_terrain_data_get_lon(msg);
296 terrain_data->grid_spacing = mavlink_msg_terrain_data_get_grid_spacing(msg);
297 mavlink_msg_terrain_data_get_data(msg, terrain_data->data);
298 terrain_data->gridbit = mavlink_msg_terrain_data_get_gridbit(msg);
299#else
300 uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_DATA_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_DATA_LEN;
301 memset(terrain_data, 0, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
302 memcpy(terrain_data, _MAV_PAYLOAD(msg), len);
303#endif
304}
Note: See TracBrowser for help on using the repository browser.