Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_statustext.h
blobb75669d35ce0f0c0e7c37979f594ee12c93da9e8
1 // MESSAGE STATUSTEXT PACKING
3 #define MAVLINK_MSG_ID_STATUSTEXT 253
5 typedef struct __mavlink_statustext_t {
6 uint8_t severity; ///< Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
7 char text[50]; ///< Status text message, without null termination character
8 } mavlink_statustext_t;
10 #define MAVLINK_MSG_ID_STATUSTEXT_LEN 51
11 #define MAVLINK_MSG_ID_253_LEN 51
13 #define MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN 50
15 #define MAVLINK_MESSAGE_INFO_STATUSTEXT \
16 { \
17 "STATUSTEXT", \
18 2, \
19 { \
20 { "severity", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_statustext_t, severity) }, \
21 { "text", NULL, MAVLINK_TYPE_CHAR, 50, 1, offsetof(mavlink_statustext_t, text) }, \
22 } \
26 /**
27 * @brief Pack a statustext message
28 * @param system_id ID of this system
29 * @param component_id ID of this component (e.g. 200 for IMU)
30 * @param msg The MAVLink message to compress the data into
32 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
33 * @param text Status text message, without null termination character
34 * @return length of the message in bytes (excluding serial stream start sign)
36 static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
37 uint8_t severity, const char *text)
39 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
40 char buf[51];
41 _mav_put_uint8_t(buf, 0, severity);
42 _mav_put_char_array(buf, 1, text, 50);
43 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 51);
44 #else
45 mavlink_statustext_t packet;
46 packet.severity = severity;
47 mav_array_memcpy(packet.text, text, sizeof(char) * 50);
48 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 51);
49 #endif
51 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
52 return mavlink_finalize_message(msg, system_id, component_id, 51, 83);
55 /**
56 * @brief Pack a statustext message on a channel
57 * @param system_id ID of this system
58 * @param component_id ID of this component (e.g. 200 for IMU)
59 * @param chan The MAVLink channel this message was sent over
60 * @param msg The MAVLink message to compress the data into
61 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
62 * @param text Status text message, without null termination character
63 * @return length of the message in bytes (excluding serial stream start sign)
65 static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
66 mavlink_message_t *msg,
67 uint8_t severity, const char *text)
69 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
70 char buf[51];
71 _mav_put_uint8_t(buf, 0, severity);
72 _mav_put_char_array(buf, 1, text, 50);
73 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 51);
74 #else
75 mavlink_statustext_t packet;
76 packet.severity = severity;
77 mav_array_memcpy(packet.text, text, sizeof(char) * 50);
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 51);
79 #endif
81 msg->msgid = MAVLINK_MSG_ID_STATUSTEXT;
82 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 51, 83);
85 /**
86 * @brief Encode a statustext struct into a message
88 * @param system_id ID of this system
89 * @param component_id ID of this component (e.g. 200 for IMU)
90 * @param msg The MAVLink message to compress the data into
91 * @param statustext C-struct to read the message contents from
93 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)
95 return mavlink_msg_statustext_pack(system_id, component_id, msg, statustext->severity, statustext->text);
98 /**
99 * @brief Send a statustext message
100 * @param chan MAVLink channel to send the message
102 * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
103 * @param text Status text message, without null termination character
105 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
107 static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text)
109 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
110 char buf[51];
111 _mav_put_uint8_t(buf, 0, severity);
112 _mav_put_char_array(buf, 1, text, 50);
113 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, buf, 51, 83);
114 #else
115 mavlink_statustext_t packet;
116 packet.severity = severity;
117 mav_array_memcpy(packet.text, text, sizeof(char) * 50);
118 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUSTEXT, (const char *)&packet, 51, 83);
119 #endif
122 #endif
124 // MESSAGE STATUSTEXT UNPACKING
128 * @brief Get field severity from statustext message
130 * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY.
132 static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t *msg)
134 return _MAV_RETURN_uint8_t(msg, 0);
138 * @brief Get field text from statustext message
140 * @return Status text message, without null termination character
142 static inline uint16_t mavlink_msg_statustext_get_text(const mavlink_message_t *msg, char *text)
144 return _MAV_RETURN_char_array(msg, text, 50, 1);
148 * @brief Decode a statustext message into a struct
150 * @param msg The message to decode
151 * @param statustext C-struct to decode the message contents into
153 static inline void mavlink_msg_statustext_decode(const mavlink_message_t *msg, mavlink_statustext_t *statustext)
155 #if MAVLINK_NEED_BYTE_SWAP
156 statustext->severity = mavlink_msg_statustext_get_severity(msg);
157 mavlink_msg_statustext_get_text(msg, statustext->text);
158 #else
159 memcpy(statustext, _MAV_PAYLOAD(msg), 51);
160 #endif