1 | // MESSAGE SET_MODE PACKING
|
---|
2 |
|
---|
3 | #define MAVLINK_MSG_ID_SET_MODE 11
|
---|
4 |
|
---|
5 | typedef struct MAVLINK_PACKED __mavlink_set_mode_t
|
---|
6 | {
|
---|
7 | uint32_t custom_mode; /*< The new autopilot-specific mode. This field can be ignored by an autopilot.*/
|
---|
8 | uint8_t target_system; /*< The system setting the mode*/
|
---|
9 | uint8_t base_mode; /*< The new base mode*/
|
---|
10 | } mavlink_set_mode_t;
|
---|
11 |
|
---|
12 | #define MAVLINK_MSG_ID_SET_MODE_LEN 6
|
---|
13 | #define MAVLINK_MSG_ID_SET_MODE_MIN_LEN 6
|
---|
14 | #define MAVLINK_MSG_ID_11_LEN 6
|
---|
15 | #define MAVLINK_MSG_ID_11_MIN_LEN 6
|
---|
16 |
|
---|
17 | #define MAVLINK_MSG_ID_SET_MODE_CRC 89
|
---|
18 | #define MAVLINK_MSG_ID_11_CRC 89
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 | #if MAVLINK_COMMAND_24BIT
|
---|
23 | #define MAVLINK_MESSAGE_INFO_SET_MODE { \
|
---|
24 | 11, \
|
---|
25 | "SET_MODE", \
|
---|
26 | 3, \
|
---|
27 | { { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_mode_t, custom_mode) }, \
|
---|
28 | { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_set_mode_t, target_system) }, \
|
---|
29 | { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_set_mode_t, base_mode) }, \
|
---|
30 | } \
|
---|
31 | }
|
---|
32 | #else
|
---|
33 | #define MAVLINK_MESSAGE_INFO_SET_MODE { \
|
---|
34 | "SET_MODE", \
|
---|
35 | 3, \
|
---|
36 | { { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_mode_t, custom_mode) }, \
|
---|
37 | { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_set_mode_t, target_system) }, \
|
---|
38 | { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_set_mode_t, base_mode) }, \
|
---|
39 | } \
|
---|
40 | }
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @brief Pack a set_mode 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
|
---|
48 | *
|
---|
49 | * @param target_system The system setting the mode
|
---|
50 | * @param base_mode The new base mode
|
---|
51 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot.
|
---|
52 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
53 | */
|
---|
54 | static inline uint16_t mavlink_msg_set_mode_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
|
---|
55 | uint8_t target_system, uint8_t base_mode, uint32_t custom_mode)
|
---|
56 | {
|
---|
57 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
58 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN];
|
---|
59 | _mav_put_uint32_t(buf, 0, custom_mode);
|
---|
60 | _mav_put_uint8_t(buf, 4, target_system);
|
---|
61 | _mav_put_uint8_t(buf, 5, base_mode);
|
---|
62 |
|
---|
63 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MODE_LEN);
|
---|
64 | #else
|
---|
65 | mavlink_set_mode_t packet;
|
---|
66 | packet.custom_mode = custom_mode;
|
---|
67 | packet.target_system = target_system;
|
---|
68 | packet.base_mode = base_mode;
|
---|
69 |
|
---|
70 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MODE_LEN);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | msg->msgid = MAVLINK_MSG_ID_SET_MODE;
|
---|
74 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
75 | }
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * @brief Pack a set_mode message on a channel
|
---|
79 | * @param system_id ID of this system
|
---|
80 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
81 | * @param chan The MAVLink channel this message will be sent over
|
---|
82 | * @param msg The MAVLink message to compress the data into
|
---|
83 | * @param target_system The system setting the mode
|
---|
84 | * @param base_mode The new base mode
|
---|
85 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot.
|
---|
86 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
87 | */
|
---|
88 | static inline uint16_t mavlink_msg_set_mode_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
|
---|
89 | mavlink_message_t* msg,
|
---|
90 | uint8_t target_system,uint8_t base_mode,uint32_t custom_mode)
|
---|
91 | {
|
---|
92 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
93 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN];
|
---|
94 | _mav_put_uint32_t(buf, 0, custom_mode);
|
---|
95 | _mav_put_uint8_t(buf, 4, target_system);
|
---|
96 | _mav_put_uint8_t(buf, 5, base_mode);
|
---|
97 |
|
---|
98 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_MODE_LEN);
|
---|
99 | #else
|
---|
100 | mavlink_set_mode_t packet;
|
---|
101 | packet.custom_mode = custom_mode;
|
---|
102 | packet.target_system = target_system;
|
---|
103 | packet.base_mode = base_mode;
|
---|
104 |
|
---|
105 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_MODE_LEN);
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | msg->msgid = MAVLINK_MSG_ID_SET_MODE;
|
---|
109 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
110 | }
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * @brief Encode a set_mode struct
|
---|
114 | *
|
---|
115 | * @param system_id ID of this system
|
---|
116 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
117 | * @param msg The MAVLink message to compress the data into
|
---|
118 | * @param set_mode C-struct to read the message contents from
|
---|
119 | */
|
---|
120 | static inline uint16_t mavlink_msg_set_mode_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode)
|
---|
121 | {
|
---|
122 | return mavlink_msg_set_mode_pack(system_id, component_id, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode);
|
---|
123 | }
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * @brief Encode a set_mode struct on a channel
|
---|
127 | *
|
---|
128 | * @param system_id ID of this system
|
---|
129 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
130 | * @param chan The MAVLink channel this message will be sent over
|
---|
131 | * @param msg The MAVLink message to compress the data into
|
---|
132 | * @param set_mode C-struct to read the message contents from
|
---|
133 | */
|
---|
134 | static inline uint16_t mavlink_msg_set_mode_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_set_mode_t* set_mode)
|
---|
135 | {
|
---|
136 | return mavlink_msg_set_mode_pack_chan(system_id, component_id, chan, msg, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode);
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * @brief Send a set_mode message
|
---|
141 | * @param chan MAVLink channel to send the message
|
---|
142 | *
|
---|
143 | * @param target_system The system setting the mode
|
---|
144 | * @param base_mode The new base mode
|
---|
145 | * @param custom_mode The new autopilot-specific mode. This field can be ignored by an autopilot.
|
---|
146 | */
|
---|
147 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
---|
148 |
|
---|
149 | static inline void mavlink_msg_set_mode_send(mavlink_channel_t chan, uint8_t target_system, uint8_t base_mode, uint32_t custom_mode)
|
---|
150 | {
|
---|
151 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
152 | char buf[MAVLINK_MSG_ID_SET_MODE_LEN];
|
---|
153 | _mav_put_uint32_t(buf, 0, custom_mode);
|
---|
154 | _mav_put_uint8_t(buf, 4, target_system);
|
---|
155 | _mav_put_uint8_t(buf, 5, base_mode);
|
---|
156 |
|
---|
157 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, buf, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
158 | #else
|
---|
159 | mavlink_set_mode_t packet;
|
---|
160 | packet.custom_mode = custom_mode;
|
---|
161 | packet.target_system = target_system;
|
---|
162 | packet.base_mode = base_mode;
|
---|
163 |
|
---|
164 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)&packet, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
165 | #endif
|
---|
166 | }
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * @brief Send a set_mode message
|
---|
170 | * @param chan MAVLink channel to send the message
|
---|
171 | * @param struct The MAVLink struct to serialize
|
---|
172 | */
|
---|
173 | static inline void mavlink_msg_set_mode_send_struct(mavlink_channel_t chan, const mavlink_set_mode_t* set_mode)
|
---|
174 | {
|
---|
175 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
176 | mavlink_msg_set_mode_send(chan, set_mode->target_system, set_mode->base_mode, set_mode->custom_mode);
|
---|
177 | #else
|
---|
178 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)set_mode, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
179 | #endif
|
---|
180 | }
|
---|
181 |
|
---|
182 | #if MAVLINK_MSG_ID_SET_MODE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
|
---|
183 | /*
|
---|
184 | This varient of _send() can be used to save stack space by re-using
|
---|
185 | memory from the receive buffer. The caller provides a
|
---|
186 | mavlink_message_t which is the size of a full mavlink message. This
|
---|
187 | is usually the receive buffer for the channel, and allows a reply to an
|
---|
188 | incoming message with minimum stack space usage.
|
---|
189 | */
|
---|
190 | static inline void mavlink_msg_set_mode_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t base_mode, uint32_t custom_mode)
|
---|
191 | {
|
---|
192 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
193 | char *buf = (char *)msgbuf;
|
---|
194 | _mav_put_uint32_t(buf, 0, custom_mode);
|
---|
195 | _mav_put_uint8_t(buf, 4, target_system);
|
---|
196 | _mav_put_uint8_t(buf, 5, base_mode);
|
---|
197 |
|
---|
198 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, buf, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
199 | #else
|
---|
200 | mavlink_set_mode_t *packet = (mavlink_set_mode_t *)msgbuf;
|
---|
201 | packet->custom_mode = custom_mode;
|
---|
202 | packet->target_system = target_system;
|
---|
203 | packet->base_mode = base_mode;
|
---|
204 |
|
---|
205 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MODE, (const char *)packet, MAVLINK_MSG_ID_SET_MODE_MIN_LEN, MAVLINK_MSG_ID_SET_MODE_LEN, MAVLINK_MSG_ID_SET_MODE_CRC);
|
---|
206 | #endif
|
---|
207 | }
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | #endif
|
---|
211 |
|
---|
212 | // MESSAGE SET_MODE UNPACKING
|
---|
213 |
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * @brief Get field target_system from set_mode message
|
---|
217 | *
|
---|
218 | * @return The system setting the mode
|
---|
219 | */
|
---|
220 | static inline uint8_t mavlink_msg_set_mode_get_target_system(const mavlink_message_t* msg)
|
---|
221 | {
|
---|
222 | return _MAV_RETURN_uint8_t(msg, 4);
|
---|
223 | }
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * @brief Get field base_mode from set_mode message
|
---|
227 | *
|
---|
228 | * @return The new base mode
|
---|
229 | */
|
---|
230 | static inline uint8_t mavlink_msg_set_mode_get_base_mode(const mavlink_message_t* msg)
|
---|
231 | {
|
---|
232 | return _MAV_RETURN_uint8_t(msg, 5);
|
---|
233 | }
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * @brief Get field custom_mode from set_mode message
|
---|
237 | *
|
---|
238 | * @return The new autopilot-specific mode. This field can be ignored by an autopilot.
|
---|
239 | */
|
---|
240 | static inline uint32_t mavlink_msg_set_mode_get_custom_mode(const mavlink_message_t* msg)
|
---|
241 | {
|
---|
242 | return _MAV_RETURN_uint32_t(msg, 0);
|
---|
243 | }
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * @brief Decode a set_mode message into a struct
|
---|
247 | *
|
---|
248 | * @param msg The message to decode
|
---|
249 | * @param set_mode C-struct to decode the message contents into
|
---|
250 | */
|
---|
251 | static inline void mavlink_msg_set_mode_decode(const mavlink_message_t* msg, mavlink_set_mode_t* set_mode)
|
---|
252 | {
|
---|
253 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
254 | set_mode->custom_mode = mavlink_msg_set_mode_get_custom_mode(msg);
|
---|
255 | set_mode->target_system = mavlink_msg_set_mode_get_target_system(msg);
|
---|
256 | set_mode->base_mode = mavlink_msg_set_mode_get_base_mode(msg);
|
---|
257 | #else
|
---|
258 | uint8_t len = msg->len < MAVLINK_MSG_ID_SET_MODE_LEN? msg->len : MAVLINK_MSG_ID_SET_MODE_LEN;
|
---|
259 | memset(set_mode, 0, MAVLINK_MSG_ID_SET_MODE_LEN);
|
---|
260 | memcpy(set_mode, _MAV_PAYLOAD(msg), len);
|
---|
261 | #endif
|
---|
262 | }
|
---|