Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_gps_status.h
blobcedd545845c3754f914e0be31279b7c559fbbe25
1 #pragma once
2 // MESSAGE GPS_STATUS PACKING
4 #define MAVLINK_MSG_ID_GPS_STATUS 25
7 typedef struct __mavlink_gps_status_t {
8 uint8_t satellites_visible; /*< Number of satellites visible*/
9 uint8_t satellite_prn[20]; /*< Global satellite ID*/
10 uint8_t satellite_used[20]; /*< 0: Satellite not used, 1: used for localization*/
11 uint8_t satellite_elevation[20]; /*< [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite*/
12 uint8_t satellite_azimuth[20]; /*< [deg] Direction of satellite, 0: 0 deg, 255: 360 deg.*/
13 uint8_t satellite_snr[20]; /*< [dB] Signal to noise ratio of satellite*/
14 } mavlink_gps_status_t;
16 #define MAVLINK_MSG_ID_GPS_STATUS_LEN 101
17 #define MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN 101
18 #define MAVLINK_MSG_ID_25_LEN 101
19 #define MAVLINK_MSG_ID_25_MIN_LEN 101
21 #define MAVLINK_MSG_ID_GPS_STATUS_CRC 23
22 #define MAVLINK_MSG_ID_25_CRC 23
24 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_PRN_LEN 20
25 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_USED_LEN 20
26 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_ELEVATION_LEN 20
27 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_AZIMUTH_LEN 20
28 #define MAVLINK_MSG_GPS_STATUS_FIELD_SATELLITE_SNR_LEN 20
30 #if MAVLINK_COMMAND_24BIT
31 #define MAVLINK_MESSAGE_INFO_GPS_STATUS { \
32 25, \
33 "GPS_STATUS", \
34 6, \
35 { { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_status_t, satellites_visible) }, \
36 { "satellite_prn", NULL, MAVLINK_TYPE_UINT8_T, 20, 1, offsetof(mavlink_gps_status_t, satellite_prn) }, \
37 { "satellite_used", NULL, MAVLINK_TYPE_UINT8_T, 20, 21, offsetof(mavlink_gps_status_t, satellite_used) }, \
38 { "satellite_elevation", NULL, MAVLINK_TYPE_UINT8_T, 20, 41, offsetof(mavlink_gps_status_t, satellite_elevation) }, \
39 { "satellite_azimuth", NULL, MAVLINK_TYPE_UINT8_T, 20, 61, offsetof(mavlink_gps_status_t, satellite_azimuth) }, \
40 { "satellite_snr", NULL, MAVLINK_TYPE_UINT8_T, 20, 81, offsetof(mavlink_gps_status_t, satellite_snr) }, \
41 } \
43 #else
44 #define MAVLINK_MESSAGE_INFO_GPS_STATUS { \
45 "GPS_STATUS", \
46 6, \
47 { { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_status_t, satellites_visible) }, \
48 { "satellite_prn", NULL, MAVLINK_TYPE_UINT8_T, 20, 1, offsetof(mavlink_gps_status_t, satellite_prn) }, \
49 { "satellite_used", NULL, MAVLINK_TYPE_UINT8_T, 20, 21, offsetof(mavlink_gps_status_t, satellite_used) }, \
50 { "satellite_elevation", NULL, MAVLINK_TYPE_UINT8_T, 20, 41, offsetof(mavlink_gps_status_t, satellite_elevation) }, \
51 { "satellite_azimuth", NULL, MAVLINK_TYPE_UINT8_T, 20, 61, offsetof(mavlink_gps_status_t, satellite_azimuth) }, \
52 { "satellite_snr", NULL, MAVLINK_TYPE_UINT8_T, 20, 81, offsetof(mavlink_gps_status_t, satellite_snr) }, \
53 } \
55 #endif
57 /**
58 * @brief Pack a gps_status message
59 * @param system_id ID of this system
60 * @param component_id ID of this component (e.g. 200 for IMU)
61 * @param msg The MAVLink message to compress the data into
63 * @param satellites_visible Number of satellites visible
64 * @param satellite_prn Global satellite ID
65 * @param satellite_used 0: Satellite not used, 1: used for localization
66 * @param satellite_elevation [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite
67 * @param satellite_azimuth [deg] Direction of satellite, 0: 0 deg, 255: 360 deg.
68 * @param satellite_snr [dB] Signal to noise ratio of satellite
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr)
74 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_GPS_STATUS_LEN];
76 _mav_put_uint8_t(buf, 0, satellites_visible);
77 _mav_put_uint8_t_array(buf, 1, satellite_prn, 20);
78 _mav_put_uint8_t_array(buf, 21, satellite_used, 20);
79 _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20);
80 _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20);
81 _mav_put_uint8_t_array(buf, 81, satellite_snr, 20);
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_STATUS_LEN);
83 #else
84 mavlink_gps_status_t packet;
85 packet.satellites_visible = satellites_visible;
86 mav_array_memcpy(packet.satellite_prn, satellite_prn, sizeof(uint8_t)*20);
87 mav_array_memcpy(packet.satellite_used, satellite_used, sizeof(uint8_t)*20);
88 mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20);
89 mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20);
90 mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20);
91 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_STATUS_LEN);
92 #endif
94 msg->msgid = MAVLINK_MSG_ID_GPS_STATUS;
95 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
98 /**
99 * @brief Pack a gps_status message on a channel
100 * @param system_id ID of this system
101 * @param component_id ID of this component (e.g. 200 for IMU)
102 * @param chan The MAVLink channel this message will be sent over
103 * @param msg The MAVLink message to compress the data into
104 * @param satellites_visible Number of satellites visible
105 * @param satellite_prn Global satellite ID
106 * @param satellite_used 0: Satellite not used, 1: used for localization
107 * @param satellite_elevation [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite
108 * @param satellite_azimuth [deg] Direction of satellite, 0: 0 deg, 255: 360 deg.
109 * @param satellite_snr [dB] Signal to noise ratio of satellite
110 * @return length of the message in bytes (excluding serial stream start sign)
112 static inline uint16_t mavlink_msg_gps_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
113 mavlink_message_t* msg,
114 uint8_t satellites_visible,const uint8_t *satellite_prn,const uint8_t *satellite_used,const uint8_t *satellite_elevation,const uint8_t *satellite_azimuth,const uint8_t *satellite_snr)
116 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
117 char buf[MAVLINK_MSG_ID_GPS_STATUS_LEN];
118 _mav_put_uint8_t(buf, 0, satellites_visible);
119 _mav_put_uint8_t_array(buf, 1, satellite_prn, 20);
120 _mav_put_uint8_t_array(buf, 21, satellite_used, 20);
121 _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20);
122 _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20);
123 _mav_put_uint8_t_array(buf, 81, satellite_snr, 20);
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_STATUS_LEN);
125 #else
126 mavlink_gps_status_t packet;
127 packet.satellites_visible = satellites_visible;
128 mav_array_memcpy(packet.satellite_prn, satellite_prn, sizeof(uint8_t)*20);
129 mav_array_memcpy(packet.satellite_used, satellite_used, sizeof(uint8_t)*20);
130 mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20);
131 mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20);
132 mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20);
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_STATUS_LEN);
134 #endif
136 msg->msgid = MAVLINK_MSG_ID_GPS_STATUS;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
141 * @brief Encode a gps_status struct
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param msg The MAVLink message to compress the data into
146 * @param gps_status C-struct to read the message contents from
148 static inline uint16_t mavlink_msg_gps_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status)
150 return mavlink_msg_gps_status_pack(system_id, component_id, msg, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr);
154 * @brief Encode a gps_status struct on a channel
156 * @param system_id ID of this system
157 * @param component_id ID of this component (e.g. 200 for IMU)
158 * @param chan The MAVLink channel this message will be sent over
159 * @param msg The MAVLink message to compress the data into
160 * @param gps_status C-struct to read the message contents from
162 static inline uint16_t mavlink_msg_gps_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_status_t* gps_status)
164 return mavlink_msg_gps_status_pack_chan(system_id, component_id, chan, msg, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr);
168 * @brief Send a gps_status message
169 * @param chan MAVLink channel to send the message
171 * @param satellites_visible Number of satellites visible
172 * @param satellite_prn Global satellite ID
173 * @param satellite_used 0: Satellite not used, 1: used for localization
174 * @param satellite_elevation [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite
175 * @param satellite_azimuth [deg] Direction of satellite, 0: 0 deg, 255: 360 deg.
176 * @param satellite_snr [dB] Signal to noise ratio of satellite
178 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
180 static inline void mavlink_msg_gps_status_send(mavlink_channel_t chan, uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_GPS_STATUS_LEN];
184 _mav_put_uint8_t(buf, 0, satellites_visible);
185 _mav_put_uint8_t_array(buf, 1, satellite_prn, 20);
186 _mav_put_uint8_t_array(buf, 21, satellite_used, 20);
187 _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20);
188 _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20);
189 _mav_put_uint8_t_array(buf, 81, satellite_snr, 20);
190 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_STATUS, buf, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
191 #else
192 mavlink_gps_status_t packet;
193 packet.satellites_visible = satellites_visible;
194 mav_array_memcpy(packet.satellite_prn, satellite_prn, sizeof(uint8_t)*20);
195 mav_array_memcpy(packet.satellite_used, satellite_used, sizeof(uint8_t)*20);
196 mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20);
197 mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20);
198 mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20);
199 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_STATUS, (const char *)&packet, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
200 #endif
204 * @brief Send a gps_status message
205 * @param chan MAVLink channel to send the message
206 * @param struct The MAVLink struct to serialize
208 static inline void mavlink_msg_gps_status_send_struct(mavlink_channel_t chan, const mavlink_gps_status_t* gps_status)
210 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
211 mavlink_msg_gps_status_send(chan, gps_status->satellites_visible, gps_status->satellite_prn, gps_status->satellite_used, gps_status->satellite_elevation, gps_status->satellite_azimuth, gps_status->satellite_snr);
212 #else
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_STATUS, (const char *)gps_status, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
214 #endif
217 #if MAVLINK_MSG_ID_GPS_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
219 This varient of _send() can be used to save stack space by re-using
220 memory from the receive buffer. The caller provides a
221 mavlink_message_t which is the size of a full mavlink message. This
222 is usually the receive buffer for the channel, and allows a reply to an
223 incoming message with minimum stack space usage.
225 static inline void mavlink_msg_gps_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t satellites_visible, const uint8_t *satellite_prn, const uint8_t *satellite_used, const uint8_t *satellite_elevation, const uint8_t *satellite_azimuth, const uint8_t *satellite_snr)
227 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
228 char *buf = (char *)msgbuf;
229 _mav_put_uint8_t(buf, 0, satellites_visible);
230 _mav_put_uint8_t_array(buf, 1, satellite_prn, 20);
231 _mav_put_uint8_t_array(buf, 21, satellite_used, 20);
232 _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20);
233 _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20);
234 _mav_put_uint8_t_array(buf, 81, satellite_snr, 20);
235 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_STATUS, buf, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
236 #else
237 mavlink_gps_status_t *packet = (mavlink_gps_status_t *)msgbuf;
238 packet->satellites_visible = satellites_visible;
239 mav_array_memcpy(packet->satellite_prn, satellite_prn, sizeof(uint8_t)*20);
240 mav_array_memcpy(packet->satellite_used, satellite_used, sizeof(uint8_t)*20);
241 mav_array_memcpy(packet->satellite_elevation, satellite_elevation, sizeof(uint8_t)*20);
242 mav_array_memcpy(packet->satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20);
243 mav_array_memcpy(packet->satellite_snr, satellite_snr, sizeof(uint8_t)*20);
244 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_STATUS, (const char *)packet, MAVLINK_MSG_ID_GPS_STATUS_MIN_LEN, MAVLINK_MSG_ID_GPS_STATUS_LEN, MAVLINK_MSG_ID_GPS_STATUS_CRC);
245 #endif
247 #endif
249 #endif
251 // MESSAGE GPS_STATUS UNPACKING
255 * @brief Get field satellites_visible from gps_status message
257 * @return Number of satellites visible
259 static inline uint8_t mavlink_msg_gps_status_get_satellites_visible(const mavlink_message_t* msg)
261 return _MAV_RETURN_uint8_t(msg, 0);
265 * @brief Get field satellite_prn from gps_status message
267 * @return Global satellite ID
269 static inline uint16_t mavlink_msg_gps_status_get_satellite_prn(const mavlink_message_t* msg, uint8_t *satellite_prn)
271 return _MAV_RETURN_uint8_t_array(msg, satellite_prn, 20, 1);
275 * @brief Get field satellite_used from gps_status message
277 * @return 0: Satellite not used, 1: used for localization
279 static inline uint16_t mavlink_msg_gps_status_get_satellite_used(const mavlink_message_t* msg, uint8_t *satellite_used)
281 return _MAV_RETURN_uint8_t_array(msg, satellite_used, 20, 21);
285 * @brief Get field satellite_elevation from gps_status message
287 * @return [deg] Elevation (0: right on top of receiver, 90: on the horizon) of satellite
289 static inline uint16_t mavlink_msg_gps_status_get_satellite_elevation(const mavlink_message_t* msg, uint8_t *satellite_elevation)
291 return _MAV_RETURN_uint8_t_array(msg, satellite_elevation, 20, 41);
295 * @brief Get field satellite_azimuth from gps_status message
297 * @return [deg] Direction of satellite, 0: 0 deg, 255: 360 deg.
299 static inline uint16_t mavlink_msg_gps_status_get_satellite_azimuth(const mavlink_message_t* msg, uint8_t *satellite_azimuth)
301 return _MAV_RETURN_uint8_t_array(msg, satellite_azimuth, 20, 61);
305 * @brief Get field satellite_snr from gps_status message
307 * @return [dB] Signal to noise ratio of satellite
309 static inline uint16_t mavlink_msg_gps_status_get_satellite_snr(const mavlink_message_t* msg, uint8_t *satellite_snr)
311 return _MAV_RETURN_uint8_t_array(msg, satellite_snr, 20, 81);
315 * @brief Decode a gps_status message into a struct
317 * @param msg The message to decode
318 * @param gps_status C-struct to decode the message contents into
320 static inline void mavlink_msg_gps_status_decode(const mavlink_message_t* msg, mavlink_gps_status_t* gps_status)
322 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
323 gps_status->satellites_visible = mavlink_msg_gps_status_get_satellites_visible(msg);
324 mavlink_msg_gps_status_get_satellite_prn(msg, gps_status->satellite_prn);
325 mavlink_msg_gps_status_get_satellite_used(msg, gps_status->satellite_used);
326 mavlink_msg_gps_status_get_satellite_elevation(msg, gps_status->satellite_elevation);
327 mavlink_msg_gps_status_get_satellite_azimuth(msg, gps_status->satellite_azimuth);
328 mavlink_msg_gps_status_get_satellite_snr(msg, gps_status->satellite_snr);
329 #else
330 uint8_t len = msg->len < MAVLINK_MSG_ID_GPS_STATUS_LEN? msg->len : MAVLINK_MSG_ID_GPS_STATUS_LEN;
331 memset(gps_status, 0, MAVLINK_MSG_ID_GPS_STATUS_LEN);
332 memcpy(gps_status, _MAV_PAYLOAD(msg), len);
333 #endif