Fixed retarded log statements in can

This commit is contained in:
2022-09-08 22:13:22 +02:00
parent 785c887efe
commit e518388631

View File

@ -304,15 +304,15 @@ void sendCanCommands()
can_sequential_bus_errors = status_info.bus_error_count;
ESP_LOGW(TAG, "twai_transmit() failed after %lldms with %s, seq err: %d, total err: %d",
(timestamp_after - timestamp_before).count(),
std::chrono::floor<std::chrono::milliseconds>(timestamp_after - timestamp_before).count(),
esp_err_to_name(result),
can_sequential_error_cnt,
can_total_error_cnt);
}
else if (result != ESP_OK)
{
ESP_LOGD(TAG, "ERROR: twai_transmit() failed after %lldms with %s",
(timestamp_after - timestamp_before).count(),
ESP_LOGE(TAG, "twai_transmit() failed after %lldms with %s",
std::chrono::floor<std::chrono::milliseconds>(timestamp_after - timestamp_before).count(),
esp_err_to_name(result));
}
else
@ -326,28 +326,28 @@ void sendCanCommands()
can_sequential_error_cnt = 0;
if (configs.canResetOnError.value())
{
ESP_LOGW(TAG, "WARNING: Something isn't right, trying to restart can ic...");
ESP_LOGW(TAG, "Something isn't right, trying to restart can ic...");
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, "twai_stop() failed with %s", esp_err_to_name(err));
}
if (configs.canUninstallOnReset.value())
{
if (const auto err = twai_driver_uninstall(); err != ESP_OK) {
ESP_LOGE(TAG, "ERROR: twai_driver_uninstall() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_driver_uninstall() failed with %s", esp_err_to_name(err));
}
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_21, GPIO_NUM_22,
TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
if (const auto err = twai_driver_install(&g_config, &t_config, &f_config); err != ESP_OK) {
ESP_LOGE(TAG, "ERROR: twai_driver_install() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_driver_install() failed with %s", esp_err_to_name(err));
}
}
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, "twai_start() failed with %s", esp_err_to_name(err));
}
}
}