You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
12 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE SENS_POWER PACKING
  3. #define MAVLINK_MSG_ID_SENS_POWER 201
  4. MAVPACKED(
  5. typedef struct __mavlink_sens_power_t {
  6. float adc121_vspb_volt; /*< [V] Power board voltage sensor reading*/
  7. float adc121_cspb_amp; /*< [A] Power board current sensor reading*/
  8. float adc121_cs1_amp; /*< [A] Board current sensor 1 reading*/
  9. float adc121_cs2_amp; /*< [A] Board current sensor 2 reading*/
  10. }) mavlink_sens_power_t;
  11. #define MAVLINK_MSG_ID_SENS_POWER_LEN 16
  12. #define MAVLINK_MSG_ID_SENS_POWER_MIN_LEN 16
  13. #define MAVLINK_MSG_ID_201_LEN 16
  14. #define MAVLINK_MSG_ID_201_MIN_LEN 16
  15. #define MAVLINK_MSG_ID_SENS_POWER_CRC 218
  16. #define MAVLINK_MSG_ID_201_CRC 218
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_SENS_POWER { \
  19. 201, \
  20. "SENS_POWER", \
  21. 4, \
  22. { { "adc121_vspb_volt", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sens_power_t, adc121_vspb_volt) }, \
  23. { "adc121_cspb_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_sens_power_t, adc121_cspb_amp) }, \
  24. { "adc121_cs1_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_sens_power_t, adc121_cs1_amp) }, \
  25. { "adc121_cs2_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sens_power_t, adc121_cs2_amp) }, \
  26. } \
  27. }
  28. #else
  29. #define MAVLINK_MESSAGE_INFO_SENS_POWER { \
  30. "SENS_POWER", \
  31. 4, \
  32. { { "adc121_vspb_volt", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_sens_power_t, adc121_vspb_volt) }, \
  33. { "adc121_cspb_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_sens_power_t, adc121_cspb_amp) }, \
  34. { "adc121_cs1_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_sens_power_t, adc121_cs1_amp) }, \
  35. { "adc121_cs2_amp", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_sens_power_t, adc121_cs2_amp) }, \
  36. } \
  37. }
  38. #endif
  39. /**
  40. * @brief Pack a sens_power message
  41. * @param system_id ID of this system
  42. * @param component_id ID of this component (e.g. 200 for IMU)
  43. * @param msg The MAVLink message to compress the data into
  44. *
  45. * @param adc121_vspb_volt [V] Power board voltage sensor reading
  46. * @param adc121_cspb_amp [A] Power board current sensor reading
  47. * @param adc121_cs1_amp [A] Board current sensor 1 reading
  48. * @param adc121_cs2_amp [A] Board current sensor 2 reading
  49. * @return length of the message in bytes (excluding serial stream start sign)
  50. */
  51. static inline uint16_t mavlink_msg_sens_power_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  52. float adc121_vspb_volt, float adc121_cspb_amp, float adc121_cs1_amp, float adc121_cs2_amp)
  53. {
  54. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  55. char buf[MAVLINK_MSG_ID_SENS_POWER_LEN];
  56. _mav_put_float(buf, 0, adc121_vspb_volt);
  57. _mav_put_float(buf, 4, adc121_cspb_amp);
  58. _mav_put_float(buf, 8, adc121_cs1_amp);
  59. _mav_put_float(buf, 12, adc121_cs2_amp);
  60. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_POWER_LEN);
  61. #else
  62. mavlink_sens_power_t packet;
  63. packet.adc121_vspb_volt = adc121_vspb_volt;
  64. packet.adc121_cspb_amp = adc121_cspb_amp;
  65. packet.adc121_cs1_amp = adc121_cs1_amp;
  66. packet.adc121_cs2_amp = adc121_cs2_amp;
  67. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_POWER_LEN);
  68. #endif
  69. msg->msgid = MAVLINK_MSG_ID_SENS_POWER;
  70. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  71. }
  72. /**
  73. * @brief Pack a sens_power 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 adc121_vspb_volt [V] Power board voltage sensor reading
  79. * @param adc121_cspb_amp [A] Power board current sensor reading
  80. * @param adc121_cs1_amp [A] Board current sensor 1 reading
  81. * @param adc121_cs2_amp [A] Board current sensor 2 reading
  82. * @return length of the message in bytes (excluding serial stream start sign)
  83. */
  84. static inline uint16_t mavlink_msg_sens_power_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  85. mavlink_message_t* msg,
  86. float adc121_vspb_volt,float adc121_cspb_amp,float adc121_cs1_amp,float adc121_cs2_amp)
  87. {
  88. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  89. char buf[MAVLINK_MSG_ID_SENS_POWER_LEN];
  90. _mav_put_float(buf, 0, adc121_vspb_volt);
  91. _mav_put_float(buf, 4, adc121_cspb_amp);
  92. _mav_put_float(buf, 8, adc121_cs1_amp);
  93. _mav_put_float(buf, 12, adc121_cs2_amp);
  94. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENS_POWER_LEN);
  95. #else
  96. mavlink_sens_power_t packet;
  97. packet.adc121_vspb_volt = adc121_vspb_volt;
  98. packet.adc121_cspb_amp = adc121_cspb_amp;
  99. packet.adc121_cs1_amp = adc121_cs1_amp;
  100. packet.adc121_cs2_amp = adc121_cs2_amp;
  101. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENS_POWER_LEN);
  102. #endif
  103. msg->msgid = MAVLINK_MSG_ID_SENS_POWER;
  104. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  105. }
  106. /**
  107. * @brief Encode a sens_power struct
  108. *
  109. * @param system_id ID of this system
  110. * @param component_id ID of this component (e.g. 200 for IMU)
  111. * @param msg The MAVLink message to compress the data into
  112. * @param sens_power C-struct to read the message contents from
  113. */
  114. static inline uint16_t mavlink_msg_sens_power_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sens_power_t* sens_power)
  115. {
  116. return mavlink_msg_sens_power_pack(system_id, component_id, msg, sens_power->adc121_vspb_volt, sens_power->adc121_cspb_amp, sens_power->adc121_cs1_amp, sens_power->adc121_cs2_amp);
  117. }
  118. /**
  119. * @brief Encode a sens_power struct on a channel
  120. *
  121. * @param system_id ID of this system
  122. * @param component_id ID of this component (e.g. 200 for IMU)
  123. * @param chan The MAVLink channel this message will be sent over
  124. * @param msg The MAVLink message to compress the data into
  125. * @param sens_power C-struct to read the message contents from
  126. */
  127. static inline uint16_t mavlink_msg_sens_power_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sens_power_t* sens_power)
  128. {
  129. return mavlink_msg_sens_power_pack_chan(system_id, component_id, chan, msg, sens_power->adc121_vspb_volt, sens_power->adc121_cspb_amp, sens_power->adc121_cs1_amp, sens_power->adc121_cs2_amp);
  130. }
  131. /**
  132. * @brief Send a sens_power message
  133. * @param chan MAVLink channel to send the message
  134. *
  135. * @param adc121_vspb_volt [V] Power board voltage sensor reading
  136. * @param adc121_cspb_amp [A] Power board current sensor reading
  137. * @param adc121_cs1_amp [A] Board current sensor 1 reading
  138. * @param adc121_cs2_amp [A] Board current sensor 2 reading
  139. */
  140. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  141. static inline void mavlink_msg_sens_power_send(mavlink_channel_t chan, float adc121_vspb_volt, float adc121_cspb_amp, float adc121_cs1_amp, float adc121_cs2_amp)
  142. {
  143. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  144. char buf[MAVLINK_MSG_ID_SENS_POWER_LEN];
  145. _mav_put_float(buf, 0, adc121_vspb_volt);
  146. _mav_put_float(buf, 4, adc121_cspb_amp);
  147. _mav_put_float(buf, 8, adc121_cs1_amp);
  148. _mav_put_float(buf, 12, adc121_cs2_amp);
  149. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENS_POWER, buf, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  150. #else
  151. mavlink_sens_power_t packet;
  152. packet.adc121_vspb_volt = adc121_vspb_volt;
  153. packet.adc121_cspb_amp = adc121_cspb_amp;
  154. packet.adc121_cs1_amp = adc121_cs1_amp;
  155. packet.adc121_cs2_amp = adc121_cs2_amp;
  156. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENS_POWER, (const char *)&packet, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  157. #endif
  158. }
  159. /**
  160. * @brief Send a sens_power message
  161. * @param chan MAVLink channel to send the message
  162. * @param struct The MAVLink struct to serialize
  163. */
  164. static inline void mavlink_msg_sens_power_send_struct(mavlink_channel_t chan, const mavlink_sens_power_t* sens_power)
  165. {
  166. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  167. mavlink_msg_sens_power_send(chan, sens_power->adc121_vspb_volt, sens_power->adc121_cspb_amp, sens_power->adc121_cs1_amp, sens_power->adc121_cs2_amp);
  168. #else
  169. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENS_POWER, (const char *)sens_power, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  170. #endif
  171. }
  172. #if MAVLINK_MSG_ID_SENS_POWER_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  173. /*
  174. This varient of _send() can be used to save stack space by re-using
  175. memory from the receive buffer. The caller provides a
  176. mavlink_message_t which is the size of a full mavlink message. This
  177. is usually the receive buffer for the channel, and allows a reply to an
  178. incoming message with minimum stack space usage.
  179. */
  180. static inline void mavlink_msg_sens_power_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float adc121_vspb_volt, float adc121_cspb_amp, float adc121_cs1_amp, float adc121_cs2_amp)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char *buf = (char *)msgbuf;
  184. _mav_put_float(buf, 0, adc121_vspb_volt);
  185. _mav_put_float(buf, 4, adc121_cspb_amp);
  186. _mav_put_float(buf, 8, adc121_cs1_amp);
  187. _mav_put_float(buf, 12, adc121_cs2_amp);
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENS_POWER, buf, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  189. #else
  190. mavlink_sens_power_t *packet = (mavlink_sens_power_t *)msgbuf;
  191. packet->adc121_vspb_volt = adc121_vspb_volt;
  192. packet->adc121_cspb_amp = adc121_cspb_amp;
  193. packet->adc121_cs1_amp = adc121_cs1_amp;
  194. packet->adc121_cs2_amp = adc121_cs2_amp;
  195. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENS_POWER, (const char *)packet, MAVLINK_MSG_ID_SENS_POWER_MIN_LEN, MAVLINK_MSG_ID_SENS_POWER_LEN, MAVLINK_MSG_ID_SENS_POWER_CRC);
  196. #endif
  197. }
  198. #endif
  199. #endif
  200. // MESSAGE SENS_POWER UNPACKING
  201. /**
  202. * @brief Get field adc121_vspb_volt from sens_power message
  203. *
  204. * @return [V] Power board voltage sensor reading
  205. */
  206. static inline float mavlink_msg_sens_power_get_adc121_vspb_volt(const mavlink_message_t* msg)
  207. {
  208. return _MAV_RETURN_float(msg, 0);
  209. }
  210. /**
  211. * @brief Get field adc121_cspb_amp from sens_power message
  212. *
  213. * @return [A] Power board current sensor reading
  214. */
  215. static inline float mavlink_msg_sens_power_get_adc121_cspb_amp(const mavlink_message_t* msg)
  216. {
  217. return _MAV_RETURN_float(msg, 4);
  218. }
  219. /**
  220. * @brief Get field adc121_cs1_amp from sens_power message
  221. *
  222. * @return [A] Board current sensor 1 reading
  223. */
  224. static inline float mavlink_msg_sens_power_get_adc121_cs1_amp(const mavlink_message_t* msg)
  225. {
  226. return _MAV_RETURN_float(msg, 8);
  227. }
  228. /**
  229. * @brief Get field adc121_cs2_amp from sens_power message
  230. *
  231. * @return [A] Board current sensor 2 reading
  232. */
  233. static inline float mavlink_msg_sens_power_get_adc121_cs2_amp(const mavlink_message_t* msg)
  234. {
  235. return _MAV_RETURN_float(msg, 12);
  236. }
  237. /**
  238. * @brief Decode a sens_power message into a struct
  239. *
  240. * @param msg The message to decode
  241. * @param sens_power C-struct to decode the message contents into
  242. */
  243. static inline void mavlink_msg_sens_power_decode(const mavlink_message_t* msg, mavlink_sens_power_t* sens_power)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. sens_power->adc121_vspb_volt = mavlink_msg_sens_power_get_adc121_vspb_volt(msg);
  247. sens_power->adc121_cspb_amp = mavlink_msg_sens_power_get_adc121_cspb_amp(msg);
  248. sens_power->adc121_cs1_amp = mavlink_msg_sens_power_get_adc121_cs1_amp(msg);
  249. sens_power->adc121_cs2_amp = mavlink_msg_sens_power_get_adc121_cs2_amp(msg);
  250. #else
  251. uint8_t len = msg->len < MAVLINK_MSG_ID_SENS_POWER_LEN? msg->len : MAVLINK_MSG_ID_SENS_POWER_LEN;
  252. memset(sens_power, 0, MAVLINK_MSG_ID_SENS_POWER_LEN);
  253. memcpy(sens_power, _MAV_PAYLOAD(msg), len);
  254. #endif
  255. }