RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_radio.h
1#pragma once
2// MESSAGE RADIO PACKING
3
4#define MAVLINK_MSG_ID_RADIO 166
5
6MAVPACKED(
7typedef struct __mavlink_radio_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; /*< how full the tx buffer is as a percentage*/
13 uint8_t noise; /*< background noise level*/
14 uint8_t remnoise; /*< remote background noise level*/
15}) mavlink_radio_t;
16
17#define MAVLINK_MSG_ID_RADIO_LEN 9
18#define MAVLINK_MSG_ID_RADIO_MIN_LEN 9
19#define MAVLINK_MSG_ID_166_LEN 9
20#define MAVLINK_MSG_ID_166_MIN_LEN 9
21
22#define MAVLINK_MSG_ID_RADIO_CRC 21
23#define MAVLINK_MSG_ID_166_CRC 21
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_RADIO { \
29 166, \
30 "RADIO", \
31 7, \
32 { { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_t, rssi) }, \
33 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_t, remrssi) }, \
34 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_t, txbuf) }, \
35 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_t, noise) }, \
36 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_t, remnoise) }, \
37 { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_t, rxerrors) }, \
38 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_t, fixed) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_RADIO { \
43 "RADIO", \
44 7, \
45 { { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_t, rssi) }, \
46 { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_t, remrssi) }, \
47 { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_t, txbuf) }, \
48 { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_t, noise) }, \
49 { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_t, remnoise) }, \
50 { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_t, rxerrors) }, \
51 { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_t, fixed) }, \
52 } \
53}
54#endif
55
71static inline uint16_t mavlink_msg_radio_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_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_LEN);
85#else
86 mavlink_radio_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_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_RADIO;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
100}
101
117static inline uint16_t mavlink_msg_radio_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_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_LEN);
132#else
133 mavlink_radio_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_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_RADIO;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
147}
148
157static inline uint16_t mavlink_msg_radio_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_radio_t* radio)
158{
159 return mavlink_msg_radio_pack(system_id, component_id, msg, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed);
160}
161
171static inline uint16_t mavlink_msg_radio_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_radio_t* radio)
172{
173 return mavlink_msg_radio_pack_chan(system_id, component_id, chan, msg, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed);
174}
175
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_radio_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_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, buf, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
203#else
204 mavlink_radio_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, (const char *)&packet, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
214#endif
215}
216
222static inline void mavlink_msg_radio_send_struct(mavlink_channel_t chan, const mavlink_radio_t* radio)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_radio_send(chan, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed);
226#else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO, (const char *)radio, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
228#endif
229}
230
231#if MAVLINK_MSG_ID_RADIO_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_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, buf, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
252#else
253 mavlink_radio_t *packet = (mavlink_radio_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, (const char *)packet, MAVLINK_MSG_ID_RADIO_MIN_LEN, MAVLINK_MSG_ID_RADIO_LEN, MAVLINK_MSG_ID_RADIO_CRC);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE RADIO UNPACKING
270
271
277static inline uint8_t mavlink_msg_radio_get_rssi(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_uint8_t(msg, 4);
280}
281
287static inline uint8_t mavlink_msg_radio_get_remrssi(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_uint8_t(msg, 5);
290}
291
297static inline uint8_t mavlink_msg_radio_get_txbuf(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_uint8_t(msg, 6);
300}
301
307static inline uint8_t mavlink_msg_radio_get_noise(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_uint8_t(msg, 7);
310}
311
317static inline uint8_t mavlink_msg_radio_get_remnoise(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_uint8_t(msg, 8);
320}
321
327static inline uint16_t mavlink_msg_radio_get_rxerrors(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_uint16_t(msg, 0);
330}
331
337static inline uint16_t mavlink_msg_radio_get_fixed(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_uint16_t(msg, 2);
340}
341
348static inline void mavlink_msg_radio_decode(const mavlink_message_t* msg, mavlink_radio_t* radio)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 radio->rxerrors = mavlink_msg_radio_get_rxerrors(msg);
352 radio->fixed = mavlink_msg_radio_get_fixed(msg);
353 radio->rssi = mavlink_msg_radio_get_rssi(msg);
354 radio->remrssi = mavlink_msg_radio_get_remrssi(msg);
355 radio->txbuf = mavlink_msg_radio_get_txbuf(msg);
356 radio->noise = mavlink_msg_radio_get_noise(msg);
357 radio->remnoise = mavlink_msg_radio_get_remnoise(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_RADIO_LEN? msg->len : MAVLINK_MSG_ID_RADIO_LEN;
360 memset(radio, 0, MAVLINK_MSG_ID_RADIO_LEN);
361 memcpy(radio, _MAV_PAYLOAD(msg), len);
362#endif
363}