15
main/can.cpp
15
main/can.cpp
@ -280,9 +280,6 @@ void parseCanInput()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t can_total_error_cnt = 0;
|
|
||||||
uint32_t can_sequential_error_cnt = 0;
|
|
||||||
|
|
||||||
void sendCanCommands()
|
void sendCanCommands()
|
||||||
{
|
{
|
||||||
constexpr auto send = [](uint32_t addr, auto value){
|
constexpr auto send = [](uint32_t addr, auto value){
|
||||||
@ -302,9 +299,13 @@ void sendCanCommands()
|
|||||||
ESP_LOGE(TAG, "ERROR: twai_transmit() failed with %s", esp_err_to_name(result));
|
ESP_LOGE(TAG, "ERROR: twai_transmit() failed with %s", esp_err_to_name(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t can_total_error_cnt = 0;
|
||||||
|
static uint32_t can_sequential_error_cnt = 0;
|
||||||
|
|
||||||
if (result == ESP_ERR_TIMEOUT) {
|
if (result == ESP_ERR_TIMEOUT) {
|
||||||
can_sequential_error_cnt++;
|
++can_sequential_error_cnt;
|
||||||
can_total_error_cnt++;
|
++can_total_error_cnt;
|
||||||
ESP_LOGW(TAG, "twai_transmit() took %lld ms, seq err: %d, total err: %d",
|
ESP_LOGW(TAG, "twai_transmit() took %lld ms, seq err: %d, total err: %d",
|
||||||
espchrono::ago(timestamp_before).count(),
|
espchrono::ago(timestamp_before).count(),
|
||||||
can_sequential_error_cnt,
|
can_sequential_error_cnt,
|
||||||
@ -317,10 +318,10 @@ void sendCanCommands()
|
|||||||
if (can_sequential_error_cnt > 3) {
|
if (can_sequential_error_cnt > 3) {
|
||||||
can_sequential_error_cnt = 0;
|
can_sequential_error_cnt = 0;
|
||||||
if (configs.canBusResetOnError.value) {
|
if (configs.canBusResetOnError.value) {
|
||||||
if (const auto err = twai_stop(); err != ESP_OK || true)
|
if (const auto err = twai_stop(); err != ESP_OK)
|
||||||
ESP_LOGE(TAG, "ERROR: twai_stop() failed with %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "ERROR: twai_stop() failed with %s", esp_err_to_name(err));
|
||||||
|
|
||||||
if (const auto err = twai_start(); err != ESP_OK || true)
|
if (const auto err = twai_start(); err != ESP_OK)
|
||||||
ESP_LOGE(TAG, "ERROR: twai_start() failed with %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "ERROR: twai_start() failed with %s", esp_err_to_name(err));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user