5 #ifndef BMS_BMS_INTERFACE_H 6 #define BMS_BMS_INTERFACE_H 23 #define MAX_BAD_READS 200 24 #define BAUD_RATE B9600 26 #define BMS_PKG_START_DELIM ':' 27 #define BMS_PKG_START_DELIM_LEN 1 28 #define BMS_PKG_END_DELIM '~' 29 #define BMS_PKG_CRC_BACK_OFFSET 3 30 #define BMS_PKG_CRC_SIZE 2 31 #define BMS_PKG_BASE 16 //hexa 32 #define BMS_PKG_CMD_SUCCESS 130 33 #define BMS_PKG_PROTOCOL_VERSION 82 35 #define BMS_PKG_ADDR_INDX 1 36 #define BMS_PKG_ADDR_SIZE 2 38 #define BMS_PKG_CMD_INDX 3 39 #define BMS_PKG_CMD_SIZE 2 41 #define BMS_PKG_VER_INDX 5 42 #define BMS_PKG_VER_SIZE 2 44 #define BMS_PKG_LEN_INDX 7 45 #define BMS_PKG_LEN_SIZE 4 47 #define BMS_PKG_TIME_INDX 11 48 #define BMS_PKG_TIME_SIZE 14 50 #define BMS_PKG_VBAT_INDX 25 51 #define BMS_PKG_VBAT_SIZE 4 53 #define BMS_PKG_CELL_NUM_INDX 29 54 #define BMS_PKG_CELL_NUM_SIZE 2 56 #define BMS_PKG_CELLS_ARR_INDX 31 57 #define BMS_PKG_CELL_SIZE 4 59 #define BMS_PKG_CHRG_CURR_INDX 31 60 #define BMS_PKG_CHRG_CURR_SIZE 4 62 #define BMS_PKG_DCHRG_CURR_INDX 35 63 #define BMS_PKG_DCHRG_CURR_SIZE 4 66 #define BMS_PKG_TEMP_NUM_INDX 39 67 #define BMS_PKG_TEMP_NUM_SIZE 2 69 #define BMS_PKG_TEMPS_ARRAY_INDX 41 70 #define BMS_PKG_TEMP_SIZE 2 73 #define BMS_PKG_VSTATE_INDX 41 74 #define BMS_PKG_VSTATE_SIZE 4 76 #define BMS_PKG_CSTATE_INDX 45 77 #define BMS_PKG_CSTATE_SIZE 4 79 #define BMS_PKG_TSTATE_INDX 49 80 #define BMS_PKG_TSTATE_SIZE 4 82 #define BMS_PKG_ALARM_INDX 53 83 #define BMS_PKG_ALARM_SIZE 4 85 #define BMS_PKG_FET_STATE_INDX 57 86 #define BMS_PKG_FET_STATE_SIZE 2 88 #define BMS_PKG_WARN_VOV_INDX 59 89 #define BMS_PKG_WARN_VOV_SIZE 4 91 #define BMS_PKG_WARN_VUV_INDX 63 92 #define BMS_PKG_WARN_VUV_SIZE 4 94 #define BMS_PKG_NUM_WARN_VHIGH_INDX 67 95 #define BMS_PKG_NUM_WARN_VHIGH_SIZE 4 97 #define BMS_PKG_NUM_WARN_VLOW_INDX 71 98 #define BMS_PKG_NUM_WARN_VLOW_SIZE 4 100 #define BMS_PKG_BALANCE_STATE_INDX 75 101 #define BMS_PKG_BALANCE_STATE_SIZE 4 103 #define BMS_PKG_DCHG_NUM_INDX 79 104 #define BMS_PKG_DCHG_NUM_SIZE 4 106 #define BMS_PKG_CHG_NUM_INDX 83 107 #define BMS_PKG_CHG_NUM_SIZE 4 109 #define BMS_PKG_SOC_INDX 87 110 #define BMS_PKG_SOC_SIZE 2 112 #define BMS_PKG_CAP_NOW_INDX 89 113 #define BMS_PKG_CAP_NOW_SIZE 4 115 #define BMS_PKG_CAP_FULL_INDX 93 116 #define BMS_PKG_CAP_FULL_SIZE 4 185 const std::string SEND_ME_DATA_ =
":000200000ee8~";
187 void setAttributes();
188 int readPkgFromBMS(
char *buff,
size_t buff_size_limit);
189 data decodePkg(
char buff[],
size_t buff_size);
190 int fetchParam(
char buff[],
int param_indx,
size_t param_size);
193 void connect(std::string port);
199 return (byte >> position) & 0x1;
204 return (byte >> position) & 0x1;
211 #endif //BMS_BMS_INTERFACE_H uint8_t getBitInByte(uint8_t byte, uint8_t position)
std::vector< uint8_t > temps
uint8_t getBitInWord(uint16_t byte, uint8_t position)
std::vector< float > vcells
BMSErrorException(std::string err_msg)
BMSException(std::string err_msg)
#define BMS_PKG_CAP_FULL_INDX
BMSWarnException(std::string err_msg)