2 // MESSAGE ESC_STATUS PACKING
4 #define MAVLINK_MSG_ID_ESC_STATUS 291
7 typedef struct __mavlink_esc_status_t
{
8 uint64_t time_usec
; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.*/
9 int32_t rpm
[4]; /*< [rpm] Reported motor RPM from each ESC (negative for reverse rotation).*/
10 float voltage
[4]; /*< [V] Voltage measured from each ESC.*/
11 float current
[4]; /*< [A] Current measured from each ESC.*/
12 uint8_t index
; /*< Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.*/
13 } mavlink_esc_status_t
;
15 #define MAVLINK_MSG_ID_ESC_STATUS_LEN 57
16 #define MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN 57
17 #define MAVLINK_MSG_ID_291_LEN 57
18 #define MAVLINK_MSG_ID_291_MIN_LEN 57
20 #define MAVLINK_MSG_ID_ESC_STATUS_CRC 10
21 #define MAVLINK_MSG_ID_291_CRC 10
23 #define MAVLINK_MSG_ESC_STATUS_FIELD_RPM_LEN 4
24 #define MAVLINK_MSG_ESC_STATUS_FIELD_VOLTAGE_LEN 4
25 #define MAVLINK_MSG_ESC_STATUS_FIELD_CURRENT_LEN 4
27 #if MAVLINK_COMMAND_24BIT
28 #define MAVLINK_MESSAGE_INFO_ESC_STATUS { \
32 { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 56, offsetof(mavlink_esc_status_t, index) }, \
33 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_esc_status_t, time_usec) }, \
34 { "rpm", NULL, MAVLINK_TYPE_INT32_T, 4, 8, offsetof(mavlink_esc_status_t, rpm) }, \
35 { "voltage", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_esc_status_t, voltage) }, \
36 { "current", NULL, MAVLINK_TYPE_FLOAT, 4, 40, offsetof(mavlink_esc_status_t, current) }, \
40 #define MAVLINK_MESSAGE_INFO_ESC_STATUS { \
43 { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 56, offsetof(mavlink_esc_status_t, index) }, \
44 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_esc_status_t, time_usec) }, \
45 { "rpm", NULL, MAVLINK_TYPE_INT32_T, 4, 8, offsetof(mavlink_esc_status_t, rpm) }, \
46 { "voltage", NULL, MAVLINK_TYPE_FLOAT, 4, 24, offsetof(mavlink_esc_status_t, voltage) }, \
47 { "current", NULL, MAVLINK_TYPE_FLOAT, 4, 40, offsetof(mavlink_esc_status_t, current) }, \
53 * @brief Pack a esc_status message
54 * @param system_id ID of this system
55 * @param component_id ID of this component (e.g. 200 for IMU)
56 * @param msg The MAVLink message to compress the data into
58 * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
59 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
60 * @param rpm [rpm] Reported motor RPM from each ESC (negative for reverse rotation).
61 * @param voltage [V] Voltage measured from each ESC.
62 * @param current [A] Current measured from each ESC.
63 * @return length of the message in bytes (excluding serial stream start sign)
65 static inline uint16_t mavlink_msg_esc_status_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
66 uint8_t index
, uint64_t time_usec
, const int32_t *rpm
, const float *voltage
, const float *current
)
68 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
69 char buf
[MAVLINK_MSG_ID_ESC_STATUS_LEN
];
70 _mav_put_uint64_t(buf
, 0, time_usec
);
71 _mav_put_uint8_t(buf
, 56, index
);
72 _mav_put_int32_t_array(buf
, 8, rpm
, 4);
73 _mav_put_float_array(buf
, 24, voltage
, 4);
74 _mav_put_float_array(buf
, 40, current
, 4);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ESC_STATUS_LEN
);
77 mavlink_esc_status_t packet
;
78 packet
.time_usec
= time_usec
;
80 mav_array_memcpy(packet
.rpm
, rpm
, sizeof(int32_t)*4);
81 mav_array_memcpy(packet
.voltage
, voltage
, sizeof(float)*4);
82 mav_array_memcpy(packet
.current
, current
, sizeof(float)*4);
83 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ESC_STATUS_LEN
);
86 msg
->msgid
= MAVLINK_MSG_ID_ESC_STATUS
;
87 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
91 * @brief Pack a esc_status message on a channel
92 * @param system_id ID of this system
93 * @param component_id ID of this component (e.g. 200 for IMU)
94 * @param chan The MAVLink channel this message will be sent over
95 * @param msg The MAVLink message to compress the data into
96 * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
97 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
98 * @param rpm [rpm] Reported motor RPM from each ESC (negative for reverse rotation).
99 * @param voltage [V] Voltage measured from each ESC.
100 * @param current [A] Current measured from each ESC.
101 * @return length of the message in bytes (excluding serial stream start sign)
103 static inline uint16_t mavlink_msg_esc_status_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
104 mavlink_message_t
* msg
,
105 uint8_t index
,uint64_t time_usec
,const int32_t *rpm
,const float *voltage
,const float *current
)
107 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 char buf
[MAVLINK_MSG_ID_ESC_STATUS_LEN
];
109 _mav_put_uint64_t(buf
, 0, time_usec
);
110 _mav_put_uint8_t(buf
, 56, index
);
111 _mav_put_int32_t_array(buf
, 8, rpm
, 4);
112 _mav_put_float_array(buf
, 24, voltage
, 4);
113 _mav_put_float_array(buf
, 40, current
, 4);
114 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ESC_STATUS_LEN
);
116 mavlink_esc_status_t packet
;
117 packet
.time_usec
= time_usec
;
118 packet
.index
= index
;
119 mav_array_memcpy(packet
.rpm
, rpm
, sizeof(int32_t)*4);
120 mav_array_memcpy(packet
.voltage
, voltage
, sizeof(float)*4);
121 mav_array_memcpy(packet
.current
, current
, sizeof(float)*4);
122 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ESC_STATUS_LEN
);
125 msg
->msgid
= MAVLINK_MSG_ID_ESC_STATUS
;
126 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
130 * @brief Encode a esc_status struct
132 * @param system_id ID of this system
133 * @param component_id ID of this component (e.g. 200 for IMU)
134 * @param msg The MAVLink message to compress the data into
135 * @param esc_status C-struct to read the message contents from
137 static inline uint16_t mavlink_msg_esc_status_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_esc_status_t
* esc_status
)
139 return mavlink_msg_esc_status_pack(system_id
, component_id
, msg
, esc_status
->index
, esc_status
->time_usec
, esc_status
->rpm
, esc_status
->voltage
, esc_status
->current
);
143 * @brief Encode a esc_status struct on a channel
145 * @param system_id ID of this system
146 * @param component_id ID of this component (e.g. 200 for IMU)
147 * @param chan The MAVLink channel this message will be sent over
148 * @param msg The MAVLink message to compress the data into
149 * @param esc_status C-struct to read the message contents from
151 static inline uint16_t mavlink_msg_esc_status_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_esc_status_t
* esc_status
)
153 return mavlink_msg_esc_status_pack_chan(system_id
, component_id
, chan
, msg
, esc_status
->index
, esc_status
->time_usec
, esc_status
->rpm
, esc_status
->voltage
, esc_status
->current
);
157 * @brief Send a esc_status message
158 * @param chan MAVLink channel to send the message
160 * @param index Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
161 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
162 * @param rpm [rpm] Reported motor RPM from each ESC (negative for reverse rotation).
163 * @param voltage [V] Voltage measured from each ESC.
164 * @param current [A] Current measured from each ESC.
166 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
168 static inline void mavlink_msg_esc_status_send(mavlink_channel_t chan
, uint8_t index
, uint64_t time_usec
, const int32_t *rpm
, const float *voltage
, const float *current
)
170 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
171 char buf
[MAVLINK_MSG_ID_ESC_STATUS_LEN
];
172 _mav_put_uint64_t(buf
, 0, time_usec
);
173 _mav_put_uint8_t(buf
, 56, index
);
174 _mav_put_int32_t_array(buf
, 8, rpm
, 4);
175 _mav_put_float_array(buf
, 24, voltage
, 4);
176 _mav_put_float_array(buf
, 40, current
, 4);
177 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ESC_STATUS
, buf
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
179 mavlink_esc_status_t packet
;
180 packet
.time_usec
= time_usec
;
181 packet
.index
= index
;
182 mav_array_memcpy(packet
.rpm
, rpm
, sizeof(int32_t)*4);
183 mav_array_memcpy(packet
.voltage
, voltage
, sizeof(float)*4);
184 mav_array_memcpy(packet
.current
, current
, sizeof(float)*4);
185 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ESC_STATUS
, (const char *)&packet
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
190 * @brief Send a esc_status message
191 * @param chan MAVLink channel to send the message
192 * @param struct The MAVLink struct to serialize
194 static inline void mavlink_msg_esc_status_send_struct(mavlink_channel_t chan
, const mavlink_esc_status_t
* esc_status
)
196 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
197 mavlink_msg_esc_status_send(chan
, esc_status
->index
, esc_status
->time_usec
, esc_status
->rpm
, esc_status
->voltage
, esc_status
->current
);
199 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ESC_STATUS
, (const char *)esc_status
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
203 #if MAVLINK_MSG_ID_ESC_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
205 This varient of _send() can be used to save stack space by re-using
206 memory from the receive buffer. The caller provides a
207 mavlink_message_t which is the size of a full mavlink message. This
208 is usually the receive buffer for the channel, and allows a reply to an
209 incoming message with minimum stack space usage.
211 static inline void mavlink_msg_esc_status_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint8_t index
, uint64_t time_usec
, const int32_t *rpm
, const float *voltage
, const float *current
)
213 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
214 char *buf
= (char *)msgbuf
;
215 _mav_put_uint64_t(buf
, 0, time_usec
);
216 _mav_put_uint8_t(buf
, 56, index
);
217 _mav_put_int32_t_array(buf
, 8, rpm
, 4);
218 _mav_put_float_array(buf
, 24, voltage
, 4);
219 _mav_put_float_array(buf
, 40, current
, 4);
220 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ESC_STATUS
, buf
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
222 mavlink_esc_status_t
*packet
= (mavlink_esc_status_t
*)msgbuf
;
223 packet
->time_usec
= time_usec
;
224 packet
->index
= index
;
225 mav_array_memcpy(packet
->rpm
, rpm
, sizeof(int32_t)*4);
226 mav_array_memcpy(packet
->voltage
, voltage
, sizeof(float)*4);
227 mav_array_memcpy(packet
->current
, current
, sizeof(float)*4);
228 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ESC_STATUS
, (const char *)packet
, MAVLINK_MSG_ID_ESC_STATUS_MIN_LEN
, MAVLINK_MSG_ID_ESC_STATUS_LEN
, MAVLINK_MSG_ID_ESC_STATUS_CRC
);
235 // MESSAGE ESC_STATUS UNPACKING
239 * @brief Get field index from esc_status message
241 * @return Index of the first ESC in this message. minValue = 0, maxValue = 60, increment = 4.
243 static inline uint8_t mavlink_msg_esc_status_get_index(const mavlink_message_t
* msg
)
245 return _MAV_RETURN_uint8_t(msg
, 56);
249 * @brief Get field time_usec from esc_status message
251 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
253 static inline uint64_t mavlink_msg_esc_status_get_time_usec(const mavlink_message_t
* msg
)
255 return _MAV_RETURN_uint64_t(msg
, 0);
259 * @brief Get field rpm from esc_status message
261 * @return [rpm] Reported motor RPM from each ESC (negative for reverse rotation).
263 static inline uint16_t mavlink_msg_esc_status_get_rpm(const mavlink_message_t
* msg
, int32_t *rpm
)
265 return _MAV_RETURN_int32_t_array(msg
, rpm
, 4, 8);
269 * @brief Get field voltage from esc_status message
271 * @return [V] Voltage measured from each ESC.
273 static inline uint16_t mavlink_msg_esc_status_get_voltage(const mavlink_message_t
* msg
, float *voltage
)
275 return _MAV_RETURN_float_array(msg
, voltage
, 4, 24);
279 * @brief Get field current from esc_status message
281 * @return [A] Current measured from each ESC.
283 static inline uint16_t mavlink_msg_esc_status_get_current(const mavlink_message_t
* msg
, float *current
)
285 return _MAV_RETURN_float_array(msg
, current
, 4, 40);
289 * @brief Decode a esc_status message into a struct
291 * @param msg The message to decode
292 * @param esc_status C-struct to decode the message contents into
294 static inline void mavlink_msg_esc_status_decode(const mavlink_message_t
* msg
, mavlink_esc_status_t
* esc_status
)
296 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
297 esc_status
->time_usec
= mavlink_msg_esc_status_get_time_usec(msg
);
298 mavlink_msg_esc_status_get_rpm(msg
, esc_status
->rpm
);
299 mavlink_msg_esc_status_get_voltage(msg
, esc_status
->voltage
);
300 mavlink_msg_esc_status_get_current(msg
, esc_status
->current
);
301 esc_status
->index
= mavlink_msg_esc_status_get_index(msg
);
303 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_ESC_STATUS_LEN
? msg
->len
: MAVLINK_MSG_ID_ESC_STATUS_LEN
;
304 memset(esc_status
, 0, MAVLINK_MSG_ID_ESC_STATUS_LEN
);
305 memcpy(esc_status
, _MAV_PAYLOAD(msg
), len
);