Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_servo_output_raw.h
blob5290ae7ca0d631e8321e3506189d9317abeacd9a
1 // MESSAGE SERVO_OUTPUT_RAW PACKING
3 #define MAVLINK_MSG_ID_SERVO_OUTPUT_RAW 36
5 typedef struct __mavlink_servo_output_raw_t {
6 uint32_t time_usec; ///< Timestamp (microseconds since system boot)
7 uint16_t servo1_raw; ///< Servo output 1 value, in microseconds
8 uint16_t servo2_raw; ///< Servo output 2 value, in microseconds
9 uint16_t servo3_raw; ///< Servo output 3 value, in microseconds
10 uint16_t servo4_raw; ///< Servo output 4 value, in microseconds
11 uint16_t servo5_raw; ///< Servo output 5 value, in microseconds
12 uint16_t servo6_raw; ///< Servo output 6 value, in microseconds
13 uint16_t servo7_raw; ///< Servo output 7 value, in microseconds
14 uint16_t servo8_raw; ///< Servo output 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 } mavlink_servo_output_raw_t;
18 #define MAVLINK_MSG_ID_SERVO_OUTPUT_RAW_LEN 21
19 #define MAVLINK_MSG_ID_36_LEN 21
22 #define MAVLINK_MESSAGE_INFO_SERVO_OUTPUT_RAW \
23 { \
24 "SERVO_OUTPUT_RAW", \
25 10, \
26 { \
27 { "time_usec", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_servo_output_raw_t, time_usec) }, \
28 { "servo1_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_servo_output_raw_t, servo1_raw) }, \
29 { "servo2_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_servo_output_raw_t, servo2_raw) }, \
30 { "servo3_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_servo_output_raw_t, servo3_raw) }, \
31 { "servo4_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_servo_output_raw_t, servo4_raw) }, \
32 { "servo5_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_servo_output_raw_t, servo5_raw) }, \
33 { "servo6_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_servo_output_raw_t, servo6_raw) }, \
34 { "servo7_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_servo_output_raw_t, servo7_raw) }, \
35 { "servo8_raw", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_servo_output_raw_t, servo8_raw) }, \
36 { "port", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_servo_output_raw_t, port) }, \
37 } \
41 /**
42 * @brief Pack a servo_output_raw message
43 * @param system_id ID of this system
44 * @param component_id ID of this component (e.g. 200 for IMU)
45 * @param msg The MAVLink message to compress the data into
47 * @param time_usec Timestamp (microseconds since system boot)
48 * @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.
49 * @param servo1_raw Servo output 1 value, in microseconds
50 * @param servo2_raw Servo output 2 value, in microseconds
51 * @param servo3_raw Servo output 3 value, in microseconds
52 * @param servo4_raw Servo output 4 value, in microseconds
53 * @param servo5_raw Servo output 5 value, in microseconds
54 * @param servo6_raw Servo output 6 value, in microseconds
55 * @param servo7_raw Servo output 7 value, in microseconds
56 * @param servo8_raw Servo output 8 value, in microseconds
57 * @return length of the message in bytes (excluding serial stream start sign)
59 static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
60 uint32_t time_usec, uint8_t port, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[21];
64 _mav_put_uint32_t(buf, 0, time_usec);
65 _mav_put_uint16_t(buf, 4, servo1_raw);
66 _mav_put_uint16_t(buf, 6, servo2_raw);
67 _mav_put_uint16_t(buf, 8, servo3_raw);
68 _mav_put_uint16_t(buf, 10, servo4_raw);
69 _mav_put_uint16_t(buf, 12, servo5_raw);
70 _mav_put_uint16_t(buf, 14, servo6_raw);
71 _mav_put_uint16_t(buf, 16, servo7_raw);
72 _mav_put_uint16_t(buf, 18, servo8_raw);
73 _mav_put_uint8_t(buf, 20, port);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21);
76 #else
77 mavlink_servo_output_raw_t packet;
78 packet.time_usec = time_usec;
79 packet.servo1_raw = servo1_raw;
80 packet.servo2_raw = servo2_raw;
81 packet.servo3_raw = servo3_raw;
82 packet.servo4_raw = servo4_raw;
83 packet.servo5_raw = servo5_raw;
84 packet.servo6_raw = servo6_raw;
85 packet.servo7_raw = servo7_raw;
86 packet.servo8_raw = servo8_raw;
87 packet.port = port;
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21);
90 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
92 msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW;
93 return mavlink_finalize_message(msg, system_id, component_id, 21, 222);
96 /**
97 * @brief Pack a servo_output_raw message on a channel
98 * @param system_id ID of this system
99 * @param component_id ID of this component (e.g. 200 for IMU)
100 * @param chan The MAVLink channel this message was sent over
101 * @param msg The MAVLink message to compress the data into
102 * @param time_usec Timestamp (microseconds since system boot)
103 * @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.
104 * @param servo1_raw Servo output 1 value, in microseconds
105 * @param servo2_raw Servo output 2 value, in microseconds
106 * @param servo3_raw Servo output 3 value, in microseconds
107 * @param servo4_raw Servo output 4 value, in microseconds
108 * @param servo5_raw Servo output 5 value, in microseconds
109 * @param servo6_raw Servo output 6 value, in microseconds
110 * @param servo7_raw Servo output 7 value, in microseconds
111 * @param servo8_raw Servo output 8 value, in microseconds
112 * @return length of the message in bytes (excluding serial stream start sign)
114 static inline uint16_t mavlink_msg_servo_output_raw_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
115 mavlink_message_t *msg,
116 uint32_t time_usec, uint8_t port, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
118 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
119 char buf[21];
120 _mav_put_uint32_t(buf, 0, time_usec);
121 _mav_put_uint16_t(buf, 4, servo1_raw);
122 _mav_put_uint16_t(buf, 6, servo2_raw);
123 _mav_put_uint16_t(buf, 8, servo3_raw);
124 _mav_put_uint16_t(buf, 10, servo4_raw);
125 _mav_put_uint16_t(buf, 12, servo5_raw);
126 _mav_put_uint16_t(buf, 14, servo6_raw);
127 _mav_put_uint16_t(buf, 16, servo7_raw);
128 _mav_put_uint16_t(buf, 18, servo8_raw);
129 _mav_put_uint8_t(buf, 20, port);
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21);
132 #else
133 mavlink_servo_output_raw_t packet;
134 packet.time_usec = time_usec;
135 packet.servo1_raw = servo1_raw;
136 packet.servo2_raw = servo2_raw;
137 packet.servo3_raw = servo3_raw;
138 packet.servo4_raw = servo4_raw;
139 packet.servo5_raw = servo5_raw;
140 packet.servo6_raw = servo6_raw;
141 packet.servo7_raw = servo7_raw;
142 packet.servo8_raw = servo8_raw;
143 packet.port = port;
145 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21);
146 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
148 msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW;
149 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 21, 222);
153 * @brief Encode a servo_output_raw struct into a message
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param msg The MAVLink message to compress the data into
158 * @param servo_output_raw C-struct to read the message contents from
160 static inline uint16_t mavlink_msg_servo_output_raw_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_servo_output_raw_t *servo_output_raw)
162 return mavlink_msg_servo_output_raw_pack(system_id, component_id, msg, servo_output_raw->time_usec, servo_output_raw->port, servo_output_raw->servo1_raw, servo_output_raw->servo2_raw, servo_output_raw->servo3_raw, servo_output_raw->servo4_raw, servo_output_raw->servo5_raw, servo_output_raw->servo6_raw, servo_output_raw->servo7_raw, servo_output_raw->servo8_raw);
166 * @brief Send a servo_output_raw message
167 * @param chan MAVLink channel to send the message
169 * @param time_usec Timestamp (microseconds since system boot)
170 * @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.
171 * @param servo1_raw Servo output 1 value, in microseconds
172 * @param servo2_raw Servo output 2 value, in microseconds
173 * @param servo3_raw Servo output 3 value, in microseconds
174 * @param servo4_raw Servo output 4 value, in microseconds
175 * @param servo5_raw Servo output 5 value, in microseconds
176 * @param servo6_raw Servo output 6 value, in microseconds
177 * @param servo7_raw Servo output 7 value, in microseconds
178 * @param servo8_raw Servo output 8 value, in microseconds
180 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
182 static inline void mavlink_msg_servo_output_raw_send(mavlink_channel_t chan, uint32_t time_usec, uint8_t port, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
184 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
185 char buf[21];
186 _mav_put_uint32_t(buf, 0, time_usec);
187 _mav_put_uint16_t(buf, 4, servo1_raw);
188 _mav_put_uint16_t(buf, 6, servo2_raw);
189 _mav_put_uint16_t(buf, 8, servo3_raw);
190 _mav_put_uint16_t(buf, 10, servo4_raw);
191 _mav_put_uint16_t(buf, 12, servo5_raw);
192 _mav_put_uint16_t(buf, 14, servo6_raw);
193 _mav_put_uint16_t(buf, 16, servo7_raw);
194 _mav_put_uint16_t(buf, 18, servo8_raw);
195 _mav_put_uint8_t(buf, 20, port);
197 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW, buf, 21, 222);
198 #else
199 mavlink_servo_output_raw_t packet;
200 packet.time_usec = time_usec;
201 packet.servo1_raw = servo1_raw;
202 packet.servo2_raw = servo2_raw;
203 packet.servo3_raw = servo3_raw;
204 packet.servo4_raw = servo4_raw;
205 packet.servo5_raw = servo5_raw;
206 packet.servo6_raw = servo6_raw;
207 packet.servo7_raw = servo7_raw;
208 packet.servo8_raw = servo8_raw;
209 packet.port = port;
211 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERVO_OUTPUT_RAW, (const char *)&packet, 21, 222);
212 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
217 // MESSAGE SERVO_OUTPUT_RAW UNPACKING
221 * @brief Get field time_usec from servo_output_raw message
223 * @return Timestamp (microseconds since system boot)
225 static inline uint32_t mavlink_msg_servo_output_raw_get_time_usec(const mavlink_message_t *msg)
227 return _MAV_RETURN_uint32_t(msg, 0);
231 * @brief Get field port from servo_output_raw message
233 * @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.
235 static inline uint8_t mavlink_msg_servo_output_raw_get_port(const mavlink_message_t *msg)
237 return _MAV_RETURN_uint8_t(msg, 20);
241 * @brief Get field servo1_raw from servo_output_raw message
243 * @return Servo output 1 value, in microseconds
245 static inline uint16_t mavlink_msg_servo_output_raw_get_servo1_raw(const mavlink_message_t *msg)
247 return _MAV_RETURN_uint16_t(msg, 4);
251 * @brief Get field servo2_raw from servo_output_raw message
253 * @return Servo output 2 value, in microseconds
255 static inline uint16_t mavlink_msg_servo_output_raw_get_servo2_raw(const mavlink_message_t *msg)
257 return _MAV_RETURN_uint16_t(msg, 6);
261 * @brief Get field servo3_raw from servo_output_raw message
263 * @return Servo output 3 value, in microseconds
265 static inline uint16_t mavlink_msg_servo_output_raw_get_servo3_raw(const mavlink_message_t *msg)
267 return _MAV_RETURN_uint16_t(msg, 8);
271 * @brief Get field servo4_raw from servo_output_raw message
273 * @return Servo output 4 value, in microseconds
275 static inline uint16_t mavlink_msg_servo_output_raw_get_servo4_raw(const mavlink_message_t *msg)
277 return _MAV_RETURN_uint16_t(msg, 10);
281 * @brief Get field servo5_raw from servo_output_raw message
283 * @return Servo output 5 value, in microseconds
285 static inline uint16_t mavlink_msg_servo_output_raw_get_servo5_raw(const mavlink_message_t *msg)
287 return _MAV_RETURN_uint16_t(msg, 12);
291 * @brief Get field servo6_raw from servo_output_raw message
293 * @return Servo output 6 value, in microseconds
295 static inline uint16_t mavlink_msg_servo_output_raw_get_servo6_raw(const mavlink_message_t *msg)
297 return _MAV_RETURN_uint16_t(msg, 14);
301 * @brief Get field servo7_raw from servo_output_raw message
303 * @return Servo output 7 value, in microseconds
305 static inline uint16_t mavlink_msg_servo_output_raw_get_servo7_raw(const mavlink_message_t *msg)
307 return _MAV_RETURN_uint16_t(msg, 16);
311 * @brief Get field servo8_raw from servo_output_raw message
313 * @return Servo output 8 value, in microseconds
315 static inline uint16_t mavlink_msg_servo_output_raw_get_servo8_raw(const mavlink_message_t *msg)
317 return _MAV_RETURN_uint16_t(msg, 18);
321 * @brief Decode a servo_output_raw message into a struct
323 * @param msg The message to decode
324 * @param servo_output_raw C-struct to decode the message contents into
326 static inline void mavlink_msg_servo_output_raw_decode(const mavlink_message_t *msg, mavlink_servo_output_raw_t *servo_output_raw)
328 #if MAVLINK_NEED_BYTE_SWAP
329 servo_output_raw->time_usec = mavlink_msg_servo_output_raw_get_time_usec(msg);
330 servo_output_raw->servo1_raw = mavlink_msg_servo_output_raw_get_servo1_raw(msg);
331 servo_output_raw->servo2_raw = mavlink_msg_servo_output_raw_get_servo2_raw(msg);
332 servo_output_raw->servo3_raw = mavlink_msg_servo_output_raw_get_servo3_raw(msg);
333 servo_output_raw->servo4_raw = mavlink_msg_servo_output_raw_get_servo4_raw(msg);
334 servo_output_raw->servo5_raw = mavlink_msg_servo_output_raw_get_servo5_raw(msg);
335 servo_output_raw->servo6_raw = mavlink_msg_servo_output_raw_get_servo6_raw(msg);
336 servo_output_raw->servo7_raw = mavlink_msg_servo_output_raw_get_servo7_raw(msg);
337 servo_output_raw->servo8_raw = mavlink_msg_servo_output_raw_get_servo8_raw(msg);
338 servo_output_raw->port = mavlink_msg_servo_output_raw_get_port(msg);
339 #else
340 memcpy(servo_output_raw, _MAV_PAYLOAD(msg), 21);
341 #endif