Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // MESSAGE HWSTATUS PACKING |
2 | |||
3 | #define MAVLINK_MSG_ID_HWSTATUS 165 |
||
4 | |||
5 | typedef struct __mavlink_hwstatus_t |
||
6 | { |
||
7 | uint16_t Vcc; ///< board voltage (mV) |
||
8 | uint8_t I2Cerr; ///< I2C error count |
||
9 | } mavlink_hwstatus_t; |
||
10 | |||
11 | #define MAVLINK_MSG_ID_HWSTATUS_LEN 3 |
||
12 | #define MAVLINK_MSG_ID_165_LEN 3 |
||
13 | |||
14 | |||
15 | |||
16 | #define MAVLINK_MESSAGE_INFO_HWSTATUS { \ |
||
17 | "HWSTATUS", \ |
||
18 | 2, \ |
||
19 | { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_hwstatus_t, Vcc) }, \ |
||
20 | { "I2Cerr", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_hwstatus_t, I2Cerr) }, \ |
||
21 | } \ |
||
22 | } |
||
23 | |||
24 | |||
25 | /** |
||
26 | * @brief Pack a hwstatus message |
||
27 | * @param system_id ID of this system |
||
28 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
29 | * @param msg The MAVLink message to compress the data into |
||
30 | * |
||
31 | * @param Vcc board voltage (mV) |
||
32 | * @param I2Cerr I2C error count |
||
33 | * @return length of the message in bytes (excluding serial stream start sign) |
||
34 | */ |
||
35 | static inline uint16_t mavlink_msg_hwstatus_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, |
||
36 | uint16_t Vcc, uint8_t I2Cerr) |
||
37 | { |
||
38 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
39 | char buf[3]; |
||
40 | _mav_put_uint16_t(buf, 0, Vcc); |
||
41 | _mav_put_uint8_t(buf, 2, I2Cerr); |
||
42 | |||
43 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); |
||
44 | #else |
||
45 | mavlink_hwstatus_t packet; |
||
46 | packet.Vcc = Vcc; |
||
47 | packet.I2Cerr = I2Cerr; |
||
48 | |||
49 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); |
||
50 | #endif |
||
51 | |||
52 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS; |
||
53 | return mavlink_finalize_message(msg, system_id, component_id, 3, 21); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @brief Pack a hwstatus message on a channel |
||
58 | * @param system_id ID of this system |
||
59 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
60 | * @param chan The MAVLink channel this message was sent over |
||
61 | * @param msg The MAVLink message to compress the data into |
||
62 | * @param Vcc board voltage (mV) |
||
63 | * @param I2Cerr I2C error count |
||
64 | * @return length of the message in bytes (excluding serial stream start sign) |
||
65 | */ |
||
66 | static inline uint16_t mavlink_msg_hwstatus_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, |
||
67 | mavlink_message_t* msg, |
||
68 | uint16_t Vcc,uint8_t I2Cerr) |
||
69 | { |
||
70 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
71 | char buf[3]; |
||
72 | _mav_put_uint16_t(buf, 0, Vcc); |
||
73 | _mav_put_uint8_t(buf, 2, I2Cerr); |
||
74 | |||
75 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); |
||
76 | #else |
||
77 | mavlink_hwstatus_t packet; |
||
78 | packet.Vcc = Vcc; |
||
79 | packet.I2Cerr = I2Cerr; |
||
80 | |||
81 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); |
||
82 | #endif |
||
83 | |||
84 | msg->msgid = MAVLINK_MSG_ID_HWSTATUS; |
||
85 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 21); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @brief Encode a hwstatus struct into a message |
||
90 | * |
||
91 | * @param system_id ID of this system |
||
92 | * @param component_id ID of this component (e.g. 200 for IMU) |
||
93 | * @param msg The MAVLink message to compress the data into |
||
94 | * @param hwstatus C-struct to read the message contents from |
||
95 | */ |
||
96 | static inline uint16_t mavlink_msg_hwstatus_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hwstatus_t* hwstatus) |
||
97 | { |
||
98 | return mavlink_msg_hwstatus_pack(system_id, component_id, msg, hwstatus->Vcc, hwstatus->I2Cerr); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @brief Send a hwstatus message |
||
103 | * @param chan MAVLink channel to send the message |
||
104 | * |
||
105 | * @param Vcc board voltage (mV) |
||
106 | * @param I2Cerr I2C error count |
||
107 | */ |
||
108 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
||
109 | |||
110 | static inline void mavlink_msg_hwstatus_send(mavlink_channel_t chan, uint16_t Vcc, uint8_t I2Cerr) |
||
111 | { |
||
112 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
113 | char buf[3]; |
||
114 | _mav_put_uint16_t(buf, 0, Vcc); |
||
115 | _mav_put_uint8_t(buf, 2, I2Cerr); |
||
116 | |||
117 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, buf, 3, 21); |
||
118 | #else |
||
119 | mavlink_hwstatus_t packet; |
||
120 | packet.Vcc = Vcc; |
||
121 | packet.I2Cerr = I2Cerr; |
||
122 | |||
123 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, (const char *)&packet, 3, 21); |
||
124 | #endif |
||
125 | } |
||
126 | |||
127 | #endif |
||
128 | |||
129 | // MESSAGE HWSTATUS UNPACKING |
||
130 | |||
131 | |||
132 | /** |
||
133 | * @brief Get field Vcc from hwstatus message |
||
134 | * |
||
135 | * @return board voltage (mV) |
||
136 | */ |
||
137 | static inline uint16_t mavlink_msg_hwstatus_get_Vcc(const mavlink_message_t* msg) |
||
138 | { |
||
139 | return _MAV_RETURN_uint16_t(msg, 0); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @brief Get field I2Cerr from hwstatus message |
||
144 | * |
||
145 | * @return I2C error count |
||
146 | */ |
||
147 | static inline uint8_t mavlink_msg_hwstatus_get_I2Cerr(const mavlink_message_t* msg) |
||
148 | { |
||
149 | return _MAV_RETURN_uint8_t(msg, 2); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @brief Decode a hwstatus message into a struct |
||
154 | * |
||
155 | * @param msg The message to decode |
||
156 | * @param hwstatus C-struct to decode the message contents into |
||
157 | */ |
||
158 | static inline void mavlink_msg_hwstatus_decode(const mavlink_message_t* msg, mavlink_hwstatus_t* hwstatus) |
||
159 | { |
||
160 | #if MAVLINK_NEED_BYTE_SWAP |
||
161 | hwstatus->Vcc = mavlink_msg_hwstatus_get_Vcc(msg); |
||
162 | hwstatus->I2Cerr = mavlink_msg_hwstatus_get_I2Cerr(msg); |
||
163 | #else |
||
164 | memcpy(hwstatus, _MAV_PAYLOAD(msg), 3); |
||
165 | #endif |
||
166 | } |