From c3594ab41ec10cb5ef993bd234113e1ffb230275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=93=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=88=D0=BA=D0=BE?= Date: Tue, 28 Nov 2023 08:21:04 +0300 Subject: [PATCH] fix logs while canup + make curr_can_state volatile --- main/can.c | 2 +- main/can.h | 2 +- main/cmd_can.c | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main/can.c b/main/can.c index d792ef8..7a779a4 100644 --- a/main/can.c +++ b/main/can.c @@ -14,7 +14,7 @@ static const char* LOG_TAG = "can"; bool is_error_passive = false; SemaphoreHandle_t can_mutex; -can_status_t curr_can_state = { 0 }; +volatile can_status_t curr_can_state = { 0 }; static can_status_t get_can_state() { can_status_t result; diff --git a/main/can.h b/main/can.h index 225cd1e..9aced92 100644 --- a/main/can.h +++ b/main/can.h @@ -51,7 +51,7 @@ static const twai_general_config_t g_config = { }; extern SemaphoreHandle_t can_mutex; -extern can_status_t curr_can_state; +extern volatile can_status_t curr_can_state; // functions diff --git a/main/cmd_can.c b/main/cmd_can.c index 693e759..efd5997 100644 --- a/main/cmd_can.c +++ b/main/cmd_can.c @@ -1,4 +1,5 @@ #include "cmd_can.h" +#include "esp_log.h" #include "freertos/portmacro.h" #include "inttypes.h" #include "driver/twai.h" @@ -116,6 +117,8 @@ static int canstats(int argc, char **argv) { static int canup(int argc, char **argv) { esp_err_t res; + esp_log_level_t prev_gpio_lvl = esp_log_level_get("gpio"); + esp_log_level_set("gpio", ESP_LOG_ERROR); xSemaphoreTake(can_mutex, portMAX_DELAY); // Install CAN driver // TODO: add CAN filtering @@ -130,6 +133,7 @@ static int canup(int argc, char **argv) { res = twai_start(); printf("CAN driver started\n"); xSemaphoreGive(can_mutex); + esp_log_level_set("gpio", prev_gpio_lvl); return 0; }