|
@@ -0,0 +1,520 @@
|
|
|
+#pragma once
|
|
|
+// MESSAGE VK_BMS_STATUS PACKING
|
|
|
+
|
|
|
+#define MAVLINK_MSG_ID_VK_BMS_STATUS 53003
|
|
|
+
|
|
|
+
|
|
|
+typedef struct __mavlink_vk_bms_status_t {
|
|
|
+ uint32_t time_boot_ms; /*< [ms] Timestamp in ms from system boot.*/
|
|
|
+ uint32_t voltage; /*< [mV] BMS voltage in mV*/
|
|
|
+ uint32_t err_code; /*< BMS error code,
|
|
|
+ 0 means no error*/
|
|
|
+ int16_t current; /*< [cA] BMS current in cA, negative value means in charging*/
|
|
|
+ uint16_t cyc_cnt; /*< BMS change and discharge
|
|
|
+ cycle times*/
|
|
|
+ int16_t temperature; /*< [degC] BMS temperature in degC*/
|
|
|
+ uint16_t cell_num; /*< BMS cell numbers*/
|
|
|
+ uint16_t cell_volt[30]; /*< [mV] BMS cell voltage in mV*/
|
|
|
+ int8_t cap_percent; /*< [%] BMS remaining power in percentage*/
|
|
|
+ uint8_t bat_id; /*< BMS id, start from
|
|
|
+ 0*/
|
|
|
+} mavlink_vk_bms_status_t;
|
|
|
+
|
|
|
+#define MAVLINK_MSG_ID_VK_BMS_STATUS_LEN 82
|
|
|
+#define MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN 82
|
|
|
+#define MAVLINK_MSG_ID_53003_LEN 82
|
|
|
+#define MAVLINK_MSG_ID_53003_MIN_LEN 82
|
|
|
+
|
|
|
+#define MAVLINK_MSG_ID_VK_BMS_STATUS_CRC 13
|
|
|
+#define MAVLINK_MSG_ID_53003_CRC 13
|
|
|
+
|
|
|
+#define MAVLINK_MSG_VK_BMS_STATUS_FIELD_CELL_VOLT_LEN 30
|
|
|
+
|
|
|
+#if MAVLINK_COMMAND_24BIT
|
|
|
+#define MAVLINK_MESSAGE_INFO_VK_BMS_STATUS { \
|
|
|
+ 53003, \
|
|
|
+ "VK_BMS_STATUS", \
|
|
|
+ 10, \
|
|
|
+ { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_vk_bms_status_t, time_boot_ms) }, \
|
|
|
+ { "voltage", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_vk_bms_status_t, voltage) }, \
|
|
|
+ { "current", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_vk_bms_status_t, current) }, \
|
|
|
+ { "cyc_cnt", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_vk_bms_status_t, cyc_cnt) }, \
|
|
|
+ { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vk_bms_status_t, temperature) }, \
|
|
|
+ { "cap_percent", NULL, MAVLINK_TYPE_INT8_T, 0, 80, offsetof(mavlink_vk_bms_status_t, cap_percent) }, \
|
|
|
+ { "bat_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 81, offsetof(mavlink_vk_bms_status_t, bat_id) }, \
|
|
|
+ { "err_code", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_vk_bms_status_t, err_code) }, \
|
|
|
+ { "cell_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vk_bms_status_t, cell_num) }, \
|
|
|
+ { "cell_volt", NULL, MAVLINK_TYPE_UINT16_T, 30, 20, offsetof(mavlink_vk_bms_status_t, cell_volt) }, \
|
|
|
+ } \
|
|
|
+}
|
|
|
+#else
|
|
|
+#define MAVLINK_MESSAGE_INFO_VK_BMS_STATUS { \
|
|
|
+ "VK_BMS_STATUS", \
|
|
|
+ 10, \
|
|
|
+ { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_vk_bms_status_t, time_boot_ms) }, \
|
|
|
+ { "voltage", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_vk_bms_status_t, voltage) }, \
|
|
|
+ { "current", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_vk_bms_status_t, current) }, \
|
|
|
+ { "cyc_cnt", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_vk_bms_status_t, cyc_cnt) }, \
|
|
|
+ { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vk_bms_status_t, temperature) }, \
|
|
|
+ { "cap_percent", NULL, MAVLINK_TYPE_INT8_T, 0, 80, offsetof(mavlink_vk_bms_status_t, cap_percent) }, \
|
|
|
+ { "bat_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 81, offsetof(mavlink_vk_bms_status_t, bat_id) }, \
|
|
|
+ { "err_code", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_vk_bms_status_t, err_code) }, \
|
|
|
+ { "cell_num", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vk_bms_status_t, cell_num) }, \
|
|
|
+ { "cell_volt", NULL, MAVLINK_TYPE_UINT16_T, 30, 20, offsetof(mavlink_vk_bms_status_t, cell_volt) }, \
|
|
|
+ } \
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Pack a vk_bms_status message
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ *
|
|
|
+ * @param time_boot_ms [ms] Timestamp in ms from system boot.
|
|
|
+ * @param voltage [mV] BMS voltage in mV
|
|
|
+ * @param current [cA] BMS current in cA, negative value means in charging
|
|
|
+ * @param cyc_cnt BMS change and discharge
|
|
|
+ cycle times
|
|
|
+ * @param temperature [degC] BMS temperature in degC
|
|
|
+ * @param cap_percent [%] BMS remaining power in percentage
|
|
|
+ * @param bat_id BMS id, start from
|
|
|
+ 0
|
|
|
+ * @param err_code BMS error code,
|
|
|
+ 0 means no error
|
|
|
+ * @param cell_num BMS cell numbers
|
|
|
+ * @param cell_volt [mV] BMS cell voltage in mV
|
|
|
+ * @return length of the message in bytes (excluding serial stream start sign)
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
|
|
|
+ uint32_t time_boot_ms, uint32_t voltage, int16_t current, uint16_t cyc_cnt, int16_t temperature, int8_t cap_percent, uint8_t bat_id, uint32_t err_code, uint16_t cell_num, const uint16_t *cell_volt)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ char buf[MAVLINK_MSG_ID_VK_BMS_STATUS_LEN];
|
|
|
+ _mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
|
+ _mav_put_uint32_t(buf, 4, voltage);
|
|
|
+ _mav_put_uint32_t(buf, 8, err_code);
|
|
|
+ _mav_put_int16_t(buf, 12, current);
|
|
|
+ _mav_put_uint16_t(buf, 14, cyc_cnt);
|
|
|
+ _mav_put_int16_t(buf, 16, temperature);
|
|
|
+ _mav_put_uint16_t(buf, 18, cell_num);
|
|
|
+ _mav_put_int8_t(buf, 80, cap_percent);
|
|
|
+ _mav_put_uint8_t(buf, 81, bat_id);
|
|
|
+ _mav_put_uint16_t_array(buf, 20, cell_volt, 30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#else
|
|
|
+ mavlink_vk_bms_status_t packet;
|
|
|
+ packet.time_boot_ms = time_boot_ms;
|
|
|
+ packet.voltage = voltage;
|
|
|
+ packet.err_code = err_code;
|
|
|
+ packet.current = current;
|
|
|
+ packet.cyc_cnt = cyc_cnt;
|
|
|
+ packet.temperature = temperature;
|
|
|
+ packet.cell_num = cell_num;
|
|
|
+ packet.cap_percent = cap_percent;
|
|
|
+ packet.bat_id = bat_id;
|
|
|
+ mav_array_memcpy(packet.cell_volt, cell_volt, sizeof(uint16_t)*30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#endif
|
|
|
+
|
|
|
+ msg->msgid = MAVLINK_MSG_ID_VK_BMS_STATUS;
|
|
|
+ return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Pack a vk_bms_status message
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param status MAVLink status structure
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ *
|
|
|
+ * @param time_boot_ms [ms] Timestamp in ms from system boot.
|
|
|
+ * @param voltage [mV] BMS voltage in mV
|
|
|
+ * @param current [cA] BMS current in cA, negative value means in charging
|
|
|
+ * @param cyc_cnt BMS change and discharge
|
|
|
+ cycle times
|
|
|
+ * @param temperature [degC] BMS temperature in degC
|
|
|
+ * @param cap_percent [%] BMS remaining power in percentage
|
|
|
+ * @param bat_id BMS id, start from
|
|
|
+ 0
|
|
|
+ * @param err_code BMS error code,
|
|
|
+ 0 means no error
|
|
|
+ * @param cell_num BMS cell numbers
|
|
|
+ * @param cell_volt [mV] BMS cell voltage in mV
|
|
|
+ * @return length of the message in bytes (excluding serial stream start sign)
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
|
|
|
+ uint32_t time_boot_ms, uint32_t voltage, int16_t current, uint16_t cyc_cnt, int16_t temperature, int8_t cap_percent, uint8_t bat_id, uint32_t err_code, uint16_t cell_num, const uint16_t *cell_volt)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ char buf[MAVLINK_MSG_ID_VK_BMS_STATUS_LEN];
|
|
|
+ _mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
|
+ _mav_put_uint32_t(buf, 4, voltage);
|
|
|
+ _mav_put_uint32_t(buf, 8, err_code);
|
|
|
+ _mav_put_int16_t(buf, 12, current);
|
|
|
+ _mav_put_uint16_t(buf, 14, cyc_cnt);
|
|
|
+ _mav_put_int16_t(buf, 16, temperature);
|
|
|
+ _mav_put_uint16_t(buf, 18, cell_num);
|
|
|
+ _mav_put_int8_t(buf, 80, cap_percent);
|
|
|
+ _mav_put_uint8_t(buf, 81, bat_id);
|
|
|
+ _mav_put_uint16_t_array(buf, 20, cell_volt, 30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#else
|
|
|
+ mavlink_vk_bms_status_t packet;
|
|
|
+ packet.time_boot_ms = time_boot_ms;
|
|
|
+ packet.voltage = voltage;
|
|
|
+ packet.err_code = err_code;
|
|
|
+ packet.current = current;
|
|
|
+ packet.cyc_cnt = cyc_cnt;
|
|
|
+ packet.temperature = temperature;
|
|
|
+ packet.cell_num = cell_num;
|
|
|
+ packet.cap_percent = cap_percent;
|
|
|
+ packet.bat_id = bat_id;
|
|
|
+ mav_array_memcpy(packet.cell_volt, cell_volt, sizeof(uint16_t)*30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#endif
|
|
|
+
|
|
|
+ msg->msgid = MAVLINK_MSG_ID_VK_BMS_STATUS;
|
|
|
+#if MAVLINK_CRC_EXTRA
|
|
|
+ return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#else
|
|
|
+ return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Pack a vk_bms_status message on a channel
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param chan The MAVLink channel this message will be sent over
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ * @param time_boot_ms [ms] Timestamp in ms from system boot.
|
|
|
+ * @param voltage [mV] BMS voltage in mV
|
|
|
+ * @param current [cA] BMS current in cA, negative value means in charging
|
|
|
+ * @param cyc_cnt BMS change and discharge
|
|
|
+ cycle times
|
|
|
+ * @param temperature [degC] BMS temperature in degC
|
|
|
+ * @param cap_percent [%] BMS remaining power in percentage
|
|
|
+ * @param bat_id BMS id, start from
|
|
|
+ 0
|
|
|
+ * @param err_code BMS error code,
|
|
|
+ 0 means no error
|
|
|
+ * @param cell_num BMS cell numbers
|
|
|
+ * @param cell_volt [mV] BMS cell voltage in mV
|
|
|
+ * @return length of the message in bytes (excluding serial stream start sign)
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
|
|
|
+ mavlink_message_t* msg,
|
|
|
+ uint32_t time_boot_ms,uint32_t voltage,int16_t current,uint16_t cyc_cnt,int16_t temperature,int8_t cap_percent,uint8_t bat_id,uint32_t err_code,uint16_t cell_num,const uint16_t *cell_volt)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ char buf[MAVLINK_MSG_ID_VK_BMS_STATUS_LEN];
|
|
|
+ _mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
|
+ _mav_put_uint32_t(buf, 4, voltage);
|
|
|
+ _mav_put_uint32_t(buf, 8, err_code);
|
|
|
+ _mav_put_int16_t(buf, 12, current);
|
|
|
+ _mav_put_uint16_t(buf, 14, cyc_cnt);
|
|
|
+ _mav_put_int16_t(buf, 16, temperature);
|
|
|
+ _mav_put_uint16_t(buf, 18, cell_num);
|
|
|
+ _mav_put_int8_t(buf, 80, cap_percent);
|
|
|
+ _mav_put_uint8_t(buf, 81, bat_id);
|
|
|
+ _mav_put_uint16_t_array(buf, 20, cell_volt, 30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#else
|
|
|
+ mavlink_vk_bms_status_t packet;
|
|
|
+ packet.time_boot_ms = time_boot_ms;
|
|
|
+ packet.voltage = voltage;
|
|
|
+ packet.err_code = err_code;
|
|
|
+ packet.current = current;
|
|
|
+ packet.cyc_cnt = cyc_cnt;
|
|
|
+ packet.temperature = temperature;
|
|
|
+ packet.cell_num = cell_num;
|
|
|
+ packet.cap_percent = cap_percent;
|
|
|
+ packet.bat_id = bat_id;
|
|
|
+ mav_array_memcpy(packet.cell_volt, cell_volt, sizeof(uint16_t)*30);
|
|
|
+ memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+#endif
|
|
|
+
|
|
|
+ msg->msgid = MAVLINK_MSG_ID_VK_BMS_STATUS;
|
|
|
+ return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Encode a vk_bms_status struct
|
|
|
+ *
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ * @param vk_bms_status C-struct to read the message contents from
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vk_bms_status_t* vk_bms_status)
|
|
|
+{
|
|
|
+ return mavlink_msg_vk_bms_status_pack(system_id, component_id, msg, vk_bms_status->time_boot_ms, vk_bms_status->voltage, vk_bms_status->current, vk_bms_status->cyc_cnt, vk_bms_status->temperature, vk_bms_status->cap_percent, vk_bms_status->bat_id, vk_bms_status->err_code, vk_bms_status->cell_num, vk_bms_status->cell_volt);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Encode a vk_bms_status struct on a channel
|
|
|
+ *
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param chan The MAVLink channel this message will be sent over
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ * @param vk_bms_status C-struct to read the message contents from
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_vk_bms_status_t* vk_bms_status)
|
|
|
+{
|
|
|
+ return mavlink_msg_vk_bms_status_pack_chan(system_id, component_id, chan, msg, vk_bms_status->time_boot_ms, vk_bms_status->voltage, vk_bms_status->current, vk_bms_status->cyc_cnt, vk_bms_status->temperature, vk_bms_status->cap_percent, vk_bms_status->bat_id, vk_bms_status->err_code, vk_bms_status->cell_num, vk_bms_status->cell_volt);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Encode a vk_bms_status struct with provided status structure
|
|
|
+ *
|
|
|
+ * @param system_id ID of this system
|
|
|
+ * @param component_id ID of this component (e.g. 200 for IMU)
|
|
|
+ * @param status MAVLink status structure
|
|
|
+ * @param msg The MAVLink message to compress the data into
|
|
|
+ * @param vk_bms_status C-struct to read the message contents from
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vk_bms_status_t* vk_bms_status)
|
|
|
+{
|
|
|
+ return mavlink_msg_vk_bms_status_pack_status(system_id, component_id, _status, msg, vk_bms_status->time_boot_ms, vk_bms_status->voltage, vk_bms_status->current, vk_bms_status->cyc_cnt, vk_bms_status->temperature, vk_bms_status->cap_percent, vk_bms_status->bat_id, vk_bms_status->err_code, vk_bms_status->cell_num, vk_bms_status->cell_volt);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Send a vk_bms_status message
|
|
|
+ * @param chan MAVLink channel to send the message
|
|
|
+ *
|
|
|
+ * @param time_boot_ms [ms] Timestamp in ms from system boot.
|
|
|
+ * @param voltage [mV] BMS voltage in mV
|
|
|
+ * @param current [cA] BMS current in cA, negative value means in charging
|
|
|
+ * @param cyc_cnt BMS change and discharge
|
|
|
+ cycle times
|
|
|
+ * @param temperature [degC] BMS temperature in degC
|
|
|
+ * @param cap_percent [%] BMS remaining power in percentage
|
|
|
+ * @param bat_id BMS id, start from
|
|
|
+ 0
|
|
|
+ * @param err_code BMS error code,
|
|
|
+ 0 means no error
|
|
|
+ * @param cell_num BMS cell numbers
|
|
|
+ * @param cell_volt [mV] BMS cell voltage in mV
|
|
|
+ */
|
|
|
+#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
|
|
+
|
|
|
+static inline void mavlink_msg_vk_bms_status_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t voltage, int16_t current, uint16_t cyc_cnt, int16_t temperature, int8_t cap_percent, uint8_t bat_id, uint32_t err_code, uint16_t cell_num, const uint16_t *cell_volt)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ char buf[MAVLINK_MSG_ID_VK_BMS_STATUS_LEN];
|
|
|
+ _mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
|
+ _mav_put_uint32_t(buf, 4, voltage);
|
|
|
+ _mav_put_uint32_t(buf, 8, err_code);
|
|
|
+ _mav_put_int16_t(buf, 12, current);
|
|
|
+ _mav_put_uint16_t(buf, 14, cyc_cnt);
|
|
|
+ _mav_put_int16_t(buf, 16, temperature);
|
|
|
+ _mav_put_uint16_t(buf, 18, cell_num);
|
|
|
+ _mav_put_int8_t(buf, 80, cap_percent);
|
|
|
+ _mav_put_uint8_t(buf, 81, bat_id);
|
|
|
+ _mav_put_uint16_t_array(buf, 20, cell_volt, 30);
|
|
|
+ _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VK_BMS_STATUS, buf, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#else
|
|
|
+ mavlink_vk_bms_status_t packet;
|
|
|
+ packet.time_boot_ms = time_boot_ms;
|
|
|
+ packet.voltage = voltage;
|
|
|
+ packet.err_code = err_code;
|
|
|
+ packet.current = current;
|
|
|
+ packet.cyc_cnt = cyc_cnt;
|
|
|
+ packet.temperature = temperature;
|
|
|
+ packet.cell_num = cell_num;
|
|
|
+ packet.cap_percent = cap_percent;
|
|
|
+ packet.bat_id = bat_id;
|
|
|
+ mav_array_memcpy(packet.cell_volt, cell_volt, sizeof(uint16_t)*30);
|
|
|
+ _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VK_BMS_STATUS, (const char *)&packet, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Send a vk_bms_status message
|
|
|
+ * @param chan MAVLink channel to send the message
|
|
|
+ * @param struct The MAVLink struct to serialize
|
|
|
+ */
|
|
|
+static inline void mavlink_msg_vk_bms_status_send_struct(mavlink_channel_t chan, const mavlink_vk_bms_status_t* vk_bms_status)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ mavlink_msg_vk_bms_status_send(chan, vk_bms_status->time_boot_ms, vk_bms_status->voltage, vk_bms_status->current, vk_bms_status->cyc_cnt, vk_bms_status->temperature, vk_bms_status->cap_percent, vk_bms_status->bat_id, vk_bms_status->err_code, vk_bms_status->cell_num, vk_bms_status->cell_volt);
|
|
|
+#else
|
|
|
+ _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VK_BMS_STATUS, (const char *)vk_bms_status, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
+#if MAVLINK_MSG_ID_VK_BMS_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
|
|
|
+/*
|
|
|
+ This variant of _send() can be used to save stack space by re-using
|
|
|
+ memory from the receive buffer. The caller provides a
|
|
|
+ mavlink_message_t which is the size of a full mavlink message. This
|
|
|
+ is usually the receive buffer for the channel, and allows a reply to an
|
|
|
+ incoming message with minimum stack space usage.
|
|
|
+ */
|
|
|
+static inline void mavlink_msg_vk_bms_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t voltage, int16_t current, uint16_t cyc_cnt, int16_t temperature, int8_t cap_percent, uint8_t bat_id, uint32_t err_code, uint16_t cell_num, const uint16_t *cell_volt)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ char *buf = (char *)msgbuf;
|
|
|
+ _mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
|
+ _mav_put_uint32_t(buf, 4, voltage);
|
|
|
+ _mav_put_uint32_t(buf, 8, err_code);
|
|
|
+ _mav_put_int16_t(buf, 12, current);
|
|
|
+ _mav_put_uint16_t(buf, 14, cyc_cnt);
|
|
|
+ _mav_put_int16_t(buf, 16, temperature);
|
|
|
+ _mav_put_uint16_t(buf, 18, cell_num);
|
|
|
+ _mav_put_int8_t(buf, 80, cap_percent);
|
|
|
+ _mav_put_uint8_t(buf, 81, bat_id);
|
|
|
+ _mav_put_uint16_t_array(buf, 20, cell_volt, 30);
|
|
|
+ _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VK_BMS_STATUS, buf, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#else
|
|
|
+ mavlink_vk_bms_status_t *packet = (mavlink_vk_bms_status_t *)msgbuf;
|
|
|
+ packet->time_boot_ms = time_boot_ms;
|
|
|
+ packet->voltage = voltage;
|
|
|
+ packet->err_code = err_code;
|
|
|
+ packet->current = current;
|
|
|
+ packet->cyc_cnt = cyc_cnt;
|
|
|
+ packet->temperature = temperature;
|
|
|
+ packet->cell_num = cell_num;
|
|
|
+ packet->cap_percent = cap_percent;
|
|
|
+ packet->bat_id = bat_id;
|
|
|
+ mav_array_memcpy(packet->cell_volt, cell_volt, sizeof(uint16_t)*30);
|
|
|
+ _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VK_BMS_STATUS, (const char *)packet, MAVLINK_MSG_ID_VK_BMS_STATUS_MIN_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN, MAVLINK_MSG_ID_VK_BMS_STATUS_CRC);
|
|
|
+#endif
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+// MESSAGE VK_BMS_STATUS UNPACKING
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field time_boot_ms from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [ms] Timestamp in ms from system boot.
|
|
|
+ */
|
|
|
+static inline uint32_t mavlink_msg_vk_bms_status_get_time_boot_ms(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint32_t(msg, 0);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field voltage from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [mV] BMS voltage in mV
|
|
|
+ */
|
|
|
+static inline uint32_t mavlink_msg_vk_bms_status_get_voltage(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint32_t(msg, 4);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field current from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [cA] BMS current in cA, negative value means in charging
|
|
|
+ */
|
|
|
+static inline int16_t mavlink_msg_vk_bms_status_get_current(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_int16_t(msg, 12);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field cyc_cnt from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return BMS change and discharge
|
|
|
+ cycle times
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_get_cyc_cnt(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint16_t(msg, 14);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field temperature from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [degC] BMS temperature in degC
|
|
|
+ */
|
|
|
+static inline int16_t mavlink_msg_vk_bms_status_get_temperature(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_int16_t(msg, 16);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field cap_percent from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [%] BMS remaining power in percentage
|
|
|
+ */
|
|
|
+static inline int8_t mavlink_msg_vk_bms_status_get_cap_percent(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_int8_t(msg, 80);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field bat_id from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return BMS id, start from
|
|
|
+ 0
|
|
|
+ */
|
|
|
+static inline uint8_t mavlink_msg_vk_bms_status_get_bat_id(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint8_t(msg, 81);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field err_code from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return BMS error code,
|
|
|
+ 0 means no error
|
|
|
+ */
|
|
|
+static inline uint32_t mavlink_msg_vk_bms_status_get_err_code(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint32_t(msg, 8);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field cell_num from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return BMS cell numbers
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_get_cell_num(const mavlink_message_t* msg)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint16_t(msg, 18);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Get field cell_volt from vk_bms_status message
|
|
|
+ *
|
|
|
+ * @return [mV] BMS cell voltage in mV
|
|
|
+ */
|
|
|
+static inline uint16_t mavlink_msg_vk_bms_status_get_cell_volt(const mavlink_message_t* msg, uint16_t *cell_volt)
|
|
|
+{
|
|
|
+ return _MAV_RETURN_uint16_t_array(msg, cell_volt, 30, 20);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Decode a vk_bms_status message into a struct
|
|
|
+ *
|
|
|
+ * @param msg The message to decode
|
|
|
+ * @param vk_bms_status C-struct to decode the message contents into
|
|
|
+ */
|
|
|
+static inline void mavlink_msg_vk_bms_status_decode(const mavlink_message_t* msg, mavlink_vk_bms_status_t* vk_bms_status)
|
|
|
+{
|
|
|
+#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
|
+ vk_bms_status->time_boot_ms = mavlink_msg_vk_bms_status_get_time_boot_ms(msg);
|
|
|
+ vk_bms_status->voltage = mavlink_msg_vk_bms_status_get_voltage(msg);
|
|
|
+ vk_bms_status->err_code = mavlink_msg_vk_bms_status_get_err_code(msg);
|
|
|
+ vk_bms_status->current = mavlink_msg_vk_bms_status_get_current(msg);
|
|
|
+ vk_bms_status->cyc_cnt = mavlink_msg_vk_bms_status_get_cyc_cnt(msg);
|
|
|
+ vk_bms_status->temperature = mavlink_msg_vk_bms_status_get_temperature(msg);
|
|
|
+ vk_bms_status->cell_num = mavlink_msg_vk_bms_status_get_cell_num(msg);
|
|
|
+ mavlink_msg_vk_bms_status_get_cell_volt(msg, vk_bms_status->cell_volt);
|
|
|
+ vk_bms_status->cap_percent = mavlink_msg_vk_bms_status_get_cap_percent(msg);
|
|
|
+ vk_bms_status->bat_id = mavlink_msg_vk_bms_status_get_bat_id(msg);
|
|
|
+#else
|
|
|
+ uint8_t len = msg->len < MAVLINK_MSG_ID_VK_BMS_STATUS_LEN? msg->len : MAVLINK_MSG_ID_VK_BMS_STATUS_LEN;
|
|
|
+ memset(vk_bms_status, 0, MAVLINK_MSG_ID_VK_BMS_STATUS_LEN);
|
|
|
+ memcpy(vk_bms_status, _MAV_PAYLOAD(msg), len);
|
|
|
+#endif
|
|
|
+}
|