mavlink_msg_terrain_data.h
Go to the documentation of this file.
1 // MESSAGE TERRAIN_DATA PACKING
2 
3 #define MAVLINK_MSG_ID_TERRAIN_DATA 134
4 
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*/
13 
14 #define MAVLINK_MSG_ID_TERRAIN_DATA_LEN 43
15 #define MAVLINK_MSG_ID_134_LEN 43
16 
17 #define MAVLINK_MSG_ID_TERRAIN_DATA_CRC 229
18 #define MAVLINK_MSG_ID_134_CRC 229
19 
20 #define MAVLINK_MSG_TERRAIN_DATA_FIELD_DATA_LEN 16
21 
22 #define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
23  "TERRAIN_DATA", \
24  5, \
25  { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
26  { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
27  { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
28  { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
29  { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
30  } \
31 }
32 
33 
47 static inline uint16_t mavlink_msg_terrain_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
48  int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
49 {
50 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
52  _mav_put_int32_t(buf, 0, lat);
53  _mav_put_int32_t(buf, 4, lon);
54  _mav_put_uint16_t(buf, 8, grid_spacing);
55  _mav_put_uint8_t(buf, 42, gridbit);
56  _mav_put_int16_t_array(buf, 10, data, 16);
58 #else
60  packet.lat = lat;
61  packet.lon = lon;
62  packet.grid_spacing = grid_spacing;
63  packet.gridbit = gridbit;
64  mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
66 #endif
67 
68  msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
69 #if MAVLINK_CRC_EXTRA
71 #else
72  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
73 #endif
74 }
75 
89 static inline uint16_t mavlink_msg_terrain_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
90  mavlink_message_t* msg,
91  int32_t lat,int32_t lon,uint16_t grid_spacing,uint8_t gridbit,const int16_t *data)
92 {
93 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
95  _mav_put_int32_t(buf, 0, lat);
96  _mav_put_int32_t(buf, 4, lon);
97  _mav_put_uint16_t(buf, 8, grid_spacing);
98  _mav_put_uint8_t(buf, 42, gridbit);
99  _mav_put_int16_t_array(buf, 10, data, 16);
101 #else
102  mavlink_terrain_data_t packet;
103  packet.lat = lat;
104  packet.lon = lon;
105  packet.grid_spacing = grid_spacing;
106  packet.gridbit = gridbit;
107  mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
109 #endif
110 
111  msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
112 #if MAVLINK_CRC_EXTRA
114 #else
115  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
116 #endif
117 }
118 
127 static 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)
128 {
129  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);
130 }
131 
141 static 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)
142 {
143  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);
144 }
145 
156 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
157 
158 static 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)
159 {
160 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
162  _mav_put_int32_t(buf, 0, lat);
163  _mav_put_int32_t(buf, 4, lon);
165  _mav_put_uint8_t(buf, 42, gridbit);
166  _mav_put_int16_t_array(buf, 10, data, 16);
167 #if MAVLINK_CRC_EXTRA
169 #else
170  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
171 #endif
172 #else
173  mavlink_terrain_data_t packet;
174  packet.lat = lat;
175  packet.lon = lon;
176  packet.grid_spacing = grid_spacing;
177  packet.gridbit = gridbit;
178  mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
179 #if MAVLINK_CRC_EXTRA
180  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
181 #else
182  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
183 #endif
184 #endif
185 }
186 
187 #if MAVLINK_MSG_ID_TERRAIN_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
188 /*
189  This varient of _send() can be used to save stack space by re-using
190  memory from the receive buffer. The caller provides a
191  mavlink_message_t which is the size of a full mavlink message. This
192  is usually the receive buffer for the channel, and allows a reply to an
193  incoming message with minimum stack space usage.
194  */
195 static 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)
196 {
197 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
198  char *buf = (char *)msgbuf;
199  _mav_put_int32_t(buf, 0, lat);
200  _mav_put_int32_t(buf, 4, lon);
202  _mav_put_uint8_t(buf, 42, gridbit);
203  _mav_put_int16_t_array(buf, 10, data, 16);
204 #if MAVLINK_CRC_EXTRA
206 #else
207  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
208 #endif
209 #else
211  packet->lat = lat;
212  packet->lon = lon;
213  packet->grid_spacing = grid_spacing;
214  packet->gridbit = gridbit;
215  mav_array_memcpy(packet->data, data, sizeof(int16_t)*16);
216 #if MAVLINK_CRC_EXTRA
217  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
218 #else
219  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
220 #endif
221 #endif
222 }
223 #endif
224 
225 #endif
226 
227 // MESSAGE TERRAIN_DATA UNPACKING
228 
229 
235 static inline int32_t mavlink_msg_terrain_data_get_lat(const mavlink_message_t* msg)
236 {
237  return _MAV_RETURN_int32_t(msg, 0);
238 }
239 
245 static inline int32_t mavlink_msg_terrain_data_get_lon(const mavlink_message_t* msg)
246 {
247  return _MAV_RETURN_int32_t(msg, 4);
248 }
249 
255 static inline uint16_t mavlink_msg_terrain_data_get_grid_spacing(const mavlink_message_t* msg)
256 {
257  return _MAV_RETURN_uint16_t(msg, 8);
258 }
259 
265 static inline uint8_t mavlink_msg_terrain_data_get_gridbit(const mavlink_message_t* msg)
266 {
267  return _MAV_RETURN_uint8_t(msg, 42);
268 }
269 
275 static inline uint16_t mavlink_msg_terrain_data_get_data(const mavlink_message_t* msg, int16_t *data)
276 {
277  return _MAV_RETURN_int16_t_array(msg, data, 16, 10);
278 }
279 
286 static inline void mavlink_msg_terrain_data_decode(const mavlink_message_t* msg, mavlink_terrain_data_t* terrain_data)
287 {
288 #if MAVLINK_NEED_BYTE_SWAP
289  terrain_data->lat = mavlink_msg_terrain_data_get_lat(msg);
290  terrain_data->lon = mavlink_msg_terrain_data_get_lon(msg);
292  mavlink_msg_terrain_data_get_data(msg, terrain_data->data);
293  terrain_data->gridbit = mavlink_msg_terrain_data_get_gridbit(msg);
294 #else
295  memcpy(terrain_data, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
296 #endif
297 }
#define _MAV_RETURN_uint8_t(msg, wire_offset)
Definition: protocol.h:244
#define _mav_put_uint8_t(buf, wire_offset, b)
Definition: protocol.h:140
#define _mav_put_int32_t(buf, wire_offset, b)
Definition: protocol.h:148
static void mav_array_memcpy(void *dest, const void *src, size_t n)
Definition: protocol.h:176
#define _mav_put_uint16_t(buf, wire_offset, b)
Definition: protocol.h:145


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:19