fix log crashes, ITEMP calculation
print CS_FLT details log errored AMS states as it happens
This commit is contained in:
parent
765f1e5ee1
commit
2bbe11267a
@ -147,7 +147,7 @@ HAL_StatusTypeDef amsAuxAndStatusMeasurement(Cell_Module (*module)[N_BMS]) {
|
||||
CHECK_RETURN(readCMD(RDSTATA, rxbuf, STATUS_GROUP_A_SIZE));
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_A_SIZE);
|
||||
(*module)[i].internalDieTemp = (mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8)) / 7.5) + 273; //datasheet page 72
|
||||
(*module)[i].internalDieTemp = (mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8)) / 7.5f) - 273; //datasheet page 72
|
||||
}
|
||||
|
||||
CHECK_RETURN(readCMD(RDSTATB, rxbuf, STATUS_GROUP_B_SIZE));
|
||||
|
@ -76,15 +76,27 @@ ADBMS_DetailedStatus AMS_Idle_Loop() {
|
||||
if (deviceSleeps > MAX_DEVICE_SLEEP) {
|
||||
return (ADBMS_DetailedStatus){ADBMS_INTERNAL_BMS_TIMEOUT, match - 1};
|
||||
} else {
|
||||
debug_log(LOG_LEVEL_WARNING, "BMS %d unexpectedly in sleep mode, resetting...", match - 1);
|
||||
amsReset();
|
||||
}
|
||||
}
|
||||
|
||||
if (any(module.status.CS_FLT || module.status.SPIFLT || module.status.CMED || module.status.SMED ||
|
||||
module.status.VDE || module.status.VDEL || module.status.OSCCHK || module.status.TMODCHK)) {
|
||||
if ((match = any(module.status.CS_FLT || module.status.SPIFLT || module.status.CMED || module.status.SMED ||
|
||||
module.status.VDE || module.status.VDEL || module.status.OSCCHK || module.status.TMODCHK))) {
|
||||
// Fault bits are latched -- clear them so we can check again next
|
||||
// iteration.
|
||||
amsClearFlag();
|
||||
// Log specific BMS fault details
|
||||
debug_log(LOG_LEVEL_ERROR, "Fault on BMS %d: ", match - 1);
|
||||
auto faultyModule = &modules[match - 1];
|
||||
if (faultyModule->status.CS_FLT) debug_log_cont(LOG_LEVEL_ERROR, "CS_FLT ");
|
||||
if (faultyModule->status.SPIFLT) debug_log_cont(LOG_LEVEL_ERROR, "SPIFLT ");
|
||||
if (faultyModule->status.CMED) debug_log_cont(LOG_LEVEL_ERROR, "CMED ");
|
||||
if (faultyModule->status.SMED) debug_log_cont(LOG_LEVEL_ERROR, "SMED ");
|
||||
if (faultyModule->status.VDE) debug_log_cont(LOG_LEVEL_ERROR, "VDE ");
|
||||
if (faultyModule->status.VDEL) debug_log_cont(LOG_LEVEL_ERROR, "VDEL ");
|
||||
if (faultyModule->status.OSCCHK) debug_log_cont(LOG_LEVEL_ERROR, "OSCCHK ");
|
||||
if (faultyModule->status.TMODCHK) debug_log_cont(LOG_LEVEL_ERROR, "TMODCHK ");
|
||||
|
||||
return (ADBMS_DetailedStatus){ADBMS_INTERNAL_BMS_FAULT, match - 1};
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ HAL_StatusTypeDef battery_update() {
|
||||
|
||||
for (size_t cell = 0; cell < N_CELLS; cell++) {
|
||||
if (voltage_flags & (1UL << cell)) {
|
||||
debug_log_cont(LOG_LEVEL_ERROR, "%zu (%d mV) ", cell, modules[ret.bms_id].cellVoltages[cell]);
|
||||
debug_log_cont(LOG_LEVEL_ERROR, "%u (%d mV) ", cell, modules[ret.bms_id].cellVoltages[cell]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ HAL_StatusTypeDef battery_update() {
|
||||
}
|
||||
|
||||
if (cellTemps[i][j] > (MAX_TEMP * (uint16_t)(TEMP_CONV))) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Cell %zu on BMS %zu overtemp: %d0 mC", j, i, cellTemps[i][j]);
|
||||
debug_log(LOG_LEVEL_ERROR, "Cell %u on BMS %u overtemp: %d0 mC", j, i, cellTemps[i][j]);
|
||||
can_send_error(TS_ERRORKIND_CELL_OVERTEMP, i);
|
||||
ts_sm_set_error_source(TS_ERROR_SOURCE_SLAVES, TS_ERRORKIND_CELL_OVERTEMP, true);
|
||||
} else {
|
||||
|
@ -139,10 +139,18 @@ void print_battery_info() {
|
||||
bufPos = stpcpy(bufPos, "VDEL ");
|
||||
hasFlags = true;
|
||||
}
|
||||
|
||||
swo_write(" Status flags: %s",
|
||||
hasFlags ? flagBuffer : "[none]");
|
||||
|
||||
|
||||
swo_write(" Status flags: %s", hasFlags ? flagBuffer : "[none]");
|
||||
|
||||
if (modules[i].status.CS_FLT) { // Print out which ADCs are faulting
|
||||
swo_write("Comparison fault on ADC/Cell(s): ");
|
||||
for (ssize_t j = 0; j < 16; j++) {
|
||||
if (modules[i].status.CS_FLT & (1u << j)) {
|
||||
swo_write("%d ", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
swo_write(" Conversion counter: %d",
|
||||
modules[i].status.CCTS);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user