Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_raw_rpm.h
blob0fa4f1a0b5ffdba32573dd1c596763ce8a045c95
1 #pragma once
2 // MESSAGE RAW_RPM PACKING
4 #define MAVLINK_MSG_ID_RAW_RPM 339
7 typedef struct __mavlink_raw_rpm_t {
8 float frequency; /*< [rpm] Indicated rate*/
9 uint8_t index; /*< Index of this RPM sensor (0-indexed)*/
10 } mavlink_raw_rpm_t;
12 #define MAVLINK_MSG_ID_RAW_RPM_LEN 5
13 #define MAVLINK_MSG_ID_RAW_RPM_MIN_LEN 5
14 #define MAVLINK_MSG_ID_339_LEN 5
15 #define MAVLINK_MSG_ID_339_MIN_LEN 5
17 #define MAVLINK_MSG_ID_RAW_RPM_CRC 199
18 #define MAVLINK_MSG_ID_339_CRC 199
22 #if MAVLINK_COMMAND_24BIT
23 #define MAVLINK_MESSAGE_INFO_RAW_RPM { \
24 339, \
25 "RAW_RPM", \
26 2, \
27 { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_raw_rpm_t, index) }, \
28 { "frequency", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_raw_rpm_t, frequency) }, \
29 } \
31 #else
32 #define MAVLINK_MESSAGE_INFO_RAW_RPM { \
33 "RAW_RPM", \
34 2, \
35 { { "index", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_raw_rpm_t, index) }, \
36 { "frequency", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_raw_rpm_t, frequency) }, \
37 } \
39 #endif
41 /**
42 * @brief Pack a raw_rpm message
43 * @param system_id ID of this system
44 * @param component_id ID of this component (e.g. 200 for IMU)
45 * @param msg The MAVLink message to compress the data into
47 * @param index Index of this RPM sensor (0-indexed)
48 * @param frequency [rpm] Indicated rate
49 * @return length of the message in bytes (excluding serial stream start sign)
51 static inline uint16_t mavlink_msg_raw_rpm_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52 uint8_t index, float frequency)
54 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55 char buf[MAVLINK_MSG_ID_RAW_RPM_LEN];
56 _mav_put_float(buf, 0, frequency);
57 _mav_put_uint8_t(buf, 4, index);
59 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_RPM_LEN);
60 #else
61 mavlink_raw_rpm_t packet;
62 packet.frequency = frequency;
63 packet.index = index;
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_RPM_LEN);
66 #endif
68 msg->msgid = MAVLINK_MSG_ID_RAW_RPM;
69 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
72 /**
73 * @brief Pack a raw_rpm message on a channel
74 * @param system_id ID of this system
75 * @param component_id ID of this component (e.g. 200 for IMU)
76 * @param chan The MAVLink channel this message will be sent over
77 * @param msg The MAVLink message to compress the data into
78 * @param index Index of this RPM sensor (0-indexed)
79 * @param frequency [rpm] Indicated rate
80 * @return length of the message in bytes (excluding serial stream start sign)
82 static inline uint16_t mavlink_msg_raw_rpm_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
83 mavlink_message_t* msg,
84 uint8_t index,float frequency)
86 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 char buf[MAVLINK_MSG_ID_RAW_RPM_LEN];
88 _mav_put_float(buf, 0, frequency);
89 _mav_put_uint8_t(buf, 4, index);
91 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_RPM_LEN);
92 #else
93 mavlink_raw_rpm_t packet;
94 packet.frequency = frequency;
95 packet.index = index;
97 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_RPM_LEN);
98 #endif
100 msg->msgid = MAVLINK_MSG_ID_RAW_RPM;
101 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
105 * @brief Encode a raw_rpm struct
107 * @param system_id ID of this system
108 * @param component_id ID of this component (e.g. 200 for IMU)
109 * @param msg The MAVLink message to compress the data into
110 * @param raw_rpm C-struct to read the message contents from
112 static inline uint16_t mavlink_msg_raw_rpm_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_rpm_t* raw_rpm)
114 return mavlink_msg_raw_rpm_pack(system_id, component_id, msg, raw_rpm->index, raw_rpm->frequency);
118 * @brief Encode a raw_rpm struct on a channel
120 * @param system_id ID of this system
121 * @param component_id ID of this component (e.g. 200 for IMU)
122 * @param chan The MAVLink channel this message will be sent over
123 * @param msg The MAVLink message to compress the data into
124 * @param raw_rpm C-struct to read the message contents from
126 static inline uint16_t mavlink_msg_raw_rpm_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_raw_rpm_t* raw_rpm)
128 return mavlink_msg_raw_rpm_pack_chan(system_id, component_id, chan, msg, raw_rpm->index, raw_rpm->frequency);
132 * @brief Send a raw_rpm message
133 * @param chan MAVLink channel to send the message
135 * @param index Index of this RPM sensor (0-indexed)
136 * @param frequency [rpm] Indicated rate
138 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
140 static inline void mavlink_msg_raw_rpm_send(mavlink_channel_t chan, uint8_t index, float frequency)
142 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
143 char buf[MAVLINK_MSG_ID_RAW_RPM_LEN];
144 _mav_put_float(buf, 0, frequency);
145 _mav_put_uint8_t(buf, 4, index);
147 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, buf, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
148 #else
149 mavlink_raw_rpm_t packet;
150 packet.frequency = frequency;
151 packet.index = index;
153 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)&packet, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
154 #endif
158 * @brief Send a raw_rpm message
159 * @param chan MAVLink channel to send the message
160 * @param struct The MAVLink struct to serialize
162 static inline void mavlink_msg_raw_rpm_send_struct(mavlink_channel_t chan, const mavlink_raw_rpm_t* raw_rpm)
164 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
165 mavlink_msg_raw_rpm_send(chan, raw_rpm->index, raw_rpm->frequency);
166 #else
167 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)raw_rpm, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
168 #endif
171 #if MAVLINK_MSG_ID_RAW_RPM_LEN <= MAVLINK_MAX_PAYLOAD_LEN
173 This varient of _send() can be used to save stack space by re-using
174 memory from the receive buffer. The caller provides a
175 mavlink_message_t which is the size of a full mavlink message. This
176 is usually the receive buffer for the channel, and allows a reply to an
177 incoming message with minimum stack space usage.
179 static inline void mavlink_msg_raw_rpm_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t index, float frequency)
181 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
182 char *buf = (char *)msgbuf;
183 _mav_put_float(buf, 0, frequency);
184 _mav_put_uint8_t(buf, 4, index);
186 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, buf, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
187 #else
188 mavlink_raw_rpm_t *packet = (mavlink_raw_rpm_t *)msgbuf;
189 packet->frequency = frequency;
190 packet->index = index;
192 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_RPM, (const char *)packet, MAVLINK_MSG_ID_RAW_RPM_MIN_LEN, MAVLINK_MSG_ID_RAW_RPM_LEN, MAVLINK_MSG_ID_RAW_RPM_CRC);
193 #endif
195 #endif
197 #endif
199 // MESSAGE RAW_RPM UNPACKING
203 * @brief Get field index from raw_rpm message
205 * @return Index of this RPM sensor (0-indexed)
207 static inline uint8_t mavlink_msg_raw_rpm_get_index(const mavlink_message_t* msg)
209 return _MAV_RETURN_uint8_t(msg, 4);
213 * @brief Get field frequency from raw_rpm message
215 * @return [rpm] Indicated rate
217 static inline float mavlink_msg_raw_rpm_get_frequency(const mavlink_message_t* msg)
219 return _MAV_RETURN_float(msg, 0);
223 * @brief Decode a raw_rpm message into a struct
225 * @param msg The message to decode
226 * @param raw_rpm C-struct to decode the message contents into
228 static inline void mavlink_msg_raw_rpm_decode(const mavlink_message_t* msg, mavlink_raw_rpm_t* raw_rpm)
230 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
231 raw_rpm->frequency = mavlink_msg_raw_rpm_get_frequency(msg);
232 raw_rpm->index = mavlink_msg_raw_rpm_get_index(msg);
233 #else
234 uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_RPM_LEN? msg->len : MAVLINK_MSG_ID_RAW_RPM_LEN;
235 memset(raw_rpm, 0, MAVLINK_MSG_ID_RAW_RPM_LEN);
236 memcpy(raw_rpm, _MAV_PAYLOAD(msg), len);
237 #endif