fix: formatting of DPEC errors
This commit is contained in:
parent
11a2121fd8
commit
44c012082b
@ -104,7 +104,7 @@ static inline void debug_clear_console() {
|
||||
}
|
||||
|
||||
[[gnu::format(printf, 2, 3)]]
|
||||
static inline void debug_log(unsigned int level, const char *msg, ...) {
|
||||
static inline void debug_log(enum log_level_t level, const char *msg, ...) {
|
||||
if (!DEBUG_CHANNEL_ENABLED(level)) {
|
||||
return;
|
||||
}
|
||||
@ -139,7 +139,7 @@ static inline void debug_log(unsigned int level, const char *msg, ...) {
|
||||
}
|
||||
|
||||
[[gnu::format(printf, 2, 3)]]
|
||||
static inline void debug_log_cont(unsigned int level, const char *msg, ...) {
|
||||
static inline void debug_log_cont(enum log_level_t level, const char *msg, ...) {
|
||||
if (!DEBUG_CHANNEL_ENABLED(level)) {
|
||||
return;
|
||||
}
|
||||
|
@ -248,6 +248,10 @@ HAL_StatusTypeDef ___readCMD(uint16_t command, uint8_t * buffer, size_t arglen)
|
||||
}
|
||||
}
|
||||
|
||||
if (arglen == 0) {
|
||||
return HAL_OK; //no data to check
|
||||
}
|
||||
|
||||
//check data PEC
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
size_t offset = BUFFER_BMS_OFFSET(i, arglen);
|
||||
@ -257,13 +261,14 @@ HAL_StatusTypeDef ___readCMD(uint16_t command, uint8_t * buffer, size_t arglen)
|
||||
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");
|
||||
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) ? "" : " ");
|
||||
for (size_t j = 0; j < arglen - 1; j++) {
|
||||
debug_log_cont(LOG_LEVEL_ERROR, (arglen < 2) ? "" : "^^^");
|
||||
}
|
||||
debug_log(LOG_LEVEL_ERROR, " ^ DPEC");
|
||||
debug_log_cont(LOG_LEVEL_ERROR, "^^ ");
|
||||
debug_log_cont(LOG_LEVEL_ERROR, " PEC ^");
|
||||
return HAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user