Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mavlink F429ZI_LCD_demo
Fork of mavlink_bridge by
mavlink/v10/common/mavlink_msg_vibration.h@0:28183cc7963f, 2015-11-24 (annotated)
- Committer:
- bhepp
- Date:
- Tue Nov 24 16:41:11 2015 +0000
- Revision:
- 0:28183cc7963f
Mavlink bridge for Mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhepp | 0:28183cc7963f | 1 | // MESSAGE VIBRATION PACKING |
bhepp | 0:28183cc7963f | 2 | |
bhepp | 0:28183cc7963f | 3 | #define MAVLINK_MSG_ID_VIBRATION 241 |
bhepp | 0:28183cc7963f | 4 | |
bhepp | 0:28183cc7963f | 5 | typedef struct __mavlink_vibration_t |
bhepp | 0:28183cc7963f | 6 | { |
bhepp | 0:28183cc7963f | 7 | uint64_t time_usec; /*< Timestamp (micros since boot or Unix epoch)*/ |
bhepp | 0:28183cc7963f | 8 | float vibration_x; /*< Vibration levels on X-axis*/ |
bhepp | 0:28183cc7963f | 9 | float vibration_y; /*< Vibration levels on Y-axis*/ |
bhepp | 0:28183cc7963f | 10 | float vibration_z; /*< Vibration levels on Z-axis*/ |
bhepp | 0:28183cc7963f | 11 | uint32_t clipping_0; /*< first accelerometer clipping count*/ |
bhepp | 0:28183cc7963f | 12 | uint32_t clipping_1; /*< second accelerometer clipping count*/ |
bhepp | 0:28183cc7963f | 13 | uint32_t clipping_2; /*< third accelerometer clipping count*/ |
bhepp | 0:28183cc7963f | 14 | } mavlink_vibration_t; |
bhepp | 0:28183cc7963f | 15 | |
bhepp | 0:28183cc7963f | 16 | #define MAVLINK_MSG_ID_VIBRATION_LEN 32 |
bhepp | 0:28183cc7963f | 17 | #define MAVLINK_MSG_ID_241_LEN 32 |
bhepp | 0:28183cc7963f | 18 | |
bhepp | 0:28183cc7963f | 19 | #define MAVLINK_MSG_ID_VIBRATION_CRC 90 |
bhepp | 0:28183cc7963f | 20 | #define MAVLINK_MSG_ID_241_CRC 90 |
bhepp | 0:28183cc7963f | 21 | |
bhepp | 0:28183cc7963f | 22 | |
bhepp | 0:28183cc7963f | 23 | |
bhepp | 0:28183cc7963f | 24 | #define MAVLINK_MESSAGE_INFO_VIBRATION { \ |
bhepp | 0:28183cc7963f | 25 | "VIBRATION", \ |
bhepp | 0:28183cc7963f | 26 | 7, \ |
bhepp | 0:28183cc7963f | 27 | { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_vibration_t, time_usec) }, \ |
bhepp | 0:28183cc7963f | 28 | { "vibration_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vibration_t, vibration_x) }, \ |
bhepp | 0:28183cc7963f | 29 | { "vibration_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vibration_t, vibration_y) }, \ |
bhepp | 0:28183cc7963f | 30 | { "vibration_z", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_vibration_t, vibration_z) }, \ |
bhepp | 0:28183cc7963f | 31 | { "clipping_0", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_vibration_t, clipping_0) }, \ |
bhepp | 0:28183cc7963f | 32 | { "clipping_1", NULL, MAVLINK_TYPE_UINT32_T, 0, 24, offsetof(mavlink_vibration_t, clipping_1) }, \ |
bhepp | 0:28183cc7963f | 33 | { "clipping_2", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_vibration_t, clipping_2) }, \ |
bhepp | 0:28183cc7963f | 34 | } \ |
bhepp | 0:28183cc7963f | 35 | } |
bhepp | 0:28183cc7963f | 36 | |
bhepp | 0:28183cc7963f | 37 | |
bhepp | 0:28183cc7963f | 38 | /** |
bhepp | 0:28183cc7963f | 39 | * @brief Pack a vibration message |
bhepp | 0:28183cc7963f | 40 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 41 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 42 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 43 | * |
bhepp | 0:28183cc7963f | 44 | * @param time_usec Timestamp (micros since boot or Unix epoch) |
bhepp | 0:28183cc7963f | 45 | * @param vibration_x Vibration levels on X-axis |
bhepp | 0:28183cc7963f | 46 | * @param vibration_y Vibration levels on Y-axis |
bhepp | 0:28183cc7963f | 47 | * @param vibration_z Vibration levels on Z-axis |
bhepp | 0:28183cc7963f | 48 | * @param clipping_0 first accelerometer clipping count |
bhepp | 0:28183cc7963f | 49 | * @param clipping_1 second accelerometer clipping count |
bhepp | 0:28183cc7963f | 50 | * @param clipping_2 third accelerometer clipping count |
bhepp | 0:28183cc7963f | 51 | * @return length of the message in bytes (excluding serial stream start sign) |
bhepp | 0:28183cc7963f | 52 | */ |
bhepp | 0:28183cc7963f | 53 | static inline uint16_t mavlink_msg_vibration_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
bhepp | 0:28183cc7963f | 54 | 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) |
bhepp | 0:28183cc7963f | 55 | { |
bhepp | 0:28183cc7963f | 56 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 57 | char buf[MAVLINK_MSG_ID_VIBRATION_LEN]; |
bhepp | 0:28183cc7963f | 58 | _mav_put_uint64_t(buf, 0, time_usec); |
bhepp | 0:28183cc7963f | 59 | _mav_put_float(buf, 8, vibration_x); |
bhepp | 0:28183cc7963f | 60 | _mav_put_float(buf, 12, vibration_y); |
bhepp | 0:28183cc7963f | 61 | _mav_put_float(buf, 16, vibration_z); |
bhepp | 0:28183cc7963f | 62 | _mav_put_uint32_t(buf, 20, clipping_0); |
bhepp | 0:28183cc7963f | 63 | _mav_put_uint32_t(buf, 24, clipping_1); |
bhepp | 0:28183cc7963f | 64 | _mav_put_uint32_t(buf, 28, clipping_2); |
bhepp | 0:28183cc7963f | 65 | |
bhepp | 0:28183cc7963f | 66 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 67 | #else |
bhepp | 0:28183cc7963f | 68 | mavlink_vibration_t packet; |
bhepp | 0:28183cc7963f | 69 | packet.time_usec = time_usec; |
bhepp | 0:28183cc7963f | 70 | packet.vibration_x = vibration_x; |
bhepp | 0:28183cc7963f | 71 | packet.vibration_y = vibration_y; |
bhepp | 0:28183cc7963f | 72 | packet.vibration_z = vibration_z; |
bhepp | 0:28183cc7963f | 73 | packet.clipping_0 = clipping_0; |
bhepp | 0:28183cc7963f | 74 | packet.clipping_1 = clipping_1; |
bhepp | 0:28183cc7963f | 75 | packet.clipping_2 = clipping_2; |
bhepp | 0:28183cc7963f | 76 | |
bhepp | 0:28183cc7963f | 77 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 78 | #endif |
bhepp | 0:28183cc7963f | 79 | |
bhepp | 0:28183cc7963f | 80 | msg->msgid = MAVLINK_MSG_ID_VIBRATION; |
bhepp | 0:28183cc7963f | 81 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 82 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 83 | #else |
bhepp | 0:28183cc7963f | 84 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 85 | #endif |
bhepp | 0:28183cc7963f | 86 | } |
bhepp | 0:28183cc7963f | 87 | |
bhepp | 0:28183cc7963f | 88 | /** |
bhepp | 0:28183cc7963f | 89 | * @brief Pack a vibration message on a channel |
bhepp | 0:28183cc7963f | 90 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 91 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 92 | * @param chan The MAVLink channel this message will be sent over |
bhepp | 0:28183cc7963f | 93 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 94 | * @param time_usec Timestamp (micros since boot or Unix epoch) |
bhepp | 0:28183cc7963f | 95 | * @param vibration_x Vibration levels on X-axis |
bhepp | 0:28183cc7963f | 96 | * @param vibration_y Vibration levels on Y-axis |
bhepp | 0:28183cc7963f | 97 | * @param vibration_z Vibration levels on Z-axis |
bhepp | 0:28183cc7963f | 98 | * @param clipping_0 first accelerometer clipping count |
bhepp | 0:28183cc7963f | 99 | * @param clipping_1 second accelerometer clipping count |
bhepp | 0:28183cc7963f | 100 | * @param clipping_2 third accelerometer clipping count |
bhepp | 0:28183cc7963f | 101 | * @return length of the message in bytes (excluding serial stream start sign) |
bhepp | 0:28183cc7963f | 102 | */ |
bhepp | 0:28183cc7963f | 103 | static inline uint16_t mavlink_msg_vibration_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
bhepp | 0:28183cc7963f | 104 | mavlink_message_t* msg, |
bhepp | 0:28183cc7963f | 105 | 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) |
bhepp | 0:28183cc7963f | 106 | { |
bhepp | 0:28183cc7963f | 107 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 108 | char buf[MAVLINK_MSG_ID_VIBRATION_LEN]; |
bhepp | 0:28183cc7963f | 109 | _mav_put_uint64_t(buf, 0, time_usec); |
bhepp | 0:28183cc7963f | 110 | _mav_put_float(buf, 8, vibration_x); |
bhepp | 0:28183cc7963f | 111 | _mav_put_float(buf, 12, vibration_y); |
bhepp | 0:28183cc7963f | 112 | _mav_put_float(buf, 16, vibration_z); |
bhepp | 0:28183cc7963f | 113 | _mav_put_uint32_t(buf, 20, clipping_0); |
bhepp | 0:28183cc7963f | 114 | _mav_put_uint32_t(buf, 24, clipping_1); |
bhepp | 0:28183cc7963f | 115 | _mav_put_uint32_t(buf, 28, clipping_2); |
bhepp | 0:28183cc7963f | 116 | |
bhepp | 0:28183cc7963f | 117 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 118 | #else |
bhepp | 0:28183cc7963f | 119 | mavlink_vibration_t packet; |
bhepp | 0:28183cc7963f | 120 | packet.time_usec = time_usec; |
bhepp | 0:28183cc7963f | 121 | packet.vibration_x = vibration_x; |
bhepp | 0:28183cc7963f | 122 | packet.vibration_y = vibration_y; |
bhepp | 0:28183cc7963f | 123 | packet.vibration_z = vibration_z; |
bhepp | 0:28183cc7963f | 124 | packet.clipping_0 = clipping_0; |
bhepp | 0:28183cc7963f | 125 | packet.clipping_1 = clipping_1; |
bhepp | 0:28183cc7963f | 126 | packet.clipping_2 = clipping_2; |
bhepp | 0:28183cc7963f | 127 | |
bhepp | 0:28183cc7963f | 128 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 129 | #endif |
bhepp | 0:28183cc7963f | 130 | |
bhepp | 0:28183cc7963f | 131 | msg->msgid = MAVLINK_MSG_ID_VIBRATION; |
bhepp | 0:28183cc7963f | 132 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 133 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 134 | #else |
bhepp | 0:28183cc7963f | 135 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 136 | #endif |
bhepp | 0:28183cc7963f | 137 | } |
bhepp | 0:28183cc7963f | 138 | |
bhepp | 0:28183cc7963f | 139 | /** |
bhepp | 0:28183cc7963f | 140 | * @brief Encode a vibration struct |
bhepp | 0:28183cc7963f | 141 | * |
bhepp | 0:28183cc7963f | 142 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 143 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 144 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 145 | * @param vibration C-struct to read the message contents from |
bhepp | 0:28183cc7963f | 146 | */ |
bhepp | 0:28183cc7963f | 147 | 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) |
bhepp | 0:28183cc7963f | 148 | { |
bhepp | 0:28183cc7963f | 149 | 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); |
bhepp | 0:28183cc7963f | 150 | } |
bhepp | 0:28183cc7963f | 151 | |
bhepp | 0:28183cc7963f | 152 | /** |
bhepp | 0:28183cc7963f | 153 | * @brief Encode a vibration struct on a channel |
bhepp | 0:28183cc7963f | 154 | * |
bhepp | 0:28183cc7963f | 155 | * @param system_id ID of this system |
bhepp | 0:28183cc7963f | 156 | * @param component_id ID of this component (e.g. 200 for IMU) |
bhepp | 0:28183cc7963f | 157 | * @param chan The MAVLink channel this message will be sent over |
bhepp | 0:28183cc7963f | 158 | * @param msg The MAVLink message to compress the data into |
bhepp | 0:28183cc7963f | 159 | * @param vibration C-struct to read the message contents from |
bhepp | 0:28183cc7963f | 160 | */ |
bhepp | 0:28183cc7963f | 161 | 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) |
bhepp | 0:28183cc7963f | 162 | { |
bhepp | 0:28183cc7963f | 163 | 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); |
bhepp | 0:28183cc7963f | 164 | } |
bhepp | 0:28183cc7963f | 165 | |
bhepp | 0:28183cc7963f | 166 | /** |
bhepp | 0:28183cc7963f | 167 | * @brief Send a vibration message |
bhepp | 0:28183cc7963f | 168 | * @param chan MAVLink channel to send the message |
bhepp | 0:28183cc7963f | 169 | * |
bhepp | 0:28183cc7963f | 170 | * @param time_usec Timestamp (micros since boot or Unix epoch) |
bhepp | 0:28183cc7963f | 171 | * @param vibration_x Vibration levels on X-axis |
bhepp | 0:28183cc7963f | 172 | * @param vibration_y Vibration levels on Y-axis |
bhepp | 0:28183cc7963f | 173 | * @param vibration_z Vibration levels on Z-axis |
bhepp | 0:28183cc7963f | 174 | * @param clipping_0 first accelerometer clipping count |
bhepp | 0:28183cc7963f | 175 | * @param clipping_1 second accelerometer clipping count |
bhepp | 0:28183cc7963f | 176 | * @param clipping_2 third accelerometer clipping count |
bhepp | 0:28183cc7963f | 177 | */ |
bhepp | 0:28183cc7963f | 178 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
bhepp | 0:28183cc7963f | 179 | |
bhepp | 0:28183cc7963f | 180 | 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) |
bhepp | 0:28183cc7963f | 181 | { |
bhepp | 0:28183cc7963f | 182 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 183 | char buf[MAVLINK_MSG_ID_VIBRATION_LEN]; |
bhepp | 0:28183cc7963f | 184 | _mav_put_uint64_t(buf, 0, time_usec); |
bhepp | 0:28183cc7963f | 185 | _mav_put_float(buf, 8, vibration_x); |
bhepp | 0:28183cc7963f | 186 | _mav_put_float(buf, 12, vibration_y); |
bhepp | 0:28183cc7963f | 187 | _mav_put_float(buf, 16, vibration_z); |
bhepp | 0:28183cc7963f | 188 | _mav_put_uint32_t(buf, 20, clipping_0); |
bhepp | 0:28183cc7963f | 189 | _mav_put_uint32_t(buf, 24, clipping_1); |
bhepp | 0:28183cc7963f | 190 | _mav_put_uint32_t(buf, 28, clipping_2); |
bhepp | 0:28183cc7963f | 191 | |
bhepp | 0:28183cc7963f | 192 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 193 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, buf, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 194 | #else |
bhepp | 0:28183cc7963f | 195 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, buf, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 196 | #endif |
bhepp | 0:28183cc7963f | 197 | #else |
bhepp | 0:28183cc7963f | 198 | mavlink_vibration_t packet; |
bhepp | 0:28183cc7963f | 199 | packet.time_usec = time_usec; |
bhepp | 0:28183cc7963f | 200 | packet.vibration_x = vibration_x; |
bhepp | 0:28183cc7963f | 201 | packet.vibration_y = vibration_y; |
bhepp | 0:28183cc7963f | 202 | packet.vibration_z = vibration_z; |
bhepp | 0:28183cc7963f | 203 | packet.clipping_0 = clipping_0; |
bhepp | 0:28183cc7963f | 204 | packet.clipping_1 = clipping_1; |
bhepp | 0:28183cc7963f | 205 | packet.clipping_2 = clipping_2; |
bhepp | 0:28183cc7963f | 206 | |
bhepp | 0:28183cc7963f | 207 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 208 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, (const char *)&packet, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 209 | #else |
bhepp | 0:28183cc7963f | 210 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, (const char *)&packet, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 211 | #endif |
bhepp | 0:28183cc7963f | 212 | #endif |
bhepp | 0:28183cc7963f | 213 | } |
bhepp | 0:28183cc7963f | 214 | |
bhepp | 0:28183cc7963f | 215 | #if MAVLINK_MSG_ID_VIBRATION_LEN <= MAVLINK_MAX_PAYLOAD_LEN |
bhepp | 0:28183cc7963f | 216 | /* |
bhepp | 0:28183cc7963f | 217 | This varient of _send() can be used to save stack space by re-using |
bhepp | 0:28183cc7963f | 218 | memory from the receive buffer. The caller provides a |
bhepp | 0:28183cc7963f | 219 | mavlink_message_t which is the size of a full mavlink message. This |
bhepp | 0:28183cc7963f | 220 | is usually the receive buffer for the channel, and allows a reply to an |
bhepp | 0:28183cc7963f | 221 | incoming message with minimum stack space usage. |
bhepp | 0:28183cc7963f | 222 | */ |
bhepp | 0:28183cc7963f | 223 | 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) |
bhepp | 0:28183cc7963f | 224 | { |
bhepp | 0:28183cc7963f | 225 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
bhepp | 0:28183cc7963f | 226 | char *buf = (char *)msgbuf; |
bhepp | 0:28183cc7963f | 227 | _mav_put_uint64_t(buf, 0, time_usec); |
bhepp | 0:28183cc7963f | 228 | _mav_put_float(buf, 8, vibration_x); |
bhepp | 0:28183cc7963f | 229 | _mav_put_float(buf, 12, vibration_y); |
bhepp | 0:28183cc7963f | 230 | _mav_put_float(buf, 16, vibration_z); |
bhepp | 0:28183cc7963f | 231 | _mav_put_uint32_t(buf, 20, clipping_0); |
bhepp | 0:28183cc7963f | 232 | _mav_put_uint32_t(buf, 24, clipping_1); |
bhepp | 0:28183cc7963f | 233 | _mav_put_uint32_t(buf, 28, clipping_2); |
bhepp | 0:28183cc7963f | 234 | |
bhepp | 0:28183cc7963f | 235 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 236 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, buf, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 237 | #else |
bhepp | 0:28183cc7963f | 238 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, buf, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 239 | #endif |
bhepp | 0:28183cc7963f | 240 | #else |
bhepp | 0:28183cc7963f | 241 | mavlink_vibration_t *packet = (mavlink_vibration_t *)msgbuf; |
bhepp | 0:28183cc7963f | 242 | packet->time_usec = time_usec; |
bhepp | 0:28183cc7963f | 243 | packet->vibration_x = vibration_x; |
bhepp | 0:28183cc7963f | 244 | packet->vibration_y = vibration_y; |
bhepp | 0:28183cc7963f | 245 | packet->vibration_z = vibration_z; |
bhepp | 0:28183cc7963f | 246 | packet->clipping_0 = clipping_0; |
bhepp | 0:28183cc7963f | 247 | packet->clipping_1 = clipping_1; |
bhepp | 0:28183cc7963f | 248 | packet->clipping_2 = clipping_2; |
bhepp | 0:28183cc7963f | 249 | |
bhepp | 0:28183cc7963f | 250 | #if MAVLINK_CRC_EXTRA |
bhepp | 0:28183cc7963f | 251 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, (const char *)packet, MAVLINK_MSG_ID_VIBRATION_LEN, MAVLINK_MSG_ID_VIBRATION_CRC); |
bhepp | 0:28183cc7963f | 252 | #else |
bhepp | 0:28183cc7963f | 253 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VIBRATION, (const char *)packet, MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 254 | #endif |
bhepp | 0:28183cc7963f | 255 | #endif |
bhepp | 0:28183cc7963f | 256 | } |
bhepp | 0:28183cc7963f | 257 | #endif |
bhepp | 0:28183cc7963f | 258 | |
bhepp | 0:28183cc7963f | 259 | #endif |
bhepp | 0:28183cc7963f | 260 | |
bhepp | 0:28183cc7963f | 261 | // MESSAGE VIBRATION UNPACKING |
bhepp | 0:28183cc7963f | 262 | |
bhepp | 0:28183cc7963f | 263 | |
bhepp | 0:28183cc7963f | 264 | /** |
bhepp | 0:28183cc7963f | 265 | * @brief Get field time_usec from vibration message |
bhepp | 0:28183cc7963f | 266 | * |
bhepp | 0:28183cc7963f | 267 | * @return Timestamp (micros since boot or Unix epoch) |
bhepp | 0:28183cc7963f | 268 | */ |
bhepp | 0:28183cc7963f | 269 | static inline uint64_t mavlink_msg_vibration_get_time_usec(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 270 | { |
bhepp | 0:28183cc7963f | 271 | return _MAV_RETURN_uint64_t(msg, 0); |
bhepp | 0:28183cc7963f | 272 | } |
bhepp | 0:28183cc7963f | 273 | |
bhepp | 0:28183cc7963f | 274 | /** |
bhepp | 0:28183cc7963f | 275 | * @brief Get field vibration_x from vibration message |
bhepp | 0:28183cc7963f | 276 | * |
bhepp | 0:28183cc7963f | 277 | * @return Vibration levels on X-axis |
bhepp | 0:28183cc7963f | 278 | */ |
bhepp | 0:28183cc7963f | 279 | static inline float mavlink_msg_vibration_get_vibration_x(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 280 | { |
bhepp | 0:28183cc7963f | 281 | return _MAV_RETURN_float(msg, 8); |
bhepp | 0:28183cc7963f | 282 | } |
bhepp | 0:28183cc7963f | 283 | |
bhepp | 0:28183cc7963f | 284 | /** |
bhepp | 0:28183cc7963f | 285 | * @brief Get field vibration_y from vibration message |
bhepp | 0:28183cc7963f | 286 | * |
bhepp | 0:28183cc7963f | 287 | * @return Vibration levels on Y-axis |
bhepp | 0:28183cc7963f | 288 | */ |
bhepp | 0:28183cc7963f | 289 | static inline float mavlink_msg_vibration_get_vibration_y(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 290 | { |
bhepp | 0:28183cc7963f | 291 | return _MAV_RETURN_float(msg, 12); |
bhepp | 0:28183cc7963f | 292 | } |
bhepp | 0:28183cc7963f | 293 | |
bhepp | 0:28183cc7963f | 294 | /** |
bhepp | 0:28183cc7963f | 295 | * @brief Get field vibration_z from vibration message |
bhepp | 0:28183cc7963f | 296 | * |
bhepp | 0:28183cc7963f | 297 | * @return Vibration levels on Z-axis |
bhepp | 0:28183cc7963f | 298 | */ |
bhepp | 0:28183cc7963f | 299 | static inline float mavlink_msg_vibration_get_vibration_z(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 300 | { |
bhepp | 0:28183cc7963f | 301 | return _MAV_RETURN_float(msg, 16); |
bhepp | 0:28183cc7963f | 302 | } |
bhepp | 0:28183cc7963f | 303 | |
bhepp | 0:28183cc7963f | 304 | /** |
bhepp | 0:28183cc7963f | 305 | * @brief Get field clipping_0 from vibration message |
bhepp | 0:28183cc7963f | 306 | * |
bhepp | 0:28183cc7963f | 307 | * @return first accelerometer clipping count |
bhepp | 0:28183cc7963f | 308 | */ |
bhepp | 0:28183cc7963f | 309 | static inline uint32_t mavlink_msg_vibration_get_clipping_0(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 310 | { |
bhepp | 0:28183cc7963f | 311 | return _MAV_RETURN_uint32_t(msg, 20); |
bhepp | 0:28183cc7963f | 312 | } |
bhepp | 0:28183cc7963f | 313 | |
bhepp | 0:28183cc7963f | 314 | /** |
bhepp | 0:28183cc7963f | 315 | * @brief Get field clipping_1 from vibration message |
bhepp | 0:28183cc7963f | 316 | * |
bhepp | 0:28183cc7963f | 317 | * @return second accelerometer clipping count |
bhepp | 0:28183cc7963f | 318 | */ |
bhepp | 0:28183cc7963f | 319 | static inline uint32_t mavlink_msg_vibration_get_clipping_1(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 320 | { |
bhepp | 0:28183cc7963f | 321 | return _MAV_RETURN_uint32_t(msg, 24); |
bhepp | 0:28183cc7963f | 322 | } |
bhepp | 0:28183cc7963f | 323 | |
bhepp | 0:28183cc7963f | 324 | /** |
bhepp | 0:28183cc7963f | 325 | * @brief Get field clipping_2 from vibration message |
bhepp | 0:28183cc7963f | 326 | * |
bhepp | 0:28183cc7963f | 327 | * @return third accelerometer clipping count |
bhepp | 0:28183cc7963f | 328 | */ |
bhepp | 0:28183cc7963f | 329 | static inline uint32_t mavlink_msg_vibration_get_clipping_2(const mavlink_message_t* msg) |
bhepp | 0:28183cc7963f | 330 | { |
bhepp | 0:28183cc7963f | 331 | return _MAV_RETURN_uint32_t(msg, 28); |
bhepp | 0:28183cc7963f | 332 | } |
bhepp | 0:28183cc7963f | 333 | |
bhepp | 0:28183cc7963f | 334 | /** |
bhepp | 0:28183cc7963f | 335 | * @brief Decode a vibration message into a struct |
bhepp | 0:28183cc7963f | 336 | * |
bhepp | 0:28183cc7963f | 337 | * @param msg The message to decode |
bhepp | 0:28183cc7963f | 338 | * @param vibration C-struct to decode the message contents into |
bhepp | 0:28183cc7963f | 339 | */ |
bhepp | 0:28183cc7963f | 340 | static inline void mavlink_msg_vibration_decode(const mavlink_message_t* msg, mavlink_vibration_t* vibration) |
bhepp | 0:28183cc7963f | 341 | { |
bhepp | 0:28183cc7963f | 342 | #if MAVLINK_NEED_BYTE_SWAP |
bhepp | 0:28183cc7963f | 343 | vibration->time_usec = mavlink_msg_vibration_get_time_usec(msg); |
bhepp | 0:28183cc7963f | 344 | vibration->vibration_x = mavlink_msg_vibration_get_vibration_x(msg); |
bhepp | 0:28183cc7963f | 345 | vibration->vibration_y = mavlink_msg_vibration_get_vibration_y(msg); |
bhepp | 0:28183cc7963f | 346 | vibration->vibration_z = mavlink_msg_vibration_get_vibration_z(msg); |
bhepp | 0:28183cc7963f | 347 | vibration->clipping_0 = mavlink_msg_vibration_get_clipping_0(msg); |
bhepp | 0:28183cc7963f | 348 | vibration->clipping_1 = mavlink_msg_vibration_get_clipping_1(msg); |
bhepp | 0:28183cc7963f | 349 | vibration->clipping_2 = mavlink_msg_vibration_get_clipping_2(msg); |
bhepp | 0:28183cc7963f | 350 | #else |
bhepp | 0:28183cc7963f | 351 | memcpy(vibration, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_VIBRATION_LEN); |
bhepp | 0:28183cc7963f | 352 | #endif |
bhepp | 0:28183cc7963f | 353 | } |