[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_radio_status.h
blob8d266bb4e8072ae219f1745699455369b08a2816
1 #pragma once
2 // MESSAGE RADIO_STATUS PACKING
4 #define MAVLINK_MSG_ID_RADIO_STATUS 109
6 MAVPACKED(
7 typedef struct __mavlink_radio_status_t {
8 uint16_t rxerrors; /*< Receive errors*/
9 uint16_t fixed; /*< Count of error corrected packets*/
10 uint8_t rssi; /*< Local signal strength*/
11 uint8_t remrssi; /*< Remote signal strength*/
12 uint8_t txbuf; /*< Remaining free buffer space in percent.*/
13 uint8_t noise; /*< Background noise level*/
14 uint8_t remnoise; /*< Remote background noise level*/
15 }) mavlink_radio_status_t;
17 #define MAVLINK_MSG_ID_RADIO_STATUS_LEN 9
18 #define MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN 9
19 #define MAVLINK_MSG_ID_109_LEN 9
20 #define MAVLINK_MSG_ID_109_MIN_LEN 9
22 #define MAVLINK_MSG_ID_RADIO_STATUS_CRC 185
23 #define MAVLINK_MSG_ID_109_CRC 185
27 #if MAVLINK_COMMAND_24BIT
28 #define MAVLINK_MESSAGE_INFO_RADIO_STATUS { \
29 109, \
30 "RADIO_STATUS", \
31 7, \
32 { { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_status_t, rxerrors) }, \
33 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_status_t, fixed) }, \
34 { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_status_t, rssi) }, \
35 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_status_t, remrssi) }, \
36 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_status_t, txbuf) }, \
37 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_status_t, noise) }, \
38 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_status_t, remnoise) }, \
39 } \
41 #else
42 #define MAVLINK_MESSAGE_INFO_RADIO_STATUS { \
43 "RADIO_STATUS", \
44 7, \
45 { { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_status_t, rxerrors) }, \
46 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_status_t, fixed) }, \
47 { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_status_t, rssi) }, \
48 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_status_t, remrssi) }, \
49 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_status_t, txbuf) }, \
50 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_status_t, noise) }, \
51 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_status_t, remnoise) }, \
52 } \
54 #endif
56 /**
57 * @brief Pack a radio_status 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
62 * @param rssi Local signal strength
63 * @param remrssi Remote signal strength
64 * @param txbuf Remaining free buffer space in percent.
65 * @param noise Background noise level
66 * @param remnoise Remote background noise level
67 * @param rxerrors Receive errors
68 * @param fixed Count of error corrected packets
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_radio_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed)
74 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_RADIO_STATUS_LEN];
76 _mav_put_uint16_t(buf, 0, rxerrors);
77 _mav_put_uint16_t(buf, 2, fixed);
78 _mav_put_uint8_t(buf, 4, rssi);
79 _mav_put_uint8_t(buf, 5, remrssi);
80 _mav_put_uint8_t(buf, 6, txbuf);
81 _mav_put_uint8_t(buf, 7, noise);
82 _mav_put_uint8_t(buf, 8, remnoise);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
85 #else
86 mavlink_radio_status_t packet;
87 packet.rxerrors = rxerrors;
88 packet.fixed = fixed;
89 packet.rssi = rssi;
90 packet.remrssi = remrssi;
91 packet.txbuf = txbuf;
92 packet.noise = noise;
93 packet.remnoise = remnoise;
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
96 #endif
98 msg->msgid = MAVLINK_MSG_ID_RADIO_STATUS;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
103 * @brief Pack a radio_status 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 rssi Local signal strength
109 * @param remrssi Remote signal strength
110 * @param txbuf Remaining free buffer space in percent.
111 * @param noise Background noise level
112 * @param remnoise Remote background noise level
113 * @param rxerrors Receive errors
114 * @param fixed Count of error corrected packets
115 * @return length of the message in bytes (excluding serial stream start sign)
117 static inline uint16_t mavlink_msg_radio_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 uint8_t rssi,uint8_t remrssi,uint8_t txbuf,uint8_t noise,uint8_t remnoise,uint16_t rxerrors,uint16_t fixed)
121 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_RADIO_STATUS_LEN];
123 _mav_put_uint16_t(buf, 0, rxerrors);
124 _mav_put_uint16_t(buf, 2, fixed);
125 _mav_put_uint8_t(buf, 4, rssi);
126 _mav_put_uint8_t(buf, 5, remrssi);
127 _mav_put_uint8_t(buf, 6, txbuf);
128 _mav_put_uint8_t(buf, 7, noise);
129 _mav_put_uint8_t(buf, 8, remnoise);
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
132 #else
133 mavlink_radio_status_t packet;
134 packet.rxerrors = rxerrors;
135 packet.fixed = fixed;
136 packet.rssi = rssi;
137 packet.remrssi = remrssi;
138 packet.txbuf = txbuf;
139 packet.noise = noise;
140 packet.remnoise = remnoise;
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
143 #endif
145 msg->msgid = MAVLINK_MSG_ID_RADIO_STATUS;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
150 * @brief Encode a radio_status struct
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 radio_status C-struct to read the message contents from
157 static inline uint16_t mavlink_msg_radio_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_radio_status_t* radio_status)
159 return mavlink_msg_radio_status_pack(system_id, component_id, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed);
163 * @brief Encode a radio_status struct on a channel
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 radio_status C-struct to read the message contents from
171 static inline uint16_t mavlink_msg_radio_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_radio_status_t* radio_status)
173 return mavlink_msg_radio_status_pack_chan(system_id, component_id, chan, msg, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed);
177 * @brief Send a radio_status message
178 * @param chan MAVLink channel to send the message
180 * @param rssi Local signal strength
181 * @param remrssi Remote signal strength
182 * @param txbuf Remaining free buffer space in percent.
183 * @param noise Background noise level
184 * @param remnoise Remote background noise level
185 * @param rxerrors Receive errors
186 * @param fixed Count of error corrected packets
188 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
190 static inline void mavlink_msg_radio_status_send(mavlink_channel_t chan, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed)
192 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_RADIO_STATUS_LEN];
194 _mav_put_uint16_t(buf, 0, rxerrors);
195 _mav_put_uint16_t(buf, 2, fixed);
196 _mav_put_uint8_t(buf, 4, rssi);
197 _mav_put_uint8_t(buf, 5, remrssi);
198 _mav_put_uint8_t(buf, 6, txbuf);
199 _mav_put_uint8_t(buf, 7, noise);
200 _mav_put_uint8_t(buf, 8, remnoise);
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO_STATUS, buf, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
203 #else
204 mavlink_radio_status_t packet;
205 packet.rxerrors = rxerrors;
206 packet.fixed = fixed;
207 packet.rssi = rssi;
208 packet.remrssi = remrssi;
209 packet.txbuf = txbuf;
210 packet.noise = noise;
211 packet.remnoise = remnoise;
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO_STATUS, (const char *)&packet, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
214 #endif
218 * @brief Send a radio_status message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
222 static inline void mavlink_msg_radio_status_send_struct(mavlink_channel_t chan, const mavlink_radio_status_t* radio_status)
224 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_radio_status_send(chan, radio_status->rssi, radio_status->remrssi, radio_status->txbuf, radio_status->noise, radio_status->remnoise, radio_status->rxerrors, radio_status->fixed);
226 #else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO_STATUS, (const char *)radio_status, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
228 #endif
231 #if MAVLINK_MSG_ID_RADIO_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
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.
239 static inline void mavlink_msg_radio_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed)
241 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_uint16_t(buf, 0, rxerrors);
244 _mav_put_uint16_t(buf, 2, fixed);
245 _mav_put_uint8_t(buf, 4, rssi);
246 _mav_put_uint8_t(buf, 5, remrssi);
247 _mav_put_uint8_t(buf, 6, txbuf);
248 _mav_put_uint8_t(buf, 7, noise);
249 _mav_put_uint8_t(buf, 8, remnoise);
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO_STATUS, buf, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
252 #else
253 mavlink_radio_status_t *packet = (mavlink_radio_status_t *)msgbuf;
254 packet->rxerrors = rxerrors;
255 packet->fixed = fixed;
256 packet->rssi = rssi;
257 packet->remrssi = remrssi;
258 packet->txbuf = txbuf;
259 packet->noise = noise;
260 packet->remnoise = remnoise;
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO_STATUS, (const char *)packet, MAVLINK_MSG_ID_RADIO_STATUS_MIN_LEN, MAVLINK_MSG_ID_RADIO_STATUS_LEN, MAVLINK_MSG_ID_RADIO_STATUS_CRC);
263 #endif
265 #endif
267 #endif
269 // MESSAGE RADIO_STATUS UNPACKING
273 * @brief Get field rssi from radio_status message
275 * @return Local signal strength
277 static inline uint8_t mavlink_msg_radio_status_get_rssi(const mavlink_message_t* msg)
279 return _MAV_RETURN_uint8_t(msg, 4);
283 * @brief Get field remrssi from radio_status message
285 * @return Remote signal strength
287 static inline uint8_t mavlink_msg_radio_status_get_remrssi(const mavlink_message_t* msg)
289 return _MAV_RETURN_uint8_t(msg, 5);
293 * @brief Get field txbuf from radio_status message
295 * @return Remaining free buffer space in percent.
297 static inline uint8_t mavlink_msg_radio_status_get_txbuf(const mavlink_message_t* msg)
299 return _MAV_RETURN_uint8_t(msg, 6);
303 * @brief Get field noise from radio_status message
305 * @return Background noise level
307 static inline uint8_t mavlink_msg_radio_status_get_noise(const mavlink_message_t* msg)
309 return _MAV_RETURN_uint8_t(msg, 7);
313 * @brief Get field remnoise from radio_status message
315 * @return Remote background noise level
317 static inline uint8_t mavlink_msg_radio_status_get_remnoise(const mavlink_message_t* msg)
319 return _MAV_RETURN_uint8_t(msg, 8);
323 * @brief Get field rxerrors from radio_status message
325 * @return Receive errors
327 static inline uint16_t mavlink_msg_radio_status_get_rxerrors(const mavlink_message_t* msg)
329 return _MAV_RETURN_uint16_t(msg, 0);
333 * @brief Get field fixed from radio_status message
335 * @return Count of error corrected packets
337 static inline uint16_t mavlink_msg_radio_status_get_fixed(const mavlink_message_t* msg)
339 return _MAV_RETURN_uint16_t(msg, 2);
343 * @brief Decode a radio_status message into a struct
345 * @param msg The message to decode
346 * @param radio_status C-struct to decode the message contents into
348 static inline void mavlink_msg_radio_status_decode(const mavlink_message_t* msg, mavlink_radio_status_t* radio_status)
350 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 radio_status->rxerrors = mavlink_msg_radio_status_get_rxerrors(msg);
352 radio_status->fixed = mavlink_msg_radio_status_get_fixed(msg);
353 radio_status->rssi = mavlink_msg_radio_status_get_rssi(msg);
354 radio_status->remrssi = mavlink_msg_radio_status_get_remrssi(msg);
355 radio_status->txbuf = mavlink_msg_radio_status_get_txbuf(msg);
356 radio_status->noise = mavlink_msg_radio_status_get_noise(msg);
357 radio_status->remnoise = mavlink_msg_radio_status_get_remnoise(msg);
358 #else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_RADIO_STATUS_LEN? msg->len : MAVLINK_MSG_ID_RADIO_STATUS_LEN;
360 memset(radio_status, 0, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
361 memcpy(radio_status, _MAV_PAYLOAD(msg), len);
362 #endif