mavlink_msg_shangfei_bms.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. #pragma once
  2. // MESSAGE SHANGFEI_BMS PACKING
  3. #define MAVLINK_MSG_ID_SHANGFEI_BMS 53310
  4. typedef struct __mavlink_shangfei_bms_t {
  5. uint32_t time_boot_ms; /*< [ms] Timestamp in ms from system boot.*/
  6. uint16_t bat_voltage; /*< [dV] Battery voltage.*/
  7. int16_t bat_current; /*< [dA] Battery current.*/
  8. uint16_t hvb_voltage; /*< [dV] High volt-box voltage.*/
  9. int8_t bat_maxtemp; /*< Battery Max_temperature.*/
  10. uint8_t cap_percent; /*< [%] Battery capacity.*/
  11. uint8_t bat_id; /*< Battery id.*/
  12. uint8_t err_code; /*< Error code.*/
  13. int8_t hvb_temp; /*< High volt-box temperature.*/
  14. } mavlink_shangfei_bms_t;
  15. #define MAVLINK_MSG_ID_SHANGFEI_BMS_LEN 15
  16. #define MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN 15
  17. #define MAVLINK_MSG_ID_53310_LEN 15
  18. #define MAVLINK_MSG_ID_53310_MIN_LEN 15
  19. #define MAVLINK_MSG_ID_SHANGFEI_BMS_CRC 63
  20. #define MAVLINK_MSG_ID_53310_CRC 63
  21. #if MAVLINK_COMMAND_24BIT
  22. #define MAVLINK_MESSAGE_INFO_SHANGFEI_BMS { \
  23. 53310, \
  24. "SHANGFEI_BMS", \
  25. 9, \
  26. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_shangfei_bms_t, time_boot_ms) }, \
  27. { "bat_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_shangfei_bms_t, bat_voltage) }, \
  28. { "bat_current", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_shangfei_bms_t, bat_current) }, \
  29. { "bat_maxtemp", NULL, MAVLINK_TYPE_INT8_T, 0, 10, offsetof(mavlink_shangfei_bms_t, bat_maxtemp) }, \
  30. { "cap_percent", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_shangfei_bms_t, cap_percent) }, \
  31. { "bat_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_shangfei_bms_t, bat_id) }, \
  32. { "err_code", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_shangfei_bms_t, err_code) }, \
  33. { "hvb_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_shangfei_bms_t, hvb_voltage) }, \
  34. { "hvb_temp", NULL, MAVLINK_TYPE_INT8_T, 0, 14, offsetof(mavlink_shangfei_bms_t, hvb_temp) }, \
  35. } \
  36. }
  37. #else
  38. #define MAVLINK_MESSAGE_INFO_SHANGFEI_BMS { \
  39. "SHANGFEI_BMS", \
  40. 9, \
  41. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_shangfei_bms_t, time_boot_ms) }, \
  42. { "bat_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_shangfei_bms_t, bat_voltage) }, \
  43. { "bat_current", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_shangfei_bms_t, bat_current) }, \
  44. { "bat_maxtemp", NULL, MAVLINK_TYPE_INT8_T, 0, 10, offsetof(mavlink_shangfei_bms_t, bat_maxtemp) }, \
  45. { "cap_percent", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_shangfei_bms_t, cap_percent) }, \
  46. { "bat_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_shangfei_bms_t, bat_id) }, \
  47. { "err_code", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_shangfei_bms_t, err_code) }, \
  48. { "hvb_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_shangfei_bms_t, hvb_voltage) }, \
  49. { "hvb_temp", NULL, MAVLINK_TYPE_INT8_T, 0, 14, offsetof(mavlink_shangfei_bms_t, hvb_temp) }, \
  50. } \
  51. }
  52. #endif
  53. /**
  54. * @brief Pack a shangfei_bms 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
  58. *
  59. * @param time_boot_ms [ms] Timestamp in ms from system boot.
  60. * @param bat_voltage [dV] Battery voltage.
  61. * @param bat_current [dA] Battery current.
  62. * @param bat_maxtemp Battery Max_temperature.
  63. * @param cap_percent [%] Battery capacity.
  64. * @param bat_id Battery id.
  65. * @param err_code Error code.
  66. * @param hvb_voltage [dV] High volt-box voltage.
  67. * @param hvb_temp High volt-box temperature.
  68. * @return length of the message in bytes (excluding serial stream start sign)
  69. */
  70. static inline uint16_t mavlink_msg_shangfei_bms_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  71. uint32_t time_boot_ms, uint16_t bat_voltage, int16_t bat_current, int8_t bat_maxtemp, uint8_t cap_percent, uint8_t bat_id, uint8_t err_code, uint16_t hvb_voltage, int8_t hvb_temp)
  72. {
  73. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  74. char buf[MAVLINK_MSG_ID_SHANGFEI_BMS_LEN];
  75. _mav_put_uint32_t(buf, 0, time_boot_ms);
  76. _mav_put_uint16_t(buf, 4, bat_voltage);
  77. _mav_put_int16_t(buf, 6, bat_current);
  78. _mav_put_uint16_t(buf, 8, hvb_voltage);
  79. _mav_put_int8_t(buf, 10, bat_maxtemp);
  80. _mav_put_uint8_t(buf, 11, cap_percent);
  81. _mav_put_uint8_t(buf, 12, bat_id);
  82. _mav_put_uint8_t(buf, 13, err_code);
  83. _mav_put_int8_t(buf, 14, hvb_temp);
  84. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  85. #else
  86. mavlink_shangfei_bms_t packet;
  87. packet.time_boot_ms = time_boot_ms;
  88. packet.bat_voltage = bat_voltage;
  89. packet.bat_current = bat_current;
  90. packet.hvb_voltage = hvb_voltage;
  91. packet.bat_maxtemp = bat_maxtemp;
  92. packet.cap_percent = cap_percent;
  93. packet.bat_id = bat_id;
  94. packet.err_code = err_code;
  95. packet.hvb_temp = hvb_temp;
  96. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  97. #endif
  98. msg->msgid = MAVLINK_MSG_ID_SHANGFEI_BMS;
  99. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  100. }
  101. /**
  102. * @brief Pack a shangfei_bms message
  103. * @param system_id ID of this system
  104. * @param component_id ID of this component (e.g. 200 for IMU)
  105. * @param status MAVLink status structure
  106. * @param msg The MAVLink message to compress the data into
  107. *
  108. * @param time_boot_ms [ms] Timestamp in ms from system boot.
  109. * @param bat_voltage [dV] Battery voltage.
  110. * @param bat_current [dA] Battery current.
  111. * @param bat_maxtemp Battery Max_temperature.
  112. * @param cap_percent [%] Battery capacity.
  113. * @param bat_id Battery id.
  114. * @param err_code Error code.
  115. * @param hvb_voltage [dV] High volt-box voltage.
  116. * @param hvb_temp High volt-box temperature.
  117. * @return length of the message in bytes (excluding serial stream start sign)
  118. */
  119. static inline uint16_t mavlink_msg_shangfei_bms_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  120. uint32_t time_boot_ms, uint16_t bat_voltage, int16_t bat_current, int8_t bat_maxtemp, uint8_t cap_percent, uint8_t bat_id, uint8_t err_code, uint16_t hvb_voltage, int8_t hvb_temp)
  121. {
  122. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  123. char buf[MAVLINK_MSG_ID_SHANGFEI_BMS_LEN];
  124. _mav_put_uint32_t(buf, 0, time_boot_ms);
  125. _mav_put_uint16_t(buf, 4, bat_voltage);
  126. _mav_put_int16_t(buf, 6, bat_current);
  127. _mav_put_uint16_t(buf, 8, hvb_voltage);
  128. _mav_put_int8_t(buf, 10, bat_maxtemp);
  129. _mav_put_uint8_t(buf, 11, cap_percent);
  130. _mav_put_uint8_t(buf, 12, bat_id);
  131. _mav_put_uint8_t(buf, 13, err_code);
  132. _mav_put_int8_t(buf, 14, hvb_temp);
  133. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  134. #else
  135. mavlink_shangfei_bms_t packet;
  136. packet.time_boot_ms = time_boot_ms;
  137. packet.bat_voltage = bat_voltage;
  138. packet.bat_current = bat_current;
  139. packet.hvb_voltage = hvb_voltage;
  140. packet.bat_maxtemp = bat_maxtemp;
  141. packet.cap_percent = cap_percent;
  142. packet.bat_id = bat_id;
  143. packet.err_code = err_code;
  144. packet.hvb_temp = hvb_temp;
  145. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  146. #endif
  147. msg->msgid = MAVLINK_MSG_ID_SHANGFEI_BMS;
  148. #if MAVLINK_CRC_EXTRA
  149. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  150. #else
  151. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  152. #endif
  153. }
  154. /**
  155. * @brief Pack a shangfei_bms message 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 time_boot_ms [ms] Timestamp in ms from system boot.
  161. * @param bat_voltage [dV] Battery voltage.
  162. * @param bat_current [dA] Battery current.
  163. * @param bat_maxtemp Battery Max_temperature.
  164. * @param cap_percent [%] Battery capacity.
  165. * @param bat_id Battery id.
  166. * @param err_code Error code.
  167. * @param hvb_voltage [dV] High volt-box voltage.
  168. * @param hvb_temp High volt-box temperature.
  169. * @return length of the message in bytes (excluding serial stream start sign)
  170. */
  171. static inline uint16_t mavlink_msg_shangfei_bms_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  172. mavlink_message_t* msg,
  173. uint32_t time_boot_ms,uint16_t bat_voltage,int16_t bat_current,int8_t bat_maxtemp,uint8_t cap_percent,uint8_t bat_id,uint8_t err_code,uint16_t hvb_voltage,int8_t hvb_temp)
  174. {
  175. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  176. char buf[MAVLINK_MSG_ID_SHANGFEI_BMS_LEN];
  177. _mav_put_uint32_t(buf, 0, time_boot_ms);
  178. _mav_put_uint16_t(buf, 4, bat_voltage);
  179. _mav_put_int16_t(buf, 6, bat_current);
  180. _mav_put_uint16_t(buf, 8, hvb_voltage);
  181. _mav_put_int8_t(buf, 10, bat_maxtemp);
  182. _mav_put_uint8_t(buf, 11, cap_percent);
  183. _mav_put_uint8_t(buf, 12, bat_id);
  184. _mav_put_uint8_t(buf, 13, err_code);
  185. _mav_put_int8_t(buf, 14, hvb_temp);
  186. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  187. #else
  188. mavlink_shangfei_bms_t packet;
  189. packet.time_boot_ms = time_boot_ms;
  190. packet.bat_voltage = bat_voltage;
  191. packet.bat_current = bat_current;
  192. packet.hvb_voltage = hvb_voltage;
  193. packet.bat_maxtemp = bat_maxtemp;
  194. packet.cap_percent = cap_percent;
  195. packet.bat_id = bat_id;
  196. packet.err_code = err_code;
  197. packet.hvb_temp = hvb_temp;
  198. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  199. #endif
  200. msg->msgid = MAVLINK_MSG_ID_SHANGFEI_BMS;
  201. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  202. }
  203. /**
  204. * @brief Encode a shangfei_bms struct
  205. *
  206. * @param system_id ID of this system
  207. * @param component_id ID of this component (e.g. 200 for IMU)
  208. * @param msg The MAVLink message to compress the data into
  209. * @param shangfei_bms C-struct to read the message contents from
  210. */
  211. static inline uint16_t mavlink_msg_shangfei_bms_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_shangfei_bms_t* shangfei_bms)
  212. {
  213. return mavlink_msg_shangfei_bms_pack(system_id, component_id, msg, shangfei_bms->time_boot_ms, shangfei_bms->bat_voltage, shangfei_bms->bat_current, shangfei_bms->bat_maxtemp, shangfei_bms->cap_percent, shangfei_bms->bat_id, shangfei_bms->err_code, shangfei_bms->hvb_voltage, shangfei_bms->hvb_temp);
  214. }
  215. /**
  216. * @brief Encode a shangfei_bms struct on a channel
  217. *
  218. * @param system_id ID of this system
  219. * @param component_id ID of this component (e.g. 200 for IMU)
  220. * @param chan The MAVLink channel this message will be sent over
  221. * @param msg The MAVLink message to compress the data into
  222. * @param shangfei_bms C-struct to read the message contents from
  223. */
  224. static inline uint16_t mavlink_msg_shangfei_bms_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_shangfei_bms_t* shangfei_bms)
  225. {
  226. return mavlink_msg_shangfei_bms_pack_chan(system_id, component_id, chan, msg, shangfei_bms->time_boot_ms, shangfei_bms->bat_voltage, shangfei_bms->bat_current, shangfei_bms->bat_maxtemp, shangfei_bms->cap_percent, shangfei_bms->bat_id, shangfei_bms->err_code, shangfei_bms->hvb_voltage, shangfei_bms->hvb_temp);
  227. }
  228. /**
  229. * @brief Encode a shangfei_bms struct with provided status structure
  230. *
  231. * @param system_id ID of this system
  232. * @param component_id ID of this component (e.g. 200 for IMU)
  233. * @param status MAVLink status structure
  234. * @param msg The MAVLink message to compress the data into
  235. * @param shangfei_bms C-struct to read the message contents from
  236. */
  237. static inline uint16_t mavlink_msg_shangfei_bms_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_shangfei_bms_t* shangfei_bms)
  238. {
  239. return mavlink_msg_shangfei_bms_pack_status(system_id, component_id, _status, msg, shangfei_bms->time_boot_ms, shangfei_bms->bat_voltage, shangfei_bms->bat_current, shangfei_bms->bat_maxtemp, shangfei_bms->cap_percent, shangfei_bms->bat_id, shangfei_bms->err_code, shangfei_bms->hvb_voltage, shangfei_bms->hvb_temp);
  240. }
  241. /**
  242. * @brief Send a shangfei_bms message
  243. * @param chan MAVLink channel to send the message
  244. *
  245. * @param time_boot_ms [ms] Timestamp in ms from system boot.
  246. * @param bat_voltage [dV] Battery voltage.
  247. * @param bat_current [dA] Battery current.
  248. * @param bat_maxtemp Battery Max_temperature.
  249. * @param cap_percent [%] Battery capacity.
  250. * @param bat_id Battery id.
  251. * @param err_code Error code.
  252. * @param hvb_voltage [dV] High volt-box voltage.
  253. * @param hvb_temp High volt-box temperature.
  254. */
  255. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  256. static inline void mavlink_msg_shangfei_bms_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t bat_voltage, int16_t bat_current, int8_t bat_maxtemp, uint8_t cap_percent, uint8_t bat_id, uint8_t err_code, uint16_t hvb_voltage, int8_t hvb_temp)
  257. {
  258. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  259. char buf[MAVLINK_MSG_ID_SHANGFEI_BMS_LEN];
  260. _mav_put_uint32_t(buf, 0, time_boot_ms);
  261. _mav_put_uint16_t(buf, 4, bat_voltage);
  262. _mav_put_int16_t(buf, 6, bat_current);
  263. _mav_put_uint16_t(buf, 8, hvb_voltage);
  264. _mav_put_int8_t(buf, 10, bat_maxtemp);
  265. _mav_put_uint8_t(buf, 11, cap_percent);
  266. _mav_put_uint8_t(buf, 12, bat_id);
  267. _mav_put_uint8_t(buf, 13, err_code);
  268. _mav_put_int8_t(buf, 14, hvb_temp);
  269. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SHANGFEI_BMS, buf, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  270. #else
  271. mavlink_shangfei_bms_t packet;
  272. packet.time_boot_ms = time_boot_ms;
  273. packet.bat_voltage = bat_voltage;
  274. packet.bat_current = bat_current;
  275. packet.hvb_voltage = hvb_voltage;
  276. packet.bat_maxtemp = bat_maxtemp;
  277. packet.cap_percent = cap_percent;
  278. packet.bat_id = bat_id;
  279. packet.err_code = err_code;
  280. packet.hvb_temp = hvb_temp;
  281. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SHANGFEI_BMS, (const char *)&packet, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  282. #endif
  283. }
  284. /**
  285. * @brief Send a shangfei_bms message
  286. * @param chan MAVLink channel to send the message
  287. * @param struct The MAVLink struct to serialize
  288. */
  289. static inline void mavlink_msg_shangfei_bms_send_struct(mavlink_channel_t chan, const mavlink_shangfei_bms_t* shangfei_bms)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. mavlink_msg_shangfei_bms_send(chan, shangfei_bms->time_boot_ms, shangfei_bms->bat_voltage, shangfei_bms->bat_current, shangfei_bms->bat_maxtemp, shangfei_bms->cap_percent, shangfei_bms->bat_id, shangfei_bms->err_code, shangfei_bms->hvb_voltage, shangfei_bms->hvb_temp);
  293. #else
  294. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SHANGFEI_BMS, (const char *)shangfei_bms, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  295. #endif
  296. }
  297. #if MAVLINK_MSG_ID_SHANGFEI_BMS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  298. /*
  299. This variant of _send() can be used to save stack space by re-using
  300. memory from the receive buffer. The caller provides a
  301. mavlink_message_t which is the size of a full mavlink message. This
  302. is usually the receive buffer for the channel, and allows a reply to an
  303. incoming message with minimum stack space usage.
  304. */
  305. static inline void mavlink_msg_shangfei_bms_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t bat_voltage, int16_t bat_current, int8_t bat_maxtemp, uint8_t cap_percent, uint8_t bat_id, uint8_t err_code, uint16_t hvb_voltage, int8_t hvb_temp)
  306. {
  307. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  308. char *buf = (char *)msgbuf;
  309. _mav_put_uint32_t(buf, 0, time_boot_ms);
  310. _mav_put_uint16_t(buf, 4, bat_voltage);
  311. _mav_put_int16_t(buf, 6, bat_current);
  312. _mav_put_uint16_t(buf, 8, hvb_voltage);
  313. _mav_put_int8_t(buf, 10, bat_maxtemp);
  314. _mav_put_uint8_t(buf, 11, cap_percent);
  315. _mav_put_uint8_t(buf, 12, bat_id);
  316. _mav_put_uint8_t(buf, 13, err_code);
  317. _mav_put_int8_t(buf, 14, hvb_temp);
  318. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SHANGFEI_BMS, buf, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  319. #else
  320. mavlink_shangfei_bms_t *packet = (mavlink_shangfei_bms_t *)msgbuf;
  321. packet->time_boot_ms = time_boot_ms;
  322. packet->bat_voltage = bat_voltage;
  323. packet->bat_current = bat_current;
  324. packet->hvb_voltage = hvb_voltage;
  325. packet->bat_maxtemp = bat_maxtemp;
  326. packet->cap_percent = cap_percent;
  327. packet->bat_id = bat_id;
  328. packet->err_code = err_code;
  329. packet->hvb_temp = hvb_temp;
  330. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SHANGFEI_BMS, (const char *)packet, MAVLINK_MSG_ID_SHANGFEI_BMS_MIN_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN, MAVLINK_MSG_ID_SHANGFEI_BMS_CRC);
  331. #endif
  332. }
  333. #endif
  334. #endif
  335. // MESSAGE SHANGFEI_BMS UNPACKING
  336. /**
  337. * @brief Get field time_boot_ms from shangfei_bms message
  338. *
  339. * @return [ms] Timestamp in ms from system boot.
  340. */
  341. static inline uint32_t mavlink_msg_shangfei_bms_get_time_boot_ms(const mavlink_message_t* msg)
  342. {
  343. return _MAV_RETURN_uint32_t(msg, 0);
  344. }
  345. /**
  346. * @brief Get field bat_voltage from shangfei_bms message
  347. *
  348. * @return [dV] Battery voltage.
  349. */
  350. static inline uint16_t mavlink_msg_shangfei_bms_get_bat_voltage(const mavlink_message_t* msg)
  351. {
  352. return _MAV_RETURN_uint16_t(msg, 4);
  353. }
  354. /**
  355. * @brief Get field bat_current from shangfei_bms message
  356. *
  357. * @return [dA] Battery current.
  358. */
  359. static inline int16_t mavlink_msg_shangfei_bms_get_bat_current(const mavlink_message_t* msg)
  360. {
  361. return _MAV_RETURN_int16_t(msg, 6);
  362. }
  363. /**
  364. * @brief Get field bat_maxtemp from shangfei_bms message
  365. *
  366. * @return Battery Max_temperature.
  367. */
  368. static inline int8_t mavlink_msg_shangfei_bms_get_bat_maxtemp(const mavlink_message_t* msg)
  369. {
  370. return _MAV_RETURN_int8_t(msg, 10);
  371. }
  372. /**
  373. * @brief Get field cap_percent from shangfei_bms message
  374. *
  375. * @return [%] Battery capacity.
  376. */
  377. static inline uint8_t mavlink_msg_shangfei_bms_get_cap_percent(const mavlink_message_t* msg)
  378. {
  379. return _MAV_RETURN_uint8_t(msg, 11);
  380. }
  381. /**
  382. * @brief Get field bat_id from shangfei_bms message
  383. *
  384. * @return Battery id.
  385. */
  386. static inline uint8_t mavlink_msg_shangfei_bms_get_bat_id(const mavlink_message_t* msg)
  387. {
  388. return _MAV_RETURN_uint8_t(msg, 12);
  389. }
  390. /**
  391. * @brief Get field err_code from shangfei_bms message
  392. *
  393. * @return Error code.
  394. */
  395. static inline uint8_t mavlink_msg_shangfei_bms_get_err_code(const mavlink_message_t* msg)
  396. {
  397. return _MAV_RETURN_uint8_t(msg, 13);
  398. }
  399. /**
  400. * @brief Get field hvb_voltage from shangfei_bms message
  401. *
  402. * @return [dV] High volt-box voltage.
  403. */
  404. static inline uint16_t mavlink_msg_shangfei_bms_get_hvb_voltage(const mavlink_message_t* msg)
  405. {
  406. return _MAV_RETURN_uint16_t(msg, 8);
  407. }
  408. /**
  409. * @brief Get field hvb_temp from shangfei_bms message
  410. *
  411. * @return High volt-box temperature.
  412. */
  413. static inline int8_t mavlink_msg_shangfei_bms_get_hvb_temp(const mavlink_message_t* msg)
  414. {
  415. return _MAV_RETURN_int8_t(msg, 14);
  416. }
  417. /**
  418. * @brief Decode a shangfei_bms message into a struct
  419. *
  420. * @param msg The message to decode
  421. * @param shangfei_bms C-struct to decode the message contents into
  422. */
  423. static inline void mavlink_msg_shangfei_bms_decode(const mavlink_message_t* msg, mavlink_shangfei_bms_t* shangfei_bms)
  424. {
  425. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  426. shangfei_bms->time_boot_ms = mavlink_msg_shangfei_bms_get_time_boot_ms(msg);
  427. shangfei_bms->bat_voltage = mavlink_msg_shangfei_bms_get_bat_voltage(msg);
  428. shangfei_bms->bat_current = mavlink_msg_shangfei_bms_get_bat_current(msg);
  429. shangfei_bms->hvb_voltage = mavlink_msg_shangfei_bms_get_hvb_voltage(msg);
  430. shangfei_bms->bat_maxtemp = mavlink_msg_shangfei_bms_get_bat_maxtemp(msg);
  431. shangfei_bms->cap_percent = mavlink_msg_shangfei_bms_get_cap_percent(msg);
  432. shangfei_bms->bat_id = mavlink_msg_shangfei_bms_get_bat_id(msg);
  433. shangfei_bms->err_code = mavlink_msg_shangfei_bms_get_err_code(msg);
  434. shangfei_bms->hvb_temp = mavlink_msg_shangfei_bms_get_hvb_temp(msg);
  435. #else
  436. uint8_t len = msg->len < MAVLINK_MSG_ID_SHANGFEI_BMS_LEN? msg->len : MAVLINK_MSG_ID_SHANGFEI_BMS_LEN;
  437. memset(shangfei_bms, 0, MAVLINK_MSG_ID_SHANGFEI_BMS_LEN);
  438. memcpy(shangfei_bms, _MAV_PAYLOAD(msg), len);
  439. #endif
  440. }