1 | // MESSAGE BATTERY_STATUS PACKING
|
---|
2 |
|
---|
3 | #define MAVLINK_MSG_ID_BATTERY_STATUS 147
|
---|
4 |
|
---|
5 | typedef struct MAVLINK_PACKED __mavlink_battery_status_t
|
---|
6 | {
|
---|
7 | int32_t current_consumed; /*< Consumed charge, in milliampere hours (1 = 1 mAh), -1: autopilot does not provide mAh consumption estimate*/
|
---|
8 | int32_t energy_consumed; /*< Consumed energy, in 100*Joules (intergrated U*I*dt) (1 = 100 Joule), -1: autopilot does not provide energy consumption estimate*/
|
---|
9 | int16_t temperature; /*< Temperature of the battery in centi-degrees celsius. INT16_MAX for unknown temperature.*/
|
---|
10 | uint16_t voltages[10]; /*< Battery voltage of cells, in millivolts (1 = 1 millivolt). Cells above the valid cell count for this battery should have the UINT16_MAX value.*/
|
---|
11 | int16_t current_battery; /*< Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current*/
|
---|
12 | uint8_t id; /*< Battery ID*/
|
---|
13 | uint8_t battery_function; /*< Function of the battery*/
|
---|
14 | uint8_t type; /*< Type (chemistry) of the battery*/
|
---|
15 | int8_t battery_remaining; /*< Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery*/
|
---|
16 | } mavlink_battery_status_t;
|
---|
17 |
|
---|
18 | #define MAVLINK_MSG_ID_BATTERY_STATUS_LEN 36
|
---|
19 | #define MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN 36
|
---|
20 | #define MAVLINK_MSG_ID_147_LEN 36
|
---|
21 | #define MAVLINK_MSG_ID_147_MIN_LEN 36
|
---|
22 |
|
---|
23 | #define MAVLINK_MSG_ID_BATTERY_STATUS_CRC 154
|
---|
24 | #define MAVLINK_MSG_ID_147_CRC 154
|
---|
25 |
|
---|
26 | #define MAVLINK_MSG_BATTERY_STATUS_FIELD_VOLTAGES_LEN 10
|
---|
27 |
|
---|
28 | #if MAVLINK_COMMAND_24BIT
|
---|
29 | #define MAVLINK_MESSAGE_INFO_BATTERY_STATUS { \
|
---|
30 | 147, \
|
---|
31 | "BATTERY_STATUS", \
|
---|
32 | 9, \
|
---|
33 | { { "current_consumed", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_battery_status_t, current_consumed) }, \
|
---|
34 | { "energy_consumed", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_battery_status_t, energy_consumed) }, \
|
---|
35 | { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_battery_status_t, temperature) }, \
|
---|
36 | { "voltages", NULL, MAVLINK_TYPE_UINT16_T, 10, 10, offsetof(mavlink_battery_status_t, voltages) }, \
|
---|
37 | { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 30, offsetof(mavlink_battery_status_t, current_battery) }, \
|
---|
38 | { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_battery_status_t, id) }, \
|
---|
39 | { "battery_function", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_battery_status_t, battery_function) }, \
|
---|
40 | { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_battery_status_t, type) }, \
|
---|
41 | { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 35, offsetof(mavlink_battery_status_t, battery_remaining) }, \
|
---|
42 | } \
|
---|
43 | }
|
---|
44 | #else
|
---|
45 | #define MAVLINK_MESSAGE_INFO_BATTERY_STATUS { \
|
---|
46 | "BATTERY_STATUS", \
|
---|
47 | 9, \
|
---|
48 | { { "current_consumed", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_battery_status_t, current_consumed) }, \
|
---|
49 | { "energy_consumed", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_battery_status_t, energy_consumed) }, \
|
---|
50 | { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_battery_status_t, temperature) }, \
|
---|
51 | { "voltages", NULL, MAVLINK_TYPE_UINT16_T, 10, 10, offsetof(mavlink_battery_status_t, voltages) }, \
|
---|
52 | { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 30, offsetof(mavlink_battery_status_t, current_battery) }, \
|
---|
53 | { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_battery_status_t, id) }, \
|
---|
54 | { "battery_function", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_battery_status_t, battery_function) }, \
|
---|
55 | { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_battery_status_t, type) }, \
|
---|
56 | { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 35, offsetof(mavlink_battery_status_t, battery_remaining) }, \
|
---|
57 | } \
|
---|
58 | }
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * @brief Pack a battery_status message
|
---|
63 | * @param system_id ID of this system
|
---|
64 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
65 | * @param msg The MAVLink message to compress the data into
|
---|
66 | *
|
---|
67 | * @param id Battery ID
|
---|
68 | * @param battery_function Function of the battery
|
---|
69 | * @param type Type (chemistry) of the battery
|
---|
70 | * @param temperature Temperature of the battery in centi-degrees celsius. INT16_MAX for unknown temperature.
|
---|
71 | * @param voltages Battery voltage of cells, in millivolts (1 = 1 millivolt). Cells above the valid cell count for this battery should have the UINT16_MAX value.
|
---|
72 | * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
|
---|
73 | * @param current_consumed Consumed charge, in milliampere hours (1 = 1 mAh), -1: autopilot does not provide mAh consumption estimate
|
---|
74 | * @param energy_consumed Consumed energy, in 100*Joules (intergrated U*I*dt) (1 = 100 Joule), -1: autopilot does not provide energy consumption estimate
|
---|
75 | * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery
|
---|
76 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
77 | */
|
---|
78 | static inline uint16_t mavlink_msg_battery_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
|
---|
79 | uint8_t id, uint8_t battery_function, uint8_t type, int16_t temperature, const uint16_t *voltages, int16_t current_battery, int32_t current_consumed, int32_t energy_consumed, int8_t battery_remaining)
|
---|
80 | {
|
---|
81 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
82 | char buf[MAVLINK_MSG_ID_BATTERY_STATUS_LEN];
|
---|
83 | _mav_put_int32_t(buf, 0, current_consumed);
|
---|
84 | _mav_put_int32_t(buf, 4, energy_consumed);
|
---|
85 | _mav_put_int16_t(buf, 8, temperature);
|
---|
86 | _mav_put_int16_t(buf, 30, current_battery);
|
---|
87 | _mav_put_uint8_t(buf, 32, id);
|
---|
88 | _mav_put_uint8_t(buf, 33, battery_function);
|
---|
89 | _mav_put_uint8_t(buf, 34, type);
|
---|
90 | _mav_put_int8_t(buf, 35, battery_remaining);
|
---|
91 | _mav_put_uint16_t_array(buf, 10, voltages, 10);
|
---|
92 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY_STATUS_LEN);
|
---|
93 | #else
|
---|
94 | mavlink_battery_status_t packet;
|
---|
95 | packet.current_consumed = current_consumed;
|
---|
96 | packet.energy_consumed = energy_consumed;
|
---|
97 | packet.temperature = temperature;
|
---|
98 | packet.current_battery = current_battery;
|
---|
99 | packet.id = id;
|
---|
100 | packet.battery_function = battery_function;
|
---|
101 | packet.type = type;
|
---|
102 | packet.battery_remaining = battery_remaining;
|
---|
103 | mav_array_memcpy(packet.voltages, voltages, sizeof(uint16_t)*10);
|
---|
104 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY_STATUS_LEN);
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS;
|
---|
108 | return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
109 | }
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * @brief Pack a battery_status message on a channel
|
---|
113 | * @param system_id ID of this system
|
---|
114 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
115 | * @param chan The MAVLink channel this message will be sent over
|
---|
116 | * @param msg The MAVLink message to compress the data into
|
---|
117 | * @param id Battery ID
|
---|
118 | * @param battery_function Function of the battery
|
---|
119 | * @param type Type (chemistry) of the battery
|
---|
120 | * @param temperature Temperature of the battery in centi-degrees celsius. INT16_MAX for unknown temperature.
|
---|
121 | * @param voltages Battery voltage of cells, in millivolts (1 = 1 millivolt). Cells above the valid cell count for this battery should have the UINT16_MAX value.
|
---|
122 | * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
|
---|
123 | * @param current_consumed Consumed charge, in milliampere hours (1 = 1 mAh), -1: autopilot does not provide mAh consumption estimate
|
---|
124 | * @param energy_consumed Consumed energy, in 100*Joules (intergrated U*I*dt) (1 = 100 Joule), -1: autopilot does not provide energy consumption estimate
|
---|
125 | * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery
|
---|
126 | * @return length of the message in bytes (excluding serial stream start sign)
|
---|
127 | */
|
---|
128 | static inline uint16_t mavlink_msg_battery_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
|
---|
129 | mavlink_message_t* msg,
|
---|
130 | uint8_t id,uint8_t battery_function,uint8_t type,int16_t temperature,const uint16_t *voltages,int16_t current_battery,int32_t current_consumed,int32_t energy_consumed,int8_t battery_remaining)
|
---|
131 | {
|
---|
132 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
133 | char buf[MAVLINK_MSG_ID_BATTERY_STATUS_LEN];
|
---|
134 | _mav_put_int32_t(buf, 0, current_consumed);
|
---|
135 | _mav_put_int32_t(buf, 4, energy_consumed);
|
---|
136 | _mav_put_int16_t(buf, 8, temperature);
|
---|
137 | _mav_put_int16_t(buf, 30, current_battery);
|
---|
138 | _mav_put_uint8_t(buf, 32, id);
|
---|
139 | _mav_put_uint8_t(buf, 33, battery_function);
|
---|
140 | _mav_put_uint8_t(buf, 34, type);
|
---|
141 | _mav_put_int8_t(buf, 35, battery_remaining);
|
---|
142 | _mav_put_uint16_t_array(buf, 10, voltages, 10);
|
---|
143 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BATTERY_STATUS_LEN);
|
---|
144 | #else
|
---|
145 | mavlink_battery_status_t packet;
|
---|
146 | packet.current_consumed = current_consumed;
|
---|
147 | packet.energy_consumed = energy_consumed;
|
---|
148 | packet.temperature = temperature;
|
---|
149 | packet.current_battery = current_battery;
|
---|
150 | packet.id = id;
|
---|
151 | packet.battery_function = battery_function;
|
---|
152 | packet.type = type;
|
---|
153 | packet.battery_remaining = battery_remaining;
|
---|
154 | mav_array_memcpy(packet.voltages, voltages, sizeof(uint16_t)*10);
|
---|
155 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BATTERY_STATUS_LEN);
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS;
|
---|
159 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
160 | }
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * @brief Encode a battery_status struct
|
---|
164 | *
|
---|
165 | * @param system_id ID of this system
|
---|
166 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
167 | * @param msg The MAVLink message to compress the data into
|
---|
168 | * @param battery_status C-struct to read the message contents from
|
---|
169 | */
|
---|
170 | static inline uint16_t mavlink_msg_battery_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_battery_status_t* battery_status)
|
---|
171 | {
|
---|
172 | return mavlink_msg_battery_status_pack(system_id, component_id, msg, battery_status->id, battery_status->battery_function, battery_status->type, battery_status->temperature, battery_status->voltages, battery_status->current_battery, battery_status->current_consumed, battery_status->energy_consumed, battery_status->battery_remaining);
|
---|
173 | }
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * @brief Encode a battery_status struct on a channel
|
---|
177 | *
|
---|
178 | * @param system_id ID of this system
|
---|
179 | * @param component_id ID of this component (e.g. 200 for IMU)
|
---|
180 | * @param chan The MAVLink channel this message will be sent over
|
---|
181 | * @param msg The MAVLink message to compress the data into
|
---|
182 | * @param battery_status C-struct to read the message contents from
|
---|
183 | */
|
---|
184 | static inline uint16_t mavlink_msg_battery_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_battery_status_t* battery_status)
|
---|
185 | {
|
---|
186 | return mavlink_msg_battery_status_pack_chan(system_id, component_id, chan, msg, battery_status->id, battery_status->battery_function, battery_status->type, battery_status->temperature, battery_status->voltages, battery_status->current_battery, battery_status->current_consumed, battery_status->energy_consumed, battery_status->battery_remaining);
|
---|
187 | }
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * @brief Send a battery_status message
|
---|
191 | * @param chan MAVLink channel to send the message
|
---|
192 | *
|
---|
193 | * @param id Battery ID
|
---|
194 | * @param battery_function Function of the battery
|
---|
195 | * @param type Type (chemistry) of the battery
|
---|
196 | * @param temperature Temperature of the battery in centi-degrees celsius. INT16_MAX for unknown temperature.
|
---|
197 | * @param voltages Battery voltage of cells, in millivolts (1 = 1 millivolt). Cells above the valid cell count for this battery should have the UINT16_MAX value.
|
---|
198 | * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
|
---|
199 | * @param current_consumed Consumed charge, in milliampere hours (1 = 1 mAh), -1: autopilot does not provide mAh consumption estimate
|
---|
200 | * @param energy_consumed Consumed energy, in 100*Joules (intergrated U*I*dt) (1 = 100 Joule), -1: autopilot does not provide energy consumption estimate
|
---|
201 | * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery
|
---|
202 | */
|
---|
203 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
---|
204 |
|
---|
205 | static inline void mavlink_msg_battery_status_send(mavlink_channel_t chan, uint8_t id, uint8_t battery_function, uint8_t type, int16_t temperature, const uint16_t *voltages, int16_t current_battery, int32_t current_consumed, int32_t energy_consumed, int8_t battery_remaining)
|
---|
206 | {
|
---|
207 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
208 | char buf[MAVLINK_MSG_ID_BATTERY_STATUS_LEN];
|
---|
209 | _mav_put_int32_t(buf, 0, current_consumed);
|
---|
210 | _mav_put_int32_t(buf, 4, energy_consumed);
|
---|
211 | _mav_put_int16_t(buf, 8, temperature);
|
---|
212 | _mav_put_int16_t(buf, 30, current_battery);
|
---|
213 | _mav_put_uint8_t(buf, 32, id);
|
---|
214 | _mav_put_uint8_t(buf, 33, battery_function);
|
---|
215 | _mav_put_uint8_t(buf, 34, type);
|
---|
216 | _mav_put_int8_t(buf, 35, battery_remaining);
|
---|
217 | _mav_put_uint16_t_array(buf, 10, voltages, 10);
|
---|
218 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, buf, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
219 | #else
|
---|
220 | mavlink_battery_status_t packet;
|
---|
221 | packet.current_consumed = current_consumed;
|
---|
222 | packet.energy_consumed = energy_consumed;
|
---|
223 | packet.temperature = temperature;
|
---|
224 | packet.current_battery = current_battery;
|
---|
225 | packet.id = id;
|
---|
226 | packet.battery_function = battery_function;
|
---|
227 | packet.type = type;
|
---|
228 | packet.battery_remaining = battery_remaining;
|
---|
229 | mav_array_memcpy(packet.voltages, voltages, sizeof(uint16_t)*10);
|
---|
230 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, (const char *)&packet, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
231 | #endif
|
---|
232 | }
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * @brief Send a battery_status message
|
---|
236 | * @param chan MAVLink channel to send the message
|
---|
237 | * @param struct The MAVLink struct to serialize
|
---|
238 | */
|
---|
239 | static inline void mavlink_msg_battery_status_send_struct(mavlink_channel_t chan, const mavlink_battery_status_t* battery_status)
|
---|
240 | {
|
---|
241 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
242 | mavlink_msg_battery_status_send(chan, battery_status->id, battery_status->battery_function, battery_status->type, battery_status->temperature, battery_status->voltages, battery_status->current_battery, battery_status->current_consumed, battery_status->energy_consumed, battery_status->battery_remaining);
|
---|
243 | #else
|
---|
244 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, (const char *)battery_status, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
245 | #endif
|
---|
246 | }
|
---|
247 |
|
---|
248 | #if MAVLINK_MSG_ID_BATTERY_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
|
---|
249 | /*
|
---|
250 | This varient of _send() can be used to save stack space by re-using
|
---|
251 | memory from the receive buffer. The caller provides a
|
---|
252 | mavlink_message_t which is the size of a full mavlink message. This
|
---|
253 | is usually the receive buffer for the channel, and allows a reply to an
|
---|
254 | incoming message with minimum stack space usage.
|
---|
255 | */
|
---|
256 | static inline void mavlink_msg_battery_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t id, uint8_t battery_function, uint8_t type, int16_t temperature, const uint16_t *voltages, int16_t current_battery, int32_t current_consumed, int32_t energy_consumed, int8_t battery_remaining)
|
---|
257 | {
|
---|
258 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
259 | char *buf = (char *)msgbuf;
|
---|
260 | _mav_put_int32_t(buf, 0, current_consumed);
|
---|
261 | _mav_put_int32_t(buf, 4, energy_consumed);
|
---|
262 | _mav_put_int16_t(buf, 8, temperature);
|
---|
263 | _mav_put_int16_t(buf, 30, current_battery);
|
---|
264 | _mav_put_uint8_t(buf, 32, id);
|
---|
265 | _mav_put_uint8_t(buf, 33, battery_function);
|
---|
266 | _mav_put_uint8_t(buf, 34, type);
|
---|
267 | _mav_put_int8_t(buf, 35, battery_remaining);
|
---|
268 | _mav_put_uint16_t_array(buf, 10, voltages, 10);
|
---|
269 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, buf, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
270 | #else
|
---|
271 | mavlink_battery_status_t *packet = (mavlink_battery_status_t *)msgbuf;
|
---|
272 | packet->current_consumed = current_consumed;
|
---|
273 | packet->energy_consumed = energy_consumed;
|
---|
274 | packet->temperature = temperature;
|
---|
275 | packet->current_battery = current_battery;
|
---|
276 | packet->id = id;
|
---|
277 | packet->battery_function = battery_function;
|
---|
278 | packet->type = type;
|
---|
279 | packet->battery_remaining = battery_remaining;
|
---|
280 | mav_array_memcpy(packet->voltages, voltages, sizeof(uint16_t)*10);
|
---|
281 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, (const char *)packet, MAVLINK_MSG_ID_BATTERY_STATUS_MIN_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_LEN, MAVLINK_MSG_ID_BATTERY_STATUS_CRC);
|
---|
282 | #endif
|
---|
283 | }
|
---|
284 | #endif
|
---|
285 |
|
---|
286 | #endif
|
---|
287 |
|
---|
288 | // MESSAGE BATTERY_STATUS UNPACKING
|
---|
289 |
|
---|
290 |
|
---|
291 | /**
|
---|
292 | * @brief Get field id from battery_status message
|
---|
293 | *
|
---|
294 | * @return Battery ID
|
---|
295 | */
|
---|
296 | static inline uint8_t mavlink_msg_battery_status_get_id(const mavlink_message_t* msg)
|
---|
297 | {
|
---|
298 | return _MAV_RETURN_uint8_t(msg, 32);
|
---|
299 | }
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * @brief Get field battery_function from battery_status message
|
---|
303 | *
|
---|
304 | * @return Function of the battery
|
---|
305 | */
|
---|
306 | static inline uint8_t mavlink_msg_battery_status_get_battery_function(const mavlink_message_t* msg)
|
---|
307 | {
|
---|
308 | return _MAV_RETURN_uint8_t(msg, 33);
|
---|
309 | }
|
---|
310 |
|
---|
311 | /**
|
---|
312 | * @brief Get field type from battery_status message
|
---|
313 | *
|
---|
314 | * @return Type (chemistry) of the battery
|
---|
315 | */
|
---|
316 | static inline uint8_t mavlink_msg_battery_status_get_type(const mavlink_message_t* msg)
|
---|
317 | {
|
---|
318 | return _MAV_RETURN_uint8_t(msg, 34);
|
---|
319 | }
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * @brief Get field temperature from battery_status message
|
---|
323 | *
|
---|
324 | * @return Temperature of the battery in centi-degrees celsius. INT16_MAX for unknown temperature.
|
---|
325 | */
|
---|
326 | static inline int16_t mavlink_msg_battery_status_get_temperature(const mavlink_message_t* msg)
|
---|
327 | {
|
---|
328 | return _MAV_RETURN_int16_t(msg, 8);
|
---|
329 | }
|
---|
330 |
|
---|
331 | /**
|
---|
332 | * @brief Get field voltages from battery_status message
|
---|
333 | *
|
---|
334 | * @return Battery voltage of cells, in millivolts (1 = 1 millivolt). Cells above the valid cell count for this battery should have the UINT16_MAX value.
|
---|
335 | */
|
---|
336 | static inline uint16_t mavlink_msg_battery_status_get_voltages(const mavlink_message_t* msg, uint16_t *voltages)
|
---|
337 | {
|
---|
338 | return _MAV_RETURN_uint16_t_array(msg, voltages, 10, 10);
|
---|
339 | }
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * @brief Get field current_battery from battery_status message
|
---|
343 | *
|
---|
344 | * @return Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current
|
---|
345 | */
|
---|
346 | static inline int16_t mavlink_msg_battery_status_get_current_battery(const mavlink_message_t* msg)
|
---|
347 | {
|
---|
348 | return _MAV_RETURN_int16_t(msg, 30);
|
---|
349 | }
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * @brief Get field current_consumed from battery_status message
|
---|
353 | *
|
---|
354 | * @return Consumed charge, in milliampere hours (1 = 1 mAh), -1: autopilot does not provide mAh consumption estimate
|
---|
355 | */
|
---|
356 | static inline int32_t mavlink_msg_battery_status_get_current_consumed(const mavlink_message_t* msg)
|
---|
357 | {
|
---|
358 | return _MAV_RETURN_int32_t(msg, 0);
|
---|
359 | }
|
---|
360 |
|
---|
361 | /**
|
---|
362 | * @brief Get field energy_consumed from battery_status message
|
---|
363 | *
|
---|
364 | * @return Consumed energy, in 100*Joules (intergrated U*I*dt) (1 = 100 Joule), -1: autopilot does not provide energy consumption estimate
|
---|
365 | */
|
---|
366 | static inline int32_t mavlink_msg_battery_status_get_energy_consumed(const mavlink_message_t* msg)
|
---|
367 | {
|
---|
368 | return _MAV_RETURN_int32_t(msg, 4);
|
---|
369 | }
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * @brief Get field battery_remaining from battery_status message
|
---|
373 | *
|
---|
374 | * @return Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery
|
---|
375 | */
|
---|
376 | static inline int8_t mavlink_msg_battery_status_get_battery_remaining(const mavlink_message_t* msg)
|
---|
377 | {
|
---|
378 | return _MAV_RETURN_int8_t(msg, 35);
|
---|
379 | }
|
---|
380 |
|
---|
381 | /**
|
---|
382 | * @brief Decode a battery_status message into a struct
|
---|
383 | *
|
---|
384 | * @param msg The message to decode
|
---|
385 | * @param battery_status C-struct to decode the message contents into
|
---|
386 | */
|
---|
387 | static inline void mavlink_msg_battery_status_decode(const mavlink_message_t* msg, mavlink_battery_status_t* battery_status)
|
---|
388 | {
|
---|
389 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
---|
390 | battery_status->current_consumed = mavlink_msg_battery_status_get_current_consumed(msg);
|
---|
391 | battery_status->energy_consumed = mavlink_msg_battery_status_get_energy_consumed(msg);
|
---|
392 | battery_status->temperature = mavlink_msg_battery_status_get_temperature(msg);
|
---|
393 | mavlink_msg_battery_status_get_voltages(msg, battery_status->voltages);
|
---|
394 | battery_status->current_battery = mavlink_msg_battery_status_get_current_battery(msg);
|
---|
395 | battery_status->id = mavlink_msg_battery_status_get_id(msg);
|
---|
396 | battery_status->battery_function = mavlink_msg_battery_status_get_battery_function(msg);
|
---|
397 | battery_status->type = mavlink_msg_battery_status_get_type(msg);
|
---|
398 | battery_status->battery_remaining = mavlink_msg_battery_status_get_battery_remaining(msg);
|
---|
399 | #else
|
---|
400 | uint8_t len = msg->len < MAVLINK_MSG_ID_BATTERY_STATUS_LEN? msg->len : MAVLINK_MSG_ID_BATTERY_STATUS_LEN;
|
---|
401 | memset(battery_status, 0, MAVLINK_MSG_ID_BATTERY_STATUS_LEN);
|
---|
402 | memcpy(battery_status, _MAV_PAYLOAD(msg), len);
|
---|
403 | #endif
|
---|
404 | }
|
---|