source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_sys_status.h@ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 28.4 KB
Line 
1// MESSAGE SYS_STATUS PACKING
2
3#define MAVLINK_MSG_ID_SYS_STATUS 1
4
5typedef struct MAVLINK_PACKED __mavlink_sys_status_t
6{
7 uint32_t onboard_control_sensors_present; /*< Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices defined by ENUM MAV_SYS_STATUS_SENSOR*/
8 uint32_t onboard_control_sensors_enabled; /*< Bitmask showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR*/
9 uint32_t onboard_control_sensors_health; /*< Bitmask showing which onboard controllers and sensors are operational or have an error: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR*/
10 uint16_t load; /*< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000*/
11 uint16_t voltage_battery; /*< Battery voltage, in millivolts (1 = 1 millivolt)*/
12 int16_t current_battery; /*< Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current*/
13 uint16_t drop_rate_comm; /*< Communication drops in percent, (0%: 0, 100%: 10'000), (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)*/
14 uint16_t errors_comm; /*< Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)*/
15 uint16_t errors_count1; /*< Autopilot-specific errors*/
16 uint16_t errors_count2; /*< Autopilot-specific errors*/
17 uint16_t errors_count3; /*< Autopilot-specific errors*/
18 uint16_t errors_count4; /*< Autopilot-specific errors*/
19 int8_t battery_remaining; /*< Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery*/
20} mavlink_sys_status_t;
21
22#define MAVLINK_MSG_ID_SYS_STATUS_LEN 31
23#define MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN 31
24#define MAVLINK_MSG_ID_1_LEN 31
25#define MAVLINK_MSG_ID_1_MIN_LEN 31
26
27#define MAVLINK_MSG_ID_SYS_STATUS_CRC 124
28#define MAVLINK_MSG_ID_1_CRC 124
29
30
31
32#if MAVLINK_COMMAND_24BIT
33#define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
34 1, \
35 "SYS_STATUS", \
36 13, \
37 { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
38 { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
39 { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
40 { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
41 { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
42 { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
43 { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
44 { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
45 { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
46 { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
47 { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
48 { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
49 { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
50 } \
51}
52#else
53#define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
54 "SYS_STATUS", \
55 13, \
56 { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
57 { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
58 { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
59 { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
60 { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
61 { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
62 { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
63 { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
64 { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
65 { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
66 { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
67 { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
68 { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
69 } \
70}
71#endif
72
73/**
74 * @brief Pack a sys_status message
75 * @param system_id ID of this system
76 * @param component_id ID of this component (e.g. 200 for IMU)
77 * @param msg The MAVLink message to compress the data into
78 *
79 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
80 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
81 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
82 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
83 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
84 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
85 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
86 * @param drop_rate_comm Communication drops in percent, (0%: 0, 100%: 10'000), (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
87 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
88 * @param errors_count1 Autopilot-specific errors
89 * @param errors_count2 Autopilot-specific errors
90 * @param errors_count3 Autopilot-specific errors
91 * @param errors_count4 Autopilot-specific errors
92 * @return length of the message in bytes (excluding serial stream start sign)
93 */
94static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
95 uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
96{
97#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
98 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
99 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
100 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
101 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
102 _mav_put_uint16_t(buf, 12, load);
103 _mav_put_uint16_t(buf, 14, voltage_battery);
104 _mav_put_int16_t(buf, 16, current_battery);
105 _mav_put_uint16_t(buf, 18, drop_rate_comm);
106 _mav_put_uint16_t(buf, 20, errors_comm);
107 _mav_put_uint16_t(buf, 22, errors_count1);
108 _mav_put_uint16_t(buf, 24, errors_count2);
109 _mav_put_uint16_t(buf, 26, errors_count3);
110 _mav_put_uint16_t(buf, 28, errors_count4);
111 _mav_put_int8_t(buf, 30, battery_remaining);
112
113 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
114#else
115 mavlink_sys_status_t packet;
116 packet.onboard_control_sensors_present = onboard_control_sensors_present;
117 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
118 packet.onboard_control_sensors_health = onboard_control_sensors_health;
119 packet.load = load;
120 packet.voltage_battery = voltage_battery;
121 packet.current_battery = current_battery;
122 packet.drop_rate_comm = drop_rate_comm;
123 packet.errors_comm = errors_comm;
124 packet.errors_count1 = errors_count1;
125 packet.errors_count2 = errors_count2;
126 packet.errors_count3 = errors_count3;
127 packet.errors_count4 = errors_count4;
128 packet.battery_remaining = battery_remaining;
129
130 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
131#endif
132
133 msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
134 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
135}
136
137/**
138 * @brief Pack a sys_status message on a channel
139 * @param system_id ID of this system
140 * @param component_id ID of this component (e.g. 200 for IMU)
141 * @param chan The MAVLink channel this message will be sent over
142 * @param msg The MAVLink message to compress the data into
143 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
144 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
145 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
146 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
147 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
148 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
149 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
150 * @param drop_rate_comm Communication drops in percent, (0%: 0, 100%: 10'000), (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
151 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
152 * @param errors_count1 Autopilot-specific errors
153 * @param errors_count2 Autopilot-specific errors
154 * @param errors_count3 Autopilot-specific errors
155 * @param errors_count4 Autopilot-specific errors
156 * @return length of the message in bytes (excluding serial stream start sign)
157 */
158static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
159 mavlink_message_t* msg,
160 uint32_t onboard_control_sensors_present,uint32_t onboard_control_sensors_enabled,uint32_t onboard_control_sensors_health,uint16_t load,uint16_t voltage_battery,int16_t current_battery,int8_t battery_remaining,uint16_t drop_rate_comm,uint16_t errors_comm,uint16_t errors_count1,uint16_t errors_count2,uint16_t errors_count3,uint16_t errors_count4)
161{
162#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
163 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
164 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
165 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
166 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
167 _mav_put_uint16_t(buf, 12, load);
168 _mav_put_uint16_t(buf, 14, voltage_battery);
169 _mav_put_int16_t(buf, 16, current_battery);
170 _mav_put_uint16_t(buf, 18, drop_rate_comm);
171 _mav_put_uint16_t(buf, 20, errors_comm);
172 _mav_put_uint16_t(buf, 22, errors_count1);
173 _mav_put_uint16_t(buf, 24, errors_count2);
174 _mav_put_uint16_t(buf, 26, errors_count3);
175 _mav_put_uint16_t(buf, 28, errors_count4);
176 _mav_put_int8_t(buf, 30, battery_remaining);
177
178 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
179#else
180 mavlink_sys_status_t packet;
181 packet.onboard_control_sensors_present = onboard_control_sensors_present;
182 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
183 packet.onboard_control_sensors_health = onboard_control_sensors_health;
184 packet.load = load;
185 packet.voltage_battery = voltage_battery;
186 packet.current_battery = current_battery;
187 packet.drop_rate_comm = drop_rate_comm;
188 packet.errors_comm = errors_comm;
189 packet.errors_count1 = errors_count1;
190 packet.errors_count2 = errors_count2;
191 packet.errors_count3 = errors_count3;
192 packet.errors_count4 = errors_count4;
193 packet.battery_remaining = battery_remaining;
194
195 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
196#endif
197
198 msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
199 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
200}
201
202/**
203 * @brief Encode a sys_status struct
204 *
205 * @param system_id ID of this system
206 * @param component_id ID of this component (e.g. 200 for IMU)
207 * @param msg The MAVLink message to compress the data into
208 * @param sys_status C-struct to read the message contents from
209 */
210static inline uint16_t mavlink_msg_sys_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sys_status_t* sys_status)
211{
212 return mavlink_msg_sys_status_pack(system_id, component_id, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
213}
214
215/**
216 * @brief Encode a sys_status struct on a channel
217 *
218 * @param system_id ID of this system
219 * @param component_id ID of this component (e.g. 200 for IMU)
220 * @param chan The MAVLink channel this message will be sent over
221 * @param msg The MAVLink message to compress the data into
222 * @param sys_status C-struct to read the message contents from
223 */
224static inline uint16_t mavlink_msg_sys_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sys_status_t* sys_status)
225{
226 return mavlink_msg_sys_status_pack_chan(system_id, component_id, chan, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
227}
228
229/**
230 * @brief Send a sys_status message
231 * @param chan MAVLink channel to send the message
232 *
233 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
234 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
235 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
236 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
237 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
238 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
239 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
240 * @param drop_rate_comm Communication drops in percent, (0%: 0, 100%: 10'000), (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
241 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
242 * @param errors_count1 Autopilot-specific errors
243 * @param errors_count2 Autopilot-specific errors
244 * @param errors_count3 Autopilot-specific errors
245 * @param errors_count4 Autopilot-specific errors
246 */
247#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
248
249static inline void mavlink_msg_sys_status_send(mavlink_channel_t chan, uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
250{
251#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
252 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
253 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
254 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
255 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
256 _mav_put_uint16_t(buf, 12, load);
257 _mav_put_uint16_t(buf, 14, voltage_battery);
258 _mav_put_int16_t(buf, 16, current_battery);
259 _mav_put_uint16_t(buf, 18, drop_rate_comm);
260 _mav_put_uint16_t(buf, 20, errors_comm);
261 _mav_put_uint16_t(buf, 22, errors_count1);
262 _mav_put_uint16_t(buf, 24, errors_count2);
263 _mav_put_uint16_t(buf, 26, errors_count3);
264 _mav_put_uint16_t(buf, 28, errors_count4);
265 _mav_put_int8_t(buf, 30, battery_remaining);
266
267 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, buf, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
268#else
269 mavlink_sys_status_t packet;
270 packet.onboard_control_sensors_present = onboard_control_sensors_present;
271 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
272 packet.onboard_control_sensors_health = onboard_control_sensors_health;
273 packet.load = load;
274 packet.voltage_battery = voltage_battery;
275 packet.current_battery = current_battery;
276 packet.drop_rate_comm = drop_rate_comm;
277 packet.errors_comm = errors_comm;
278 packet.errors_count1 = errors_count1;
279 packet.errors_count2 = errors_count2;
280 packet.errors_count3 = errors_count3;
281 packet.errors_count4 = errors_count4;
282 packet.battery_remaining = battery_remaining;
283
284 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)&packet, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
285#endif
286}
287
288/**
289 * @brief Send a sys_status message
290 * @param chan MAVLink channel to send the message
291 * @param struct The MAVLink struct to serialize
292 */
293static inline void mavlink_msg_sys_status_send_struct(mavlink_channel_t chan, const mavlink_sys_status_t* sys_status)
294{
295#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
296 mavlink_msg_sys_status_send(chan, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
297#else
298 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)sys_status, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
299#endif
300}
301
302#if MAVLINK_MSG_ID_SYS_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
303/*
304 This varient of _send() can be used to save stack space by re-using
305 memory from the receive buffer. The caller provides a
306 mavlink_message_t which is the size of a full mavlink message. This
307 is usually the receive buffer for the channel, and allows a reply to an
308 incoming message with minimum stack space usage.
309 */
310static inline void mavlink_msg_sys_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
311{
312#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
313 char *buf = (char *)msgbuf;
314 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
315 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
316 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
317 _mav_put_uint16_t(buf, 12, load);
318 _mav_put_uint16_t(buf, 14, voltage_battery);
319 _mav_put_int16_t(buf, 16, current_battery);
320 _mav_put_uint16_t(buf, 18, drop_rate_comm);
321 _mav_put_uint16_t(buf, 20, errors_comm);
322 _mav_put_uint16_t(buf, 22, errors_count1);
323 _mav_put_uint16_t(buf, 24, errors_count2);
324 _mav_put_uint16_t(buf, 26, errors_count3);
325 _mav_put_uint16_t(buf, 28, errors_count4);
326 _mav_put_int8_t(buf, 30, battery_remaining);
327
328 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, buf, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
329#else
330 mavlink_sys_status_t *packet = (mavlink_sys_status_t *)msgbuf;
331 packet->onboard_control_sensors_present = onboard_control_sensors_present;
332 packet->onboard_control_sensors_enabled = onboard_control_sensors_enabled;
333 packet->onboard_control_sensors_health = onboard_control_sensors_health;
334 packet->load = load;
335 packet->voltage_battery = voltage_battery;
336 packet->current_battery = current_battery;
337 packet->drop_rate_comm = drop_rate_comm;
338 packet->errors_comm = errors_comm;
339 packet->errors_count1 = errors_count1;
340 packet->errors_count2 = errors_count2;
341 packet->errors_count3 = errors_count3;
342 packet->errors_count4 = errors_count4;
343 packet->battery_remaining = battery_remaining;
344
345 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)packet, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
346#endif
347}
348#endif
349
350#endif
351
352// MESSAGE SYS_STATUS UNPACKING
353
354
355/**
356 * @brief Get field onboard_control_sensors_present from sys_status message
357 *
358 * @return Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
359 */
360static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_present(const mavlink_message_t* msg)
361{
362 return _MAV_RETURN_uint32_t(msg, 0);
363}
364
365/**
366 * @brief Get field onboard_control_sensors_enabled from sys_status message
367 *
368 * @return Bitmask showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
369 */
370static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_enabled(const mavlink_message_t* msg)
371{
372 return _MAV_RETURN_uint32_t(msg, 4);
373}
374
375/**
376 * @brief Get field onboard_control_sensors_health from sys_status message
377 *
378 * @return Bitmask showing which onboard controllers and sensors are operational or have an error: Value of 0: not enabled. Value of 1: enabled. Indices defined by ENUM MAV_SYS_STATUS_SENSOR
379 */
380static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_health(const mavlink_message_t* msg)
381{
382 return _MAV_RETURN_uint32_t(msg, 8);
383}
384
385/**
386 * @brief Get field load from sys_status message
387 *
388 * @return Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
389 */
390static inline uint16_t mavlink_msg_sys_status_get_load(const mavlink_message_t* msg)
391{
392 return _MAV_RETURN_uint16_t(msg, 12);
393}
394
395/**
396 * @brief Get field voltage_battery from sys_status message
397 *
398 * @return Battery voltage, in millivolts (1 = 1 millivolt)
399 */
400static inline uint16_t mavlink_msg_sys_status_get_voltage_battery(const mavlink_message_t* msg)
401{
402 return _MAV_RETURN_uint16_t(msg, 14);
403}
404
405/**
406 * @brief Get field current_battery from sys_status message
407 *
408 * @return Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
409 */
410static inline int16_t mavlink_msg_sys_status_get_current_battery(const mavlink_message_t* msg)
411{
412 return _MAV_RETURN_int16_t(msg, 16);
413}
414
415/**
416 * @brief Get field battery_remaining from sys_status message
417 *
418 * @return Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
419 */
420static inline int8_t mavlink_msg_sys_status_get_battery_remaining(const mavlink_message_t* msg)
421{
422 return _MAV_RETURN_int8_t(msg, 30);
423}
424
425/**
426 * @brief Get field drop_rate_comm from sys_status message
427 *
428 * @return Communication drops in percent, (0%: 0, 100%: 10'000), (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
429 */
430static inline uint16_t mavlink_msg_sys_status_get_drop_rate_comm(const mavlink_message_t* msg)
431{
432 return _MAV_RETURN_uint16_t(msg, 18);
433}
434
435/**
436 * @brief Get field errors_comm from sys_status message
437 *
438 * @return Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
439 */
440static inline uint16_t mavlink_msg_sys_status_get_errors_comm(const mavlink_message_t* msg)
441{
442 return _MAV_RETURN_uint16_t(msg, 20);
443}
444
445/**
446 * @brief Get field errors_count1 from sys_status message
447 *
448 * @return Autopilot-specific errors
449 */
450static inline uint16_t mavlink_msg_sys_status_get_errors_count1(const mavlink_message_t* msg)
451{
452 return _MAV_RETURN_uint16_t(msg, 22);
453}
454
455/**
456 * @brief Get field errors_count2 from sys_status message
457 *
458 * @return Autopilot-specific errors
459 */
460static inline uint16_t mavlink_msg_sys_status_get_errors_count2(const mavlink_message_t* msg)
461{
462 return _MAV_RETURN_uint16_t(msg, 24);
463}
464
465/**
466 * @brief Get field errors_count3 from sys_status message
467 *
468 * @return Autopilot-specific errors
469 */
470static inline uint16_t mavlink_msg_sys_status_get_errors_count3(const mavlink_message_t* msg)
471{
472 return _MAV_RETURN_uint16_t(msg, 26);
473}
474
475/**
476 * @brief Get field errors_count4 from sys_status message
477 *
478 * @return Autopilot-specific errors
479 */
480static inline uint16_t mavlink_msg_sys_status_get_errors_count4(const mavlink_message_t* msg)
481{
482 return _MAV_RETURN_uint16_t(msg, 28);
483}
484
485/**
486 * @brief Decode a sys_status message into a struct
487 *
488 * @param msg The message to decode
489 * @param sys_status C-struct to decode the message contents into
490 */
491static inline void mavlink_msg_sys_status_decode(const mavlink_message_t* msg, mavlink_sys_status_t* sys_status)
492{
493#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
494 sys_status->onboard_control_sensors_present = mavlink_msg_sys_status_get_onboard_control_sensors_present(msg);
495 sys_status->onboard_control_sensors_enabled = mavlink_msg_sys_status_get_onboard_control_sensors_enabled(msg);
496 sys_status->onboard_control_sensors_health = mavlink_msg_sys_status_get_onboard_control_sensors_health(msg);
497 sys_status->load = mavlink_msg_sys_status_get_load(msg);
498 sys_status->voltage_battery = mavlink_msg_sys_status_get_voltage_battery(msg);
499 sys_status->current_battery = mavlink_msg_sys_status_get_current_battery(msg);
500 sys_status->drop_rate_comm = mavlink_msg_sys_status_get_drop_rate_comm(msg);
501 sys_status->errors_comm = mavlink_msg_sys_status_get_errors_comm(msg);
502 sys_status->errors_count1 = mavlink_msg_sys_status_get_errors_count1(msg);
503 sys_status->errors_count2 = mavlink_msg_sys_status_get_errors_count2(msg);
504 sys_status->errors_count3 = mavlink_msg_sys_status_get_errors_count3(msg);
505 sys_status->errors_count4 = mavlink_msg_sys_status_get_errors_count4(msg);
506 sys_status->battery_remaining = mavlink_msg_sys_status_get_battery_remaining(msg);
507#else
508 uint8_t len = msg->len < MAVLINK_MSG_ID_SYS_STATUS_LEN? msg->len : MAVLINK_MSG_ID_SYS_STATUS_LEN;
509 memset(sys_status, 0, MAVLINK_MSG_ID_SYS_STATUS_LEN);
510 memcpy(sys_status, _MAV_PAYLOAD(msg), len);
511#endif
512}
Note: See TracBrowser for help on using the repository browser.