Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_rc_channels_raw.h
blobf2958157524f577f307c0e3b4fcb5613c686af7e
1 // MESSAGE RC_CHANNELS_RAW PACKING
3 #define MAVLINK_MSG_ID_RC_CHANNELS_RAW 35
5 typedef struct __mavlink_rc_channels_raw_t {
6 uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
7 uint16_t chan1_raw; ///< RC channel 1 value, in microseconds
8 uint16_t chan2_raw; ///< RC channel 2 value, in microseconds
9 uint16_t chan3_raw; ///< RC channel 3 value, in microseconds
10 uint16_t chan4_raw; ///< RC channel 4 value, in microseconds
11 uint16_t chan5_raw; ///< RC channel 5 value, in microseconds
12 uint16_t chan6_raw; ///< RC channel 6 value, in microseconds
13 uint16_t chan7_raw; ///< RC channel 7 value, in microseconds
14 uint16_t chan8_raw; ///< RC channel 8 value, in microseconds
15 uint8_t port; ///< Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos.
16 uint8_t rssi; ///< Receive signal strength indicator, 0: 0%, 255: 100%
17 } mavlink_rc_channels_raw_t;
19 #define MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN 22
20 #define MAVLINK_MSG_ID_35_LEN 22
23 #define MAVLINK_MESSAGE_INFO_RC_CHANNELS_RAW \
24 { \
25 "RC_CHANNELS_RAW", \
26 11, \
27 { \
28 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_rc_channels_raw_t, time_boot_ms) }, \
29 { "chan1_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_rc_channels_raw_t, chan1_raw) }, \
30 { "chan2_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_rc_channels_raw_t, chan2_raw) }, \
31 { "chan3_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_rc_channels_raw_t, chan3_raw) }, \
32 { "chan4_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_rc_channels_raw_t, chan4_raw) }, \
33 { "chan5_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_rc_channels_raw_t, chan5_raw) }, \
34 { "chan6_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_rc_channels_raw_t, chan6_raw) }, \
35 { "chan7_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_rc_channels_raw_t, chan7_raw) }, \
36 { "chan8_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_rc_channels_raw_t, chan8_raw) }, \
37 { "port", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_rc_channels_raw_t, port) }, \
38 { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_rc_channels_raw_t, rssi) }, \
39 } \
43 /**
44 * @brief Pack a rc_channels_raw message
45 * @param system_id ID of this system
46 * @param component_id ID of this component (e.g. 200 for IMU)
47 * @param msg The MAVLink message to compress the data into
49 * @param time_boot_ms Timestamp (milliseconds since system boot)
50 * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos.
51 * @param chan1_raw RC channel 1 value, in microseconds
52 * @param chan2_raw RC channel 2 value, in microseconds
53 * @param chan3_raw RC channel 3 value, in microseconds
54 * @param chan4_raw RC channel 4 value, in microseconds
55 * @param chan5_raw RC channel 5 value, in microseconds
56 * @param chan6_raw RC channel 6 value, in microseconds
57 * @param chan7_raw RC channel 7 value, in microseconds
58 * @param chan8_raw RC channel 8 value, in microseconds
59 * @param rssi Receive signal strength indicator, 0: 0%, 255: 100%
60 * @return length of the message in bytes (excluding serial stream start sign)
62 static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
63 uint32_t time_boot_ms, uint8_t port, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint8_t rssi)
65 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[22];
67 _mav_put_uint32_t(buf, 0, time_boot_ms);
68 _mav_put_uint16_t(buf, 4, chan1_raw);
69 _mav_put_uint16_t(buf, 6, chan2_raw);
70 _mav_put_uint16_t(buf, 8, chan3_raw);
71 _mav_put_uint16_t(buf, 10, chan4_raw);
72 _mav_put_uint16_t(buf, 12, chan5_raw);
73 _mav_put_uint16_t(buf, 14, chan6_raw);
74 _mav_put_uint16_t(buf, 16, chan7_raw);
75 _mav_put_uint16_t(buf, 18, chan8_raw);
76 _mav_put_uint8_t(buf, 20, port);
77 _mav_put_uint8_t(buf, 21, rssi);
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22);
80 #else
81 mavlink_rc_channels_raw_t packet;
82 packet.time_boot_ms = time_boot_ms;
83 packet.chan1_raw = chan1_raw;
84 packet.chan2_raw = chan2_raw;
85 packet.chan3_raw = chan3_raw;
86 packet.chan4_raw = chan4_raw;
87 packet.chan5_raw = chan5_raw;
88 packet.chan6_raw = chan6_raw;
89 packet.chan7_raw = chan7_raw;
90 packet.chan8_raw = chan8_raw;
91 packet.port = port;
92 packet.rssi = rssi;
94 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22);
95 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
97 msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW;
98 return mavlink_finalize_message(msg, system_id, component_id, 22, 244);
102 * @brief Pack a rc_channels_raw message on a channel
103 * @param system_id ID of this system
104 * @param component_id ID of this component (e.g. 200 for IMU)
105 * @param chan The MAVLink channel this message was sent over
106 * @param msg The MAVLink message to compress the data into
107 * @param time_boot_ms Timestamp (milliseconds since system boot)
108 * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos.
109 * @param chan1_raw RC channel 1 value, in microseconds
110 * @param chan2_raw RC channel 2 value, in microseconds
111 * @param chan3_raw RC channel 3 value, in microseconds
112 * @param chan4_raw RC channel 4 value, in microseconds
113 * @param chan5_raw RC channel 5 value, in microseconds
114 * @param chan6_raw RC channel 6 value, in microseconds
115 * @param chan7_raw RC channel 7 value, in microseconds
116 * @param chan8_raw RC channel 8 value, in microseconds
117 * @param rssi Receive signal strength indicator, 0: 0%, 255: 100%
118 * @return length of the message in bytes (excluding serial stream start sign)
120 static inline uint16_t mavlink_msg_rc_channels_raw_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
121 mavlink_message_t *msg,
122 uint32_t time_boot_ms, uint8_t port, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint8_t rssi)
124 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
125 char buf[22];
126 _mav_put_uint32_t(buf, 0, time_boot_ms);
127 _mav_put_uint16_t(buf, 4, chan1_raw);
128 _mav_put_uint16_t(buf, 6, chan2_raw);
129 _mav_put_uint16_t(buf, 8, chan3_raw);
130 _mav_put_uint16_t(buf, 10, chan4_raw);
131 _mav_put_uint16_t(buf, 12, chan5_raw);
132 _mav_put_uint16_t(buf, 14, chan6_raw);
133 _mav_put_uint16_t(buf, 16, chan7_raw);
134 _mav_put_uint16_t(buf, 18, chan8_raw);
135 _mav_put_uint8_t(buf, 20, port);
136 _mav_put_uint8_t(buf, 21, rssi);
138 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22);
139 #else
140 mavlink_rc_channels_raw_t packet;
141 packet.time_boot_ms = time_boot_ms;
142 packet.chan1_raw = chan1_raw;
143 packet.chan2_raw = chan2_raw;
144 packet.chan3_raw = chan3_raw;
145 packet.chan4_raw = chan4_raw;
146 packet.chan5_raw = chan5_raw;
147 packet.chan6_raw = chan6_raw;
148 packet.chan7_raw = chan7_raw;
149 packet.chan8_raw = chan8_raw;
150 packet.port = port;
151 packet.rssi = rssi;
153 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22);
154 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
156 msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW;
157 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 22, 244);
161 * @brief Encode a rc_channels_raw struct into a message
163 * @param system_id ID of this system
164 * @param component_id ID of this component (e.g. 200 for IMU)
165 * @param msg The MAVLink message to compress the data into
166 * @param rc_channels_raw C-struct to read the message contents from
168 static inline uint16_t mavlink_msg_rc_channels_raw_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_rc_channels_raw_t *rc_channels_raw)
170 return mavlink_msg_rc_channels_raw_pack(system_id, component_id, msg, rc_channels_raw->time_boot_ms, rc_channels_raw->port, rc_channels_raw->chan1_raw, rc_channels_raw->chan2_raw, rc_channels_raw->chan3_raw, rc_channels_raw->chan4_raw, rc_channels_raw->chan5_raw, rc_channels_raw->chan6_raw, rc_channels_raw->chan7_raw, rc_channels_raw->chan8_raw, rc_channels_raw->rssi);
174 * @brief Send a rc_channels_raw message
175 * @param chan MAVLink channel to send the message
177 * @param time_boot_ms Timestamp (milliseconds since system boot)
178 * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos.
179 * @param chan1_raw RC channel 1 value, in microseconds
180 * @param chan2_raw RC channel 2 value, in microseconds
181 * @param chan3_raw RC channel 3 value, in microseconds
182 * @param chan4_raw RC channel 4 value, in microseconds
183 * @param chan5_raw RC channel 5 value, in microseconds
184 * @param chan6_raw RC channel 6 value, in microseconds
185 * @param chan7_raw RC channel 7 value, in microseconds
186 * @param chan8_raw RC channel 8 value, in microseconds
187 * @param rssi Receive signal strength indicator, 0: 0%, 255: 100%
189 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
191 static inline void mavlink_msg_rc_channels_raw_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t port, uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, uint16_t chan7_raw, uint16_t chan8_raw, uint8_t rssi)
193 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 char buf[22];
195 _mav_put_uint32_t(buf, 0, time_boot_ms);
196 _mav_put_uint16_t(buf, 4, chan1_raw);
197 _mav_put_uint16_t(buf, 6, chan2_raw);
198 _mav_put_uint16_t(buf, 8, chan3_raw);
199 _mav_put_uint16_t(buf, 10, chan4_raw);
200 _mav_put_uint16_t(buf, 12, chan5_raw);
201 _mav_put_uint16_t(buf, 14, chan6_raw);
202 _mav_put_uint16_t(buf, 16, chan7_raw);
203 _mav_put_uint16_t(buf, 18, chan8_raw);
204 _mav_put_uint8_t(buf, 20, port);
205 _mav_put_uint8_t(buf, 21, rssi);
207 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RC_CHANNELS_RAW, buf, 22, 244);
208 #else
209 mavlink_rc_channels_raw_t packet;
210 packet.time_boot_ms = time_boot_ms;
211 packet.chan1_raw = chan1_raw;
212 packet.chan2_raw = chan2_raw;
213 packet.chan3_raw = chan3_raw;
214 packet.chan4_raw = chan4_raw;
215 packet.chan5_raw = chan5_raw;
216 packet.chan6_raw = chan6_raw;
217 packet.chan7_raw = chan7_raw;
218 packet.chan8_raw = chan8_raw;
219 packet.port = port;
220 packet.rssi = rssi;
222 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RC_CHANNELS_RAW, (const char *)&packet, 22, 244);
223 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
226 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
228 // MESSAGE RC_CHANNELS_RAW UNPACKING
232 * @brief Get field time_boot_ms from rc_channels_raw message
234 * @return Timestamp (milliseconds since system boot)
236 static inline uint32_t mavlink_msg_rc_channels_raw_get_time_boot_ms(const mavlink_message_t *msg)
238 return _MAV_RETURN_uint32_t(msg, 0);
242 * @brief Get field port from rc_channels_raw message
244 * @return Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos.
246 static inline uint8_t mavlink_msg_rc_channels_raw_get_port(const mavlink_message_t *msg)
248 return _MAV_RETURN_uint8_t(msg, 20);
252 * @brief Get field chan1_raw from rc_channels_raw message
254 * @return RC channel 1 value, in microseconds
256 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan1_raw(const mavlink_message_t *msg)
258 return _MAV_RETURN_uint16_t(msg, 4);
262 * @brief Get field chan2_raw from rc_channels_raw message
264 * @return RC channel 2 value, in microseconds
266 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan2_raw(const mavlink_message_t *msg)
268 return _MAV_RETURN_uint16_t(msg, 6);
272 * @brief Get field chan3_raw from rc_channels_raw message
274 * @return RC channel 3 value, in microseconds
276 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan3_raw(const mavlink_message_t *msg)
278 return _MAV_RETURN_uint16_t(msg, 8);
282 * @brief Get field chan4_raw from rc_channels_raw message
284 * @return RC channel 4 value, in microseconds
286 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan4_raw(const mavlink_message_t *msg)
288 return _MAV_RETURN_uint16_t(msg, 10);
292 * @brief Get field chan5_raw from rc_channels_raw message
294 * @return RC channel 5 value, in microseconds
296 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan5_raw(const mavlink_message_t *msg)
298 return _MAV_RETURN_uint16_t(msg, 12);
302 * @brief Get field chan6_raw from rc_channels_raw message
304 * @return RC channel 6 value, in microseconds
306 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan6_raw(const mavlink_message_t *msg)
308 return _MAV_RETURN_uint16_t(msg, 14);
312 * @brief Get field chan7_raw from rc_channels_raw message
314 * @return RC channel 7 value, in microseconds
316 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan7_raw(const mavlink_message_t *msg)
318 return _MAV_RETURN_uint16_t(msg, 16);
322 * @brief Get field chan8_raw from rc_channels_raw message
324 * @return RC channel 8 value, in microseconds
326 static inline uint16_t mavlink_msg_rc_channels_raw_get_chan8_raw(const mavlink_message_t *msg)
328 return _MAV_RETURN_uint16_t(msg, 18);
332 * @brief Get field rssi from rc_channels_raw message
334 * @return Receive signal strength indicator, 0: 0%, 255: 100%
336 static inline uint8_t mavlink_msg_rc_channels_raw_get_rssi(const mavlink_message_t *msg)
338 return _MAV_RETURN_uint8_t(msg, 21);
342 * @brief Decode a rc_channels_raw message into a struct
344 * @param msg The message to decode
345 * @param rc_channels_raw C-struct to decode the message contents into
347 static inline void mavlink_msg_rc_channels_raw_decode(const mavlink_message_t *msg, mavlink_rc_channels_raw_t *rc_channels_raw)
349 #if MAVLINK_NEED_BYTE_SWAP
350 rc_channels_raw->time_boot_ms = mavlink_msg_rc_channels_raw_get_time_boot_ms(msg);
351 rc_channels_raw->chan1_raw = mavlink_msg_rc_channels_raw_get_chan1_raw(msg);
352 rc_channels_raw->chan2_raw = mavlink_msg_rc_channels_raw_get_chan2_raw(msg);
353 rc_channels_raw->chan3_raw = mavlink_msg_rc_channels_raw_get_chan3_raw(msg);
354 rc_channels_raw->chan4_raw = mavlink_msg_rc_channels_raw_get_chan4_raw(msg);
355 rc_channels_raw->chan5_raw = mavlink_msg_rc_channels_raw_get_chan5_raw(msg);
356 rc_channels_raw->chan6_raw = mavlink_msg_rc_channels_raw_get_chan6_raw(msg);
357 rc_channels_raw->chan7_raw = mavlink_msg_rc_channels_raw_get_chan7_raw(msg);
358 rc_channels_raw->chan8_raw = mavlink_msg_rc_channels_raw_get_chan8_raw(msg);
359 rc_channels_raw->port = mavlink_msg_rc_channels_raw_get_port(msg);
360 rc_channels_raw->rssi = mavlink_msg_rc_channels_raw_get_rssi(msg);
361 #else
362 memcpy(rc_channels_raw, _MAV_PAYLOAD(msg), 22);
363 #endif