NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_uav_status.h
Go to the documentation of this file.
1 // MESSAGE UAV_STATUS PACKING
2 
3 #define MAVLINK_MSG_ID_UAV_STATUS 193
4 
5 typedef struct __mavlink_uav_status_t
6 {
7  float latitude;
8  float longitude;
9  float altitude;
10  float speed;
11  float course;
12  uint8_t target;
14 
15 #define MAVLINK_MSG_ID_UAV_STATUS_LEN 21
16 #define MAVLINK_MSG_ID_193_LEN 21
17 
18 #define MAVLINK_MSG_ID_UAV_STATUS_CRC 160
19 #define MAVLINK_MSG_ID_193_CRC 160
20 
21 
22 
23 #define MAVLINK_MESSAGE_INFO_UAV_STATUS { \
24  "UAV_STATUS", \
25  6, \
26  { { "latitude", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_uav_status_t, latitude) }, \
27  { "longitude", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_uav_status_t, longitude) }, \
28  { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_uav_status_t, altitude) }, \
29  { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_uav_status_t, speed) }, \
30  { "course", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_uav_status_t, course) }, \
31  { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_uav_status_t, target) }, \
32  } \
33 }
34 
35 
50 static inline uint16_t mavlink_msg_uav_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51  uint8_t target, float latitude, float longitude, float altitude, float speed, float course)
52 {
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55  _mav_put_float(buf, 0, latitude);
56  _mav_put_float(buf, 4, longitude);
57  _mav_put_float(buf, 8, altitude);
58  _mav_put_float(buf, 12, speed);
59  _mav_put_float(buf, 16, course);
60  _mav_put_uint8_t(buf, 20, target);
61 
63 #else
64  mavlink_uav_status_t packet;
65  packet.latitude = latitude;
66  packet.longitude = longitude;
67  packet.altitude = altitude;
68  packet.speed = speed;
69  packet.course = course;
70  packet.target = target;
71 
73 #endif
74 
75  msg->msgid = MAVLINK_MSG_ID_UAV_STATUS;
76 #if MAVLINK_CRC_EXTRA
78 #else
79  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAV_STATUS_LEN);
80 #endif
81 }
82 
97 static inline uint16_t mavlink_msg_uav_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
98  mavlink_message_t* msg,
99  uint8_t target,float latitude,float longitude,float altitude,float speed,float course)
100 {
101 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
103  _mav_put_float(buf, 0, latitude);
104  _mav_put_float(buf, 4, longitude);
105  _mav_put_float(buf, 8, altitude);
106  _mav_put_float(buf, 12, speed);
107  _mav_put_float(buf, 16, course);
108  _mav_put_uint8_t(buf, 20, target);
109 
111 #else
112  mavlink_uav_status_t packet;
113  packet.latitude = latitude;
114  packet.longitude = longitude;
115  packet.altitude = altitude;
116  packet.speed = speed;
117  packet.course = course;
118  packet.target = target;
119 
121 #endif
122 
123  msg->msgid = MAVLINK_MSG_ID_UAV_STATUS;
124 #if MAVLINK_CRC_EXTRA
126 #else
127  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_UAV_STATUS_LEN);
128 #endif
129 }
130 
139 static inline uint16_t mavlink_msg_uav_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_uav_status_t* uav_status)
140 {
141  return mavlink_msg_uav_status_pack(system_id, component_id, msg, uav_status->target, uav_status->latitude, uav_status->longitude, uav_status->altitude, uav_status->speed, uav_status->course);
142 }
143 
153 static inline uint16_t mavlink_msg_uav_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_uav_status_t* uav_status)
154 {
155  return mavlink_msg_uav_status_pack_chan(system_id, component_id, chan, msg, uav_status->target, uav_status->latitude, uav_status->longitude, uav_status->altitude, uav_status->speed, uav_status->course);
156 }
157 
169 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 
171 static inline void mavlink_msg_uav_status_send(mavlink_channel_t chan, uint8_t target, float latitude, float longitude, float altitude, float speed, float course)
172 {
173 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
175  _mav_put_float(buf, 0, latitude);
176  _mav_put_float(buf, 4, longitude);
177  _mav_put_float(buf, 8, altitude);
178  _mav_put_float(buf, 12, speed);
179  _mav_put_float(buf, 16, course);
180  _mav_put_uint8_t(buf, 20, target);
181 
182 #if MAVLINK_CRC_EXTRA
183  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, buf, MAVLINK_MSG_ID_UAV_STATUS_LEN, MAVLINK_MSG_ID_UAV_STATUS_CRC);
184 #else
185  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, buf, MAVLINK_MSG_ID_UAV_STATUS_LEN);
186 #endif
187 #else
188  mavlink_uav_status_t packet;
189  packet.latitude = latitude;
190  packet.longitude = longitude;
191  packet.altitude = altitude;
192  packet.speed = speed;
193  packet.course = course;
194  packet.target = target;
195 
196 #if MAVLINK_CRC_EXTRA
197  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, (const char *)&packet, MAVLINK_MSG_ID_UAV_STATUS_LEN, MAVLINK_MSG_ID_UAV_STATUS_CRC);
198 #else
199  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, (const char *)&packet, MAVLINK_MSG_ID_UAV_STATUS_LEN);
200 #endif
201 #endif
202 }
203 
204 #if MAVLINK_MSG_ID_UAV_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
205 /*
206  This varient of _send() can be used to save stack space by re-using
207  memory from the receive buffer. The caller provides a
208  mavlink_message_t which is the size of a full mavlink message. This
209  is usually the receive buffer for the channel, and allows a reply to an
210  incoming message with minimum stack space usage.
211  */
212 static inline void mavlink_msg_uav_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target, float latitude, float longitude, float altitude, float speed, float course)
213 {
214 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215  char *buf = (char *)msgbuf;
216  _mav_put_float(buf, 0, latitude);
217  _mav_put_float(buf, 4, longitude);
218  _mav_put_float(buf, 8, altitude);
219  _mav_put_float(buf, 12, speed);
220  _mav_put_float(buf, 16, course);
221  _mav_put_uint8_t(buf, 20, target);
222 
223 #if MAVLINK_CRC_EXTRA
224  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, buf, MAVLINK_MSG_ID_UAV_STATUS_LEN, MAVLINK_MSG_ID_UAV_STATUS_CRC);
225 #else
226  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, buf, MAVLINK_MSG_ID_UAV_STATUS_LEN);
227 #endif
228 #else
229  mavlink_uav_status_t *packet = (mavlink_uav_status_t *)msgbuf;
230  packet->latitude = latitude;
231  packet->longitude = longitude;
232  packet->altitude = altitude;
233  packet->speed = speed;
234  packet->course = course;
235  packet->target = target;
236 
237 #if MAVLINK_CRC_EXTRA
238  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, (const char *)packet, MAVLINK_MSG_ID_UAV_STATUS_LEN, MAVLINK_MSG_ID_UAV_STATUS_CRC);
239 #else
240  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAV_STATUS, (const char *)packet, MAVLINK_MSG_ID_UAV_STATUS_LEN);
241 #endif
242 #endif
243 }
244 #endif
245 
246 #endif
247 
248 // MESSAGE UAV_STATUS UNPACKING
249 
250 
256 static inline uint8_t mavlink_msg_uav_status_get_target(const mavlink_message_t* msg)
257 {
258  return _MAV_RETURN_uint8_t(msg, 20);
259 }
260 
266 static inline float mavlink_msg_uav_status_get_latitude(const mavlink_message_t* msg)
267 {
268  return _MAV_RETURN_float(msg, 0);
269 }
270 
276 static inline float mavlink_msg_uav_status_get_longitude(const mavlink_message_t* msg)
277 {
278  return _MAV_RETURN_float(msg, 4);
279 }
280 
286 static inline float mavlink_msg_uav_status_get_altitude(const mavlink_message_t* msg)
287 {
288  return _MAV_RETURN_float(msg, 8);
289 }
290 
296 static inline float mavlink_msg_uav_status_get_speed(const mavlink_message_t* msg)
297 {
298  return _MAV_RETURN_float(msg, 12);
299 }
300 
306 static inline float mavlink_msg_uav_status_get_course(const mavlink_message_t* msg)
307 {
308  return _MAV_RETURN_float(msg, 16);
309 }
310 
317 static inline void mavlink_msg_uav_status_decode(const mavlink_message_t* msg, mavlink_uav_status_t* uav_status)
318 {
319 #if MAVLINK_NEED_BYTE_SWAP
320  uav_status->latitude = mavlink_msg_uav_status_get_latitude(msg);
321  uav_status->longitude = mavlink_msg_uav_status_get_longitude(msg);
322  uav_status->altitude = mavlink_msg_uav_status_get_altitude(msg);
323  uav_status->speed = mavlink_msg_uav_status_get_speed(msg);
324  uav_status->course = mavlink_msg_uav_status_get_course(msg);
325  uav_status->target = mavlink_msg_uav_status_get_target(msg);
326 #else
327  memcpy(uav_status, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_UAV_STATUS_LEN);
328 #endif
329 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
#define _MAV_RETURN_uint8_t(msg, wire_offset)
Definition: protocol.h:238
#define _mav_put_uint8_t(buf, wire_offset, b)
Definition: protocol.h:134