add: better error message when DPEC fails to validate
This commit is contained in:
parent
c9c9ac06d3
commit
6145508e8b
@ -85,8 +85,7 @@ HAL_StatusTypeDef initAMS(SPI_HandleTypeDef* hspi) {
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef amsWakeUp() {
|
||||
uint8_t buffer[CMD_BUFFER_SIZE(CFG_GROUP_A_SIZE)] = {0};
|
||||
return readCMD(RDCFGA, buffer, CFG_GROUP_A_SIZE);
|
||||
return __pollCMD(PLADC, 100); //wake up ADBMS6830, wait for T_wake = 200 us (100 cycles at 500 kHz)
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef amsCellMeasurement(Cell_Module (*module)[N_BMS]) {
|
||||
|
@ -252,6 +252,18 @@ HAL_StatusTypeDef ___readCMD(uint16_t command, uint8_t * buffer, size_t arglen)
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
size_t offset = BUFFER_BMS_OFFSET(i, arglen);
|
||||
if (checkDataPEC(&buffer[offset], arglen + 2) != 0) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Invalid data PEC when reading BMS %d", i);
|
||||
debug_log(LOG_LEVEL_ERROR, "Received: ");
|
||||
for (size_t j = 0; j < arglen + 2; j++) {
|
||||
debug_log_cont(LOG_LEVEL_ERROR, "%02X ", buffer[offset + j]);
|
||||
}
|
||||
debug_log_cont(LOG_LEVEL_ERROR, " | %02X %02X ", buffer[offset + arglen], buffer[offset + arglen + 1]); //print out the DPEC
|
||||
debug_log(LOG_LEVEL_ERROR, "^ DATA");
|
||||
//print out spaces until start of DPEC
|
||||
for (size_t j = 0; j < arglen; j++) {
|
||||
debug_log_cont(LOG_LEVEL_ERROR, (arglen < 2) ? "" : " ");
|
||||
}
|
||||
debug_log(LOG_LEVEL_ERROR, " ^ DPEC");
|
||||
return HAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user