RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_fence_point.h
1#pragma once
2// MESSAGE FENCE_POINT PACKING
3
4#define MAVLINK_MSG_ID_FENCE_POINT 160
5
6MAVPACKED(
7typedef struct __mavlink_fence_point_t {
8 float lat; /*< Latitude of point*/
9 float lng; /*< Longitude of point*/
10 uint8_t target_system; /*< System ID*/
11 uint8_t target_component; /*< Component ID*/
12 uint8_t idx; /*< point index (first point is 1, 0 is for return point)*/
13 uint8_t count; /*< total number of points (for sanity checking)*/
14}) mavlink_fence_point_t;
15
16#define MAVLINK_MSG_ID_FENCE_POINT_LEN 12
17#define MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN 12
18#define MAVLINK_MSG_ID_160_LEN 12
19#define MAVLINK_MSG_ID_160_MIN_LEN 12
20
21#define MAVLINK_MSG_ID_FENCE_POINT_CRC 78
22#define MAVLINK_MSG_ID_160_CRC 78
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_FENCE_POINT { \
28 160, \
29 "FENCE_POINT", \
30 6, \
31 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_point_t, target_system) }, \
32 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_fence_point_t, target_component) }, \
33 { "idx", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_fence_point_t, idx) }, \
34 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_fence_point_t, count) }, \
35 { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_fence_point_t, lat) }, \
36 { "lng", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_fence_point_t, lng) }, \
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_FENCE_POINT { \
41 "FENCE_POINT", \
42 6, \
43 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_fence_point_t, target_system) }, \
44 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_fence_point_t, target_component) }, \
45 { "idx", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_fence_point_t, idx) }, \
46 { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_fence_point_t, count) }, \
47 { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_fence_point_t, lat) }, \
48 { "lng", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_fence_point_t, lng) }, \
49 } \
50}
51#endif
52
67static inline uint16_t mavlink_msg_fence_point_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
72 _mav_put_float(buf, 0, lat);
73 _mav_put_float(buf, 4, lng);
74 _mav_put_uint8_t(buf, 8, target_system);
75 _mav_put_uint8_t(buf, 9, target_component);
76 _mav_put_uint8_t(buf, 10, idx);
77 _mav_put_uint8_t(buf, 11, count);
78
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_POINT_LEN);
80#else
81 mavlink_fence_point_t packet;
82 packet.lat = lat;
83 packet.lng = lng;
84 packet.target_system = target_system;
85 packet.target_component = target_component;
86 packet.idx = idx;
87 packet.count = count;
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_POINT_LEN);
90#endif
91
92 msg->msgid = MAVLINK_MSG_ID_FENCE_POINT;
93 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
94}
95
110static inline uint16_t mavlink_msg_fence_point_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
111 mavlink_message_t* msg,
112 uint8_t target_system,uint8_t target_component,uint8_t idx,uint8_t count,float lat,float lng)
113{
114#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
116 _mav_put_float(buf, 0, lat);
117 _mav_put_float(buf, 4, lng);
118 _mav_put_uint8_t(buf, 8, target_system);
119 _mav_put_uint8_t(buf, 9, target_component);
120 _mav_put_uint8_t(buf, 10, idx);
121 _mav_put_uint8_t(buf, 11, count);
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FENCE_POINT_LEN);
124#else
125 mavlink_fence_point_t packet;
126 packet.lat = lat;
127 packet.lng = lng;
128 packet.target_system = target_system;
129 packet.target_component = target_component;
130 packet.idx = idx;
131 packet.count = count;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FENCE_POINT_LEN);
134#endif
135
136 msg->msgid = MAVLINK_MSG_ID_FENCE_POINT;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
138}
139
148static inline uint16_t mavlink_msg_fence_point_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_fence_point_t* fence_point)
149{
150 return mavlink_msg_fence_point_pack(system_id, component_id, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
151}
152
162static inline uint16_t mavlink_msg_fence_point_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_fence_point_t* fence_point)
163{
164 return mavlink_msg_fence_point_pack_chan(system_id, component_id, chan, msg, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
165}
166
178#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
179
180static inline void mavlink_msg_fence_point_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
181{
182#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_FENCE_POINT_LEN];
184 _mav_put_float(buf, 0, lat);
185 _mav_put_float(buf, 4, lng);
186 _mav_put_uint8_t(buf, 8, target_system);
187 _mav_put_uint8_t(buf, 9, target_component);
188 _mav_put_uint8_t(buf, 10, idx);
189 _mav_put_uint8_t(buf, 11, count);
190
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, buf, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
192#else
193 mavlink_fence_point_t packet;
194 packet.lat = lat;
195 packet.lng = lng;
196 packet.target_system = target_system;
197 packet.target_component = target_component;
198 packet.idx = idx;
199 packet.count = count;
200
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)&packet, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
202#endif
203}
204
210static inline void mavlink_msg_fence_point_send_struct(mavlink_channel_t chan, const mavlink_fence_point_t* fence_point)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 mavlink_msg_fence_point_send(chan, fence_point->target_system, fence_point->target_component, fence_point->idx, fence_point->count, fence_point->lat, fence_point->lng);
214#else
215 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)fence_point, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
216#endif
217}
218
219#if MAVLINK_MSG_ID_FENCE_POINT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
220/*
221 This varient of _send() can be used to save stack space by re-using
222 memory from the receive buffer. The caller provides a
223 mavlink_message_t which is the size of a full mavlink message. This
224 is usually the receive buffer for the channel, and allows a reply to an
225 incoming message with minimum stack space usage.
226 */
227static inline void mavlink_msg_fence_point_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t idx, uint8_t count, float lat, float lng)
228{
229#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 char *buf = (char *)msgbuf;
231 _mav_put_float(buf, 0, lat);
232 _mav_put_float(buf, 4, lng);
233 _mav_put_uint8_t(buf, 8, target_system);
234 _mav_put_uint8_t(buf, 9, target_component);
235 _mav_put_uint8_t(buf, 10, idx);
236 _mav_put_uint8_t(buf, 11, count);
237
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, buf, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
239#else
240 mavlink_fence_point_t *packet = (mavlink_fence_point_t *)msgbuf;
241 packet->lat = lat;
242 packet->lng = lng;
243 packet->target_system = target_system;
244 packet->target_component = target_component;
245 packet->idx = idx;
246 packet->count = count;
247
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FENCE_POINT, (const char *)packet, MAVLINK_MSG_ID_FENCE_POINT_MIN_LEN, MAVLINK_MSG_ID_FENCE_POINT_LEN, MAVLINK_MSG_ID_FENCE_POINT_CRC);
249#endif
250}
251#endif
252
253#endif
254
255// MESSAGE FENCE_POINT UNPACKING
256
257
263static inline uint8_t mavlink_msg_fence_point_get_target_system(const mavlink_message_t* msg)
264{
265 return _MAV_RETURN_uint8_t(msg, 8);
266}
267
273static inline uint8_t mavlink_msg_fence_point_get_target_component(const mavlink_message_t* msg)
274{
275 return _MAV_RETURN_uint8_t(msg, 9);
276}
277
283static inline uint8_t mavlink_msg_fence_point_get_idx(const mavlink_message_t* msg)
284{
285 return _MAV_RETURN_uint8_t(msg, 10);
286}
287
293static inline uint8_t mavlink_msg_fence_point_get_count(const mavlink_message_t* msg)
294{
295 return _MAV_RETURN_uint8_t(msg, 11);
296}
297
303static inline float mavlink_msg_fence_point_get_lat(const mavlink_message_t* msg)
304{
305 return _MAV_RETURN_float(msg, 0);
306}
307
313static inline float mavlink_msg_fence_point_get_lng(const mavlink_message_t* msg)
314{
315 return _MAV_RETURN_float(msg, 4);
316}
317
324static inline void mavlink_msg_fence_point_decode(const mavlink_message_t* msg, mavlink_fence_point_t* fence_point)
325{
326#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
327 fence_point->lat = mavlink_msg_fence_point_get_lat(msg);
328 fence_point->lng = mavlink_msg_fence_point_get_lng(msg);
329 fence_point->target_system = mavlink_msg_fence_point_get_target_system(msg);
330 fence_point->target_component = mavlink_msg_fence_point_get_target_component(msg);
331 fence_point->idx = mavlink_msg_fence_point_get_idx(msg);
332 fence_point->count = mavlink_msg_fence_point_get_count(msg);
333#else
334 uint8_t len = msg->len < MAVLINK_MSG_ID_FENCE_POINT_LEN? msg->len : MAVLINK_MSG_ID_FENCE_POINT_LEN;
335 memset(fence_point, 0, MAVLINK_MSG_ID_FENCE_POINT_LEN);
336 memcpy(fence_point, _MAV_PAYLOAD(msg), len);
337#endif
338}