2 // MESSAGE VIBRATION PACKING
4 #define MAVLINK_MSG_ID_VIBRATION 241
7 typedef struct __mavlink_vibration_t
{
8 uint64_t time_usec
; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
9 float vibration_x
; /*< Vibration levels on X-axis*/
10 float vibration_y
; /*< Vibration levels on Y-axis*/
11 float vibration_z
; /*< Vibration levels on Z-axis*/
12 uint32_t clipping_0
; /*< first accelerometer clipping count*/
13 uint32_t clipping_1
; /*< second accelerometer clipping count*/
14 uint32_t clipping_2
; /*< third accelerometer clipping count*/
15 } mavlink_vibration_t
;
17 #define MAVLINK_MSG_ID_VIBRATION_LEN 32
18 #define MAVLINK_MSG_ID_VIBRATION_MIN_LEN 32
19 #define MAVLINK_MSG_ID_241_LEN 32
20 #define MAVLINK_MSG_ID_241_MIN_LEN 32
22 #define MAVLINK_MSG_ID_VIBRATION_CRC 90
23 #define MAVLINK_MSG_ID_241_CRC 90
27 #if MAVLINK_COMMAND_24BIT
28 #define MAVLINK_MESSAGE_INFO_VIBRATION { \
32 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_vibration_t, time_usec) }, \
33 { "vibration_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vibration_t, vibration_x) }, \
34 { "vibration_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vibration_t, vibration_y) }, \
35 { "vibration_z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_vibration_t, vibration_z) }, \
36 { "clipping_0", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_vibration_t, clipping_0) }, \
37 { "clipping_1", NULL, MAVLINK_TYPE_UINT32_T, 0, 24, offsetof(mavlink_vibration_t, clipping_1) }, \
38 { "clipping_2", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_vibration_t, clipping_2) }, \
42 #define MAVLINK_MESSAGE_INFO_VIBRATION { \
45 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_vibration_t, time_usec) }, \
46 { "vibration_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vibration_t, vibration_x) }, \
47 { "vibration_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vibration_t, vibration_y) }, \
48 { "vibration_z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_vibration_t, vibration_z) }, \
49 { "clipping_0", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_vibration_t, clipping_0) }, \
50 { "clipping_1", NULL, MAVLINK_TYPE_UINT32_T, 0, 24, offsetof(mavlink_vibration_t, clipping_1) }, \
51 { "clipping_2", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_vibration_t, clipping_2) }, \
57 * @brief Pack a vibration message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
62 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
63 * @param vibration_x Vibration levels on X-axis
64 * @param vibration_y Vibration levels on Y-axis
65 * @param vibration_z Vibration levels on Z-axis
66 * @param clipping_0 first accelerometer clipping count
67 * @param clipping_1 second accelerometer clipping count
68 * @param clipping_2 third accelerometer clipping count
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_vibration_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
72 uint64_t time_usec
, float vibration_x
, float vibration_y
, float vibration_z
, uint32_t clipping_0
, uint32_t clipping_1
, uint32_t clipping_2
)
74 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf
[MAVLINK_MSG_ID_VIBRATION_LEN
];
76 _mav_put_uint64_t(buf
, 0, time_usec
);
77 _mav_put_float(buf
, 8, vibration_x
);
78 _mav_put_float(buf
, 12, vibration_y
);
79 _mav_put_float(buf
, 16, vibration_z
);
80 _mav_put_uint32_t(buf
, 20, clipping_0
);
81 _mav_put_uint32_t(buf
, 24, clipping_1
);
82 _mav_put_uint32_t(buf
, 28, clipping_2
);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_VIBRATION_LEN
);
86 mavlink_vibration_t packet
;
87 packet
.time_usec
= time_usec
;
88 packet
.vibration_x
= vibration_x
;
89 packet
.vibration_y
= vibration_y
;
90 packet
.vibration_z
= vibration_z
;
91 packet
.clipping_0
= clipping_0
;
92 packet
.clipping_1
= clipping_1
;
93 packet
.clipping_2
= clipping_2
;
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_VIBRATION_LEN
);
98 msg
->msgid
= MAVLINK_MSG_ID_VIBRATION
;
99 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
103 * @brief Pack a vibration message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
109 * @param vibration_x Vibration levels on X-axis
110 * @param vibration_y Vibration levels on Y-axis
111 * @param vibration_z Vibration levels on Z-axis
112 * @param clipping_0 first accelerometer clipping count
113 * @param clipping_1 second accelerometer clipping count
114 * @param clipping_2 third accelerometer clipping count
115 * @return length of the message in bytes (excluding serial stream start sign)
117 static inline uint16_t mavlink_msg_vibration_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
118 mavlink_message_t
* msg
,
119 uint64_t time_usec
,float vibration_x
,float vibration_y
,float vibration_z
,uint32_t clipping_0
,uint32_t clipping_1
,uint32_t clipping_2
)
121 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf
[MAVLINK_MSG_ID_VIBRATION_LEN
];
123 _mav_put_uint64_t(buf
, 0, time_usec
);
124 _mav_put_float(buf
, 8, vibration_x
);
125 _mav_put_float(buf
, 12, vibration_y
);
126 _mav_put_float(buf
, 16, vibration_z
);
127 _mav_put_uint32_t(buf
, 20, clipping_0
);
128 _mav_put_uint32_t(buf
, 24, clipping_1
);
129 _mav_put_uint32_t(buf
, 28, clipping_2
);
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_VIBRATION_LEN
);
133 mavlink_vibration_t packet
;
134 packet
.time_usec
= time_usec
;
135 packet
.vibration_x
= vibration_x
;
136 packet
.vibration_y
= vibration_y
;
137 packet
.vibration_z
= vibration_z
;
138 packet
.clipping_0
= clipping_0
;
139 packet
.clipping_1
= clipping_1
;
140 packet
.clipping_2
= clipping_2
;
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_VIBRATION_LEN
);
145 msg
->msgid
= MAVLINK_MSG_ID_VIBRATION
;
146 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
150 * @brief Encode a vibration struct
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param vibration C-struct to read the message contents from
157 static inline uint16_t mavlink_msg_vibration_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_vibration_t
* vibration
)
159 return mavlink_msg_vibration_pack(system_id
, component_id
, msg
, vibration
->time_usec
, vibration
->vibration_x
, vibration
->vibration_y
, vibration
->vibration_z
, vibration
->clipping_0
, vibration
->clipping_1
, vibration
->clipping_2
);
163 * @brief Encode a vibration struct on a channel
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param vibration C-struct to read the message contents from
171 static inline uint16_t mavlink_msg_vibration_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_vibration_t
* vibration
)
173 return mavlink_msg_vibration_pack_chan(system_id
, component_id
, chan
, msg
, vibration
->time_usec
, vibration
->vibration_x
, vibration
->vibration_y
, vibration
->vibration_z
, vibration
->clipping_0
, vibration
->clipping_1
, vibration
->clipping_2
);
177 * @brief Send a vibration message
178 * @param chan MAVLink channel to send the message
180 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
181 * @param vibration_x Vibration levels on X-axis
182 * @param vibration_y Vibration levels on Y-axis
183 * @param vibration_z Vibration levels on Z-axis
184 * @param clipping_0 first accelerometer clipping count
185 * @param clipping_1 second accelerometer clipping count
186 * @param clipping_2 third accelerometer clipping count
188 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
190 static inline void mavlink_msg_vibration_send(mavlink_channel_t chan
, uint64_t time_usec
, float vibration_x
, float vibration_y
, float vibration_z
, uint32_t clipping_0
, uint32_t clipping_1
, uint32_t clipping_2
)
192 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf
[MAVLINK_MSG_ID_VIBRATION_LEN
];
194 _mav_put_uint64_t(buf
, 0, time_usec
);
195 _mav_put_float(buf
, 8, vibration_x
);
196 _mav_put_float(buf
, 12, vibration_y
);
197 _mav_put_float(buf
, 16, vibration_z
);
198 _mav_put_uint32_t(buf
, 20, clipping_0
);
199 _mav_put_uint32_t(buf
, 24, clipping_1
);
200 _mav_put_uint32_t(buf
, 28, clipping_2
);
202 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VIBRATION
, buf
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
204 mavlink_vibration_t packet
;
205 packet
.time_usec
= time_usec
;
206 packet
.vibration_x
= vibration_x
;
207 packet
.vibration_y
= vibration_y
;
208 packet
.vibration_z
= vibration_z
;
209 packet
.clipping_0
= clipping_0
;
210 packet
.clipping_1
= clipping_1
;
211 packet
.clipping_2
= clipping_2
;
213 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VIBRATION
, (const char *)&packet
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
218 * @brief Send a vibration message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
222 static inline void mavlink_msg_vibration_send_struct(mavlink_channel_t chan
, const mavlink_vibration_t
* vibration
)
224 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_vibration_send(chan
, vibration
->time_usec
, vibration
->vibration_x
, vibration
->vibration_y
, vibration
->vibration_z
, vibration
->clipping_0
, vibration
->clipping_1
, vibration
->clipping_2
);
227 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VIBRATION
, (const char *)vibration
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
231 #if MAVLINK_MSG_ID_VIBRATION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
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.
239 static inline void mavlink_msg_vibration_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint64_t time_usec
, float vibration_x
, float vibration_y
, float vibration_z
, uint32_t clipping_0
, uint32_t clipping_1
, uint32_t clipping_2
)
241 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf
= (char *)msgbuf
;
243 _mav_put_uint64_t(buf
, 0, time_usec
);
244 _mav_put_float(buf
, 8, vibration_x
);
245 _mav_put_float(buf
, 12, vibration_y
);
246 _mav_put_float(buf
, 16, vibration_z
);
247 _mav_put_uint32_t(buf
, 20, clipping_0
);
248 _mav_put_uint32_t(buf
, 24, clipping_1
);
249 _mav_put_uint32_t(buf
, 28, clipping_2
);
251 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VIBRATION
, buf
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
253 mavlink_vibration_t
*packet
= (mavlink_vibration_t
*)msgbuf
;
254 packet
->time_usec
= time_usec
;
255 packet
->vibration_x
= vibration_x
;
256 packet
->vibration_y
= vibration_y
;
257 packet
->vibration_z
= vibration_z
;
258 packet
->clipping_0
= clipping_0
;
259 packet
->clipping_1
= clipping_1
;
260 packet
->clipping_2
= clipping_2
;
262 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_VIBRATION
, (const char *)packet
, MAVLINK_MSG_ID_VIBRATION_MIN_LEN
, MAVLINK_MSG_ID_VIBRATION_LEN
, MAVLINK_MSG_ID_VIBRATION_CRC
);
269 // MESSAGE VIBRATION UNPACKING
273 * @brief Get field time_usec from vibration message
275 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
277 static inline uint64_t mavlink_msg_vibration_get_time_usec(const mavlink_message_t
* msg
)
279 return _MAV_RETURN_uint64_t(msg
, 0);
283 * @brief Get field vibration_x from vibration message
285 * @return Vibration levels on X-axis
287 static inline float mavlink_msg_vibration_get_vibration_x(const mavlink_message_t
* msg
)
289 return _MAV_RETURN_float(msg
, 8);
293 * @brief Get field vibration_y from vibration message
295 * @return Vibration levels on Y-axis
297 static inline float mavlink_msg_vibration_get_vibration_y(const mavlink_message_t
* msg
)
299 return _MAV_RETURN_float(msg
, 12);
303 * @brief Get field vibration_z from vibration message
305 * @return Vibration levels on Z-axis
307 static inline float mavlink_msg_vibration_get_vibration_z(const mavlink_message_t
* msg
)
309 return _MAV_RETURN_float(msg
, 16);
313 * @brief Get field clipping_0 from vibration message
315 * @return first accelerometer clipping count
317 static inline uint32_t mavlink_msg_vibration_get_clipping_0(const mavlink_message_t
* msg
)
319 return _MAV_RETURN_uint32_t(msg
, 20);
323 * @brief Get field clipping_1 from vibration message
325 * @return second accelerometer clipping count
327 static inline uint32_t mavlink_msg_vibration_get_clipping_1(const mavlink_message_t
* msg
)
329 return _MAV_RETURN_uint32_t(msg
, 24);
333 * @brief Get field clipping_2 from vibration message
335 * @return third accelerometer clipping count
337 static inline uint32_t mavlink_msg_vibration_get_clipping_2(const mavlink_message_t
* msg
)
339 return _MAV_RETURN_uint32_t(msg
, 28);
343 * @brief Decode a vibration message into a struct
345 * @param msg The message to decode
346 * @param vibration C-struct to decode the message contents into
348 static inline void mavlink_msg_vibration_decode(const mavlink_message_t
* msg
, mavlink_vibration_t
* vibration
)
350 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 vibration
->time_usec
= mavlink_msg_vibration_get_time_usec(msg
);
352 vibration
->vibration_x
= mavlink_msg_vibration_get_vibration_x(msg
);
353 vibration
->vibration_y
= mavlink_msg_vibration_get_vibration_y(msg
);
354 vibration
->vibration_z
= mavlink_msg_vibration_get_vibration_z(msg
);
355 vibration
->clipping_0
= mavlink_msg_vibration_get_clipping_0(msg
);
356 vibration
->clipping_1
= mavlink_msg_vibration_get_clipping_1(msg
);
357 vibration
->clipping_2
= mavlink_msg_vibration_get_clipping_2(msg
);
359 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_VIBRATION_LEN
? msg
->len
: MAVLINK_MSG_ID_VIBRATION_LEN
;
360 memset(vibration
, 0, MAVLINK_MSG_ID_VIBRATION_LEN
);
361 memcpy(vibration
, _MAV_PAYLOAD(msg
), len
);