forked from test34/can_wizard
fix error passive after can restart
This commit is contained in:
parent
f28e4d953f
commit
4b95cb9a53
3 changed files with 9 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "can.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/portmacro.h"
|
||||
#include "freertos/projdefs.h"
|
||||
|
@ -96,7 +97,8 @@ void can_task(void* arg) {
|
|||
print_w_clr_time("CAN recovered!", LOG_COLOR_BLUE, false);
|
||||
if (auto_recovery) {
|
||||
print_w_clr_time("Starting CAN...", LOG_COLOR_GREEN, false);
|
||||
twai_start();
|
||||
ESP_ERROR_CHECK(twai_start());
|
||||
is_error_passive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ extern SemaphoreHandle_t can_mutex;
|
|||
extern volatile can_status_t curr_can_state;
|
||||
extern bool timestamp_enabled;
|
||||
extern bool auto_recovery;
|
||||
extern bool is_error_passive;
|
||||
|
||||
// functions
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@ static int canup(int argc, char **argv) {
|
|||
esp_restart();
|
||||
}
|
||||
ESP_ERROR_CHECK(twai_start());
|
||||
is_error_passive = false;
|
||||
print_w_clr_time("CAN driver started", LOG_COLOR_BLUE, true);
|
||||
free_exit:
|
||||
xSemaphoreGive(can_mutex);
|
||||
|
@ -247,8 +248,10 @@ free_exit:
|
|||
static int canstart(int argc, char **argv) {
|
||||
xSemaphoreTake(can_mutex, portMAX_DELAY);
|
||||
esp_err_t res = twai_start();
|
||||
if (res == ESP_OK) print_w_clr_time("CAN driver started", LOG_COLOR_GREEN, true);
|
||||
else print_w_clr_time("Driver is not in stopped state, or is not installed.", LOG_COLOR_RED, true);
|
||||
if (res == ESP_OK) {
|
||||
print_w_clr_time("CAN driver started", LOG_COLOR_GREEN, true);
|
||||
is_error_passive = false;
|
||||
} else print_w_clr_time("Driver is not in stopped state, or is not installed.", LOG_COLOR_RED, true);
|
||||
xSemaphoreGive(can_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue