Skip to content

Commit 101f293

Browse files
committed
Added new BMS counters
1 parent 2848ec1 commit 101f293

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

bms.c

+30
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,30 @@ bool bms_process_can_frame(uint32_t can_id, uint8_t *data8, int len, bool is_ext
268268
}
269269
} break;
270270

271+
case CAN_PACKET_BMS_AH_WH_CHG_TOTAL: {
272+
used_data = true;
273+
274+
if (id == m_values.can_id || UTILS_AGE_S(m_values.update_time) > MAX_CAN_AGE_SEC) {
275+
int32_t ind = 0;
276+
m_values.can_id = id;
277+
m_values.update_time = chVTGetSystemTimeX();
278+
m_values.ah_cnt_chg_total = buffer_get_float32_auto(data8, &ind);
279+
m_values.wh_cnt_chg_total = buffer_get_float32_auto(data8, &ind);
280+
}
281+
} break;
282+
283+
case CAN_PACKET_BMS_AH_WH_DIS_TOTAL: {
284+
used_data = true;
285+
286+
if (id == m_values.can_id || UTILS_AGE_S(m_values.update_time) > MAX_CAN_AGE_SEC) {
287+
int32_t ind = 0;
288+
m_values.can_id = id;
289+
m_values.update_time = chVTGetSystemTimeX();
290+
m_values.ah_cnt_dis_total = buffer_get_float32_auto(data8, &ind);
291+
m_values.wh_cnt_dis_total = buffer_get_float32_auto(data8, &ind);
292+
}
293+
} break;
294+
271295
default:
272296
break;
273297
}
@@ -390,6 +414,12 @@ void bms_process_cmd(unsigned char *data, unsigned int len,
390414
// CAN ID
391415
send_buffer[ind++] = m_values.can_id;
392416

417+
// Total charge and discharge counters
418+
buffer_append_float32_auto(send_buffer, m_values.ah_cnt_chg_total, &ind);
419+
buffer_append_float32_auto(send_buffer, m_values.wh_cnt_chg_total, &ind);
420+
buffer_append_float32_auto(send_buffer, m_values.ah_cnt_dis_total, &ind);
421+
buffer_append_float32_auto(send_buffer, m_values.wh_cnt_dis_total, &ind);
422+
393423
reply_func(send_buffer, ind);
394424
} break;
395425

conf_general.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define FW_VERSION_MAJOR 5
2525
#define FW_VERSION_MINOR 03
2626
// Set to 0 for building a release and iterate during beta test builds
27-
#define FW_TEST_VERSION_NUMBER 17
27+
#define FW_TEST_VERSION_NUMBER 18
2828

2929
#include "datatypes.h"
3030

datatypes.h

+6
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ typedef struct {
264264
float soc;
265265
float soh;
266266
int can_id;
267+
float ah_cnt_chg_total;
268+
float wh_cnt_chg_total;
269+
float ah_cnt_dis_total;
270+
float wh_cnt_dis_total;
267271
systime_t update_time;
268272
} bms_values;
269273

@@ -1014,6 +1018,8 @@ typedef enum {
10141018
CAN_PACKET_BMS_HW_DATA_3,
10151019
CAN_PACKET_BMS_HW_DATA_4,
10161020
CAN_PACKET_BMS_HW_DATA_5,
1021+
CAN_PACKET_BMS_AH_WH_CHG_TOTAL,
1022+
CAN_PACKET_BMS_AH_WH_DIS_TOTAL,
10171023
} CAN_PACKET_ID;
10181024

10191025
// Logged fault data

0 commit comments

Comments
 (0)