![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
MAVlink/include/pixhawk/mavlink_msg_aux_status.h@25:bb5356402687, 2018-11-30 (annotated)
- Committer:
- shimniok
- Date:
- Fri Nov 30 16:11:53 2018 +0000
- Revision:
- 25:bb5356402687
- Parent:
- 0:a6a169de725f
Initial publish of revised version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | // MESSAGE AUX_STATUS PACKING |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | #define MAVLINK_MSG_ID_AUX_STATUS 142 |
shimniok | 0:a6a169de725f | 4 | |
shimniok | 0:a6a169de725f | 5 | typedef struct __mavlink_aux_status_t |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | uint16_t load; ///< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 8 | uint16_t i2c0_err_count; ///< Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 9 | uint16_t i2c1_err_count; ///< Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 10 | uint16_t spi0_err_count; ///< Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 11 | uint16_t spi1_err_count; ///< Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 12 | uint16_t uart_total_err_count; ///< Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 13 | |
shimniok | 0:a6a169de725f | 14 | } mavlink_aux_status_t; |
shimniok | 0:a6a169de725f | 15 | |
shimniok | 0:a6a169de725f | 16 | |
shimniok | 0:a6a169de725f | 17 | |
shimniok | 0:a6a169de725f | 18 | /** |
shimniok | 0:a6a169de725f | 19 | * @brief Pack a aux_status message |
shimniok | 0:a6a169de725f | 20 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 21 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 22 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 23 | * |
shimniok | 0:a6a169de725f | 24 | * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 25 | * @param i2c0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 26 | * @param i2c1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 27 | * @param spi0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 28 | * @param spi1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 29 | * @param uart_total_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 30 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 31 | */ |
shimniok | 0:a6a169de725f | 32 | static inline uint16_t mavlink_msg_aux_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint16_t load, uint16_t i2c0_err_count, uint16_t i2c1_err_count, uint16_t spi0_err_count, uint16_t spi1_err_count, uint16_t uart_total_err_count) |
shimniok | 0:a6a169de725f | 33 | { |
shimniok | 0:a6a169de725f | 34 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 35 | msg->msgid = MAVLINK_MSG_ID_AUX_STATUS; |
shimniok | 0:a6a169de725f | 36 | |
shimniok | 0:a6a169de725f | 37 | i += put_uint16_t_by_index(load, i, msg->payload); // Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 38 | i += put_uint16_t_by_index(i2c0_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 39 | i += put_uint16_t_by_index(i2c1_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 40 | i += put_uint16_t_by_index(spi0_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 41 | i += put_uint16_t_by_index(spi1_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 42 | i += put_uint16_t_by_index(uart_total_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 43 | |
shimniok | 0:a6a169de725f | 44 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:a6a169de725f | 45 | } |
shimniok | 0:a6a169de725f | 46 | |
shimniok | 0:a6a169de725f | 47 | /** |
shimniok | 0:a6a169de725f | 48 | * @brief Pack a aux_status message |
shimniok | 0:a6a169de725f | 49 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 50 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 51 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:a6a169de725f | 52 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 53 | * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 54 | * @param i2c0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 55 | * @param i2c1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 56 | * @param spi0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 57 | * @param spi1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 58 | * @param uart_total_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 59 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:a6a169de725f | 60 | */ |
shimniok | 0:a6a169de725f | 61 | static inline uint16_t mavlink_msg_aux_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint16_t load, uint16_t i2c0_err_count, uint16_t i2c1_err_count, uint16_t spi0_err_count, uint16_t spi1_err_count, uint16_t uart_total_err_count) |
shimniok | 0:a6a169de725f | 62 | { |
shimniok | 0:a6a169de725f | 63 | uint16_t i = 0; |
shimniok | 0:a6a169de725f | 64 | msg->msgid = MAVLINK_MSG_ID_AUX_STATUS; |
shimniok | 0:a6a169de725f | 65 | |
shimniok | 0:a6a169de725f | 66 | i += put_uint16_t_by_index(load, i, msg->payload); // Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 67 | i += put_uint16_t_by_index(i2c0_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 68 | i += put_uint16_t_by_index(i2c1_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 69 | i += put_uint16_t_by_index(spi0_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 70 | i += put_uint16_t_by_index(spi1_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 71 | i += put_uint16_t_by_index(uart_total_err_count, i, msg->payload); // Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 72 | |
shimniok | 0:a6a169de725f | 73 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:a6a169de725f | 74 | } |
shimniok | 0:a6a169de725f | 75 | |
shimniok | 0:a6a169de725f | 76 | /** |
shimniok | 0:a6a169de725f | 77 | * @brief Encode a aux_status struct into a message |
shimniok | 0:a6a169de725f | 78 | * |
shimniok | 0:a6a169de725f | 79 | * @param system_id ID of this system |
shimniok | 0:a6a169de725f | 80 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:a6a169de725f | 81 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:a6a169de725f | 82 | * @param aux_status C-struct to read the message contents from |
shimniok | 0:a6a169de725f | 83 | */ |
shimniok | 0:a6a169de725f | 84 | static inline uint16_t mavlink_msg_aux_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_aux_status_t* aux_status) |
shimniok | 0:a6a169de725f | 85 | { |
shimniok | 0:a6a169de725f | 86 | return mavlink_msg_aux_status_pack(system_id, component_id, msg, aux_status->load, aux_status->i2c0_err_count, aux_status->i2c1_err_count, aux_status->spi0_err_count, aux_status->spi1_err_count, aux_status->uart_total_err_count); |
shimniok | 0:a6a169de725f | 87 | } |
shimniok | 0:a6a169de725f | 88 | |
shimniok | 0:a6a169de725f | 89 | /** |
shimniok | 0:a6a169de725f | 90 | * @brief Send a aux_status message |
shimniok | 0:a6a169de725f | 91 | * @param chan MAVLink channel to send the message |
shimniok | 0:a6a169de725f | 92 | * |
shimniok | 0:a6a169de725f | 93 | * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 94 | * @param i2c0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 95 | * @param i2c1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 96 | * @param spi0_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 97 | * @param spi1_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 98 | * @param uart_total_err_count Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 99 | */ |
shimniok | 0:a6a169de725f | 100 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:a6a169de725f | 101 | |
shimniok | 0:a6a169de725f | 102 | static inline void mavlink_msg_aux_status_send(mavlink_channel_t chan, uint16_t load, uint16_t i2c0_err_count, uint16_t i2c1_err_count, uint16_t spi0_err_count, uint16_t spi1_err_count, uint16_t uart_total_err_count) |
shimniok | 0:a6a169de725f | 103 | { |
shimniok | 0:a6a169de725f | 104 | mavlink_message_t msg; |
shimniok | 0:a6a169de725f | 105 | mavlink_msg_aux_status_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, load, i2c0_err_count, i2c1_err_count, spi0_err_count, spi1_err_count, uart_total_err_count); |
shimniok | 0:a6a169de725f | 106 | mavlink_send_uart(chan, &msg); |
shimniok | 0:a6a169de725f | 107 | } |
shimniok | 0:a6a169de725f | 108 | |
shimniok | 0:a6a169de725f | 109 | #endif |
shimniok | 0:a6a169de725f | 110 | // MESSAGE AUX_STATUS UNPACKING |
shimniok | 0:a6a169de725f | 111 | |
shimniok | 0:a6a169de725f | 112 | /** |
shimniok | 0:a6a169de725f | 113 | * @brief Get field load from aux_status message |
shimniok | 0:a6a169de725f | 114 | * |
shimniok | 0:a6a169de725f | 115 | * @return Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 |
shimniok | 0:a6a169de725f | 116 | */ |
shimniok | 0:a6a169de725f | 117 | static inline uint16_t mavlink_msg_aux_status_get_load(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 118 | { |
shimniok | 0:a6a169de725f | 119 | generic_16bit r; |
shimniok | 0:a6a169de725f | 120 | r.b[1] = (msg->payload)[0]; |
shimniok | 0:a6a169de725f | 121 | r.b[0] = (msg->payload)[1]; |
shimniok | 0:a6a169de725f | 122 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 123 | } |
shimniok | 0:a6a169de725f | 124 | |
shimniok | 0:a6a169de725f | 125 | /** |
shimniok | 0:a6a169de725f | 126 | * @brief Get field i2c0_err_count from aux_status message |
shimniok | 0:a6a169de725f | 127 | * |
shimniok | 0:a6a169de725f | 128 | * @return Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 129 | */ |
shimniok | 0:a6a169de725f | 130 | static inline uint16_t mavlink_msg_aux_status_get_i2c0_err_count(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 131 | { |
shimniok | 0:a6a169de725f | 132 | generic_16bit r; |
shimniok | 0:a6a169de725f | 133 | r.b[1] = (msg->payload+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 134 | r.b[0] = (msg->payload+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 135 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 136 | } |
shimniok | 0:a6a169de725f | 137 | |
shimniok | 0:a6a169de725f | 138 | /** |
shimniok | 0:a6a169de725f | 139 | * @brief Get field i2c1_err_count from aux_status message |
shimniok | 0:a6a169de725f | 140 | * |
shimniok | 0:a6a169de725f | 141 | * @return Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 142 | */ |
shimniok | 0:a6a169de725f | 143 | static inline uint16_t mavlink_msg_aux_status_get_i2c1_err_count(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 144 | { |
shimniok | 0:a6a169de725f | 145 | generic_16bit r; |
shimniok | 0:a6a169de725f | 146 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 147 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 148 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 149 | } |
shimniok | 0:a6a169de725f | 150 | |
shimniok | 0:a6a169de725f | 151 | /** |
shimniok | 0:a6a169de725f | 152 | * @brief Get field spi0_err_count from aux_status message |
shimniok | 0:a6a169de725f | 153 | * |
shimniok | 0:a6a169de725f | 154 | * @return Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 155 | */ |
shimniok | 0:a6a169de725f | 156 | static inline uint16_t mavlink_msg_aux_status_get_spi0_err_count(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 157 | { |
shimniok | 0:a6a169de725f | 158 | generic_16bit r; |
shimniok | 0:a6a169de725f | 159 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 160 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 161 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 162 | } |
shimniok | 0:a6a169de725f | 163 | |
shimniok | 0:a6a169de725f | 164 | /** |
shimniok | 0:a6a169de725f | 165 | * @brief Get field spi1_err_count from aux_status message |
shimniok | 0:a6a169de725f | 166 | * |
shimniok | 0:a6a169de725f | 167 | * @return Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 168 | */ |
shimniok | 0:a6a169de725f | 169 | static inline uint16_t mavlink_msg_aux_status_get_spi1_err_count(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 170 | { |
shimniok | 0:a6a169de725f | 171 | generic_16bit r; |
shimniok | 0:a6a169de725f | 172 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 173 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 174 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 175 | } |
shimniok | 0:a6a169de725f | 176 | |
shimniok | 0:a6a169de725f | 177 | /** |
shimniok | 0:a6a169de725f | 178 | * @brief Get field uart_total_err_count from aux_status message |
shimniok | 0:a6a169de725f | 179 | * |
shimniok | 0:a6a169de725f | 180 | * @return Number of I2C errors since startup |
shimniok | 0:a6a169de725f | 181 | */ |
shimniok | 0:a6a169de725f | 182 | static inline uint16_t mavlink_msg_aux_status_get_uart_total_err_count(const mavlink_message_t* msg) |
shimniok | 0:a6a169de725f | 183 | { |
shimniok | 0:a6a169de725f | 184 | generic_16bit r; |
shimniok | 0:a6a169de725f | 185 | r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0]; |
shimniok | 0:a6a169de725f | 186 | r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1]; |
shimniok | 0:a6a169de725f | 187 | return (uint16_t)r.s; |
shimniok | 0:a6a169de725f | 188 | } |
shimniok | 0:a6a169de725f | 189 | |
shimniok | 0:a6a169de725f | 190 | /** |
shimniok | 0:a6a169de725f | 191 | * @brief Decode a aux_status message into a struct |
shimniok | 0:a6a169de725f | 192 | * |
shimniok | 0:a6a169de725f | 193 | * @param msg The message to decode |
shimniok | 0:a6a169de725f | 194 | * @param aux_status C-struct to decode the message contents into |
shimniok | 0:a6a169de725f | 195 | */ |
shimniok | 0:a6a169de725f | 196 | static inline void mavlink_msg_aux_status_decode(const mavlink_message_t* msg, mavlink_aux_status_t* aux_status) |
shimniok | 0:a6a169de725f | 197 | { |
shimniok | 0:a6a169de725f | 198 | aux_status->load = mavlink_msg_aux_status_get_load(msg); |
shimniok | 0:a6a169de725f | 199 | aux_status->i2c0_err_count = mavlink_msg_aux_status_get_i2c0_err_count(msg); |
shimniok | 0:a6a169de725f | 200 | aux_status->i2c1_err_count = mavlink_msg_aux_status_get_i2c1_err_count(msg); |
shimniok | 0:a6a169de725f | 201 | aux_status->spi0_err_count = mavlink_msg_aux_status_get_spi0_err_count(msg); |
shimniok | 0:a6a169de725f | 202 | aux_status->spi1_err_count = mavlink_msg_aux_status_get_spi1_err_count(msg); |
shimniok | 0:a6a169de725f | 203 | aux_status->uart_total_err_count = mavlink_msg_aux_status_get_uart_total_err_count(msg); |
shimniok | 0:a6a169de725f | 204 | } |