Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
mavlink_msg_statustext.h
00001 // MESSAGE STATUSTEXT PACKING 00002 00003 #define MAVLINK_MSG_ID_STATUSTEXT 254 00004 00005 typedef struct __mavlink_statustext_t 00006 { 00007 uint8_t severity; ///< Severity of status, 0 = info message, 255 = critical fault 00008 int8_t text[50]; ///< Status text message, without null termination character 00009 00010 } mavlink_statustext_t; 00011 00012 #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50 00013 00014 00015 /** 00016 * @brief Pack a statustext message 00017 * @param system_id ID of this system 00018 * @param component_id ID of this component (e.g. 200 for IMU) 00019 * @param msg The MAVLink message to compress the data into 00020 * 00021 * @param severity Severity of status, 0 = info message, 255 = critical fault 00022 * @param text Status text message, without null termination character 00023 * @return length of the message in bytes (excluding serial stream start sign) 00024 */ 00025 static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t severity, const int8_t* text) 00026 { 00027 uint16_t i = 0; 00028 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; 00029 00030 i += put_uint8_t_by_index(severity, i, msg->payload); // Severity of status, 0 = info message, 255 = critical fault 00031 i += put_array_by_index((const int8_t*)text, sizeof(int8_t)*50, i, msg->payload); // Status text message, without null termination character 00032 00033 return mavlink_finalize_message(msg, system_id, component_id, i); 00034 } 00035 00036 /** 00037 * @brief Pack a statustext message 00038 * @param system_id ID of this system 00039 * @param component_id ID of this component (e.g. 200 for IMU) 00040 * @param chan The MAVLink channel this message was sent over 00041 * @param msg The MAVLink message to compress the data into 00042 * @param severity Severity of status, 0 = info message, 255 = critical fault 00043 * @param text Status text message, without null termination character 00044 * @return length of the message in bytes (excluding serial stream start sign) 00045 */ 00046 static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t severity, const int8_t* text) 00047 { 00048 uint16_t i = 0; 00049 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; 00050 00051 i += put_uint8_t_by_index(severity, i, msg->payload); // Severity of status, 0 = info message, 255 = critical fault 00052 i += put_array_by_index((const int8_t*)text, sizeof(int8_t)*50, i, msg->payload); // Status text message, without null termination character 00053 00054 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); 00055 } 00056 00057 /** 00058 * @brief Encode a statustext struct into a message 00059 * 00060 * @param system_id ID of this system 00061 * @param component_id ID of this component (e.g. 200 for IMU) 00062 * @param msg The MAVLink message to compress the data into 00063 * @param statustext C-struct to read the message contents from 00064 */ 00065 static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_statustext_t* statustext) 00066 { 00067 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text); 00068 } 00069 00070 /** 00071 * @brief Send a statustext message 00072 * @param chan MAVLink channel to send the message 00073 * 00074 * @param severity Severity of status, 0 = info message, 255 = critical fault 00075 * @param text Status text message, without null termination character 00076 */ 00077 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS 00078 00079 static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const int8_t* text) 00080 { 00081 mavlink_message_t msg; 00082 mavlink_msg_statustext_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, severity, text); 00083 mavlink_send_uart(chan, &msg); 00084 } 00085 00086 #endif 00087 // MESSAGE STATUSTEXT UNPACKING 00088 00089 /** 00090 * @brief Get field severity from statustext message 00091 * 00092 * @return Severity of status, 0 = info message, 255 = critical fault 00093 */ 00094 static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg) 00095 { 00096 return (uint8_t)(msg->payload)[0]; 00097 } 00098 00099 /** 00100 * @brief Get field text from statustext message 00101 * 00102 * @return Status text message, without null termination character 00103 */ 00104 static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t* msg, int8_t* r_data) 00105 { 00106 00107 memcpy(r_data, msg->payload+sizeof(uint8_t), sizeof(int8_t)*50); 00108 return sizeof(int8_t)*50; 00109 } 00110 00111 /** 00112 * @brief Decode a statustext message into a struct 00113 * 00114 * @param msg The message to decode 00115 * @param statustext C-struct to decode the message contents into 00116 */ 00117 static inline void mavlink_msg_statustext_decode(const mavlink_message_t* msg, mavlink_statustext_t* statustext) 00118 { 00119 statustext->severity = mavlink_msg_statustext_get_severity(msg); 00120 mavlink_msg_statustext_get_text(msg, statustext->text); 00121 }
Generated on Tue Jul 12 2022 14:09:27 by 1.7.2