Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_winch_status.h
blob62bd61695f77832ab0f00e2e3cbf111905c31972
1 #pragma once
2 // MESSAGE WINCH_STATUS PACKING
4 #define MAVLINK_MSG_ID_WINCH_STATUS 9005
7 typedef struct __mavlink_winch_status_t {
8 uint64_t time_usec; /*< [us] Timestamp (synced to UNIX time or since system boot).*/
9 float line_length; /*< [m] Length of line released. NaN if unknown*/
10 float speed; /*< [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown*/
11 float tension; /*< [kg] Tension on the line. NaN if unknown*/
12 float voltage; /*< [V] Voltage of the battery supplying the winch. NaN if unknown*/
13 float current; /*< [A] Current draw from the winch. NaN if unknown*/
14 uint32_t status; /*< Status flags*/
15 int16_t temperature; /*< [degC] Temperature of the motor. INT16_MAX if unknown*/
16 } mavlink_winch_status_t;
18 #define MAVLINK_MSG_ID_WINCH_STATUS_LEN 34
19 #define MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN 34
20 #define MAVLINK_MSG_ID_9005_LEN 34
21 #define MAVLINK_MSG_ID_9005_MIN_LEN 34
23 #define MAVLINK_MSG_ID_WINCH_STATUS_CRC 117
24 #define MAVLINK_MSG_ID_9005_CRC 117
28 #if MAVLINK_COMMAND_24BIT
29 #define MAVLINK_MESSAGE_INFO_WINCH_STATUS { \
30 9005, \
31 "WINCH_STATUS", \
32 8, \
33 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_winch_status_t, time_usec) }, \
34 { "line_length", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_winch_status_t, line_length) }, \
35 { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_winch_status_t, speed) }, \
36 { "tension", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_winch_status_t, tension) }, \
37 { "voltage", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_winch_status_t, voltage) }, \
38 { "current", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_winch_status_t, current) }, \
39 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 32, offsetof(mavlink_winch_status_t, temperature) }, \
40 { "status", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_winch_status_t, status) }, \
41 } \
43 #else
44 #define MAVLINK_MESSAGE_INFO_WINCH_STATUS { \
45 "WINCH_STATUS", \
46 8, \
47 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_winch_status_t, time_usec) }, \
48 { "line_length", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_winch_status_t, line_length) }, \
49 { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_winch_status_t, speed) }, \
50 { "tension", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_winch_status_t, tension) }, \
51 { "voltage", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_winch_status_t, voltage) }, \
52 { "current", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_winch_status_t, current) }, \
53 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 32, offsetof(mavlink_winch_status_t, temperature) }, \
54 { "status", NULL, MAVLINK_TYPE_UINT32_T, 0, 28, offsetof(mavlink_winch_status_t, status) }, \
55 } \
57 #endif
59 /**
60 * @brief Pack a winch_status message
61 * @param system_id ID of this system
62 * @param component_id ID of this component (e.g. 200 for IMU)
63 * @param msg The MAVLink message to compress the data into
65 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
66 * @param line_length [m] Length of line released. NaN if unknown
67 * @param speed [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown
68 * @param tension [kg] Tension on the line. NaN if unknown
69 * @param voltage [V] Voltage of the battery supplying the winch. NaN if unknown
70 * @param current [A] Current draw from the winch. NaN if unknown
71 * @param temperature [degC] Temperature of the motor. INT16_MAX if unknown
72 * @param status Status flags
73 * @return length of the message in bytes (excluding serial stream start sign)
75 static inline uint16_t mavlink_msg_winch_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
76 uint64_t time_usec, float line_length, float speed, float tension, float voltage, float current, int16_t temperature, uint32_t status)
78 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
79 char buf[MAVLINK_MSG_ID_WINCH_STATUS_LEN];
80 _mav_put_uint64_t(buf, 0, time_usec);
81 _mav_put_float(buf, 8, line_length);
82 _mav_put_float(buf, 12, speed);
83 _mav_put_float(buf, 16, tension);
84 _mav_put_float(buf, 20, voltage);
85 _mav_put_float(buf, 24, current);
86 _mav_put_uint32_t(buf, 28, status);
87 _mav_put_int16_t(buf, 32, temperature);
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WINCH_STATUS_LEN);
90 #else
91 mavlink_winch_status_t packet;
92 packet.time_usec = time_usec;
93 packet.line_length = line_length;
94 packet.speed = speed;
95 packet.tension = tension;
96 packet.voltage = voltage;
97 packet.current = current;
98 packet.status = status;
99 packet.temperature = temperature;
101 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WINCH_STATUS_LEN);
102 #endif
104 msg->msgid = MAVLINK_MSG_ID_WINCH_STATUS;
105 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
109 * @brief Pack a winch_status message on a channel
110 * @param system_id ID of this system
111 * @param component_id ID of this component (e.g. 200 for IMU)
112 * @param chan The MAVLink channel this message will be sent over
113 * @param msg The MAVLink message to compress the data into
114 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
115 * @param line_length [m] Length of line released. NaN if unknown
116 * @param speed [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown
117 * @param tension [kg] Tension on the line. NaN if unknown
118 * @param voltage [V] Voltage of the battery supplying the winch. NaN if unknown
119 * @param current [A] Current draw from the winch. NaN if unknown
120 * @param temperature [degC] Temperature of the motor. INT16_MAX if unknown
121 * @param status Status flags
122 * @return length of the message in bytes (excluding serial stream start sign)
124 static inline uint16_t mavlink_msg_winch_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
125 mavlink_message_t* msg,
126 uint64_t time_usec,float line_length,float speed,float tension,float voltage,float current,int16_t temperature,uint32_t status)
128 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
129 char buf[MAVLINK_MSG_ID_WINCH_STATUS_LEN];
130 _mav_put_uint64_t(buf, 0, time_usec);
131 _mav_put_float(buf, 8, line_length);
132 _mav_put_float(buf, 12, speed);
133 _mav_put_float(buf, 16, tension);
134 _mav_put_float(buf, 20, voltage);
135 _mav_put_float(buf, 24, current);
136 _mav_put_uint32_t(buf, 28, status);
137 _mav_put_int16_t(buf, 32, temperature);
139 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WINCH_STATUS_LEN);
140 #else
141 mavlink_winch_status_t packet;
142 packet.time_usec = time_usec;
143 packet.line_length = line_length;
144 packet.speed = speed;
145 packet.tension = tension;
146 packet.voltage = voltage;
147 packet.current = current;
148 packet.status = status;
149 packet.temperature = temperature;
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WINCH_STATUS_LEN);
152 #endif
154 msg->msgid = MAVLINK_MSG_ID_WINCH_STATUS;
155 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
159 * @brief Encode a winch_status struct
161 * @param system_id ID of this system
162 * @param component_id ID of this component (e.g. 200 for IMU)
163 * @param msg The MAVLink message to compress the data into
164 * @param winch_status C-struct to read the message contents from
166 static inline uint16_t mavlink_msg_winch_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_winch_status_t* winch_status)
168 return mavlink_msg_winch_status_pack(system_id, component_id, msg, winch_status->time_usec, winch_status->line_length, winch_status->speed, winch_status->tension, winch_status->voltage, winch_status->current, winch_status->temperature, winch_status->status);
172 * @brief Encode a winch_status struct on a channel
174 * @param system_id ID of this system
175 * @param component_id ID of this component (e.g. 200 for IMU)
176 * @param chan The MAVLink channel this message will be sent over
177 * @param msg The MAVLink message to compress the data into
178 * @param winch_status C-struct to read the message contents from
180 static inline uint16_t mavlink_msg_winch_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_winch_status_t* winch_status)
182 return mavlink_msg_winch_status_pack_chan(system_id, component_id, chan, msg, winch_status->time_usec, winch_status->line_length, winch_status->speed, winch_status->tension, winch_status->voltage, winch_status->current, winch_status->temperature, winch_status->status);
186 * @brief Send a winch_status message
187 * @param chan MAVLink channel to send the message
189 * @param time_usec [us] Timestamp (synced to UNIX time or since system boot).
190 * @param line_length [m] Length of line released. NaN if unknown
191 * @param speed [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown
192 * @param tension [kg] Tension on the line. NaN if unknown
193 * @param voltage [V] Voltage of the battery supplying the winch. NaN if unknown
194 * @param current [A] Current draw from the winch. NaN if unknown
195 * @param temperature [degC] Temperature of the motor. INT16_MAX if unknown
196 * @param status Status flags
198 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
200 static inline void mavlink_msg_winch_status_send(mavlink_channel_t chan, uint64_t time_usec, float line_length, float speed, float tension, float voltage, float current, int16_t temperature, uint32_t status)
202 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
203 char buf[MAVLINK_MSG_ID_WINCH_STATUS_LEN];
204 _mav_put_uint64_t(buf, 0, time_usec);
205 _mav_put_float(buf, 8, line_length);
206 _mav_put_float(buf, 12, speed);
207 _mav_put_float(buf, 16, tension);
208 _mav_put_float(buf, 20, voltage);
209 _mav_put_float(buf, 24, current);
210 _mav_put_uint32_t(buf, 28, status);
211 _mav_put_int16_t(buf, 32, temperature);
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WINCH_STATUS, buf, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
214 #else
215 mavlink_winch_status_t packet;
216 packet.time_usec = time_usec;
217 packet.line_length = line_length;
218 packet.speed = speed;
219 packet.tension = tension;
220 packet.voltage = voltage;
221 packet.current = current;
222 packet.status = status;
223 packet.temperature = temperature;
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WINCH_STATUS, (const char *)&packet, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
226 #endif
230 * @brief Send a winch_status message
231 * @param chan MAVLink channel to send the message
232 * @param struct The MAVLink struct to serialize
234 static inline void mavlink_msg_winch_status_send_struct(mavlink_channel_t chan, const mavlink_winch_status_t* winch_status)
236 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 mavlink_msg_winch_status_send(chan, winch_status->time_usec, winch_status->line_length, winch_status->speed, winch_status->tension, winch_status->voltage, winch_status->current, winch_status->temperature, winch_status->status);
238 #else
239 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WINCH_STATUS, (const char *)winch_status, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
240 #endif
243 #if MAVLINK_MSG_ID_WINCH_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
245 This varient of _send() can be used to save stack space by re-using
246 memory from the receive buffer. The caller provides a
247 mavlink_message_t which is the size of a full mavlink message. This
248 is usually the receive buffer for the channel, and allows a reply to an
249 incoming message with minimum stack space usage.
251 static inline void mavlink_msg_winch_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float line_length, float speed, float tension, float voltage, float current, int16_t temperature, uint32_t status)
253 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_uint64_t(buf, 0, time_usec);
256 _mav_put_float(buf, 8, line_length);
257 _mav_put_float(buf, 12, speed);
258 _mav_put_float(buf, 16, tension);
259 _mav_put_float(buf, 20, voltage);
260 _mav_put_float(buf, 24, current);
261 _mav_put_uint32_t(buf, 28, status);
262 _mav_put_int16_t(buf, 32, temperature);
264 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WINCH_STATUS, buf, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
265 #else
266 mavlink_winch_status_t *packet = (mavlink_winch_status_t *)msgbuf;
267 packet->time_usec = time_usec;
268 packet->line_length = line_length;
269 packet->speed = speed;
270 packet->tension = tension;
271 packet->voltage = voltage;
272 packet->current = current;
273 packet->status = status;
274 packet->temperature = temperature;
276 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WINCH_STATUS, (const char *)packet, MAVLINK_MSG_ID_WINCH_STATUS_MIN_LEN, MAVLINK_MSG_ID_WINCH_STATUS_LEN, MAVLINK_MSG_ID_WINCH_STATUS_CRC);
277 #endif
279 #endif
281 #endif
283 // MESSAGE WINCH_STATUS UNPACKING
287 * @brief Get field time_usec from winch_status message
289 * @return [us] Timestamp (synced to UNIX time or since system boot).
291 static inline uint64_t mavlink_msg_winch_status_get_time_usec(const mavlink_message_t* msg)
293 return _MAV_RETURN_uint64_t(msg, 0);
297 * @brief Get field line_length from winch_status message
299 * @return [m] Length of line released. NaN if unknown
301 static inline float mavlink_msg_winch_status_get_line_length(const mavlink_message_t* msg)
303 return _MAV_RETURN_float(msg, 8);
307 * @brief Get field speed from winch_status message
309 * @return [m/s] Speed line is being released or retracted. Positive values if being released, negative values if being retracted, NaN if unknown
311 static inline float mavlink_msg_winch_status_get_speed(const mavlink_message_t* msg)
313 return _MAV_RETURN_float(msg, 12);
317 * @brief Get field tension from winch_status message
319 * @return [kg] Tension on the line. NaN if unknown
321 static inline float mavlink_msg_winch_status_get_tension(const mavlink_message_t* msg)
323 return _MAV_RETURN_float(msg, 16);
327 * @brief Get field voltage from winch_status message
329 * @return [V] Voltage of the battery supplying the winch. NaN if unknown
331 static inline float mavlink_msg_winch_status_get_voltage(const mavlink_message_t* msg)
333 return _MAV_RETURN_float(msg, 20);
337 * @brief Get field current from winch_status message
339 * @return [A] Current draw from the winch. NaN if unknown
341 static inline float mavlink_msg_winch_status_get_current(const mavlink_message_t* msg)
343 return _MAV_RETURN_float(msg, 24);
347 * @brief Get field temperature from winch_status message
349 * @return [degC] Temperature of the motor. INT16_MAX if unknown
351 static inline int16_t mavlink_msg_winch_status_get_temperature(const mavlink_message_t* msg)
353 return _MAV_RETURN_int16_t(msg, 32);
357 * @brief Get field status from winch_status message
359 * @return Status flags
361 static inline uint32_t mavlink_msg_winch_status_get_status(const mavlink_message_t* msg)
363 return _MAV_RETURN_uint32_t(msg, 28);
367 * @brief Decode a winch_status message into a struct
369 * @param msg The message to decode
370 * @param winch_status C-struct to decode the message contents into
372 static inline void mavlink_msg_winch_status_decode(const mavlink_message_t* msg, mavlink_winch_status_t* winch_status)
374 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
375 winch_status->time_usec = mavlink_msg_winch_status_get_time_usec(msg);
376 winch_status->line_length = mavlink_msg_winch_status_get_line_length(msg);
377 winch_status->speed = mavlink_msg_winch_status_get_speed(msg);
378 winch_status->tension = mavlink_msg_winch_status_get_tension(msg);
379 winch_status->voltage = mavlink_msg_winch_status_get_voltage(msg);
380 winch_status->current = mavlink_msg_winch_status_get_current(msg);
381 winch_status->status = mavlink_msg_winch_status_get_status(msg);
382 winch_status->temperature = mavlink_msg_winch_status_get_temperature(msg);
383 #else
384 uint8_t len = msg->len < MAVLINK_MSG_ID_WINCH_STATUS_LEN? msg->len : MAVLINK_MSG_ID_WINCH_STATUS_LEN;
385 memset(winch_status, 0, MAVLINK_MSG_ID_WINCH_STATUS_LEN);
386 memcpy(winch_status, _MAV_PAYLOAD(msg), len);
387 #endif