source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_vfr_hud.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.6 KB
Line 
1// MESSAGE VFR_HUD PACKING
2
3#define MAVLINK_MSG_ID_VFR_HUD 74
4
5typedef struct MAVLINK_PACKED __mavlink_vfr_hud_t
6{
7 float airspeed; /*< Current airspeed in m/s*/
8 float groundspeed; /*< Current ground speed in m/s*/
9 float alt; /*< Current altitude (MSL), in meters*/
10 float climb; /*< Current climb rate in meters/second*/
11 int16_t heading; /*< Current heading in degrees, in compass units (0..360, 0=north)*/
12 uint16_t throttle; /*< Current throttle setting in integer percent, 0 to 100*/
13} mavlink_vfr_hud_t;
14
15#define MAVLINK_MSG_ID_VFR_HUD_LEN 20
16#define MAVLINK_MSG_ID_VFR_HUD_MIN_LEN 20
17#define MAVLINK_MSG_ID_74_LEN 20
18#define MAVLINK_MSG_ID_74_MIN_LEN 20
19
20#define MAVLINK_MSG_ID_VFR_HUD_CRC 20
21#define MAVLINK_MSG_ID_74_CRC 20
22
23
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_VFR_HUD { \
27 74, \
28 "VFR_HUD", \
29 6, \
30 { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
31 { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
32 { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
33 { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
34 { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
35 { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
36 } \
37}
38#else
39#define MAVLINK_MESSAGE_INFO_VFR_HUD { \
40 "VFR_HUD", \
41 6, \
42 { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
43 { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
44 { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
45 { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
46 { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
47 { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
48 } \
49}
50#endif
51
52/**
53 * @brief Pack a vfr_hud message
54 * @param system_id ID of this system
55 * @param component_id ID of this component (e.g. 200 for IMU)
56 * @param msg The MAVLink message to compress the data into
57 *
58 * @param airspeed Current airspeed in m/s
59 * @param groundspeed Current ground speed in m/s
60 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
61 * @param throttle Current throttle setting in integer percent, 0 to 100
62 * @param alt Current altitude (MSL), in meters
63 * @param climb Current climb rate in meters/second
64 * @return length of the message in bytes (excluding serial stream start sign)
65 */
66static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
67 float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
68{
69#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
70 char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
71 _mav_put_float(buf, 0, airspeed);
72 _mav_put_float(buf, 4, groundspeed);
73 _mav_put_float(buf, 8, alt);
74 _mav_put_float(buf, 12, climb);
75 _mav_put_int16_t(buf, 16, heading);
76 _mav_put_uint16_t(buf, 18, throttle);
77
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
79#else
80 mavlink_vfr_hud_t packet;
81 packet.airspeed = airspeed;
82 packet.groundspeed = groundspeed;
83 packet.alt = alt;
84 packet.climb = climb;
85 packet.heading = heading;
86 packet.throttle = throttle;
87
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
89#endif
90
91 msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
92 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
93}
94
95/**
96 * @brief Pack a vfr_hud message on a channel
97 * @param system_id ID of this system
98 * @param component_id ID of this component (e.g. 200 for IMU)
99 * @param chan The MAVLink channel this message will be sent over
100 * @param msg The MAVLink message to compress the data into
101 * @param airspeed Current airspeed in m/s
102 * @param groundspeed Current ground speed in m/s
103 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
104 * @param throttle Current throttle setting in integer percent, 0 to 100
105 * @param alt Current altitude (MSL), in meters
106 * @param climb Current climb rate in meters/second
107 * @return length of the message in bytes (excluding serial stream start sign)
108 */
109static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
110 mavlink_message_t* msg,
111 float airspeed,float groundspeed,int16_t heading,uint16_t throttle,float alt,float climb)
112{
113#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114 char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
115 _mav_put_float(buf, 0, airspeed);
116 _mav_put_float(buf, 4, groundspeed);
117 _mav_put_float(buf, 8, alt);
118 _mav_put_float(buf, 12, climb);
119 _mav_put_int16_t(buf, 16, heading);
120 _mav_put_uint16_t(buf, 18, throttle);
121
122 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
123#else
124 mavlink_vfr_hud_t packet;
125 packet.airspeed = airspeed;
126 packet.groundspeed = groundspeed;
127 packet.alt = alt;
128 packet.climb = climb;
129 packet.heading = heading;
130 packet.throttle = throttle;
131
132 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
133#endif
134
135 msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
136 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
137}
138
139/**
140 * @brief Encode a vfr_hud struct
141 *
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param msg The MAVLink message to compress the data into
145 * @param vfr_hud C-struct to read the message contents from
146 */
147static inline uint16_t mavlink_msg_vfr_hud_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
148{
149 return mavlink_msg_vfr_hud_pack(system_id, component_id, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
150}
151
152/**
153 * @brief Encode a vfr_hud struct on a channel
154 *
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param vfr_hud C-struct to read the message contents from
160 */
161static inline uint16_t mavlink_msg_vfr_hud_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
162{
163 return mavlink_msg_vfr_hud_pack_chan(system_id, component_id, chan, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
164}
165
166/**
167 * @brief Send a vfr_hud message
168 * @param chan MAVLink channel to send the message
169 *
170 * @param airspeed Current airspeed in m/s
171 * @param groundspeed Current ground speed in m/s
172 * @param heading Current heading in degrees, in compass units (0..360, 0=north)
173 * @param throttle Current throttle setting in integer percent, 0 to 100
174 * @param alt Current altitude (MSL), in meters
175 * @param climb Current climb rate in meters/second
176 */
177#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
178
179static inline void mavlink_msg_vfr_hud_send(mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
180{
181#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
183 _mav_put_float(buf, 0, airspeed);
184 _mav_put_float(buf, 4, groundspeed);
185 _mav_put_float(buf, 8, alt);
186 _mav_put_float(buf, 12, climb);
187 _mav_put_int16_t(buf, 16, heading);
188 _mav_put_uint16_t(buf, 18, throttle);
189
190 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
191#else
192 mavlink_vfr_hud_t packet;
193 packet.airspeed = airspeed;
194 packet.groundspeed = groundspeed;
195 packet.alt = alt;
196 packet.climb = climb;
197 packet.heading = heading;
198 packet.throttle = throttle;
199
200 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)&packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
201#endif
202}
203
204/**
205 * @brief Send a vfr_hud message
206 * @param chan MAVLink channel to send the message
207 * @param struct The MAVLink struct to serialize
208 */
209static inline void mavlink_msg_vfr_hud_send_struct(mavlink_channel_t chan, const mavlink_vfr_hud_t* vfr_hud)
210{
211#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
212 mavlink_msg_vfr_hud_send(chan, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
213#else
214 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)vfr_hud, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
215#endif
216}
217
218#if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
219/*
220 This varient of _send() can be used to save stack space by re-using
221 memory from the receive buffer. The caller provides a
222 mavlink_message_t which is the size of a full mavlink message. This
223 is usually the receive buffer for the channel, and allows a reply to an
224 incoming message with minimum stack space usage.
225 */
226static inline void mavlink_msg_vfr_hud_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
227{
228#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
229 char *buf = (char *)msgbuf;
230 _mav_put_float(buf, 0, airspeed);
231 _mav_put_float(buf, 4, groundspeed);
232 _mav_put_float(buf, 8, alt);
233 _mav_put_float(buf, 12, climb);
234 _mav_put_int16_t(buf, 16, heading);
235 _mav_put_uint16_t(buf, 18, throttle);
236
237 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
238#else
239 mavlink_vfr_hud_t *packet = (mavlink_vfr_hud_t *)msgbuf;
240 packet->airspeed = airspeed;
241 packet->groundspeed = groundspeed;
242 packet->alt = alt;
243 packet->climb = climb;
244 packet->heading = heading;
245 packet->throttle = throttle;
246
247 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
248#endif
249}
250#endif
251
252#endif
253
254// MESSAGE VFR_HUD UNPACKING
255
256
257/**
258 * @brief Get field airspeed from vfr_hud message
259 *
260 * @return Current airspeed in m/s
261 */
262static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg)
263{
264 return _MAV_RETURN_float(msg, 0);
265}
266
267/**
268 * @brief Get field groundspeed from vfr_hud message
269 *
270 * @return Current ground speed in m/s
271 */
272static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg)
273{
274 return _MAV_RETURN_float(msg, 4);
275}
276
277/**
278 * @brief Get field heading from vfr_hud message
279 *
280 * @return Current heading in degrees, in compass units (0..360, 0=north)
281 */
282static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg)
283{
284 return _MAV_RETURN_int16_t(msg, 16);
285}
286
287/**
288 * @brief Get field throttle from vfr_hud message
289 *
290 * @return Current throttle setting in integer percent, 0 to 100
291 */
292static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg)
293{
294 return _MAV_RETURN_uint16_t(msg, 18);
295}
296
297/**
298 * @brief Get field alt from vfr_hud message
299 *
300 * @return Current altitude (MSL), in meters
301 */
302static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg)
303{
304 return _MAV_RETURN_float(msg, 8);
305}
306
307/**
308 * @brief Get field climb from vfr_hud message
309 *
310 * @return Current climb rate in meters/second
311 */
312static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg)
313{
314 return _MAV_RETURN_float(msg, 12);
315}
316
317/**
318 * @brief Decode a vfr_hud message into a struct
319 *
320 * @param msg The message to decode
321 * @param vfr_hud C-struct to decode the message contents into
322 */
323static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud)
324{
325#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
326 vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg);
327 vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg);
328 vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg);
329 vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg);
330 vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg);
331 vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg);
332#else
333 uint8_t len = msg->len < MAVLINK_MSG_ID_VFR_HUD_LEN? msg->len : MAVLINK_MSG_ID_VFR_HUD_LEN;
334 memset(vfr_hud, 0, MAVLINK_MSG_ID_VFR_HUD_LEN);
335 memcpy(vfr_hud, _MAV_PAYLOAD(msg), len);
336#endif
337}
Note: See TracBrowser for help on using the repository browser.