[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_sys_status.h
blob28a85b53f5736cde88efe0ad01a9ee6eb0110300
1 #pragma once
2 // MESSAGE SYS_STATUS PACKING
4 #define MAVLINK_MSG_ID_SYS_STATUS 1
6 MAVPACKED(
7 typedef struct __mavlink_sys_status_t {
8 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*/
9 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*/
10 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*/
11 uint16_t load; /*< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000*/
12 uint16_t voltage_battery; /*< Battery voltage, in millivolts (1 = 1 millivolt)*/
13 int16_t current_battery; /*< Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current*/
14 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)*/
15 uint16_t errors_comm; /*< Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)*/
16 uint16_t errors_count1; /*< Autopilot-specific errors*/
17 uint16_t errors_count2; /*< Autopilot-specific errors*/
18 uint16_t errors_count3; /*< Autopilot-specific errors*/
19 uint16_t errors_count4; /*< Autopilot-specific errors*/
20 int8_t battery_remaining; /*< Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery*/
21 }) mavlink_sys_status_t;
23 #define MAVLINK_MSG_ID_SYS_STATUS_LEN 31
24 #define MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN 31
25 #define MAVLINK_MSG_ID_1_LEN 31
26 #define MAVLINK_MSG_ID_1_MIN_LEN 31
28 #define MAVLINK_MSG_ID_SYS_STATUS_CRC 124
29 #define MAVLINK_MSG_ID_1_CRC 124
33 #if MAVLINK_COMMAND_24BIT
34 #define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
35 1, \
36 "SYS_STATUS", \
37 13, \
38 { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
39 { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
40 { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
41 { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
42 { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
43 { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
44 { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
45 { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
46 { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
47 { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
48 { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
49 { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
50 { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
51 } \
53 #else
54 #define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
55 "SYS_STATUS", \
56 13, \
57 { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
58 { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
59 { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
60 { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
61 { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
62 { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
63 { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
64 { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
65 { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
66 { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
67 { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
68 { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
69 { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
70 } \
72 #endif
74 /**
75 * @brief Pack a sys_status message
76 * @param system_id ID of this system
77 * @param component_id ID of this component (e.g. 200 for IMU)
78 * @param msg The MAVLink message to compress the data into
80 * @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
81 * @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
82 * @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
83 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
84 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
85 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
86 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
87 * @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)
88 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
89 * @param errors_count1 Autopilot-specific errors
90 * @param errors_count2 Autopilot-specific errors
91 * @param errors_count3 Autopilot-specific errors
92 * @param errors_count4 Autopilot-specific errors
93 * @return length of the message in bytes (excluding serial stream start sign)
95 static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
96 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)
98 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
100 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
101 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
102 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
103 _mav_put_uint16_t(buf, 12, load);
104 _mav_put_uint16_t(buf, 14, voltage_battery);
105 _mav_put_int16_t(buf, 16, current_battery);
106 _mav_put_uint16_t(buf, 18, drop_rate_comm);
107 _mav_put_uint16_t(buf, 20, errors_comm);
108 _mav_put_uint16_t(buf, 22, errors_count1);
109 _mav_put_uint16_t(buf, 24, errors_count2);
110 _mav_put_uint16_t(buf, 26, errors_count3);
111 _mav_put_uint16_t(buf, 28, errors_count4);
112 _mav_put_int8_t(buf, 30, battery_remaining);
114 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
115 #else
116 mavlink_sys_status_t packet;
117 packet.onboard_control_sensors_present = onboard_control_sensors_present;
118 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
119 packet.onboard_control_sensors_health = onboard_control_sensors_health;
120 packet.load = load;
121 packet.voltage_battery = voltage_battery;
122 packet.current_battery = current_battery;
123 packet.drop_rate_comm = drop_rate_comm;
124 packet.errors_comm = errors_comm;
125 packet.errors_count1 = errors_count1;
126 packet.errors_count2 = errors_count2;
127 packet.errors_count3 = errors_count3;
128 packet.errors_count4 = errors_count4;
129 packet.battery_remaining = battery_remaining;
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
132 #endif
134 msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
135 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);
139 * @brief Pack a sys_status message on a channel
140 * @param system_id ID of this system
141 * @param component_id ID of this component (e.g. 200 for IMU)
142 * @param chan The MAVLink channel this message will be sent over
143 * @param msg The MAVLink message to compress the data into
144 * @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
145 * @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
146 * @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
147 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
148 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
149 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
150 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
151 * @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)
152 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
153 * @param errors_count1 Autopilot-specific errors
154 * @param errors_count2 Autopilot-specific errors
155 * @param errors_count3 Autopilot-specific errors
156 * @param errors_count4 Autopilot-specific errors
157 * @return length of the message in bytes (excluding serial stream start sign)
159 static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
160 mavlink_message_t* msg,
161 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)
163 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
164 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
165 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
166 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
167 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
168 _mav_put_uint16_t(buf, 12, load);
169 _mav_put_uint16_t(buf, 14, voltage_battery);
170 _mav_put_int16_t(buf, 16, current_battery);
171 _mav_put_uint16_t(buf, 18, drop_rate_comm);
172 _mav_put_uint16_t(buf, 20, errors_comm);
173 _mav_put_uint16_t(buf, 22, errors_count1);
174 _mav_put_uint16_t(buf, 24, errors_count2);
175 _mav_put_uint16_t(buf, 26, errors_count3);
176 _mav_put_uint16_t(buf, 28, errors_count4);
177 _mav_put_int8_t(buf, 30, battery_remaining);
179 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
180 #else
181 mavlink_sys_status_t packet;
182 packet.onboard_control_sensors_present = onboard_control_sensors_present;
183 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
184 packet.onboard_control_sensors_health = onboard_control_sensors_health;
185 packet.load = load;
186 packet.voltage_battery = voltage_battery;
187 packet.current_battery = current_battery;
188 packet.drop_rate_comm = drop_rate_comm;
189 packet.errors_comm = errors_comm;
190 packet.errors_count1 = errors_count1;
191 packet.errors_count2 = errors_count2;
192 packet.errors_count3 = errors_count3;
193 packet.errors_count4 = errors_count4;
194 packet.battery_remaining = battery_remaining;
196 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
197 #endif
199 msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
200 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);
204 * @brief Encode a sys_status struct
206 * @param system_id ID of this system
207 * @param component_id ID of this component (e.g. 200 for IMU)
208 * @param msg The MAVLink message to compress the data into
209 * @param sys_status C-struct to read the message contents from
211 static 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)
213 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);
217 * @brief Encode a sys_status struct on a channel
219 * @param system_id ID of this system
220 * @param component_id ID of this component (e.g. 200 for IMU)
221 * @param chan The MAVLink channel this message will be sent over
222 * @param msg The MAVLink message to compress the data into
223 * @param sys_status C-struct to read the message contents from
225 static 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)
227 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);
231 * @brief Send a sys_status message
232 * @param chan MAVLink channel to send the message
234 * @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
235 * @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
236 * @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
237 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
238 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
239 * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
240 * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
241 * @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)
242 * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
243 * @param errors_count1 Autopilot-specific errors
244 * @param errors_count2 Autopilot-specific errors
245 * @param errors_count3 Autopilot-specific errors
246 * @param errors_count4 Autopilot-specific errors
248 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
250 static 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)
252 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
253 char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
254 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
255 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
256 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
257 _mav_put_uint16_t(buf, 12, load);
258 _mav_put_uint16_t(buf, 14, voltage_battery);
259 _mav_put_int16_t(buf, 16, current_battery);
260 _mav_put_uint16_t(buf, 18, drop_rate_comm);
261 _mav_put_uint16_t(buf, 20, errors_comm);
262 _mav_put_uint16_t(buf, 22, errors_count1);
263 _mav_put_uint16_t(buf, 24, errors_count2);
264 _mav_put_uint16_t(buf, 26, errors_count3);
265 _mav_put_uint16_t(buf, 28, errors_count4);
266 _mav_put_int8_t(buf, 30, battery_remaining);
268 _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);
269 #else
270 mavlink_sys_status_t packet;
271 packet.onboard_control_sensors_present = onboard_control_sensors_present;
272 packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
273 packet.onboard_control_sensors_health = onboard_control_sensors_health;
274 packet.load = load;
275 packet.voltage_battery = voltage_battery;
276 packet.current_battery = current_battery;
277 packet.drop_rate_comm = drop_rate_comm;
278 packet.errors_comm = errors_comm;
279 packet.errors_count1 = errors_count1;
280 packet.errors_count2 = errors_count2;
281 packet.errors_count3 = errors_count3;
282 packet.errors_count4 = errors_count4;
283 packet.battery_remaining = battery_remaining;
285 _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);
286 #endif
290 * @brief Send a sys_status message
291 * @param chan MAVLink channel to send the message
292 * @param struct The MAVLink struct to serialize
294 static inline void mavlink_msg_sys_status_send_struct(mavlink_channel_t chan, const mavlink_sys_status_t* sys_status)
296 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
297 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);
298 #else
299 _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);
300 #endif
303 #if MAVLINK_MSG_ID_SYS_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
305 This varient of _send() can be used to save stack space by re-using
306 memory from the receive buffer. The caller provides a
307 mavlink_message_t which is the size of a full mavlink message. This
308 is usually the receive buffer for the channel, and allows a reply to an
309 incoming message with minimum stack space usage.
311 static 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)
313 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
314 char *buf = (char *)msgbuf;
315 _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
316 _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
317 _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
318 _mav_put_uint16_t(buf, 12, load);
319 _mav_put_uint16_t(buf, 14, voltage_battery);
320 _mav_put_int16_t(buf, 16, current_battery);
321 _mav_put_uint16_t(buf, 18, drop_rate_comm);
322 _mav_put_uint16_t(buf, 20, errors_comm);
323 _mav_put_uint16_t(buf, 22, errors_count1);
324 _mav_put_uint16_t(buf, 24, errors_count2);
325 _mav_put_uint16_t(buf, 26, errors_count3);
326 _mav_put_uint16_t(buf, 28, errors_count4);
327 _mav_put_int8_t(buf, 30, battery_remaining);
329 _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);
330 #else
331 mavlink_sys_status_t *packet = (mavlink_sys_status_t *)msgbuf;
332 packet->onboard_control_sensors_present = onboard_control_sensors_present;
333 packet->onboard_control_sensors_enabled = onboard_control_sensors_enabled;
334 packet->onboard_control_sensors_health = onboard_control_sensors_health;
335 packet->load = load;
336 packet->voltage_battery = voltage_battery;
337 packet->current_battery = current_battery;
338 packet->drop_rate_comm = drop_rate_comm;
339 packet->errors_comm = errors_comm;
340 packet->errors_count1 = errors_count1;
341 packet->errors_count2 = errors_count2;
342 packet->errors_count3 = errors_count3;
343 packet->errors_count4 = errors_count4;
344 packet->battery_remaining = battery_remaining;
346 _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);
347 #endif
349 #endif
351 #endif
353 // MESSAGE SYS_STATUS UNPACKING
357 * @brief Get field onboard_control_sensors_present from sys_status message
359 * @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
361 static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_present(const mavlink_message_t* msg)
363 return _MAV_RETURN_uint32_t(msg, 0);
367 * @brief Get field onboard_control_sensors_enabled from sys_status message
369 * @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
371 static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_enabled(const mavlink_message_t* msg)
373 return _MAV_RETURN_uint32_t(msg, 4);
377 * @brief Get field onboard_control_sensors_health from sys_status message
379 * @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
381 static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_health(const mavlink_message_t* msg)
383 return _MAV_RETURN_uint32_t(msg, 8);
387 * @brief Get field load from sys_status message
389 * @return Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
391 static inline uint16_t mavlink_msg_sys_status_get_load(const mavlink_message_t* msg)
393 return _MAV_RETURN_uint16_t(msg, 12);
397 * @brief Get field voltage_battery from sys_status message
399 * @return Battery voltage, in millivolts (1 = 1 millivolt)
401 static inline uint16_t mavlink_msg_sys_status_get_voltage_battery(const mavlink_message_t* msg)
403 return _MAV_RETURN_uint16_t(msg, 14);
407 * @brief Get field current_battery from sys_status message
409 * @return Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
411 static inline int16_t mavlink_msg_sys_status_get_current_battery(const mavlink_message_t* msg)
413 return _MAV_RETURN_int16_t(msg, 16);
417 * @brief Get field battery_remaining from sys_status message
419 * @return Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery
421 static inline int8_t mavlink_msg_sys_status_get_battery_remaining(const mavlink_message_t* msg)
423 return _MAV_RETURN_int8_t(msg, 30);
427 * @brief Get field drop_rate_comm from sys_status message
429 * @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)
431 static inline uint16_t mavlink_msg_sys_status_get_drop_rate_comm(const mavlink_message_t* msg)
433 return _MAV_RETURN_uint16_t(msg, 18);
437 * @brief Get field errors_comm from sys_status message
439 * @return Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
441 static inline uint16_t mavlink_msg_sys_status_get_errors_comm(const mavlink_message_t* msg)
443 return _MAV_RETURN_uint16_t(msg, 20);
447 * @brief Get field errors_count1 from sys_status message
449 * @return Autopilot-specific errors
451 static inline uint16_t mavlink_msg_sys_status_get_errors_count1(const mavlink_message_t* msg)
453 return _MAV_RETURN_uint16_t(msg, 22);
457 * @brief Get field errors_count2 from sys_status message
459 * @return Autopilot-specific errors
461 static inline uint16_t mavlink_msg_sys_status_get_errors_count2(const mavlink_message_t* msg)
463 return _MAV_RETURN_uint16_t(msg, 24);
467 * @brief Get field errors_count3 from sys_status message
469 * @return Autopilot-specific errors
471 static inline uint16_t mavlink_msg_sys_status_get_errors_count3(const mavlink_message_t* msg)
473 return _MAV_RETURN_uint16_t(msg, 26);
477 * @brief Get field errors_count4 from sys_status message
479 * @return Autopilot-specific errors
481 static inline uint16_t mavlink_msg_sys_status_get_errors_count4(const mavlink_message_t* msg)
483 return _MAV_RETURN_uint16_t(msg, 28);
487 * @brief Decode a sys_status message into a struct
489 * @param msg The message to decode
490 * @param sys_status C-struct to decode the message contents into
492 static inline void mavlink_msg_sys_status_decode(const mavlink_message_t* msg, mavlink_sys_status_t* sys_status)
494 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
495 sys_status->onboard_control_sensors_present = mavlink_msg_sys_status_get_onboard_control_sensors_present(msg);
496 sys_status->onboard_control_sensors_enabled = mavlink_msg_sys_status_get_onboard_control_sensors_enabled(msg);
497 sys_status->onboard_control_sensors_health = mavlink_msg_sys_status_get_onboard_control_sensors_health(msg);
498 sys_status->load = mavlink_msg_sys_status_get_load(msg);
499 sys_status->voltage_battery = mavlink_msg_sys_status_get_voltage_battery(msg);
500 sys_status->current_battery = mavlink_msg_sys_status_get_current_battery(msg);
501 sys_status->drop_rate_comm = mavlink_msg_sys_status_get_drop_rate_comm(msg);
502 sys_status->errors_comm = mavlink_msg_sys_status_get_errors_comm(msg);
503 sys_status->errors_count1 = mavlink_msg_sys_status_get_errors_count1(msg);
504 sys_status->errors_count2 = mavlink_msg_sys_status_get_errors_count2(msg);
505 sys_status->errors_count3 = mavlink_msg_sys_status_get_errors_count3(msg);
506 sys_status->errors_count4 = mavlink_msg_sys_status_get_errors_count4(msg);
507 sys_status->battery_remaining = mavlink_msg_sys_status_get_battery_remaining(msg);
508 #else
509 uint8_t len = msg->len < MAVLINK_MSG_ID_SYS_STATUS_LEN? msg->len : MAVLINK_MSG_ID_SYS_STATUS_LEN;
510 memset(sys_status, 0, MAVLINK_MSG_ID_SYS_STATUS_LEN);
511 memcpy(sys_status, _MAV_PAYLOAD(msg), len);
512 #endif