Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_relay_status.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE RELAY_STATUS PACKING
3
4#define MAVLINK_MSG_ID_RELAY_STATUS 376
5
6
8 uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
9 uint16_t on; /*< Relay states. Relay instance numbers are represented as individual bits in this mask by offset.*/
10 uint16_t present; /*< Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.*/
11} mavlink_relay_status_t;
12
13#define MAVLINK_MSG_ID_RELAY_STATUS_LEN 8
14#define MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN 8
15#define MAVLINK_MSG_ID_376_LEN 8
16#define MAVLINK_MSG_ID_376_MIN_LEN 8
17
18#define MAVLINK_MSG_ID_RELAY_STATUS_CRC 199
19#define MAVLINK_MSG_ID_376_CRC 199
20
21
22
23#if MAVLINK_COMMAND_24BIT
24#define MAVLINK_MESSAGE_INFO_RELAY_STATUS {
25 376,
26 "RELAY_STATUS",
27 3,
28 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_relay_status_t, time_boot_ms) },
29 { "on", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_relay_status_t, on) },
30 { "present", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_relay_status_t, present) },
31 } \
32}
33#else
34#define MAVLINK_MESSAGE_INFO_RELAY_STATUS {
35 "RELAY_STATUS",
36 3,
37 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_relay_status_t, time_boot_ms) },
38 { "on", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_relay_status_t, on) },
39 { "present", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_relay_status_t, present) },
40 } \
41}
42#endif
43
44/**
45 * @brief Pack a relay_status message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
49 *
50 * @param time_boot_ms [ms] Timestamp (time since system boot).
51 * @param on Relay states. Relay instance numbers are represented as individual bits in this mask by offset.
52 * @param present Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.
53 * @return length of the message in bytes (excluding serial stream start sign)
54 */
55static inline uint16_t mavlink_msg_relay_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
56 uint32_t time_boot_ms, uint16_t on, uint16_t present)
57{
58#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 _mav_put_uint32_t(buf, 0, time_boot_ms);
61 _mav_put_uint16_t(buf, 4, on);
62 _mav_put_uint16_t(buf, 6, present);
63
64 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
65#else
66 mavlink_relay_status_t packet;
67 packet.time_boot_ms = time_boot_ms;
68 packet.on = on;
69 packet.present = present;
70
71 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
72#endif
73
74 msg->msgid = MAVLINK_MSG_ID_RELAY_STATUS;
75 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
76}
77
78/**
79 * @brief Pack a relay_status message
80 * @param system_id ID of this system
81 * @param component_id ID of this component (e.g. 200 for IMU)
82 * @param status MAVLink status structure
83 * @param msg The MAVLink message to compress the data into
84 *
85 * @param time_boot_ms [ms] Timestamp (time since system boot).
86 * @param on Relay states. Relay instance numbers are represented as individual bits in this mask by offset.
87 * @param present Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.
88 * @return length of the message in bytes (excluding serial stream start sign)
89 */
90static inline uint16_t mavlink_msg_relay_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
91 uint32_t time_boot_ms, uint16_t on, uint16_t present)
92{
93#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
95 _mav_put_uint32_t(buf, 0, time_boot_ms);
96 _mav_put_uint16_t(buf, 4, on);
97 _mav_put_uint16_t(buf, 6, present);
98
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
100#else
101 mavlink_relay_status_t packet;
102 packet.time_boot_ms = time_boot_ms;
103 packet.on = on;
104 packet.present = present;
105
106 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
107#endif
108
109 msg->msgid = MAVLINK_MSG_ID_RELAY_STATUS;
110#if MAVLINK_CRC_EXTRA
111 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
112#else
113 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
114#endif
115}
116
117/**
118 * @brief Pack a relay_status message on a channel
119 * @param system_id ID of this system
120 * @param component_id ID of this component (e.g. 200 for IMU)
121 * @param chan The MAVLink channel this message will be sent over
122 * @param msg The MAVLink message to compress the data into
123 * @param time_boot_ms [ms] Timestamp (time since system boot).
124 * @param on Relay states. Relay instance numbers are represented as individual bits in this mask by offset.
125 * @param present Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.
126 * @return length of the message in bytes (excluding serial stream start sign)
127 */
128static inline uint16_t mavlink_msg_relay_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
129 mavlink_message_t* msg,
130 uint32_t time_boot_ms,uint16_t on,uint16_t present)
131{
132#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
134 _mav_put_uint32_t(buf, 0, time_boot_ms);
135 _mav_put_uint16_t(buf, 4, on);
136 _mav_put_uint16_t(buf, 6, present);
137
138 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
139#else
140 mavlink_relay_status_t packet;
141 packet.time_boot_ms = time_boot_ms;
142 packet.on = on;
143 packet.present = present;
144
145 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
146#endif
147
148 msg->msgid = MAVLINK_MSG_ID_RELAY_STATUS;
149 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
150}
151
152/**
153 * @brief Encode a relay_status struct
154 *
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param msg The MAVLink message to compress the data into
158 * @param relay_status C-struct to read the message contents from
159 */
160static inline uint16_t mavlink_msg_relay_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_relay_status_t* relay_status)
161{
162 return mavlink_msg_relay_status_pack(system_id, component_id, msg, relay_status->time_boot_ms, relay_status->on, relay_status->present);
163}
164
165/**
166 * @brief Encode a relay_status struct on a channel
167 *
168 * @param system_id ID of this system
169 * @param component_id ID of this component (e.g. 200 for IMU)
170 * @param chan The MAVLink channel this message will be sent over
171 * @param msg The MAVLink message to compress the data into
172 * @param relay_status C-struct to read the message contents from
173 */
174static inline uint16_t mavlink_msg_relay_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_relay_status_t* relay_status)
175{
176 return mavlink_msg_relay_status_pack_chan(system_id, component_id, chan, msg, relay_status->time_boot_ms, relay_status->on, relay_status->present);
177}
178
179/**
180 * @brief Encode a relay_status struct with provided status structure
181 *
182 * @param system_id ID of this system
183 * @param component_id ID of this component (e.g. 200 for IMU)
184 * @param status MAVLink status structure
185 * @param msg The MAVLink message to compress the data into
186 * @param relay_status C-struct to read the message contents from
187 */
188static inline uint16_t mavlink_msg_relay_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_relay_status_t* relay_status)
189{
190 return mavlink_msg_relay_status_pack_status(system_id, component_id, _status, msg, relay_status->time_boot_ms, relay_status->on, relay_status->present);
191}
192
193/**
194 * @brief Send a relay_status message
195 * @param chan MAVLink channel to send the message
196 *
197 * @param time_boot_ms [ms] Timestamp (time since system boot).
198 * @param on Relay states. Relay instance numbers are represented as individual bits in this mask by offset.
199 * @param present Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.
200 */
201#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
202
203static inline void mavlink_msg_relay_status_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t on, uint16_t present)
204{
205#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
206 char buf[MAVLINK_MSG_ID_RELAY_STATUS_LEN];
207 _mav_put_uint32_t(buf, 0, time_boot_ms);
208 _mav_put_uint16_t(buf, 4, on);
209 _mav_put_uint16_t(buf, 6, present);
210
211 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RELAY_STATUS, buf, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
212#else
213 mavlink_relay_status_t packet;
214 packet.time_boot_ms = time_boot_ms;
215 packet.on = on;
216 packet.present = present;
217
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RELAY_STATUS, (const char *)&packet, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
219#endif
220}
221
222/**
223 * @brief Send a relay_status message
224 * @param chan MAVLink channel to send the message
225 * @param struct The MAVLink struct to serialize
226 */
227static inline void mavlink_msg_relay_status_send_struct(mavlink_channel_t chan, const mavlink_relay_status_t* relay_status)
228{
229#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 mavlink_msg_relay_status_send(chan, relay_status->time_boot_ms, relay_status->on, relay_status->present);
231#else
232 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RELAY_STATUS, (const char *)relay_status, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
233#endif
234}
235
236#if MAVLINK_MSG_ID_RELAY_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
237/*
238 This variant of _send() can be used to save stack space by reusing
239 memory from the receive buffer. The caller provides a
240 mavlink_message_t which is the size of a full mavlink message. This
241 is usually the receive buffer for the channel, and allows a reply to an
242 incoming message with minimum stack space usage.
243 */
244static inline void mavlink_msg_relay_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t on, uint16_t present)
245{
246#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
247 char *buf = (char *)msgbuf;
248 _mav_put_uint32_t(buf, 0, time_boot_ms);
249 _mav_put_uint16_t(buf, 4, on);
250 _mav_put_uint16_t(buf, 6, present);
251
252 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RELAY_STATUS, buf, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
253#else
254 mavlink_relay_status_t *packet = (mavlink_relay_status_t *)msgbuf;
255 packet->time_boot_ms = time_boot_ms;
256 packet->on = on;
257 packet->present = present;
258
259 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RELAY_STATUS, (const char *)packet, MAVLINK_MSG_ID_RELAY_STATUS_MIN_LEN, MAVLINK_MSG_ID_RELAY_STATUS_LEN, MAVLINK_MSG_ID_RELAY_STATUS_CRC);
260#endif
261}
262#endif
263
264#endif
265
266// MESSAGE RELAY_STATUS UNPACKING
267
268
269/**
270 * @brief Get field time_boot_ms from relay_status message
271 *
272 * @return [ms] Timestamp (time since system boot).
273 */
274static inline uint32_t mavlink_msg_relay_status_get_time_boot_ms(const mavlink_message_t* msg)
275{
276 return _MAV_RETURN_uint32_t(msg, 0);
277}
278
279/**
280 * @brief Get field on from relay_status message
281 *
282 * @return Relay states. Relay instance numbers are represented as individual bits in this mask by offset.
283 */
284static inline uint16_t mavlink_msg_relay_status_get_on(const mavlink_message_t* msg)
285{
286 return _MAV_RETURN_uint16_t(msg, 4);
287}
288
289/**
290 * @brief Get field present from relay_status message
291 *
292 * @return Relay present. Relay instance numbers are represented as individual bits in this mask by offset. Bits will be true if a relay instance is configured.
293 */
294static inline uint16_t mavlink_msg_relay_status_get_present(const mavlink_message_t* msg)
295{
296 return _MAV_RETURN_uint16_t(msg, 6);
297}
298
299/**
300 * @brief Decode a relay_status message into a struct
301 *
302 * @param msg The message to decode
303 * @param relay_status C-struct to decode the message contents into
304 */
305static inline void mavlink_msg_relay_status_decode(const mavlink_message_t* msg, mavlink_relay_status_t* relay_status)
306{
307#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
308 relay_status->time_boot_ms = mavlink_msg_relay_status_get_time_boot_ms(msg);
309 relay_status->on = mavlink_msg_relay_status_get_on(msg);
310 relay_status->present = mavlink_msg_relay_status_get_present(msg);
311#else
312 uint8_t len = msg->len < MAVLINK_MSG_ID_RELAY_STATUS_LEN? msg->len : MAVLINK_MSG_ID_RELAY_STATUS_LEN;
313 memset(relay_status, 0, MAVLINK_MSG_ID_RELAY_STATUS_LEN);
314 memcpy(relay_status, _MAV_PAYLOAD(msg), len);
315#endif
316}