RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_status_gps.h
1#pragma once
2// MESSAGE STATUS_GPS PACKING
3
4#define MAVLINK_MSG_ID_STATUS_GPS 194
5
6MAVPACKED(
7typedef struct __mavlink_status_gps_t {
8 float magVar; /*< Magnetic variation, degrees */
9 uint16_t csFails; /*< Number of times checksum has failed*/
10 uint8_t gpsQuality; /*< The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a*/
11 uint8_t msgsType; /*< Indicates if GN, GL or GP messages are being received*/
12 uint8_t posStatus; /*< A = data valid, V = data invalid*/
13 int8_t magDir; /*< Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course*/
14 uint8_t modeInd; /*< Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid*/
15}) mavlink_status_gps_t;
16
17#define MAVLINK_MSG_ID_STATUS_GPS_LEN 11
18#define MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN 11
19#define MAVLINK_MSG_ID_194_LEN 11
20#define MAVLINK_MSG_ID_194_MIN_LEN 11
21
22#define MAVLINK_MSG_ID_STATUS_GPS_CRC 51
23#define MAVLINK_MSG_ID_194_CRC 51
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_STATUS_GPS { \
29 194, \
30 "STATUS_GPS", \
31 7, \
32 { { "csFails", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_status_gps_t, csFails) }, \
33 { "gpsQuality", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_status_gps_t, gpsQuality) }, \
34 { "msgsType", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_status_gps_t, msgsType) }, \
35 { "posStatus", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_status_gps_t, posStatus) }, \
36 { "magVar", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_status_gps_t, magVar) }, \
37 { "magDir", NULL, MAVLINK_TYPE_INT8_T, 0, 9, offsetof(mavlink_status_gps_t, magDir) }, \
38 { "modeInd", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_status_gps_t, modeInd) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_STATUS_GPS { \
43 "STATUS_GPS", \
44 7, \
45 { { "csFails", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_status_gps_t, csFails) }, \
46 { "gpsQuality", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_status_gps_t, gpsQuality) }, \
47 { "msgsType", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_status_gps_t, msgsType) }, \
48 { "posStatus", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_status_gps_t, posStatus) }, \
49 { "magVar", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_status_gps_t, magVar) }, \
50 { "magDir", NULL, MAVLINK_TYPE_INT8_T, 0, 9, offsetof(mavlink_status_gps_t, magDir) }, \
51 { "modeInd", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_status_gps_t, modeInd) }, \
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a status_gps message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
61 *
62 * @param csFails Number of times checksum has failed
63 * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
64 * @param msgsType Indicates if GN, GL or GP messages are being received
65 * @param posStatus A = data valid, V = data invalid
66 * @param magVar Magnetic variation, degrees
67 * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
68 * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
69 * @return length of the message in bytes (excluding serial stream start sign)
70 */
71static inline uint16_t mavlink_msg_status_gps_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
76 _mav_put_float(buf, 0, magVar);
77 _mav_put_uint16_t(buf, 4, csFails);
78 _mav_put_uint8_t(buf, 6, gpsQuality);
79 _mav_put_uint8_t(buf, 7, msgsType);
80 _mav_put_uint8_t(buf, 8, posStatus);
81 _mav_put_int8_t(buf, 9, magDir);
82 _mav_put_uint8_t(buf, 10, modeInd);
83
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUS_GPS_LEN);
85#else
86 mavlink_status_gps_t packet;
87 packet.magVar = magVar;
88 packet.csFails = csFails;
89 packet.gpsQuality = gpsQuality;
90 packet.msgsType = msgsType;
91 packet.posStatus = posStatus;
92 packet.magDir = magDir;
93 packet.modeInd = modeInd;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUS_GPS_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_STATUS_GPS;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
100}
101
102/**
103 * @brief Pack a status_gps message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param csFails Number of times checksum has failed
109 * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
110 * @param msgsType Indicates if GN, GL or GP messages are being received
111 * @param posStatus A = data valid, V = data invalid
112 * @param magVar Magnetic variation, degrees
113 * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
114 * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
115 * @return length of the message in bytes (excluding serial stream start sign)
116 */
117static inline uint16_t mavlink_msg_status_gps_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 uint16_t csFails,uint8_t gpsQuality,uint8_t msgsType,uint8_t posStatus,float magVar,int8_t magDir,uint8_t modeInd)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
123 _mav_put_float(buf, 0, magVar);
124 _mav_put_uint16_t(buf, 4, csFails);
125 _mav_put_uint8_t(buf, 6, gpsQuality);
126 _mav_put_uint8_t(buf, 7, msgsType);
127 _mav_put_uint8_t(buf, 8, posStatus);
128 _mav_put_int8_t(buf, 9, magDir);
129 _mav_put_uint8_t(buf, 10, modeInd);
130
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUS_GPS_LEN);
132#else
133 mavlink_status_gps_t packet;
134 packet.magVar = magVar;
135 packet.csFails = csFails;
136 packet.gpsQuality = gpsQuality;
137 packet.msgsType = msgsType;
138 packet.posStatus = posStatus;
139 packet.magDir = magDir;
140 packet.modeInd = modeInd;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUS_GPS_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_STATUS_GPS;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
147}
148
149/**
150 * @brief Encode a status_gps struct
151 *
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param status_gps C-struct to read the message contents from
156 */
157static inline uint16_t mavlink_msg_status_gps_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_status_gps_t* status_gps)
158{
159 return mavlink_msg_status_gps_pack(system_id, component_id, msg, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
160}
161
162/**
163 * @brief Encode a status_gps struct on a channel
164 *
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param status_gps C-struct to read the message contents from
170 */
171static inline uint16_t mavlink_msg_status_gps_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_status_gps_t* status_gps)
172{
173 return mavlink_msg_status_gps_pack_chan(system_id, component_id, chan, msg, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
174}
175
176/**
177 * @brief Send a status_gps message
178 * @param chan MAVLink channel to send the message
179 *
180 * @param csFails Number of times checksum has failed
181 * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
182 * @param msgsType Indicates if GN, GL or GP messages are being received
183 * @param posStatus A = data valid, V = data invalid
184 * @param magVar Magnetic variation, degrees
185 * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
186 * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_status_gps_send(mavlink_channel_t chan, uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
194 _mav_put_float(buf, 0, magVar);
195 _mav_put_uint16_t(buf, 4, csFails);
196 _mav_put_uint8_t(buf, 6, gpsQuality);
197 _mav_put_uint8_t(buf, 7, msgsType);
198 _mav_put_uint8_t(buf, 8, posStatus);
199 _mav_put_int8_t(buf, 9, magDir);
200 _mav_put_uint8_t(buf, 10, modeInd);
201
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, buf, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
203#else
204 mavlink_status_gps_t packet;
205 packet.magVar = magVar;
206 packet.csFails = csFails;
207 packet.gpsQuality = gpsQuality;
208 packet.msgsType = msgsType;
209 packet.posStatus = posStatus;
210 packet.magDir = magDir;
211 packet.modeInd = modeInd;
212
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)&packet, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
214#endif
215}
216
217/**
218 * @brief Send a status_gps message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
221 */
222static inline void mavlink_msg_status_gps_send_struct(mavlink_channel_t chan, const mavlink_status_gps_t* status_gps)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_status_gps_send(chan, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
226#else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)status_gps, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
228#endif
229}
230
231#if MAVLINK_MSG_ID_STATUS_GPS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
232/*
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
238 */
239static inline void mavlink_msg_status_gps_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_float(buf, 0, magVar);
244 _mav_put_uint16_t(buf, 4, csFails);
245 _mav_put_uint8_t(buf, 6, gpsQuality);
246 _mav_put_uint8_t(buf, 7, msgsType);
247 _mav_put_uint8_t(buf, 8, posStatus);
248 _mav_put_int8_t(buf, 9, magDir);
249 _mav_put_uint8_t(buf, 10, modeInd);
250
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, buf, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
252#else
253 mavlink_status_gps_t *packet = (mavlink_status_gps_t *)msgbuf;
254 packet->magVar = magVar;
255 packet->csFails = csFails;
256 packet->gpsQuality = gpsQuality;
257 packet->msgsType = msgsType;
258 packet->posStatus = posStatus;
259 packet->magDir = magDir;
260 packet->modeInd = modeInd;
261
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)packet, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE STATUS_GPS UNPACKING
270
271
272/**
273 * @brief Get field csFails from status_gps message
274 *
275 * @return Number of times checksum has failed
276 */
277static inline uint16_t mavlink_msg_status_gps_get_csFails(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_uint16_t(msg, 4);
280}
281
282/**
283 * @brief Get field gpsQuality from status_gps message
284 *
285 * @return The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
286 */
287static inline uint8_t mavlink_msg_status_gps_get_gpsQuality(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_uint8_t(msg, 6);
290}
291
292/**
293 * @brief Get field msgsType from status_gps message
294 *
295 * @return Indicates if GN, GL or GP messages are being received
296 */
297static inline uint8_t mavlink_msg_status_gps_get_msgsType(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_uint8_t(msg, 7);
300}
301
302/**
303 * @brief Get field posStatus from status_gps message
304 *
305 * @return A = data valid, V = data invalid
306 */
307static inline uint8_t mavlink_msg_status_gps_get_posStatus(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_uint8_t(msg, 8);
310}
311
312/**
313 * @brief Get field magVar from status_gps message
314 *
315 * @return Magnetic variation, degrees
316 */
317static inline float mavlink_msg_status_gps_get_magVar(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_float(msg, 0);
320}
321
322/**
323 * @brief Get field magDir from status_gps message
324 *
325 * @return Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
326 */
327static inline int8_t mavlink_msg_status_gps_get_magDir(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_int8_t(msg, 9);
330}
331
332/**
333 * @brief Get field modeInd from status_gps message
334 *
335 * @return Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
336 */
337static inline uint8_t mavlink_msg_status_gps_get_modeInd(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_uint8_t(msg, 10);
340}
341
342/**
343 * @brief Decode a status_gps message into a struct
344 *
345 * @param msg The message to decode
346 * @param status_gps C-struct to decode the message contents into
347 */
348static inline void mavlink_msg_status_gps_decode(const mavlink_message_t* msg, mavlink_status_gps_t* status_gps)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 status_gps->magVar = mavlink_msg_status_gps_get_magVar(msg);
352 status_gps->csFails = mavlink_msg_status_gps_get_csFails(msg);
353 status_gps->gpsQuality = mavlink_msg_status_gps_get_gpsQuality(msg);
354 status_gps->msgsType = mavlink_msg_status_gps_get_msgsType(msg);
355 status_gps->posStatus = mavlink_msg_status_gps_get_posStatus(msg);
356 status_gps->magDir = mavlink_msg_status_gps_get_magDir(msg);
357 status_gps->modeInd = mavlink_msg_status_gps_get_modeInd(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_STATUS_GPS_LEN? msg->len : MAVLINK_MSG_ID_STATUS_GPS_LEN;
360 memset(status_gps, 0, MAVLINK_MSG_ID_STATUS_GPS_LEN);
361 memcpy(status_gps, _MAV_PAYLOAD(msg), len);
362#endif
363}