Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mavlink_msg_scaled_pressure.h Source File

mavlink_msg_scaled_pressure.h

00001 // MESSAGE SCALED_PRESSURE PACKING
00002 
00003 #define MAVLINK_MSG_ID_SCALED_PRESSURE 38
00004 
00005 typedef struct __mavlink_scaled_pressure_t 
00006 {
00007     uint64_t usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00008     float press_abs; ///< Absolute pressure (hectopascal)
00009     float press_diff; ///< Differential pressure 1 (hectopascal)
00010     int16_t temperature; ///< Temperature measurement (0.01 degrees celsius)
00011 
00012 } mavlink_scaled_pressure_t;
00013 
00014 
00015 
00016 /**
00017  * @brief Pack a scaled_pressure message
00018  * @param system_id ID of this system
00019  * @param component_id ID of this component (e.g. 200 for IMU)
00020  * @param msg The MAVLink message to compress the data into
00021  *
00022  * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00023  * @param press_abs Absolute pressure (hectopascal)
00024  * @param press_diff Differential pressure 1 (hectopascal)
00025  * @param temperature Temperature measurement (0.01 degrees celsius)
00026  * @return length of the message in bytes (excluding serial stream start sign)
00027  */
00028 static inline uint16_t mavlink_msg_scaled_pressure_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint64_t usec, float press_abs, float press_diff, int16_t temperature)
00029 {
00030     uint16_t i = 0;
00031     msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE;
00032 
00033     i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00034     i += put_float_by_index(press_abs, i, msg->payload); // Absolute pressure (hectopascal)
00035     i += put_float_by_index(press_diff, i, msg->payload); // Differential pressure 1 (hectopascal)
00036     i += put_int16_t_by_index(temperature, i, msg->payload); // Temperature measurement (0.01 degrees celsius)
00037 
00038     return mavlink_finalize_message(msg, system_id, component_id, i);
00039 }
00040 
00041 /**
00042  * @brief Pack a scaled_pressure message
00043  * @param system_id ID of this system
00044  * @param component_id ID of this component (e.g. 200 for IMU)
00045  * @param chan The MAVLink channel this message was sent over
00046  * @param msg The MAVLink message to compress the data into
00047  * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00048  * @param press_abs Absolute pressure (hectopascal)
00049  * @param press_diff Differential pressure 1 (hectopascal)
00050  * @param temperature Temperature measurement (0.01 degrees celsius)
00051  * @return length of the message in bytes (excluding serial stream start sign)
00052  */
00053 static inline uint16_t mavlink_msg_scaled_pressure_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint64_t usec, float press_abs, float press_diff, int16_t temperature)
00054 {
00055     uint16_t i = 0;
00056     msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE;
00057 
00058     i += put_uint64_t_by_index(usec, i, msg->payload); // Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00059     i += put_float_by_index(press_abs, i, msg->payload); // Absolute pressure (hectopascal)
00060     i += put_float_by_index(press_diff, i, msg->payload); // Differential pressure 1 (hectopascal)
00061     i += put_int16_t_by_index(temperature, i, msg->payload); // Temperature measurement (0.01 degrees celsius)
00062 
00063     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
00064 }
00065 
00066 /**
00067  * @brief Encode a scaled_pressure struct into a message
00068  *
00069  * @param system_id ID of this system
00070  * @param component_id ID of this component (e.g. 200 for IMU)
00071  * @param msg The MAVLink message to compress the data into
00072  * @param scaled_pressure C-struct to read the message contents from
00073  */
00074 static inline uint16_t mavlink_msg_scaled_pressure_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_scaled_pressure_t* scaled_pressure)
00075 {
00076     return mavlink_msg_scaled_pressure_pack(system_id, component_id, msg, scaled_pressure->usec, scaled_pressure->press_abs, scaled_pressure->press_diff, scaled_pressure->temperature);
00077 }
00078 
00079 /**
00080  * @brief Send a scaled_pressure message
00081  * @param chan MAVLink channel to send the message
00082  *
00083  * @param usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00084  * @param press_abs Absolute pressure (hectopascal)
00085  * @param press_diff Differential pressure 1 (hectopascal)
00086  * @param temperature Temperature measurement (0.01 degrees celsius)
00087  */
00088 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00089 
00090 static inline void mavlink_msg_scaled_pressure_send(mavlink_channel_t chan, uint64_t usec, float press_abs, float press_diff, int16_t temperature)
00091 {
00092     mavlink_message_t msg;
00093     mavlink_msg_scaled_pressure_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, usec, press_abs, press_diff, temperature);
00094     mavlink_send_uart(chan, &msg);
00095 }
00096 
00097 #endif
00098 // MESSAGE SCALED_PRESSURE UNPACKING
00099 
00100 /**
00101  * @brief Get field usec from scaled_pressure message
00102  *
00103  * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
00104  */
00105 static inline uint64_t mavlink_msg_scaled_pressure_get_usec(const mavlink_message_t* msg)
00106 {
00107     generic_64bit r;
00108     r.b[7] = (msg->payload)[0];
00109     r.b[6] = (msg->payload)[1];
00110     r.b[5] = (msg->payload)[2];
00111     r.b[4] = (msg->payload)[3];
00112     r.b[3] = (msg->payload)[4];
00113     r.b[2] = (msg->payload)[5];
00114     r.b[1] = (msg->payload)[6];
00115     r.b[0] = (msg->payload)[7];
00116     return (uint64_t)r.ll;
00117 }
00118 
00119 /**
00120  * @brief Get field press_abs from scaled_pressure message
00121  *
00122  * @return Absolute pressure (hectopascal)
00123  */
00124 static inline float mavlink_msg_scaled_pressure_get_press_abs(const mavlink_message_t* msg)
00125 {
00126     generic_32bit r;
00127     r.b[3] = (msg->payload+sizeof(uint64_t))[0];
00128     r.b[2] = (msg->payload+sizeof(uint64_t))[1];
00129     r.b[1] = (msg->payload+sizeof(uint64_t))[2];
00130     r.b[0] = (msg->payload+sizeof(uint64_t))[3];
00131     return (float)r.f;
00132 }
00133 
00134 /**
00135  * @brief Get field press_diff from scaled_pressure message
00136  *
00137  * @return Differential pressure 1 (hectopascal)
00138  */
00139 static inline float mavlink_msg_scaled_pressure_get_press_diff(const mavlink_message_t* msg)
00140 {
00141     generic_32bit r;
00142     r.b[3] = (msg->payload+sizeof(uint64_t)+sizeof(float))[0];
00143     r.b[2] = (msg->payload+sizeof(uint64_t)+sizeof(float))[1];
00144     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float))[2];
00145     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float))[3];
00146     return (float)r.f;
00147 }
00148 
00149 /**
00150  * @brief Get field temperature from scaled_pressure message
00151  *
00152  * @return Temperature measurement (0.01 degrees celsius)
00153  */
00154 static inline int16_t mavlink_msg_scaled_pressure_get_temperature(const mavlink_message_t* msg)
00155 {
00156     generic_16bit r;
00157     r.b[1] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[0];
00158     r.b[0] = (msg->payload+sizeof(uint64_t)+sizeof(float)+sizeof(float))[1];
00159     return (int16_t)r.s;
00160 }
00161 
00162 /**
00163  * @brief Decode a scaled_pressure message into a struct
00164  *
00165  * @param msg The message to decode
00166  * @param scaled_pressure C-struct to decode the message contents into
00167  */
00168 static inline void mavlink_msg_scaled_pressure_decode(const mavlink_message_t* msg, mavlink_scaled_pressure_t* scaled_pressure)
00169 {
00170     scaled_pressure->usec = mavlink_msg_scaled_pressure_get_usec(msg);
00171     scaled_pressure->press_abs = mavlink_msg_scaled_pressure_get_press_abs(msg);
00172     scaled_pressure->press_diff = mavlink_msg_scaled_pressure_get_press_diff(msg);
00173     scaled_pressure->temperature = mavlink_msg_scaled_pressure_get_temperature(msg);
00174 }