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/slugs/mavlink_msg_cpu_load.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 CPU_LOAD PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_CPU_LOAD 170 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_cpu_load_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint8_t sensLoad; ///< Sensor DSC Load |
shimniok | 0:826c6171fc1b | 8 | uint8_t ctrlLoad; ///< Control DSC Load |
shimniok | 0:826c6171fc1b | 9 | uint16_t batVolt; ///< Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 10 | |
shimniok | 0:826c6171fc1b | 11 | } mavlink_cpu_load_t; |
shimniok | 0:826c6171fc1b | 12 | |
shimniok | 0:826c6171fc1b | 13 | |
shimniok | 0:826c6171fc1b | 14 | |
shimniok | 0:826c6171fc1b | 15 | /** |
shimniok | 0:826c6171fc1b | 16 | * @brief Pack a cpu_load message |
shimniok | 0:826c6171fc1b | 17 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 18 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 19 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 20 | * |
shimniok | 0:826c6171fc1b | 21 | * @param sensLoad Sensor DSC Load |
shimniok | 0:826c6171fc1b | 22 | * @param ctrlLoad Control DSC Load |
shimniok | 0:826c6171fc1b | 23 | * @param batVolt Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 24 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 25 | */ |
shimniok | 0:826c6171fc1b | 26 | static inline uint16_t mavlink_msg_cpu_load_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t sensLoad, uint8_t ctrlLoad, uint16_t batVolt) |
shimniok | 0:826c6171fc1b | 27 | { |
shimniok | 0:826c6171fc1b | 28 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 29 | msg->msgid = MAVLINK_MSG_ID_CPU_LOAD; |
shimniok | 0:826c6171fc1b | 30 | |
shimniok | 0:826c6171fc1b | 31 | i += put_uint8_t_by_index(sensLoad, i, msg->payload); // Sensor DSC Load |
shimniok | 0:826c6171fc1b | 32 | i += put_uint8_t_by_index(ctrlLoad, i, msg->payload); // Control DSC Load |
shimniok | 0:826c6171fc1b | 33 | i += put_uint16_t_by_index(batVolt, i, msg->payload); // Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 34 | |
shimniok | 0:826c6171fc1b | 35 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 36 | } |
shimniok | 0:826c6171fc1b | 37 | |
shimniok | 0:826c6171fc1b | 38 | /** |
shimniok | 0:826c6171fc1b | 39 | * @brief Pack a cpu_load message |
shimniok | 0:826c6171fc1b | 40 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 41 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 42 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 43 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 44 | * @param sensLoad Sensor DSC Load |
shimniok | 0:826c6171fc1b | 45 | * @param ctrlLoad Control DSC Load |
shimniok | 0:826c6171fc1b | 46 | * @param batVolt Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 47 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 48 | */ |
shimniok | 0:826c6171fc1b | 49 | static inline uint16_t mavlink_msg_cpu_load_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t sensLoad, uint8_t ctrlLoad, uint16_t batVolt) |
shimniok | 0:826c6171fc1b | 50 | { |
shimniok | 0:826c6171fc1b | 51 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 52 | msg->msgid = MAVLINK_MSG_ID_CPU_LOAD; |
shimniok | 0:826c6171fc1b | 53 | |
shimniok | 0:826c6171fc1b | 54 | i += put_uint8_t_by_index(sensLoad, i, msg->payload); // Sensor DSC Load |
shimniok | 0:826c6171fc1b | 55 | i += put_uint8_t_by_index(ctrlLoad, i, msg->payload); // Control DSC Load |
shimniok | 0:826c6171fc1b | 56 | i += put_uint16_t_by_index(batVolt, i, msg->payload); // Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 57 | |
shimniok | 0:826c6171fc1b | 58 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 59 | } |
shimniok | 0:826c6171fc1b | 60 | |
shimniok | 0:826c6171fc1b | 61 | /** |
shimniok | 0:826c6171fc1b | 62 | * @brief Encode a cpu_load struct into a message |
shimniok | 0:826c6171fc1b | 63 | * |
shimniok | 0:826c6171fc1b | 64 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 65 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 66 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 67 | * @param cpu_load C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 68 | */ |
shimniok | 0:826c6171fc1b | 69 | static inline uint16_t mavlink_msg_cpu_load_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_cpu_load_t* cpu_load) |
shimniok | 0:826c6171fc1b | 70 | { |
shimniok | 0:826c6171fc1b | 71 | return mavlink_msg_cpu_load_pack(system_id, component_id, msg, cpu_load->sensLoad, cpu_load->ctrlLoad, cpu_load->batVolt); |
shimniok | 0:826c6171fc1b | 72 | } |
shimniok | 0:826c6171fc1b | 73 | |
shimniok | 0:826c6171fc1b | 74 | /** |
shimniok | 0:826c6171fc1b | 75 | * @brief Send a cpu_load message |
shimniok | 0:826c6171fc1b | 76 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 77 | * |
shimniok | 0:826c6171fc1b | 78 | * @param sensLoad Sensor DSC Load |
shimniok | 0:826c6171fc1b | 79 | * @param ctrlLoad Control DSC Load |
shimniok | 0:826c6171fc1b | 80 | * @param batVolt Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 81 | */ |
shimniok | 0:826c6171fc1b | 82 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 83 | |
shimniok | 0:826c6171fc1b | 84 | static inline void mavlink_msg_cpu_load_send(mavlink_channel_t chan, uint8_t sensLoad, uint8_t ctrlLoad, uint16_t batVolt) |
shimniok | 0:826c6171fc1b | 85 | { |
shimniok | 0:826c6171fc1b | 86 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 87 | mavlink_msg_cpu_load_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, sensLoad, ctrlLoad, batVolt); |
shimniok | 0:826c6171fc1b | 88 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 89 | } |
shimniok | 0:826c6171fc1b | 90 | |
shimniok | 0:826c6171fc1b | 91 | #endif |
shimniok | 0:826c6171fc1b | 92 | // MESSAGE CPU_LOAD UNPACKING |
shimniok | 0:826c6171fc1b | 93 | |
shimniok | 0:826c6171fc1b | 94 | /** |
shimniok | 0:826c6171fc1b | 95 | * @brief Get field sensLoad from cpu_load message |
shimniok | 0:826c6171fc1b | 96 | * |
shimniok | 0:826c6171fc1b | 97 | * @return Sensor DSC Load |
shimniok | 0:826c6171fc1b | 98 | */ |
shimniok | 0:826c6171fc1b | 99 | static inline uint8_t mavlink_msg_cpu_load_get_sensLoad(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 100 | { |
shimniok | 0:826c6171fc1b | 101 | return (uint8_t)(msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 102 | } |
shimniok | 0:826c6171fc1b | 103 | |
shimniok | 0:826c6171fc1b | 104 | /** |
shimniok | 0:826c6171fc1b | 105 | * @brief Get field ctrlLoad from cpu_load message |
shimniok | 0:826c6171fc1b | 106 | * |
shimniok | 0:826c6171fc1b | 107 | * @return Control DSC Load |
shimniok | 0:826c6171fc1b | 108 | */ |
shimniok | 0:826c6171fc1b | 109 | static inline uint8_t mavlink_msg_cpu_load_get_ctrlLoad(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 110 | { |
shimniok | 0:826c6171fc1b | 111 | return (uint8_t)(msg->payload+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 112 | } |
shimniok | 0:826c6171fc1b | 113 | |
shimniok | 0:826c6171fc1b | 114 | /** |
shimniok | 0:826c6171fc1b | 115 | * @brief Get field batVolt from cpu_load message |
shimniok | 0:826c6171fc1b | 116 | * |
shimniok | 0:826c6171fc1b | 117 | * @return Battery Voltage in millivolts |
shimniok | 0:826c6171fc1b | 118 | */ |
shimniok | 0:826c6171fc1b | 119 | static inline uint16_t mavlink_msg_cpu_load_get_batVolt(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 120 | { |
shimniok | 0:826c6171fc1b | 121 | generic_16bit r; |
shimniok | 0:826c6171fc1b | 122 | r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 123 | r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[1]; |
shimniok | 0:826c6171fc1b | 124 | return (uint16_t)r.s; |
shimniok | 0:826c6171fc1b | 125 | } |
shimniok | 0:826c6171fc1b | 126 | |
shimniok | 0:826c6171fc1b | 127 | /** |
shimniok | 0:826c6171fc1b | 128 | * @brief Decode a cpu_load message into a struct |
shimniok | 0:826c6171fc1b | 129 | * |
shimniok | 0:826c6171fc1b | 130 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 131 | * @param cpu_load C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 132 | */ |
shimniok | 0:826c6171fc1b | 133 | static inline void mavlink_msg_cpu_load_decode(const mavlink_message_t* msg, mavlink_cpu_load_t* cpu_load) |
shimniok | 0:826c6171fc1b | 134 | { |
shimniok | 0:826c6171fc1b | 135 | cpu_load->sensLoad = mavlink_msg_cpu_load_get_sensLoad(msg); |
shimniok | 0:826c6171fc1b | 136 | cpu_load->ctrlLoad = mavlink_msg_cpu_load_get_ctrlLoad(msg); |
shimniok | 0:826c6171fc1b | 137 | cpu_load->batVolt = mavlink_msg_cpu_load_get_batVolt(msg); |
shimniok | 0:826c6171fc1b | 138 | } |