feat: bmu/ccm state

This commit is contained in:
matt
2020-10-06 23:13:01 +08:00
parent e638f7a252
commit 54c7286a2c
5 changed files with 1210 additions and 3 deletions
File diff suppressed because one or more lines are too long
+731
View File
@@ -0,0 +1,731 @@
#pragma once
// MESSAGE BMUState PACKING
#define MAVLINK_MSG_ID_BMUState 20301
typedef struct __mavlink_bmustate_t {
uint32_t time_boot_ms; /*< [ms] Timestamp (milliseconds since system boot)*/
uint16_t BAT1_group_voltage_mv; /*< group_voltage_mv*/
uint16_t BAT1_group_current_dA; /*< group_current_dA*/
uint16_t BAT1_remain_perc; /*< remain_perc*/
uint16_t BAT1_low_temp_degC; /*< low_temp_degC*/
uint16_t BAT1_hi_temp_degC; /*< hi_temp_degC*/
uint16_t BAT1_voltages_mv[7]; /*< voltages_mv*/
uint16_t BAT1_hi_voltage_mv; /*< hi_voltage_mv*/
uint16_t BAT1_low_voltage_mv; /*< low_voltage_mv*/
uint16_t BAT2_group_voltage_mv; /*< group_voltage_mv*/
uint16_t BAT2_group_current_dA; /*< group_current_dA*/
uint16_t BAT2_remain_perc; /*< remain_perc*/
uint16_t BAT2_low_temp_degC; /*< low_temp_degC*/
uint16_t BAT2_hi_temp_degC; /*< hi_temp_degC*/
uint16_t BAT2_voltages_mv[14]; /*< voltages_mv*/
uint16_t BAT2_hi_voltage_mv; /*< hi_voltage_mv*/
uint16_t BAT2_low_voltage_mv; /*< low_voltage_mv*/
uint8_t BAT1_STA1; /*< BAT1_STA1*/
uint8_t BAT1_STA2; /*< BAT1_STA2*/
uint8_t BAT2_STA1; /*< BAT2_STA1*/
uint8_t BAT2_STA2; /*< BAT2_STA2*/
uint8_t p500w_enabled; /*< p500w_enabled*/
} mavlink_bmustate_t;
#define MAVLINK_MSG_ID_BMUState_LEN 79
#define MAVLINK_MSG_ID_BMUState_MIN_LEN 79
#define MAVLINK_MSG_ID_20301_LEN 79
#define MAVLINK_MSG_ID_20301_MIN_LEN 79
#define MAVLINK_MSG_ID_BMUState_CRC 233
#define MAVLINK_MSG_ID_20301_CRC 233
#define MAVLINK_MSG_BMUState_FIELD_BAT1_VOLTAGES_MV_LEN 7
#define MAVLINK_MSG_BMUState_FIELD_BAT2_VOLTAGES_MV_LEN 14
#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_BMUState { \
20301, \
"BMUState", \
22, \
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_bmustate_t, time_boot_ms) }, \
{ "BAT1_group_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_bmustate_t, BAT1_group_voltage_mv) }, \
{ "BAT1_group_current_dA", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_bmustate_t, BAT1_group_current_dA) }, \
{ "BAT1_remain_perc", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_bmustate_t, BAT1_remain_perc) }, \
{ "BAT1_low_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_bmustate_t, BAT1_low_temp_degC) }, \
{ "BAT1_hi_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_bmustate_t, BAT1_hi_temp_degC) }, \
{ "BAT1_voltages_mv", NULL, MAVLINK_TYPE_UINT16_T, 7, 14, offsetof(mavlink_bmustate_t, BAT1_voltages_mv) }, \
{ "BAT1_hi_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_bmustate_t, BAT1_hi_voltage_mv) }, \
{ "BAT1_low_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 30, offsetof(mavlink_bmustate_t, BAT1_low_voltage_mv) }, \
{ "BAT2_group_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 32, offsetof(mavlink_bmustate_t, BAT2_group_voltage_mv) }, \
{ "BAT2_group_current_dA", NULL, MAVLINK_TYPE_UINT16_T, 0, 34, offsetof(mavlink_bmustate_t, BAT2_group_current_dA) }, \
{ "BAT2_remain_perc", NULL, MAVLINK_TYPE_UINT16_T, 0, 36, offsetof(mavlink_bmustate_t, BAT2_remain_perc) }, \
{ "BAT2_low_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 38, offsetof(mavlink_bmustate_t, BAT2_low_temp_degC) }, \
{ "BAT2_hi_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 40, offsetof(mavlink_bmustate_t, BAT2_hi_temp_degC) }, \
{ "BAT2_voltages_mv", NULL, MAVLINK_TYPE_UINT16_T, 14, 42, offsetof(mavlink_bmustate_t, BAT2_voltages_mv) }, \
{ "BAT2_hi_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 70, offsetof(mavlink_bmustate_t, BAT2_hi_voltage_mv) }, \
{ "BAT2_low_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 72, offsetof(mavlink_bmustate_t, BAT2_low_voltage_mv) }, \
{ "BAT1_STA1", NULL, MAVLINK_TYPE_UINT8_T, 0, 74, offsetof(mavlink_bmustate_t, BAT1_STA1) }, \
{ "BAT1_STA2", NULL, MAVLINK_TYPE_UINT8_T, 0, 75, offsetof(mavlink_bmustate_t, BAT1_STA2) }, \
{ "BAT2_STA1", NULL, MAVLINK_TYPE_UINT8_T, 0, 76, offsetof(mavlink_bmustate_t, BAT2_STA1) }, \
{ "BAT2_STA2", NULL, MAVLINK_TYPE_UINT8_T, 0, 77, offsetof(mavlink_bmustate_t, BAT2_STA2) }, \
{ "p500w_enabled", NULL, MAVLINK_TYPE_UINT8_T, 0, 78, offsetof(mavlink_bmustate_t, p500w_enabled) }, \
} \
}
#else
#define MAVLINK_MESSAGE_INFO_BMUState { \
"BMUState", \
22, \
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_bmustate_t, time_boot_ms) }, \
{ "BAT1_group_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_bmustate_t, BAT1_group_voltage_mv) }, \
{ "BAT1_group_current_dA", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_bmustate_t, BAT1_group_current_dA) }, \
{ "BAT1_remain_perc", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_bmustate_t, BAT1_remain_perc) }, \
{ "BAT1_low_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_bmustate_t, BAT1_low_temp_degC) }, \
{ "BAT1_hi_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_bmustate_t, BAT1_hi_temp_degC) }, \
{ "BAT1_voltages_mv", NULL, MAVLINK_TYPE_UINT16_T, 7, 14, offsetof(mavlink_bmustate_t, BAT1_voltages_mv) }, \
{ "BAT1_hi_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_bmustate_t, BAT1_hi_voltage_mv) }, \
{ "BAT1_low_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 30, offsetof(mavlink_bmustate_t, BAT1_low_voltage_mv) }, \
{ "BAT2_group_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 32, offsetof(mavlink_bmustate_t, BAT2_group_voltage_mv) }, \
{ "BAT2_group_current_dA", NULL, MAVLINK_TYPE_UINT16_T, 0, 34, offsetof(mavlink_bmustate_t, BAT2_group_current_dA) }, \
{ "BAT2_remain_perc", NULL, MAVLINK_TYPE_UINT16_T, 0, 36, offsetof(mavlink_bmustate_t, BAT2_remain_perc) }, \
{ "BAT2_low_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 38, offsetof(mavlink_bmustate_t, BAT2_low_temp_degC) }, \
{ "BAT2_hi_temp_degC", NULL, MAVLINK_TYPE_UINT16_T, 0, 40, offsetof(mavlink_bmustate_t, BAT2_hi_temp_degC) }, \
{ "BAT2_voltages_mv", NULL, MAVLINK_TYPE_UINT16_T, 14, 42, offsetof(mavlink_bmustate_t, BAT2_voltages_mv) }, \
{ "BAT2_hi_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 70, offsetof(mavlink_bmustate_t, BAT2_hi_voltage_mv) }, \
{ "BAT2_low_voltage_mv", NULL, MAVLINK_TYPE_UINT16_T, 0, 72, offsetof(mavlink_bmustate_t, BAT2_low_voltage_mv) }, \
{ "BAT1_STA1", NULL, MAVLINK_TYPE_UINT8_T, 0, 74, offsetof(mavlink_bmustate_t, BAT1_STA1) }, \
{ "BAT1_STA2", NULL, MAVLINK_TYPE_UINT8_T, 0, 75, offsetof(mavlink_bmustate_t, BAT1_STA2) }, \
{ "BAT2_STA1", NULL, MAVLINK_TYPE_UINT8_T, 0, 76, offsetof(mavlink_bmustate_t, BAT2_STA1) }, \
{ "BAT2_STA2", NULL, MAVLINK_TYPE_UINT8_T, 0, 77, offsetof(mavlink_bmustate_t, BAT2_STA2) }, \
{ "p500w_enabled", NULL, MAVLINK_TYPE_UINT8_T, 0, 78, offsetof(mavlink_bmustate_t, p500w_enabled) }, \
} \
}
#endif
/**
* @brief Pack a bmustate 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 (milliseconds since system boot)
* @param BAT1_group_voltage_mv group_voltage_mv
* @param BAT1_group_current_dA group_current_dA
* @param BAT1_remain_perc remain_perc
* @param BAT1_low_temp_degC low_temp_degC
* @param BAT1_hi_temp_degC hi_temp_degC
* @param BAT1_voltages_mv voltages_mv
* @param BAT1_hi_voltage_mv hi_voltage_mv
* @param BAT1_low_voltage_mv low_voltage_mv
* @param BAT2_group_voltage_mv group_voltage_mv
* @param BAT2_group_current_dA group_current_dA
* @param BAT2_remain_perc remain_perc
* @param BAT2_low_temp_degC low_temp_degC
* @param BAT2_hi_temp_degC hi_temp_degC
* @param BAT2_voltages_mv voltages_mv
* @param BAT2_hi_voltage_mv hi_voltage_mv
* @param BAT2_low_voltage_mv low_voltage_mv
* @param BAT1_STA1 BAT1_STA1
* @param BAT1_STA2 BAT1_STA2
* @param BAT2_STA1 BAT2_STA1
* @param BAT2_STA2 BAT2_STA2
* @param p500w_enabled p500w_enabled
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_bmustate_pack(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg,
uint32_t time_boot_ms, uint16_t BAT1_group_voltage_mv, uint16_t BAT1_group_current_dA, uint16_t BAT1_remain_perc, uint16_t BAT1_low_temp_degC, uint16_t BAT1_hi_temp_degC, const uint16_t *BAT1_voltages_mv, uint16_t BAT1_hi_voltage_mv, uint16_t BAT1_low_voltage_mv, uint16_t BAT2_group_voltage_mv, uint16_t BAT2_group_current_dA, uint16_t BAT2_remain_perc, uint16_t BAT2_low_temp_degC, uint16_t BAT2_hi_temp_degC, const uint16_t *BAT2_voltages_mv, uint16_t BAT2_hi_voltage_mv, uint16_t BAT2_low_voltage_mv, uint8_t BAT1_STA1, uint8_t BAT1_STA2, uint8_t BAT2_STA1, uint8_t BAT2_STA2, uint8_t p500w_enabled)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_BMUState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint16_t(buf, 4, BAT1_group_voltage_mv);
_mav_put_uint16_t(buf, 6, BAT1_group_current_dA);
_mav_put_uint16_t(buf, 8, BAT1_remain_perc);
_mav_put_uint16_t(buf, 10, BAT1_low_temp_degC);
_mav_put_uint16_t(buf, 12, BAT1_hi_temp_degC);
_mav_put_uint16_t(buf, 28, BAT1_hi_voltage_mv);
_mav_put_uint16_t(buf, 30, BAT1_low_voltage_mv);
_mav_put_uint16_t(buf, 32, BAT2_group_voltage_mv);
_mav_put_uint16_t(buf, 34, BAT2_group_current_dA);
_mav_put_uint16_t(buf, 36, BAT2_remain_perc);
_mav_put_uint16_t(buf, 38, BAT2_low_temp_degC);
_mav_put_uint16_t(buf, 40, BAT2_hi_temp_degC);
_mav_put_uint16_t(buf, 70, BAT2_hi_voltage_mv);
_mav_put_uint16_t(buf, 72, BAT2_low_voltage_mv);
_mav_put_uint8_t(buf, 74, BAT1_STA1);
_mav_put_uint8_t(buf, 75, BAT1_STA2);
_mav_put_uint8_t(buf, 76, BAT2_STA1);
_mav_put_uint8_t(buf, 77, BAT2_STA2);
_mav_put_uint8_t(buf, 78, p500w_enabled);
_mav_put_uint16_t_array(buf, 14, BAT1_voltages_mv, 7);
_mav_put_uint16_t_array(buf, 42, BAT2_voltages_mv, 14);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BMUState_LEN);
#else
mavlink_bmustate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.BAT1_group_voltage_mv = BAT1_group_voltage_mv;
packet.BAT1_group_current_dA = BAT1_group_current_dA;
packet.BAT1_remain_perc = BAT1_remain_perc;
packet.BAT1_low_temp_degC = BAT1_low_temp_degC;
packet.BAT1_hi_temp_degC = BAT1_hi_temp_degC;
packet.BAT1_hi_voltage_mv = BAT1_hi_voltage_mv;
packet.BAT1_low_voltage_mv = BAT1_low_voltage_mv;
packet.BAT2_group_voltage_mv = BAT2_group_voltage_mv;
packet.BAT2_group_current_dA = BAT2_group_current_dA;
packet.BAT2_remain_perc = BAT2_remain_perc;
packet.BAT2_low_temp_degC = BAT2_low_temp_degC;
packet.BAT2_hi_temp_degC = BAT2_hi_temp_degC;
packet.BAT2_hi_voltage_mv = BAT2_hi_voltage_mv;
packet.BAT2_low_voltage_mv = BAT2_low_voltage_mv;
packet.BAT1_STA1 = BAT1_STA1;
packet.BAT1_STA2 = BAT1_STA2;
packet.BAT2_STA1 = BAT2_STA1;
packet.BAT2_STA2 = BAT2_STA2;
packet.p500w_enabled = p500w_enabled;
mav_array_memcpy(packet.BAT1_voltages_mv, BAT1_voltages_mv, sizeof(uint16_t)*7);
mav_array_memcpy(packet.BAT2_voltages_mv, BAT2_voltages_mv, sizeof(uint16_t)*14);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BMUState_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_BMUState;
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
}
/**
* @brief Pack a bmustate 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 (milliseconds since system boot)
* @param BAT1_group_voltage_mv group_voltage_mv
* @param BAT1_group_current_dA group_current_dA
* @param BAT1_remain_perc remain_perc
* @param BAT1_low_temp_degC low_temp_degC
* @param BAT1_hi_temp_degC hi_temp_degC
* @param BAT1_voltages_mv voltages_mv
* @param BAT1_hi_voltage_mv hi_voltage_mv
* @param BAT1_low_voltage_mv low_voltage_mv
* @param BAT2_group_voltage_mv group_voltage_mv
* @param BAT2_group_current_dA group_current_dA
* @param BAT2_remain_perc remain_perc
* @param BAT2_low_temp_degC low_temp_degC
* @param BAT2_hi_temp_degC hi_temp_degC
* @param BAT2_voltages_mv voltages_mv
* @param BAT2_hi_voltage_mv hi_voltage_mv
* @param BAT2_low_voltage_mv low_voltage_mv
* @param BAT1_STA1 BAT1_STA1
* @param BAT1_STA2 BAT1_STA2
* @param BAT2_STA1 BAT2_STA1
* @param BAT2_STA2 BAT2_STA2
* @param p500w_enabled p500w_enabled
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_bmustate_pack_chan(uint16_t system_id, uint8_t component_id, uint8_t chan,
mavlink_message_t* msg,
uint32_t time_boot_ms,uint16_t BAT1_group_voltage_mv,uint16_t BAT1_group_current_dA,uint16_t BAT1_remain_perc,uint16_t BAT1_low_temp_degC,uint16_t BAT1_hi_temp_degC,const uint16_t *BAT1_voltages_mv,uint16_t BAT1_hi_voltage_mv,uint16_t BAT1_low_voltage_mv,uint16_t BAT2_group_voltage_mv,uint16_t BAT2_group_current_dA,uint16_t BAT2_remain_perc,uint16_t BAT2_low_temp_degC,uint16_t BAT2_hi_temp_degC,const uint16_t *BAT2_voltages_mv,uint16_t BAT2_hi_voltage_mv,uint16_t BAT2_low_voltage_mv,uint8_t BAT1_STA1,uint8_t BAT1_STA2,uint8_t BAT2_STA1,uint8_t BAT2_STA2,uint8_t p500w_enabled)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_BMUState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint16_t(buf, 4, BAT1_group_voltage_mv);
_mav_put_uint16_t(buf, 6, BAT1_group_current_dA);
_mav_put_uint16_t(buf, 8, BAT1_remain_perc);
_mav_put_uint16_t(buf, 10, BAT1_low_temp_degC);
_mav_put_uint16_t(buf, 12, BAT1_hi_temp_degC);
_mav_put_uint16_t(buf, 28, BAT1_hi_voltage_mv);
_mav_put_uint16_t(buf, 30, BAT1_low_voltage_mv);
_mav_put_uint16_t(buf, 32, BAT2_group_voltage_mv);
_mav_put_uint16_t(buf, 34, BAT2_group_current_dA);
_mav_put_uint16_t(buf, 36, BAT2_remain_perc);
_mav_put_uint16_t(buf, 38, BAT2_low_temp_degC);
_mav_put_uint16_t(buf, 40, BAT2_hi_temp_degC);
_mav_put_uint16_t(buf, 70, BAT2_hi_voltage_mv);
_mav_put_uint16_t(buf, 72, BAT2_low_voltage_mv);
_mav_put_uint8_t(buf, 74, BAT1_STA1);
_mav_put_uint8_t(buf, 75, BAT1_STA2);
_mav_put_uint8_t(buf, 76, BAT2_STA1);
_mav_put_uint8_t(buf, 77, BAT2_STA2);
_mav_put_uint8_t(buf, 78, p500w_enabled);
_mav_put_uint16_t_array(buf, 14, BAT1_voltages_mv, 7);
_mav_put_uint16_t_array(buf, 42, BAT2_voltages_mv, 14);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BMUState_LEN);
#else
mavlink_bmustate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.BAT1_group_voltage_mv = BAT1_group_voltage_mv;
packet.BAT1_group_current_dA = BAT1_group_current_dA;
packet.BAT1_remain_perc = BAT1_remain_perc;
packet.BAT1_low_temp_degC = BAT1_low_temp_degC;
packet.BAT1_hi_temp_degC = BAT1_hi_temp_degC;
packet.BAT1_hi_voltage_mv = BAT1_hi_voltage_mv;
packet.BAT1_low_voltage_mv = BAT1_low_voltage_mv;
packet.BAT2_group_voltage_mv = BAT2_group_voltage_mv;
packet.BAT2_group_current_dA = BAT2_group_current_dA;
packet.BAT2_remain_perc = BAT2_remain_perc;
packet.BAT2_low_temp_degC = BAT2_low_temp_degC;
packet.BAT2_hi_temp_degC = BAT2_hi_temp_degC;
packet.BAT2_hi_voltage_mv = BAT2_hi_voltage_mv;
packet.BAT2_low_voltage_mv = BAT2_low_voltage_mv;
packet.BAT1_STA1 = BAT1_STA1;
packet.BAT1_STA2 = BAT1_STA2;
packet.BAT2_STA1 = BAT2_STA1;
packet.BAT2_STA2 = BAT2_STA2;
packet.p500w_enabled = p500w_enabled;
mav_array_memcpy(packet.BAT1_voltages_mv, BAT1_voltages_mv, sizeof(uint16_t)*7);
mav_array_memcpy(packet.BAT2_voltages_mv, BAT2_voltages_mv, sizeof(uint16_t)*14);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BMUState_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_BMUState;
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
}
/**
* @brief Encode a bmustate 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 bmustate C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_bmustate_encode(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_bmustate_t* bmustate)
{
return mavlink_msg_bmustate_pack(system_id, component_id, msg, bmustate->time_boot_ms, bmustate->BAT1_group_voltage_mv, bmustate->BAT1_group_current_dA, bmustate->BAT1_remain_perc, bmustate->BAT1_low_temp_degC, bmustate->BAT1_hi_temp_degC, bmustate->BAT1_voltages_mv, bmustate->BAT1_hi_voltage_mv, bmustate->BAT1_low_voltage_mv, bmustate->BAT2_group_voltage_mv, bmustate->BAT2_group_current_dA, bmustate->BAT2_remain_perc, bmustate->BAT2_low_temp_degC, bmustate->BAT2_hi_temp_degC, bmustate->BAT2_voltages_mv, bmustate->BAT2_hi_voltage_mv, bmustate->BAT2_low_voltage_mv, bmustate->BAT1_STA1, bmustate->BAT1_STA2, bmustate->BAT2_STA1, bmustate->BAT2_STA2, bmustate->p500w_enabled);
}
/**
* @brief Encode a bmustate 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 bmustate C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_bmustate_encode_chan(uint16_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_bmustate_t* bmustate)
{
return mavlink_msg_bmustate_pack_chan(system_id, component_id, chan, msg, bmustate->time_boot_ms, bmustate->BAT1_group_voltage_mv, bmustate->BAT1_group_current_dA, bmustate->BAT1_remain_perc, bmustate->BAT1_low_temp_degC, bmustate->BAT1_hi_temp_degC, bmustate->BAT1_voltages_mv, bmustate->BAT1_hi_voltage_mv, bmustate->BAT1_low_voltage_mv, bmustate->BAT2_group_voltage_mv, bmustate->BAT2_group_current_dA, bmustate->BAT2_remain_perc, bmustate->BAT2_low_temp_degC, bmustate->BAT2_hi_temp_degC, bmustate->BAT2_voltages_mv, bmustate->BAT2_hi_voltage_mv, bmustate->BAT2_low_voltage_mv, bmustate->BAT1_STA1, bmustate->BAT1_STA2, bmustate->BAT2_STA1, bmustate->BAT2_STA2, bmustate->p500w_enabled);
}
/**
* @brief Send a bmustate message
* @param chan MAVLink channel to send the message
*
* @param time_boot_ms [ms] Timestamp (milliseconds since system boot)
* @param BAT1_group_voltage_mv group_voltage_mv
* @param BAT1_group_current_dA group_current_dA
* @param BAT1_remain_perc remain_perc
* @param BAT1_low_temp_degC low_temp_degC
* @param BAT1_hi_temp_degC hi_temp_degC
* @param BAT1_voltages_mv voltages_mv
* @param BAT1_hi_voltage_mv hi_voltage_mv
* @param BAT1_low_voltage_mv low_voltage_mv
* @param BAT2_group_voltage_mv group_voltage_mv
* @param BAT2_group_current_dA group_current_dA
* @param BAT2_remain_perc remain_perc
* @param BAT2_low_temp_degC low_temp_degC
* @param BAT2_hi_temp_degC hi_temp_degC
* @param BAT2_voltages_mv voltages_mv
* @param BAT2_hi_voltage_mv hi_voltage_mv
* @param BAT2_low_voltage_mv low_voltage_mv
* @param BAT1_STA1 BAT1_STA1
* @param BAT1_STA2 BAT1_STA2
* @param BAT2_STA1 BAT2_STA1
* @param BAT2_STA2 BAT2_STA2
* @param p500w_enabled p500w_enabled
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_bmustate_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t BAT1_group_voltage_mv, uint16_t BAT1_group_current_dA, uint16_t BAT1_remain_perc, uint16_t BAT1_low_temp_degC, uint16_t BAT1_hi_temp_degC, const uint16_t *BAT1_voltages_mv, uint16_t BAT1_hi_voltage_mv, uint16_t BAT1_low_voltage_mv, uint16_t BAT2_group_voltage_mv, uint16_t BAT2_group_current_dA, uint16_t BAT2_remain_perc, uint16_t BAT2_low_temp_degC, uint16_t BAT2_hi_temp_degC, const uint16_t *BAT2_voltages_mv, uint16_t BAT2_hi_voltage_mv, uint16_t BAT2_low_voltage_mv, uint8_t BAT1_STA1, uint8_t BAT1_STA2, uint8_t BAT2_STA1, uint8_t BAT2_STA2, uint8_t p500w_enabled)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_BMUState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint16_t(buf, 4, BAT1_group_voltage_mv);
_mav_put_uint16_t(buf, 6, BAT1_group_current_dA);
_mav_put_uint16_t(buf, 8, BAT1_remain_perc);
_mav_put_uint16_t(buf, 10, BAT1_low_temp_degC);
_mav_put_uint16_t(buf, 12, BAT1_hi_temp_degC);
_mav_put_uint16_t(buf, 28, BAT1_hi_voltage_mv);
_mav_put_uint16_t(buf, 30, BAT1_low_voltage_mv);
_mav_put_uint16_t(buf, 32, BAT2_group_voltage_mv);
_mav_put_uint16_t(buf, 34, BAT2_group_current_dA);
_mav_put_uint16_t(buf, 36, BAT2_remain_perc);
_mav_put_uint16_t(buf, 38, BAT2_low_temp_degC);
_mav_put_uint16_t(buf, 40, BAT2_hi_temp_degC);
_mav_put_uint16_t(buf, 70, BAT2_hi_voltage_mv);
_mav_put_uint16_t(buf, 72, BAT2_low_voltage_mv);
_mav_put_uint8_t(buf, 74, BAT1_STA1);
_mav_put_uint8_t(buf, 75, BAT1_STA2);
_mav_put_uint8_t(buf, 76, BAT2_STA1);
_mav_put_uint8_t(buf, 77, BAT2_STA2);
_mav_put_uint8_t(buf, 78, p500w_enabled);
_mav_put_uint16_t_array(buf, 14, BAT1_voltages_mv, 7);
_mav_put_uint16_t_array(buf, 42, BAT2_voltages_mv, 14);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BMUState, buf, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
#else
mavlink_bmustate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.BAT1_group_voltage_mv = BAT1_group_voltage_mv;
packet.BAT1_group_current_dA = BAT1_group_current_dA;
packet.BAT1_remain_perc = BAT1_remain_perc;
packet.BAT1_low_temp_degC = BAT1_low_temp_degC;
packet.BAT1_hi_temp_degC = BAT1_hi_temp_degC;
packet.BAT1_hi_voltage_mv = BAT1_hi_voltage_mv;
packet.BAT1_low_voltage_mv = BAT1_low_voltage_mv;
packet.BAT2_group_voltage_mv = BAT2_group_voltage_mv;
packet.BAT2_group_current_dA = BAT2_group_current_dA;
packet.BAT2_remain_perc = BAT2_remain_perc;
packet.BAT2_low_temp_degC = BAT2_low_temp_degC;
packet.BAT2_hi_temp_degC = BAT2_hi_temp_degC;
packet.BAT2_hi_voltage_mv = BAT2_hi_voltage_mv;
packet.BAT2_low_voltage_mv = BAT2_low_voltage_mv;
packet.BAT1_STA1 = BAT1_STA1;
packet.BAT1_STA2 = BAT1_STA2;
packet.BAT2_STA1 = BAT2_STA1;
packet.BAT2_STA2 = BAT2_STA2;
packet.p500w_enabled = p500w_enabled;
mav_array_memcpy(packet.BAT1_voltages_mv, BAT1_voltages_mv, sizeof(uint16_t)*7);
mav_array_memcpy(packet.BAT2_voltages_mv, BAT2_voltages_mv, sizeof(uint16_t)*14);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BMUState, (const char *)&packet, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
#endif
}
/**
* @brief Send a bmustate message
* @param chan MAVLink channel to send the message
* @param struct The MAVLink struct to serialize
*/
static inline void mavlink_msg_bmustate_send_struct(mavlink_channel_t chan, const mavlink_bmustate_t* bmustate)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
mavlink_msg_bmustate_send(chan, bmustate->time_boot_ms, bmustate->BAT1_group_voltage_mv, bmustate->BAT1_group_current_dA, bmustate->BAT1_remain_perc, bmustate->BAT1_low_temp_degC, bmustate->BAT1_hi_temp_degC, bmustate->BAT1_voltages_mv, bmustate->BAT1_hi_voltage_mv, bmustate->BAT1_low_voltage_mv, bmustate->BAT2_group_voltage_mv, bmustate->BAT2_group_current_dA, bmustate->BAT2_remain_perc, bmustate->BAT2_low_temp_degC, bmustate->BAT2_hi_temp_degC, bmustate->BAT2_voltages_mv, bmustate->BAT2_hi_voltage_mv, bmustate->BAT2_low_voltage_mv, bmustate->BAT1_STA1, bmustate->BAT1_STA2, bmustate->BAT2_STA1, bmustate->BAT2_STA2, bmustate->p500w_enabled);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BMUState, (const char *)bmustate, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
#endif
}
#if MAVLINK_MSG_ID_BMUState_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
This varient 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_bmustate_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t BAT1_group_voltage_mv, uint16_t BAT1_group_current_dA, uint16_t BAT1_remain_perc, uint16_t BAT1_low_temp_degC, uint16_t BAT1_hi_temp_degC, const uint16_t *BAT1_voltages_mv, uint16_t BAT1_hi_voltage_mv, uint16_t BAT1_low_voltage_mv, uint16_t BAT2_group_voltage_mv, uint16_t BAT2_group_current_dA, uint16_t BAT2_remain_perc, uint16_t BAT2_low_temp_degC, uint16_t BAT2_hi_temp_degC, const uint16_t *BAT2_voltages_mv, uint16_t BAT2_hi_voltage_mv, uint16_t BAT2_low_voltage_mv, uint8_t BAT1_STA1, uint8_t BAT1_STA2, uint8_t BAT2_STA1, uint8_t BAT2_STA2, uint8_t p500w_enabled)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char *buf = (char *)msgbuf;
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint16_t(buf, 4, BAT1_group_voltage_mv);
_mav_put_uint16_t(buf, 6, BAT1_group_current_dA);
_mav_put_uint16_t(buf, 8, BAT1_remain_perc);
_mav_put_uint16_t(buf, 10, BAT1_low_temp_degC);
_mav_put_uint16_t(buf, 12, BAT1_hi_temp_degC);
_mav_put_uint16_t(buf, 28, BAT1_hi_voltage_mv);
_mav_put_uint16_t(buf, 30, BAT1_low_voltage_mv);
_mav_put_uint16_t(buf, 32, BAT2_group_voltage_mv);
_mav_put_uint16_t(buf, 34, BAT2_group_current_dA);
_mav_put_uint16_t(buf, 36, BAT2_remain_perc);
_mav_put_uint16_t(buf, 38, BAT2_low_temp_degC);
_mav_put_uint16_t(buf, 40, BAT2_hi_temp_degC);
_mav_put_uint16_t(buf, 70, BAT2_hi_voltage_mv);
_mav_put_uint16_t(buf, 72, BAT2_low_voltage_mv);
_mav_put_uint8_t(buf, 74, BAT1_STA1);
_mav_put_uint8_t(buf, 75, BAT1_STA2);
_mav_put_uint8_t(buf, 76, BAT2_STA1);
_mav_put_uint8_t(buf, 77, BAT2_STA2);
_mav_put_uint8_t(buf, 78, p500w_enabled);
_mav_put_uint16_t_array(buf, 14, BAT1_voltages_mv, 7);
_mav_put_uint16_t_array(buf, 42, BAT2_voltages_mv, 14);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BMUState, buf, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
#else
mavlink_bmustate_t *packet = (mavlink_bmustate_t *)msgbuf;
packet->time_boot_ms = time_boot_ms;
packet->BAT1_group_voltage_mv = BAT1_group_voltage_mv;
packet->BAT1_group_current_dA = BAT1_group_current_dA;
packet->BAT1_remain_perc = BAT1_remain_perc;
packet->BAT1_low_temp_degC = BAT1_low_temp_degC;
packet->BAT1_hi_temp_degC = BAT1_hi_temp_degC;
packet->BAT1_hi_voltage_mv = BAT1_hi_voltage_mv;
packet->BAT1_low_voltage_mv = BAT1_low_voltage_mv;
packet->BAT2_group_voltage_mv = BAT2_group_voltage_mv;
packet->BAT2_group_current_dA = BAT2_group_current_dA;
packet->BAT2_remain_perc = BAT2_remain_perc;
packet->BAT2_low_temp_degC = BAT2_low_temp_degC;
packet->BAT2_hi_temp_degC = BAT2_hi_temp_degC;
packet->BAT2_hi_voltage_mv = BAT2_hi_voltage_mv;
packet->BAT2_low_voltage_mv = BAT2_low_voltage_mv;
packet->BAT1_STA1 = BAT1_STA1;
packet->BAT1_STA2 = BAT1_STA2;
packet->BAT2_STA1 = BAT2_STA1;
packet->BAT2_STA2 = BAT2_STA2;
packet->p500w_enabled = p500w_enabled;
mav_array_memcpy(packet->BAT1_voltages_mv, BAT1_voltages_mv, sizeof(uint16_t)*7);
mav_array_memcpy(packet->BAT2_voltages_mv, BAT2_voltages_mv, sizeof(uint16_t)*14);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BMUState, (const char *)packet, MAVLINK_MSG_ID_BMUState_MIN_LEN, MAVLINK_MSG_ID_BMUState_LEN, MAVLINK_MSG_ID_BMUState_CRC);
#endif
}
#endif
#endif
// MESSAGE BMUState UNPACKING
/**
* @brief Get field time_boot_ms from bmustate message
*
* @return [ms] Timestamp (milliseconds since system boot)
*/
static inline uint32_t mavlink_msg_bmustate_get_time_boot_ms(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint32_t(msg, 0);
}
/**
* @brief Get field BAT1_group_voltage_mv from bmustate message
*
* @return group_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_group_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 4);
}
/**
* @brief Get field BAT1_group_current_dA from bmustate message
*
* @return group_current_dA
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_group_current_dA(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 6);
}
/**
* @brief Get field BAT1_remain_perc from bmustate message
*
* @return remain_perc
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_remain_perc(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 8);
}
/**
* @brief Get field BAT1_low_temp_degC from bmustate message
*
* @return low_temp_degC
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_low_temp_degC(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 10);
}
/**
* @brief Get field BAT1_hi_temp_degC from bmustate message
*
* @return hi_temp_degC
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_hi_temp_degC(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 12);
}
/**
* @brief Get field BAT1_voltages_mv from bmustate message
*
* @return voltages_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_voltages_mv(const mavlink_message_t* msg, uint16_t *BAT1_voltages_mv)
{
return _MAV_RETURN_uint16_t_array(msg, BAT1_voltages_mv, 7, 14);
}
/**
* @brief Get field BAT1_hi_voltage_mv from bmustate message
*
* @return hi_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_hi_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 28);
}
/**
* @brief Get field BAT1_low_voltage_mv from bmustate message
*
* @return low_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT1_low_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 30);
}
/**
* @brief Get field BAT2_group_voltage_mv from bmustate message
*
* @return group_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_group_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 32);
}
/**
* @brief Get field BAT2_group_current_dA from bmustate message
*
* @return group_current_dA
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_group_current_dA(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 34);
}
/**
* @brief Get field BAT2_remain_perc from bmustate message
*
* @return remain_perc
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_remain_perc(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 36);
}
/**
* @brief Get field BAT2_low_temp_degC from bmustate message
*
* @return low_temp_degC
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_low_temp_degC(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 38);
}
/**
* @brief Get field BAT2_hi_temp_degC from bmustate message
*
* @return hi_temp_degC
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_hi_temp_degC(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 40);
}
/**
* @brief Get field BAT2_voltages_mv from bmustate message
*
* @return voltages_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_voltages_mv(const mavlink_message_t* msg, uint16_t *BAT2_voltages_mv)
{
return _MAV_RETURN_uint16_t_array(msg, BAT2_voltages_mv, 14, 42);
}
/**
* @brief Get field BAT2_hi_voltage_mv from bmustate message
*
* @return hi_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_hi_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 70);
}
/**
* @brief Get field BAT2_low_voltage_mv from bmustate message
*
* @return low_voltage_mv
*/
static inline uint16_t mavlink_msg_bmustate_get_BAT2_low_voltage_mv(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 72);
}
/**
* @brief Get field BAT1_STA1 from bmustate message
*
* @return BAT1_STA1
*/
static inline uint8_t mavlink_msg_bmustate_get_BAT1_STA1(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 74);
}
/**
* @brief Get field BAT1_STA2 from bmustate message
*
* @return BAT1_STA2
*/
static inline uint8_t mavlink_msg_bmustate_get_BAT1_STA2(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 75);
}
/**
* @brief Get field BAT2_STA1 from bmustate message
*
* @return BAT2_STA1
*/
static inline uint8_t mavlink_msg_bmustate_get_BAT2_STA1(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 76);
}
/**
* @brief Get field BAT2_STA2 from bmustate message
*
* @return BAT2_STA2
*/
static inline uint8_t mavlink_msg_bmustate_get_BAT2_STA2(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 77);
}
/**
* @brief Get field p500w_enabled from bmustate message
*
* @return p500w_enabled
*/
static inline uint8_t mavlink_msg_bmustate_get_p500w_enabled(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 78);
}
/**
* @brief Decode a bmustate message into a struct
*
* @param msg The message to decode
* @param bmustate C-struct to decode the message contents into
*/
static inline void mavlink_msg_bmustate_decode(const mavlink_message_t* msg, mavlink_bmustate_t* bmustate)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
bmustate->time_boot_ms = mavlink_msg_bmustate_get_time_boot_ms(msg);
bmustate->BAT1_group_voltage_mv = mavlink_msg_bmustate_get_BAT1_group_voltage_mv(msg);
bmustate->BAT1_group_current_dA = mavlink_msg_bmustate_get_BAT1_group_current_dA(msg);
bmustate->BAT1_remain_perc = mavlink_msg_bmustate_get_BAT1_remain_perc(msg);
bmustate->BAT1_low_temp_degC = mavlink_msg_bmustate_get_BAT1_low_temp_degC(msg);
bmustate->BAT1_hi_temp_degC = mavlink_msg_bmustate_get_BAT1_hi_temp_degC(msg);
mavlink_msg_bmustate_get_BAT1_voltages_mv(msg, bmustate->BAT1_voltages_mv);
bmustate->BAT1_hi_voltage_mv = mavlink_msg_bmustate_get_BAT1_hi_voltage_mv(msg);
bmustate->BAT1_low_voltage_mv = mavlink_msg_bmustate_get_BAT1_low_voltage_mv(msg);
bmustate->BAT2_group_voltage_mv = mavlink_msg_bmustate_get_BAT2_group_voltage_mv(msg);
bmustate->BAT2_group_current_dA = mavlink_msg_bmustate_get_BAT2_group_current_dA(msg);
bmustate->BAT2_remain_perc = mavlink_msg_bmustate_get_BAT2_remain_perc(msg);
bmustate->BAT2_low_temp_degC = mavlink_msg_bmustate_get_BAT2_low_temp_degC(msg);
bmustate->BAT2_hi_temp_degC = mavlink_msg_bmustate_get_BAT2_hi_temp_degC(msg);
mavlink_msg_bmustate_get_BAT2_voltages_mv(msg, bmustate->BAT2_voltages_mv);
bmustate->BAT2_hi_voltage_mv = mavlink_msg_bmustate_get_BAT2_hi_voltage_mv(msg);
bmustate->BAT2_low_voltage_mv = mavlink_msg_bmustate_get_BAT2_low_voltage_mv(msg);
bmustate->BAT1_STA1 = mavlink_msg_bmustate_get_BAT1_STA1(msg);
bmustate->BAT1_STA2 = mavlink_msg_bmustate_get_BAT1_STA2(msg);
bmustate->BAT2_STA1 = mavlink_msg_bmustate_get_BAT2_STA1(msg);
bmustate->BAT2_STA2 = mavlink_msg_bmustate_get_BAT2_STA2(msg);
bmustate->p500w_enabled = mavlink_msg_bmustate_get_p500w_enabled(msg);
#else
uint8_t len = msg->len < MAVLINK_MSG_ID_BMUState_LEN? msg->len : MAVLINK_MSG_ID_BMUState_LEN;
memset(bmustate, 0, MAVLINK_MSG_ID_BMUState_LEN);
memcpy(bmustate, _MAV_PAYLOAD(msg), len);
#endif
}
+306
View File
@@ -0,0 +1,306 @@
#pragma once
// MESSAGE CCMState PACKING
#define MAVLINK_MSG_ID_CCMState 20302
typedef struct __mavlink_ccmstate_t {
uint32_t time_boot_ms; /*< [ms] Timestamp (milliseconds since system boot)*/
uint32_t fuel_level; /*< fuel level*/
int16_t temp[4]; /*< temp*/
uint16_t volts[4]; /*< volts*/
uint8_t echo_seq; /*< echo seq*/
} mavlink_ccmstate_t;
#define MAVLINK_MSG_ID_CCMState_LEN 25
#define MAVLINK_MSG_ID_CCMState_MIN_LEN 25
#define MAVLINK_MSG_ID_20302_LEN 25
#define MAVLINK_MSG_ID_20302_MIN_LEN 25
#define MAVLINK_MSG_ID_CCMState_CRC 5
#define MAVLINK_MSG_ID_20302_CRC 5
#define MAVLINK_MSG_CCMState_FIELD_TEMP_LEN 4
#define MAVLINK_MSG_CCMState_FIELD_VOLTS_LEN 4
#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_CCMState { \
20302, \
"CCMState", \
5, \
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_ccmstate_t, time_boot_ms) }, \
{ "fuel_level", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_ccmstate_t, fuel_level) }, \
{ "temp", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_ccmstate_t, temp) }, \
{ "volts", NULL, MAVLINK_TYPE_UINT16_T, 4, 16, offsetof(mavlink_ccmstate_t, volts) }, \
{ "echo_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_ccmstate_t, echo_seq) }, \
} \
}
#else
#define MAVLINK_MESSAGE_INFO_CCMState { \
"CCMState", \
5, \
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_ccmstate_t, time_boot_ms) }, \
{ "fuel_level", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_ccmstate_t, fuel_level) }, \
{ "temp", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_ccmstate_t, temp) }, \
{ "volts", NULL, MAVLINK_TYPE_UINT16_T, 4, 16, offsetof(mavlink_ccmstate_t, volts) }, \
{ "echo_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_ccmstate_t, echo_seq) }, \
} \
}
#endif
/**
* @brief Pack a ccmstate 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 (milliseconds since system boot)
* @param fuel_level fuel level
* @param temp temp
* @param volts volts
* @param echo_seq echo seq
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_ccmstate_pack(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg,
uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_CCMState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint32_t(buf, 4, fuel_level);
_mav_put_uint8_t(buf, 24, echo_seq);
_mav_put_int16_t_array(buf, 8, temp, 4);
_mav_put_uint16_t_array(buf, 16, volts, 4);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CCMState_LEN);
#else
mavlink_ccmstate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.fuel_level = fuel_level;
packet.echo_seq = echo_seq;
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CCMState_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_CCMState;
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
}
/**
* @brief Pack a ccmstate 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 (milliseconds since system boot)
* @param fuel_level fuel level
* @param temp temp
* @param volts volts
* @param echo_seq echo seq
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_ccmstate_pack_chan(uint16_t system_id, uint8_t component_id, uint8_t chan,
mavlink_message_t* msg,
uint32_t time_boot_ms,uint32_t fuel_level,const int16_t *temp,const uint16_t *volts,uint8_t echo_seq)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_CCMState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint32_t(buf, 4, fuel_level);
_mav_put_uint8_t(buf, 24, echo_seq);
_mav_put_int16_t_array(buf, 8, temp, 4);
_mav_put_uint16_t_array(buf, 16, volts, 4);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CCMState_LEN);
#else
mavlink_ccmstate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.fuel_level = fuel_level;
packet.echo_seq = echo_seq;
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CCMState_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_CCMState;
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
}
/**
* @brief Encode a ccmstate 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 ccmstate C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_ccmstate_encode(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ccmstate_t* ccmstate)
{
return mavlink_msg_ccmstate_pack(system_id, component_id, msg, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
}
/**
* @brief Encode a ccmstate 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 ccmstate C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_ccmstate_encode_chan(uint16_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ccmstate_t* ccmstate)
{
return mavlink_msg_ccmstate_pack_chan(system_id, component_id, chan, msg, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
}
/**
* @brief Send a ccmstate message
* @param chan MAVLink channel to send the message
*
* @param time_boot_ms [ms] Timestamp (milliseconds since system boot)
* @param fuel_level fuel level
* @param temp temp
* @param volts volts
* @param echo_seq echo seq
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_ccmstate_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_CCMState_LEN];
_mav_put_uint32_t(buf, 0, time_boot_ms);
_mav_put_uint32_t(buf, 4, fuel_level);
_mav_put_uint8_t(buf, 24, echo_seq);
_mav_put_int16_t_array(buf, 8, temp, 4);
_mav_put_uint16_t_array(buf, 16, volts, 4);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, buf, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
#else
mavlink_ccmstate_t packet;
packet.time_boot_ms = time_boot_ms;
packet.fuel_level = fuel_level;
packet.echo_seq = echo_seq;
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)&packet, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
#endif
}
/**
* @brief Send a ccmstate message
* @param chan MAVLink channel to send the message
* @param struct The MAVLink struct to serialize
*/
static inline void mavlink_msg_ccmstate_send_struct(mavlink_channel_t chan, const mavlink_ccmstate_t* ccmstate)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
mavlink_msg_ccmstate_send(chan, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)ccmstate, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
#endif
}
#if MAVLINK_MSG_ID_CCMState_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
This varient 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_ccmstate_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
{
#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, fuel_level);
_mav_put_uint8_t(buf, 24, echo_seq);
_mav_put_int16_t_array(buf, 8, temp, 4);
_mav_put_uint16_t_array(buf, 16, volts, 4);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, buf, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
#else
mavlink_ccmstate_t *packet = (mavlink_ccmstate_t *)msgbuf;
packet->time_boot_ms = time_boot_ms;
packet->fuel_level = fuel_level;
packet->echo_seq = echo_seq;
mav_array_memcpy(packet->temp, temp, sizeof(int16_t)*4);
mav_array_memcpy(packet->volts, volts, sizeof(uint16_t)*4);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)packet, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
#endif
}
#endif
#endif
// MESSAGE CCMState UNPACKING
/**
* @brief Get field time_boot_ms from ccmstate message
*
* @return [ms] Timestamp (milliseconds since system boot)
*/
static inline uint32_t mavlink_msg_ccmstate_get_time_boot_ms(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint32_t(msg, 0);
}
/**
* @brief Get field fuel_level from ccmstate message
*
* @return fuel level
*/
static inline uint32_t mavlink_msg_ccmstate_get_fuel_level(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint32_t(msg, 4);
}
/**
* @brief Get field temp from ccmstate message
*
* @return temp
*/
static inline uint16_t mavlink_msg_ccmstate_get_temp(const mavlink_message_t* msg, int16_t *temp)
{
return _MAV_RETURN_int16_t_array(msg, temp, 4, 8);
}
/**
* @brief Get field volts from ccmstate message
*
* @return volts
*/
static inline uint16_t mavlink_msg_ccmstate_get_volts(const mavlink_message_t* msg, uint16_t *volts)
{
return _MAV_RETURN_uint16_t_array(msg, volts, 4, 16);
}
/**
* @brief Get field echo_seq from ccmstate message
*
* @return echo seq
*/
static inline uint8_t mavlink_msg_ccmstate_get_echo_seq(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 24);
}
/**
* @brief Decode a ccmstate message into a struct
*
* @param msg The message to decode
* @param ccmstate C-struct to decode the message contents into
*/
static inline void mavlink_msg_ccmstate_decode(const mavlink_message_t* msg, mavlink_ccmstate_t* ccmstate)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
ccmstate->time_boot_ms = mavlink_msg_ccmstate_get_time_boot_ms(msg);
ccmstate->fuel_level = mavlink_msg_ccmstate_get_fuel_level(msg);
mavlink_msg_ccmstate_get_temp(msg, ccmstate->temp);
mavlink_msg_ccmstate_get_volts(msg, ccmstate->volts);
ccmstate->echo_seq = mavlink_msg_ccmstate_get_echo_seq(msg);
#else
uint8_t len = msg->len < MAVLINK_MSG_ID_CCMState_LEN? msg->len : MAVLINK_MSG_ID_CCMState_LEN;
memset(ccmstate, 0, MAVLINK_MSG_ID_CCMState_LEN);
memcpy(ccmstate, _MAV_PAYLOAD(msg), len);
#endif
}
+135
View File
@@ -4447,6 +4447,139 @@ static void mavlink_test_turbinestate(uint16_t system_id, uint8_t component_id,
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}
static void mavlink_test_bmustate(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_BMUState >= 256) {
return;
}
#endif
mavlink_message_t msg;
uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
uint16_t i;
mavlink_bmustate_t packet_in = {
963497464,17443,17547,17651,17755,17859,{ 17963, 17964, 17965, 17966, 17967, 17968, 17969 },18691,18795,18899,19003,19107,19211,19315,{ 19419, 19420, 19421, 19422, 19423, 19424, 19425, 19426, 19427, 19428, 19429, 19430, 19431, 19432 },20875,20979,99,166,233,44,111
};
mavlink_bmustate_t packet1, packet2;
memset(&packet1, 0, sizeof(packet1));
packet1.time_boot_ms = packet_in.time_boot_ms;
packet1.BAT1_group_voltage_mv = packet_in.BAT1_group_voltage_mv;
packet1.BAT1_group_current_dA = packet_in.BAT1_group_current_dA;
packet1.BAT1_remain_perc = packet_in.BAT1_remain_perc;
packet1.BAT1_low_temp_degC = packet_in.BAT1_low_temp_degC;
packet1.BAT1_hi_temp_degC = packet_in.BAT1_hi_temp_degC;
packet1.BAT1_hi_voltage_mv = packet_in.BAT1_hi_voltage_mv;
packet1.BAT1_low_voltage_mv = packet_in.BAT1_low_voltage_mv;
packet1.BAT2_group_voltage_mv = packet_in.BAT2_group_voltage_mv;
packet1.BAT2_group_current_dA = packet_in.BAT2_group_current_dA;
packet1.BAT2_remain_perc = packet_in.BAT2_remain_perc;
packet1.BAT2_low_temp_degC = packet_in.BAT2_low_temp_degC;
packet1.BAT2_hi_temp_degC = packet_in.BAT2_hi_temp_degC;
packet1.BAT2_hi_voltage_mv = packet_in.BAT2_hi_voltage_mv;
packet1.BAT2_low_voltage_mv = packet_in.BAT2_low_voltage_mv;
packet1.BAT1_STA1 = packet_in.BAT1_STA1;
packet1.BAT1_STA2 = packet_in.BAT1_STA2;
packet1.BAT2_STA1 = packet_in.BAT2_STA1;
packet1.BAT2_STA2 = packet_in.BAT2_STA2;
packet1.p500w_enabled = packet_in.p500w_enabled;
mav_array_memcpy(packet1.BAT1_voltages_mv, packet_in.BAT1_voltages_mv, sizeof(uint16_t)*7);
mav_array_memcpy(packet1.BAT2_voltages_mv, packet_in.BAT2_voltages_mv, sizeof(uint16_t)*14);
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
// cope with extensions
memset(MAVLINK_MSG_ID_BMUState_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_BMUState_MIN_LEN);
}
#endif
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_bmustate_encode(system_id, component_id, &msg, &packet1);
mavlink_msg_bmustate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_bmustate_pack(system_id, component_id, &msg , packet1.time_boot_ms , packet1.BAT1_group_voltage_mv , packet1.BAT1_group_current_dA , packet1.BAT1_remain_perc , packet1.BAT1_low_temp_degC , packet1.BAT1_hi_temp_degC , packet1.BAT1_voltages_mv , packet1.BAT1_hi_voltage_mv , packet1.BAT1_low_voltage_mv , packet1.BAT2_group_voltage_mv , packet1.BAT2_group_current_dA , packet1.BAT2_remain_perc , packet1.BAT2_low_temp_degC , packet1.BAT2_hi_temp_degC , packet1.BAT2_voltages_mv , packet1.BAT2_hi_voltage_mv , packet1.BAT2_low_voltage_mv , packet1.BAT1_STA1 , packet1.BAT1_STA2 , packet1.BAT2_STA1 , packet1.BAT2_STA2 , packet1.p500w_enabled );
mavlink_msg_bmustate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_bmustate_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.time_boot_ms , packet1.BAT1_group_voltage_mv , packet1.BAT1_group_current_dA , packet1.BAT1_remain_perc , packet1.BAT1_low_temp_degC , packet1.BAT1_hi_temp_degC , packet1.BAT1_voltages_mv , packet1.BAT1_hi_voltage_mv , packet1.BAT1_low_voltage_mv , packet1.BAT2_group_voltage_mv , packet1.BAT2_group_current_dA , packet1.BAT2_remain_perc , packet1.BAT2_low_temp_degC , packet1.BAT2_hi_temp_degC , packet1.BAT2_voltages_mv , packet1.BAT2_hi_voltage_mv , packet1.BAT2_low_voltage_mv , packet1.BAT1_STA1 , packet1.BAT1_STA2 , packet1.BAT2_STA1 , packet1.BAT2_STA2 , packet1.p500w_enabled );
mavlink_msg_bmustate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_to_send_buffer(buffer, &msg);
for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
comm_send_ch(MAVLINK_COMM_0, buffer[i]);
}
mavlink_msg_bmustate_decode(last_msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_bmustate_send(MAVLINK_COMM_1 , packet1.time_boot_ms , packet1.BAT1_group_voltage_mv , packet1.BAT1_group_current_dA , packet1.BAT1_remain_perc , packet1.BAT1_low_temp_degC , packet1.BAT1_hi_temp_degC , packet1.BAT1_voltages_mv , packet1.BAT1_hi_voltage_mv , packet1.BAT1_low_voltage_mv , packet1.BAT2_group_voltage_mv , packet1.BAT2_group_current_dA , packet1.BAT2_remain_perc , packet1.BAT2_low_temp_degC , packet1.BAT2_hi_temp_degC , packet1.BAT2_voltages_mv , packet1.BAT2_hi_voltage_mv , packet1.BAT2_low_voltage_mv , packet1.BAT1_STA1 , packet1.BAT1_STA2 , packet1.BAT2_STA1 , packet1.BAT2_STA2 , packet1.p500w_enabled );
mavlink_msg_bmustate_decode(last_msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}
static void mavlink_test_ccmstate(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_CCMState >= 256) {
return;
}
#endif
mavlink_message_t msg;
uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
uint16_t i;
mavlink_ccmstate_t packet_in = {
963497464,963497672,{ 17651, 17652, 17653, 17654 },{ 18067, 18068, 18069, 18070 },77
};
mavlink_ccmstate_t packet1, packet2;
memset(&packet1, 0, sizeof(packet1));
packet1.time_boot_ms = packet_in.time_boot_ms;
packet1.fuel_level = packet_in.fuel_level;
packet1.echo_seq = packet_in.echo_seq;
mav_array_memcpy(packet1.temp, packet_in.temp, sizeof(int16_t)*4);
mav_array_memcpy(packet1.volts, packet_in.volts, sizeof(uint16_t)*4);
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
// cope with extensions
memset(MAVLINK_MSG_ID_CCMState_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_CCMState_MIN_LEN);
}
#endif
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_ccmstate_encode(system_id, component_id, &msg, &packet1);
mavlink_msg_ccmstate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_ccmstate_pack(system_id, component_id, &msg , packet1.time_boot_ms , packet1.fuel_level , packet1.temp , packet1.volts , packet1.echo_seq );
mavlink_msg_ccmstate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_ccmstate_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.time_boot_ms , packet1.fuel_level , packet1.temp , packet1.volts , packet1.echo_seq );
mavlink_msg_ccmstate_decode(&msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_to_send_buffer(buffer, &msg);
for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
comm_send_ch(MAVLINK_COMM_0, buffer[i]);
}
mavlink_msg_ccmstate_decode(last_msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
memset(&packet2, 0, sizeof(packet2));
mavlink_msg_ccmstate_send(MAVLINK_COMM_1 , packet1.time_boot_ms , packet1.fuel_level , packet1.temp , packet1.volts , packet1.echo_seq );
mavlink_msg_ccmstate_decode(last_msg, &packet2);
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}
static void mavlink_test_ardupilotmega(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
mavlink_test_sensor_offsets(system_id, component_id, last_msg);
@@ -4522,6 +4655,8 @@ static void mavlink_test_ardupilotmega(uint16_t system_id, uint8_t component_id,
mavlink_test_enginestatus(system_id, component_id, last_msg);
mavlink_test_enginestate(system_id, component_id, last_msg);
mavlink_test_turbinestate(system_id, component_id, last_msg);
mavlink_test_bmustate(system_id, component_id, last_msg);
mavlink_test_ccmstate(system_id, component_id, last_msg);
}
#ifdef __cplusplus
+33
View File
@@ -1798,5 +1798,38 @@
<field type="uint8_t" name="CFuelMode">CFuelMode</field>
<field type="uint8_t" name="Cmd">Cmd</field>
</message>
<message id="20301" name="BMUState">
<description>BMU Status</description>
<field type="uint32_t" name="time_boot_ms" units="ms">Timestamp (milliseconds since system boot)</field>
<field type="uint16_t" name="BAT1_group_voltage_mv">group_voltage_mv</field>
<field type="uint16_t" name="BAT1_group_current_dA">group_current_dA</field>
<field type="uint16_t" name="BAT1_remain_perc">remain_perc</field>
<field type="uint16_t" name="BAT1_low_temp_degC">low_temp_degC</field>
<field type="uint16_t" name="BAT1_hi_temp_degC">hi_temp_degC</field>
<field type="uint16_t[7]" name="BAT1_voltages_mv">voltages_mv</field>
<field type="uint16_t" name="BAT1_hi_voltage_mv">hi_voltage_mv</field>
<field type="uint16_t" name="BAT1_low_voltage_mv">low_voltage_mv</field>
<field type="uint16_t" name="BAT2_group_voltage_mv">group_voltage_mv</field>
<field type="uint16_t" name="BAT2_group_current_dA">group_current_dA</field>
<field type="uint16_t" name="BAT2_remain_perc">remain_perc</field>
<field type="uint16_t" name="BAT2_low_temp_degC">low_temp_degC</field>
<field type="uint16_t" name="BAT2_hi_temp_degC">hi_temp_degC</field>
<field type="uint16_t[14]" name="BAT2_voltages_mv">voltages_mv</field>
<field type="uint16_t" name="BAT2_hi_voltage_mv">hi_voltage_mv</field>
<field type="uint16_t" name="BAT2_low_voltage_mv">low_voltage_mv</field>
<field type="uint8_t" name="BAT1_STA1">BAT1_STA1</field>
<field type="uint8_t" name="BAT1_STA2">BAT1_STA2</field>
<field type="uint8_t" name="BAT2_STA1">BAT2_STA1</field>
<field type="uint8_t" name="BAT2_STA2">BAT2_STA2</field>
<field type="uint8_t" name="p500w_enabled">p500w_enabled</field>
</message>
<message id="20302" name="CCMState">
<description>CCM Status</description>
<field type="uint32_t" name="time_boot_ms" units="ms">Timestamp (milliseconds since system boot)</field>
<field type="uint32_t" name="fuel_level">fuel level</field>
<field type="int16_t[4]" name="temp">temp</field>
<field type="uint16_t[4]" name="volts">volts</field>
<field type="uint8_t" name="echo_seq">echo seq</field>
</message>
</messages>
</mavlink>