RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_radio_status.h
1#pragma once
2// MESSAGE RADIO_STATUS PACKING
3
4#define MAVLINK_MSG_ID_RADIO_STATUS 109
5
6MAVPACKED(
7typedef 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;
16
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
21
22#define MAVLINK_MSG_ID_RADIO_STATUS_CRC 185
23#define MAVLINK_MSG_ID_109_CRC 185
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_RADIO_STATUS { \
29 109, \
30 "RADIO_STATUS", \
31 7, \
32 { { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_status_t, rssi) }, \
33 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_status_t, remrssi) }, \
34 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_status_t, txbuf) }, \
35 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_status_t, noise) }, \
36 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_status_t, remnoise) }, \
37 { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_status_t, rxerrors) }, \
38 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_status_t, fixed) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_RADIO_STATUS { \
43 "RADIO_STATUS", \
44 7, \
45 { { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_status_t, rssi) }, \
46 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_status_t, remrssi) }, \
47 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_status_t, txbuf) }, \
48 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_status_t, noise) }, \
49 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_status_t, remnoise) }, \
50 { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_status_t, rxerrors) }, \
51 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_status_t, fixed) }, \
52 } \
53}
54#endif
55
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
61 *
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)
70 */
71static 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)
73{
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);
83
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;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
96#endif
97
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);
100}
101
102/**
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)
116 */
117static 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)
120{
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);
130
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;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RADIO_STATUS_LEN);
143#endif
144
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);
147}
148
149/**
150 * @brief Encode a radio_status 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 radio_status C-struct to read the message contents from
156 */
157static 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)
158{
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);
160}
161
162/**
163 * @brief Encode a radio_status 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 radio_status C-struct to read the message contents from
170 */
171static 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)
172{
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);
174}
175
176/**
177 * @brief Send a radio_status message
178 * @param chan MAVLink channel to send the message
179 *
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
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static 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)
191{
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);
201
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;
212
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
215}
216
217/**
218 * @brief Send a radio_status message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
221 */
222static inline void mavlink_msg_radio_status_send_struct(mavlink_channel_t chan, const mavlink_radio_status_t* radio_status)
223{
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
229}
230
231#if MAVLINK_MSG_ID_RADIO_STATUS_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_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)
240{
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);
250
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;
261
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
264}
265#endif
266
267#endif
268
269// MESSAGE RADIO_STATUS UNPACKING
270
271
272/**
273 * @brief Get field rssi from radio_status message
274 *
275 * @return Local signal strength
276 */
277static inline uint8_t mavlink_msg_radio_status_get_rssi(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_uint8_t(msg, 4);
280}
281
282/**
283 * @brief Get field remrssi from radio_status message
284 *
285 * @return Remote signal strength
286 */
287static inline uint8_t mavlink_msg_radio_status_get_remrssi(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_uint8_t(msg, 5);
290}
291
292/**
293 * @brief Get field txbuf from radio_status message
294 *
295 * @return Remaining free buffer space in percent.
296 */
297static inline uint8_t mavlink_msg_radio_status_get_txbuf(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_uint8_t(msg, 6);
300}
301
302/**
303 * @brief Get field noise from radio_status message
304 *
305 * @return Background noise level
306 */
307static inline uint8_t mavlink_msg_radio_status_get_noise(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_uint8_t(msg, 7);
310}
311
312/**
313 * @brief Get field remnoise from radio_status message
314 *
315 * @return Remote background noise level
316 */
317static inline uint8_t mavlink_msg_radio_status_get_remnoise(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_uint8_t(msg, 8);
320}
321
322/**
323 * @brief Get field rxerrors from radio_status message
324 *
325 * @return Receive errors
326 */
327static inline uint16_t mavlink_msg_radio_status_get_rxerrors(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_uint16_t(msg, 0);
330}
331
332/**
333 * @brief Get field fixed from radio_status message
334 *
335 * @return Count of error corrected packets
336 */
337static inline uint16_t mavlink_msg_radio_status_get_fixed(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_uint16_t(msg, 2);
340}
341
342/**
343 * @brief Decode a radio_status message into a struct
344 *
345 * @param msg The message to decode
346 * @param radio_status C-struct to decode the message contents into
347 */
348static inline void mavlink_msg_radio_status_decode(const mavlink_message_t* msg, mavlink_radio_status_t* radio_status)
349{
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
363}