Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_named_value_int.h
blobb067f7a20a2ad32ebac41d882886cc81120b2b9a
1 // MESSAGE NAMED_VALUE_INT PACKING
3 #define MAVLINK_MSG_ID_NAMED_VALUE_INT 252
5 typedef struct __mavlink_named_value_int_t {
6 uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
7 int32_t value; ///< Signed integer value
8 char name[10]; ///< Name of the debug variable
9 } mavlink_named_value_int_t;
11 #define MAVLINK_MSG_ID_NAMED_VALUE_INT_LEN 18
12 #define MAVLINK_MSG_ID_252_LEN 18
14 #define MAVLINK_MSG_NAMED_VALUE_INT_FIELD_NAME_LEN 10
16 #define MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT \
17 { \
18 "NAMED_VALUE_INT", \
19 3, \
20 { \
21 { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_named_value_int_t, time_boot_ms) }, \
22 { "value", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_named_value_int_t, value) }, \
23 { "name", NULL, MAVLINK_TYPE_CHAR, 10, 8, offsetof(mavlink_named_value_int_t, name) }, \
24 } \
28 /**
29 * @brief Pack a named_value_int message
30 * @param system_id ID of this system
31 * @param component_id ID of this component (e.g. 200 for IMU)
32 * @param msg The MAVLink message to compress the data into
34 * @param time_boot_ms Timestamp (milliseconds since system boot)
35 * @param name Name of the debug variable
36 * @param value Signed integer value
37 * @return length of the message in bytes (excluding serial stream start sign)
39 static inline uint16_t mavlink_msg_named_value_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
40 uint32_t time_boot_ms, const char *name, int32_t value)
42 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
43 char buf[18];
44 _mav_put_uint32_t(buf, 0, time_boot_ms);
45 _mav_put_int32_t(buf, 4, value);
46 _mav_put_char_array(buf, 8, name, 10);
47 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18);
48 #else
49 mavlink_named_value_int_t packet;
50 packet.time_boot_ms = time_boot_ms;
51 packet.value = value;
52 mav_array_memcpy(packet.name, name, sizeof(char) * 10);
53 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18);
54 #endif
56 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT;
57 return mavlink_finalize_message(msg, system_id, component_id, 18, 44);
60 /**
61 * @brief Pack a named_value_int message on a channel
62 * @param system_id ID of this system
63 * @param component_id ID of this component (e.g. 200 for IMU)
64 * @param chan The MAVLink channel this message was sent over
65 * @param msg The MAVLink message to compress the data into
66 * @param time_boot_ms Timestamp (milliseconds since system boot)
67 * @param name Name of the debug variable
68 * @param value Signed integer value
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_named_value_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
72 mavlink_message_t *msg,
73 uint32_t time_boot_ms, const char *name, int32_t value)
75 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
76 char buf[18];
77 _mav_put_uint32_t(buf, 0, time_boot_ms);
78 _mav_put_int32_t(buf, 4, value);
79 _mav_put_char_array(buf, 8, name, 10);
80 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18);
81 #else
82 mavlink_named_value_int_t packet;
83 packet.time_boot_ms = time_boot_ms;
84 packet.value = value;
85 mav_array_memcpy(packet.name, name, sizeof(char) * 10);
86 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18);
87 #endif
89 msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT;
90 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 18, 44);
93 /**
94 * @brief Encode a named_value_int struct into a message
96 * @param system_id ID of this system
97 * @param component_id ID of this component (e.g. 200 for IMU)
98 * @param msg The MAVLink message to compress the data into
99 * @param named_value_int C-struct to read the message contents from
101 static inline uint16_t mavlink_msg_named_value_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg, const mavlink_named_value_int_t *named_value_int)
103 return mavlink_msg_named_value_int_pack(system_id, component_id, msg, named_value_int->time_boot_ms, named_value_int->name, named_value_int->value);
107 * @brief Send a named_value_int message
108 * @param chan MAVLink channel to send the message
110 * @param time_boot_ms Timestamp (milliseconds since system boot)
111 * @param name Name of the debug variable
112 * @param value Signed integer value
114 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
116 static inline void mavlink_msg_named_value_int_send(mavlink_channel_t chan, uint32_t time_boot_ms, const char *name, int32_t value)
118 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
119 char buf[18];
120 _mav_put_uint32_t(buf, 0, time_boot_ms);
121 _mav_put_int32_t(buf, 4, value);
122 _mav_put_char_array(buf, 8, name, 10);
123 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, buf, 18, 44);
124 #else
125 mavlink_named_value_int_t packet;
126 packet.time_boot_ms = time_boot_ms;
127 packet.value = value;
128 mav_array_memcpy(packet.name, name, sizeof(char) * 10);
129 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_NAMED_VALUE_INT, (const char *)&packet, 18, 44);
130 #endif
133 #endif
135 // MESSAGE NAMED_VALUE_INT UNPACKING
139 * @brief Get field time_boot_ms from named_value_int message
141 * @return Timestamp (milliseconds since system boot)
143 static inline uint32_t mavlink_msg_named_value_int_get_time_boot_ms(const mavlink_message_t *msg)
145 return _MAV_RETURN_uint32_t(msg, 0);
149 * @brief Get field name from named_value_int message
151 * @return Name of the debug variable
153 static inline uint16_t mavlink_msg_named_value_int_get_name(const mavlink_message_t *msg, char *name)
155 return _MAV_RETURN_char_array(msg, name, 10, 8);
159 * @brief Get field value from named_value_int message
161 * @return Signed integer value
163 static inline int32_t mavlink_msg_named_value_int_get_value(const mavlink_message_t *msg)
165 return _MAV_RETURN_int32_t(msg, 4);
169 * @brief Decode a named_value_int message into a struct
171 * @param msg The message to decode
172 * @param named_value_int C-struct to decode the message contents into
174 static inline void mavlink_msg_named_value_int_decode(const mavlink_message_t *msg, mavlink_named_value_int_t *named_value_int)
176 #if MAVLINK_NEED_BYTE_SWAP
177 named_value_int->time_boot_ms = mavlink_msg_named_value_int_get_time_boot_ms(msg);
178 named_value_int->value = mavlink_msg_named_value_int_get_value(msg);
179 mavlink_msg_named_value_int_get_name(msg, named_value_int->name);
180 #else
181 memcpy(named_value_int, _MAV_PAYLOAD(msg), 18);
182 #endif