Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_uavcan_node_status.h
blob6f1d8d8fd3f74cab592cff7685beddbe2ace01e1
1 #pragma once
2 // MESSAGE UAVCAN_NODE_STATUS PACKING
4 #define MAVLINK_MSG_ID_UAVCAN_NODE_STATUS 310
7 typedef struct __mavlink_uavcan_node_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 of the number.*/
9 uint32_t uptime_sec; /*< [s] Time since the start-up of the node.*/
10 uint16_t vendor_specific_status_code; /*< Vendor-specific status information.*/
11 uint8_t health; /*< Generalized node health status.*/
12 uint8_t mode; /*< Generalized operating mode.*/
13 uint8_t sub_mode; /*< Not used currently.*/
14 } mavlink_uavcan_node_status_t;
16 #define MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN 17
17 #define MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN 17
18 #define MAVLINK_MSG_ID_310_LEN 17
19 #define MAVLINK_MSG_ID_310_MIN_LEN 17
21 #define MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC 28
22 #define MAVLINK_MSG_ID_310_CRC 28
26 #if MAVLINK_COMMAND_24BIT
27 #define MAVLINK_MESSAGE_INFO_UAVCAN_NODE_STATUS { \
28 310, \
29 "UAVCAN_NODE_STATUS", \
30 6, \
31 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_uavcan_node_status_t, time_usec) }, \
32 { "uptime_sec", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_uavcan_node_status_t, uptime_sec) }, \
33 { "health", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_uavcan_node_status_t, health) }, \
34 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 15, offsetof(mavlink_uavcan_node_status_t, mode) }, \
35 { "sub_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_uavcan_node_status_t, sub_mode) }, \
36 { "vendor_specific_status_code", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_uavcan_node_status_t, vendor_specific_status_code) }, \
37 } \
39 #else
40 #define MAVLINK_MESSAGE_INFO_UAVCAN_NODE_STATUS { \
41 "UAVCAN_NODE_STATUS", \
42 6, \
43 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_uavcan_node_status_t, time_usec) }, \
44 { "uptime_sec", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_uavcan_node_status_t, uptime_sec) }, \
45 { "health", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_uavcan_node_status_t, health) }, \
46 { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 15, offsetof(mavlink_uavcan_node_status_t, mode) }, \
47 { "sub_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_uavcan_node_status_t, sub_mode) }, \
48 { "vendor_specific_status_code", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_uavcan_node_status_t, vendor_specific_status_code) }, \
49 } \
51 #endif
53 /**
54 * @brief Pack a uavcan_node_status message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
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 of the number.
60 * @param uptime_sec [s] Time since the start-up of the node.
61 * @param health Generalized node health status.
62 * @param mode Generalized operating mode.
63 * @param sub_mode Not used currently.
64 * @param vendor_specific_status_code Vendor-specific status information.
65 * @return length of the message in bytes (excluding serial stream start sign)
67 static inline uint16_t mavlink_msg_uavcan_node_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 uint64_t time_usec, uint32_t uptime_sec, uint8_t health, uint8_t mode, uint8_t sub_mode, uint16_t vendor_specific_status_code)
70 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN];
72 _mav_put_uint64_t(buf, 0, time_usec);
73 _mav_put_uint32_t(buf, 8, uptime_sec);
74 _mav_put_uint16_t(buf, 12, vendor_specific_status_code);
75 _mav_put_uint8_t(buf, 14, health);
76 _mav_put_uint8_t(buf, 15, mode);
77 _mav_put_uint8_t(buf, 16, sub_mode);
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN);
80 #else
81 mavlink_uavcan_node_status_t packet;
82 packet.time_usec = time_usec;
83 packet.uptime_sec = uptime_sec;
84 packet.vendor_specific_status_code = vendor_specific_status_code;
85 packet.health = health;
86 packet.mode = mode;
87 packet.sub_mode = sub_mode;
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN);
90 #endif
92 msg->msgid = MAVLINK_MSG_ID_UAVCAN_NODE_STATUS;
93 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
96 /**
97 * @brief Pack a uavcan_node_status message on a channel
98 * @param system_id ID of this system
99 * @param component_id ID of this component (e.g. 200 for IMU)
100 * @param chan The MAVLink channel this message will be sent over
101 * @param msg The MAVLink message to compress the data into
102 * @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 of the number.
103 * @param uptime_sec [s] Time since the start-up of the node.
104 * @param health Generalized node health status.
105 * @param mode Generalized operating mode.
106 * @param sub_mode Not used currently.
107 * @param vendor_specific_status_code Vendor-specific status information.
108 * @return length of the message in bytes (excluding serial stream start sign)
110 static inline uint16_t mavlink_msg_uavcan_node_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
111 mavlink_message_t* msg,
112 uint64_t time_usec,uint32_t uptime_sec,uint8_t health,uint8_t mode,uint8_t sub_mode,uint16_t vendor_specific_status_code)
114 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 char buf[MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN];
116 _mav_put_uint64_t(buf, 0, time_usec);
117 _mav_put_uint32_t(buf, 8, uptime_sec);
118 _mav_put_uint16_t(buf, 12, vendor_specific_status_code);
119 _mav_put_uint8_t(buf, 14, health);
120 _mav_put_uint8_t(buf, 15, mode);
121 _mav_put_uint8_t(buf, 16, sub_mode);
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN);
124 #else
125 mavlink_uavcan_node_status_t packet;
126 packet.time_usec = time_usec;
127 packet.uptime_sec = uptime_sec;
128 packet.vendor_specific_status_code = vendor_specific_status_code;
129 packet.health = health;
130 packet.mode = mode;
131 packet.sub_mode = sub_mode;
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN);
134 #endif
136 msg->msgid = MAVLINK_MSG_ID_UAVCAN_NODE_STATUS;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
141 * @brief Encode a uavcan_node_status struct
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param msg The MAVLink message to compress the data into
146 * @param uavcan_node_status C-struct to read the message contents from
148 static inline uint16_t mavlink_msg_uavcan_node_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_uavcan_node_status_t* uavcan_node_status)
150 return mavlink_msg_uavcan_node_status_pack(system_id, component_id, msg, uavcan_node_status->time_usec, uavcan_node_status->uptime_sec, uavcan_node_status->health, uavcan_node_status->mode, uavcan_node_status->sub_mode, uavcan_node_status->vendor_specific_status_code);
154 * @brief Encode a uavcan_node_status struct on a channel
156 * @param system_id ID of this system
157 * @param component_id ID of this component (e.g. 200 for IMU)
158 * @param chan The MAVLink channel this message will be sent over
159 * @param msg The MAVLink message to compress the data into
160 * @param uavcan_node_status C-struct to read the message contents from
162 static inline uint16_t mavlink_msg_uavcan_node_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_uavcan_node_status_t* uavcan_node_status)
164 return mavlink_msg_uavcan_node_status_pack_chan(system_id, component_id, chan, msg, uavcan_node_status->time_usec, uavcan_node_status->uptime_sec, uavcan_node_status->health, uavcan_node_status->mode, uavcan_node_status->sub_mode, uavcan_node_status->vendor_specific_status_code);
168 * @brief Send a uavcan_node_status message
169 * @param chan MAVLink channel to send the message
171 * @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 of the number.
172 * @param uptime_sec [s] Time since the start-up of the node.
173 * @param health Generalized node health status.
174 * @param mode Generalized operating mode.
175 * @param sub_mode Not used currently.
176 * @param vendor_specific_status_code Vendor-specific status information.
178 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
180 static inline void mavlink_msg_uavcan_node_status_send(mavlink_channel_t chan, uint64_t time_usec, uint32_t uptime_sec, uint8_t health, uint8_t mode, uint8_t sub_mode, uint16_t vendor_specific_status_code)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN];
184 _mav_put_uint64_t(buf, 0, time_usec);
185 _mav_put_uint32_t(buf, 8, uptime_sec);
186 _mav_put_uint16_t(buf, 12, vendor_specific_status_code);
187 _mav_put_uint8_t(buf, 14, health);
188 _mav_put_uint8_t(buf, 15, mode);
189 _mav_put_uint8_t(buf, 16, sub_mode);
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS, buf, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
192 #else
193 mavlink_uavcan_node_status_t packet;
194 packet.time_usec = time_usec;
195 packet.uptime_sec = uptime_sec;
196 packet.vendor_specific_status_code = vendor_specific_status_code;
197 packet.health = health;
198 packet.mode = mode;
199 packet.sub_mode = sub_mode;
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS, (const char *)&packet, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
202 #endif
206 * @brief Send a uavcan_node_status message
207 * @param chan MAVLink channel to send the message
208 * @param struct The MAVLink struct to serialize
210 static inline void mavlink_msg_uavcan_node_status_send_struct(mavlink_channel_t chan, const mavlink_uavcan_node_status_t* uavcan_node_status)
212 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 mavlink_msg_uavcan_node_status_send(chan, uavcan_node_status->time_usec, uavcan_node_status->uptime_sec, uavcan_node_status->health, uavcan_node_status->mode, uavcan_node_status->sub_mode, uavcan_node_status->vendor_specific_status_code);
214 #else
215 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS, (const char *)uavcan_node_status, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
216 #endif
219 #if MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
221 This varient of _send() can be used to save stack space by re-using
222 memory from the receive buffer. The caller provides a
223 mavlink_message_t which is the size of a full mavlink message. This
224 is usually the receive buffer for the channel, and allows a reply to an
225 incoming message with minimum stack space usage.
227 static inline void mavlink_msg_uavcan_node_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint32_t uptime_sec, uint8_t health, uint8_t mode, uint8_t sub_mode, uint16_t vendor_specific_status_code)
229 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 char *buf = (char *)msgbuf;
231 _mav_put_uint64_t(buf, 0, time_usec);
232 _mav_put_uint32_t(buf, 8, uptime_sec);
233 _mav_put_uint16_t(buf, 12, vendor_specific_status_code);
234 _mav_put_uint8_t(buf, 14, health);
235 _mav_put_uint8_t(buf, 15, mode);
236 _mav_put_uint8_t(buf, 16, sub_mode);
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS, buf, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
239 #else
240 mavlink_uavcan_node_status_t *packet = (mavlink_uavcan_node_status_t *)msgbuf;
241 packet->time_usec = time_usec;
242 packet->uptime_sec = uptime_sec;
243 packet->vendor_specific_status_code = vendor_specific_status_code;
244 packet->health = health;
245 packet->mode = mode;
246 packet->sub_mode = sub_mode;
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS, (const char *)packet, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_MIN_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_CRC);
249 #endif
251 #endif
253 #endif
255 // MESSAGE UAVCAN_NODE_STATUS UNPACKING
259 * @brief Get field time_usec from uavcan_node_status message
261 * @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 of the number.
263 static inline uint64_t mavlink_msg_uavcan_node_status_get_time_usec(const mavlink_message_t* msg)
265 return _MAV_RETURN_uint64_t(msg, 0);
269 * @brief Get field uptime_sec from uavcan_node_status message
271 * @return [s] Time since the start-up of the node.
273 static inline uint32_t mavlink_msg_uavcan_node_status_get_uptime_sec(const mavlink_message_t* msg)
275 return _MAV_RETURN_uint32_t(msg, 8);
279 * @brief Get field health from uavcan_node_status message
281 * @return Generalized node health status.
283 static inline uint8_t mavlink_msg_uavcan_node_status_get_health(const mavlink_message_t* msg)
285 return _MAV_RETURN_uint8_t(msg, 14);
289 * @brief Get field mode from uavcan_node_status message
291 * @return Generalized operating mode.
293 static inline uint8_t mavlink_msg_uavcan_node_status_get_mode(const mavlink_message_t* msg)
295 return _MAV_RETURN_uint8_t(msg, 15);
299 * @brief Get field sub_mode from uavcan_node_status message
301 * @return Not used currently.
303 static inline uint8_t mavlink_msg_uavcan_node_status_get_sub_mode(const mavlink_message_t* msg)
305 return _MAV_RETURN_uint8_t(msg, 16);
309 * @brief Get field vendor_specific_status_code from uavcan_node_status message
311 * @return Vendor-specific status information.
313 static inline uint16_t mavlink_msg_uavcan_node_status_get_vendor_specific_status_code(const mavlink_message_t* msg)
315 return _MAV_RETURN_uint16_t(msg, 12);
319 * @brief Decode a uavcan_node_status message into a struct
321 * @param msg The message to decode
322 * @param uavcan_node_status C-struct to decode the message contents into
324 static inline void mavlink_msg_uavcan_node_status_decode(const mavlink_message_t* msg, mavlink_uavcan_node_status_t* uavcan_node_status)
326 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
327 uavcan_node_status->time_usec = mavlink_msg_uavcan_node_status_get_time_usec(msg);
328 uavcan_node_status->uptime_sec = mavlink_msg_uavcan_node_status_get_uptime_sec(msg);
329 uavcan_node_status->vendor_specific_status_code = mavlink_msg_uavcan_node_status_get_vendor_specific_status_code(msg);
330 uavcan_node_status->health = mavlink_msg_uavcan_node_status_get_health(msg);
331 uavcan_node_status->mode = mavlink_msg_uavcan_node_status_get_mode(msg);
332 uavcan_node_status->sub_mode = mavlink_msg_uavcan_node_status_get_sub_mode(msg);
333 #else
334 uint8_t len = msg->len < MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN? msg->len : MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN;
335 memset(uavcan_node_status, 0, MAVLINK_MSG_ID_UAVCAN_NODE_STATUS_LEN);
336 memcpy(uavcan_node_status, _MAV_PAYLOAD(msg), len);
337 #endif