Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/pixhawk/mavlink_msg_raw_aux.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE RAW_AUX PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_RAW_AUX 141 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_raw_aux_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint16_t adc1; ///< ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 8 | uint16_t adc2; ///< ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 9 | uint16_t adc3; ///< ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 10 | uint16_t adc4; ///< ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 11 | uint16_t vbat; ///< Battery voltage |
shimniok | 0:826c6171fc1b | 12 | int16_t temp; ///< Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 13 | int32_t baro; ///< Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 14 | |
shimniok | 0:826c6171fc1b | 15 | } mavlink_raw_aux_t; |
shimniok | 0:826c6171fc1b | 16 | |
shimniok | 0:826c6171fc1b | 17 | |
shimniok | 0:826c6171fc1b | 18 | |
shimniok | 0:826c6171fc1b | 19 | /** |
shimniok | 0:826c6171fc1b | 20 | * @brief Pack a raw_aux message |
shimniok | 0:826c6171fc1b | 21 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 22 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 23 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 24 | * |
shimniok | 0:826c6171fc1b | 25 | * @param adc1 ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 26 | * @param adc2 ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 27 | * @param adc3 ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 28 | * @param adc4 ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 29 | * @param vbat Battery voltage |
shimniok | 0:826c6171fc1b | 30 | * @param temp Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 31 | * @param baro Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 32 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 33 | */ |
shimniok | 0:826c6171fc1b | 34 | static inline uint16_t mavlink_msg_raw_aux_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro) |
shimniok | 0:826c6171fc1b | 35 | { |
shimniok | 0:826c6171fc1b | 36 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 37 | msg->msgid = MAVLINK_MSG_ID_RAW_AUX; |
shimniok | 0:826c6171fc1b | 38 | |
shimniok | 0:826c6171fc1b | 39 | i += put_uint16_t_by_index(adc1, i, msg->payload); // ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 40 | i += put_uint16_t_by_index(adc2, i, msg->payload); // ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 41 | i += put_uint16_t_by_index(adc3, i, msg->payload); // ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 42 | i += put_uint16_t_by_index(adc4, i, msg->payload); // ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 43 | i += put_uint16_t_by_index(vbat, i, msg->payload); // Battery voltage |
shimniok | 0:826c6171fc1b | 44 | i += put_int16_t_by_index(temp, i, msg->payload); // Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 45 | i += put_int32_t_by_index(baro, i, msg->payload); // Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 46 | |
shimniok | 0:826c6171fc1b | 47 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 48 | } |
shimniok | 0:826c6171fc1b | 49 | |
shimniok | 0:826c6171fc1b | 50 | /** |
shimniok | 0:826c6171fc1b | 51 | * @brief Pack a raw_aux message |
shimniok | 0:826c6171fc1b | 52 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 53 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 54 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 55 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 56 | * @param adc1 ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 57 | * @param adc2 ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 58 | * @param adc3 ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 59 | * @param adc4 ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 60 | * @param vbat Battery voltage |
shimniok | 0:826c6171fc1b | 61 | * @param temp Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 62 | * @param baro Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 63 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 64 | */ |
shimniok | 0:826c6171fc1b | 65 | static inline uint16_t mavlink_msg_raw_aux_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro) |
shimniok | 0:826c6171fc1b | 66 | { |
shimniok | 0:826c6171fc1b | 67 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 68 | msg->msgid = MAVLINK_MSG_ID_RAW_AUX; |
shimniok | 0:826c6171fc1b | 69 | |
shimniok | 0:826c6171fc1b | 70 | i += put_uint16_t_by_index(adc1, i, msg->payload); // ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 71 | i += put_uint16_t_by_index(adc2, i, msg->payload); // ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 72 | i += put_uint16_t_by_index(adc3, i, msg->payload); // ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 73 | i += put_uint16_t_by_index(adc4, i, msg->payload); // ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 74 | i += put_uint16_t_by_index(vbat, i, msg->payload); // Battery voltage |
shimniok | 0:826c6171fc1b | 75 | i += put_int16_t_by_index(temp, i, msg->payload); // Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 76 | i += put_int32_t_by_index(baro, i, msg->payload); // Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 77 | |
shimniok | 0:826c6171fc1b | 78 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 79 | } |
shimniok | 0:826c6171fc1b | 80 | |
shimniok | 0:826c6171fc1b | 81 | /** |
shimniok | 0:826c6171fc1b | 82 | * @brief Encode a raw_aux struct into a message |
shimniok | 0:826c6171fc1b | 83 | * |
shimniok | 0:826c6171fc1b | 84 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 85 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 86 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 87 | * @param raw_aux C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 88 | */ |
shimniok | 0:826c6171fc1b | 89 | static inline uint16_t mavlink_msg_raw_aux_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_aux_t* raw_aux) |
shimniok | 0:826c6171fc1b | 90 | { |
shimniok | 0:826c6171fc1b | 91 | return mavlink_msg_raw_aux_pack(system_id, component_id, msg, raw_aux->adc1, raw_aux->adc2, raw_aux->adc3, raw_aux->adc4, raw_aux->vbat, raw_aux->temp, raw_aux->baro); |
shimniok | 0:826c6171fc1b | 92 | } |
shimniok | 0:826c6171fc1b | 93 | |
shimniok | 0:826c6171fc1b | 94 | /** |
shimniok | 0:826c6171fc1b | 95 | * @brief Send a raw_aux message |
shimniok | 0:826c6171fc1b | 96 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 97 | * |
shimniok | 0:826c6171fc1b | 98 | * @param adc1 ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 99 | * @param adc2 ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 100 | * @param adc3 ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 101 | * @param adc4 ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 102 | * @param vbat Battery voltage |
shimniok | 0:826c6171fc1b | 103 | * @param temp Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 104 | * @param baro Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 105 | */ |
shimniok | 0:826c6171fc1b | 106 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 107 | |
shimniok | 0:826c6171fc1b | 108 | static inline void mavlink_msg_raw_aux_send(mavlink_channel_t chan, uint16_t adc1, uint16_t adc2, uint16_t adc3, uint16_t adc4, uint16_t vbat, int16_t temp, int32_t baro) |
shimniok | 0:826c6171fc1b | 109 | { |
shimniok | 0:826c6171fc1b | 110 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 111 | mavlink_msg_raw_aux_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, adc1, adc2, adc3, adc4, vbat, temp, baro); |
shimniok | 0:826c6171fc1b | 112 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 113 | } |
shimniok | 0:826c6171fc1b | 114 | |
shimniok | 0:826c6171fc1b | 115 | #endif |
shimniok | 0:826c6171fc1b | 116 | // MESSAGE RAW_AUX UNPACKING |
shimniok | 0:826c6171fc1b | 117 | |
shimniok | 0:826c6171fc1b | 118 | /** |
shimniok | 0:826c6171fc1b | 119 | * @brief Get field adc1 from raw_aux message |
shimniok | 0:826c6171fc1b | 120 | * |
shimniok | 0:826c6171fc1b | 121 | * @return ADC1 (J405 ADC3, LPC2148 AD0.6) |
shimniok | 0:826c6171fc1b | 122 | */ |
shimniok | 0:826c6171fc1b | 123 | static inline uint16_t mavlink_msg_raw_aux_get_adc1(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 124 | { |
shimniok | 0:826c6171fc1b | 125 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 126 | r.b[1] = (msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 127 | r.b[0] = (msg->payload)[1]; |
shimniok | 0:826c6171fc1b | 128 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 129 | } |
shimniok | 0:826c6171fc1b | 130 | |
shimniok | 0:826c6171fc1b | 131 | /** |
shimniok | 0:826c6171fc1b | 132 | * @brief Get field adc2 from raw_aux message |
shimniok | 0:826c6171fc1b | 133 | * |
shimniok | 0:826c6171fc1b | 134 | * @return ADC2 (J405 ADC5, LPC2148 AD0.2) |
shimniok | 0:826c6171fc1b | 135 | */ |
shimniok | 0:826c6171fc1b | 136 | static inline uint16_t mavlink_msg_raw_aux_get_adc2(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 137 | { |
shimniok | 0:826c6171fc1b | 138 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 139 | r.b[1] = (msg->payload+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 140 | r.b[0] = (msg->payload+sizeof(uint16_t))[1]; |
shimniok | 0:826c6171fc1b | 141 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 142 | } |
shimniok | 0:826c6171fc1b | 143 | |
shimniok | 0:826c6171fc1b | 144 | /** |
shimniok | 0:826c6171fc1b | 145 | * @brief Get field adc3 from raw_aux message |
shimniok | 0:826c6171fc1b | 146 | * |
shimniok | 0:826c6171fc1b | 147 | * @return ADC3 (J405 ADC6, LPC2148 AD0.1) |
shimniok | 0:826c6171fc1b | 148 | */ |
shimniok | 0:826c6171fc1b | 149 | static inline uint16_t mavlink_msg_raw_aux_get_adc3(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 150 | { |
shimniok | 0:826c6171fc1b | 151 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 152 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 153 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:826c6171fc1b | 154 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 155 | } |
shimniok | 0:826c6171fc1b | 156 | |
shimniok | 0:826c6171fc1b | 157 | /** |
shimniok | 0:826c6171fc1b | 158 | * @brief Get field adc4 from raw_aux message |
shimniok | 0:826c6171fc1b | 159 | * |
shimniok | 0:826c6171fc1b | 160 | * @return ADC4 (J405 ADC7, LPC2148 AD1.3) |
shimniok | 0:826c6171fc1b | 161 | */ |
shimniok | 0:826c6171fc1b | 162 | static inline uint16_t mavlink_msg_raw_aux_get_adc4(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 163 | { |
shimniok | 0:826c6171fc1b | 164 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 165 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 166 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:826c6171fc1b | 167 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 168 | } |
shimniok | 0:826c6171fc1b | 169 | |
shimniok | 0:826c6171fc1b | 170 | /** |
shimniok | 0:826c6171fc1b | 171 | * @brief Get field vbat from raw_aux message |
shimniok | 0:826c6171fc1b | 172 | * |
shimniok | 0:826c6171fc1b | 173 | * @return Battery voltage |
shimniok | 0:826c6171fc1b | 174 | */ |
shimniok | 0:826c6171fc1b | 175 | static inline uint16_t mavlink_msg_raw_aux_get_vbat(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 176 | { |
shimniok | 0:826c6171fc1b | 177 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 178 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 179 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:826c6171fc1b | 180 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 181 | } |
shimniok | 0:826c6171fc1b | 182 | |
shimniok | 0:826c6171fc1b | 183 | /** |
shimniok | 0:826c6171fc1b | 184 | * @brief Get field temp from raw_aux message |
shimniok | 0:826c6171fc1b | 185 | * |
shimniok | 0:826c6171fc1b | 186 | * @return Temperature (degrees celcius) |
shimniok | 0:826c6171fc1b | 187 | */ |
shimniok | 0:826c6171fc1b | 188 | static inline int16_t mavlink_msg_raw_aux_get_temp(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 189 | { |
shimniok | 0:826c6171fc1b | 190 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 191 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:826c6171fc1b | 192 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:826c6171fc1b | 193 | return (int16_t)r.s; |
shimniok | 0:826c6171fc1b | 194 | } |
shimniok | 0:826c6171fc1b | 195 | |
shimniok | 0:826c6171fc1b | 196 | /** |
shimniok | 0:826c6171fc1b | 197 | * @brief Get field baro from raw_aux message |
shimniok | 0:826c6171fc1b | 198 | * |
shimniok | 0:826c6171fc1b | 199 | * @return Barometric pressure (hecto Pascal) |
shimniok | 0:826c6171fc1b | 200 | */ |
shimniok | 0:826c6171fc1b | 201 | static inline int32_t mavlink_msg_raw_aux_get_baro(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 202 | { |
shimniok | 0:826c6171fc1b | 203 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 204 | r.b[3] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(int16_t))[0]; |
shimniok | 0:826c6171fc1b | 205 | r.b[2] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(int16_t))[1]; |
shimniok | 0:826c6171fc1b | 206 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(int16_t))[2]; |
shimniok | 0:826c6171fc1b | 207 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(int16_t))[3]; |
shimniok | 0:826c6171fc1b | 208 | return (int32_t)r.i; |
shimniok | 0:826c6171fc1b | 209 | } |
shimniok | 0:826c6171fc1b | 210 | |
shimniok | 0:826c6171fc1b | 211 | /** |
shimniok | 0:826c6171fc1b | 212 | * @brief Decode a raw_aux message into a struct |
shimniok | 0:826c6171fc1b | 213 | * |
shimniok | 0:826c6171fc1b | 214 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 215 | * @param raw_aux C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 216 | */ |
shimniok | 0:826c6171fc1b | 217 | static inline void mavlink_msg_raw_aux_decode(const mavlink_message_t* msg, mavlink_raw_aux_t* raw_aux) |
shimniok | 0:826c6171fc1b | 218 | { |
shimniok | 0:826c6171fc1b | 219 | raw_aux->adc1 = mavlink_msg_raw_aux_get_adc1(msg); |
shimniok | 0:826c6171fc1b | 220 | raw_aux->adc2 = mavlink_msg_raw_aux_get_adc2(msg); |
shimniok | 0:826c6171fc1b | 221 | raw_aux->adc3 = mavlink_msg_raw_aux_get_adc3(msg); |
shimniok | 0:826c6171fc1b | 222 | raw_aux->adc4 = mavlink_msg_raw_aux_get_adc4(msg); |
shimniok | 0:826c6171fc1b | 223 | raw_aux->vbat = mavlink_msg_raw_aux_get_vbat(msg); |
shimniok | 0:826c6171fc1b | 224 | raw_aux->temp = mavlink_msg_raw_aux_get_temp(msg); |
shimniok | 0:826c6171fc1b | 225 | raw_aux->baro = mavlink_msg_raw_aux_get_baro(msg); |
shimniok | 0:826c6171fc1b | 226 | } |