From 0433229be16defdeaff8aa3638c4946eda1b56ea 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 15:05:24 +0300 Subject: [PATCH] improve canstart --- main/cmd_can.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main/cmd_can.c b/main/cmd_can.c index 14763c9..ee52e5f 100644 --- a/main/cmd_can.c +++ b/main/cmd_can.c @@ -96,7 +96,6 @@ invalid_args: return 1; } - static int canrecover(int argc, char **argv) { esp_err_t res = twai_initiate_recovery(); if (res == ESP_OK) print_w_clr_time("Started CAN recovery.", LOG_COLOR_GREEN, false); @@ -153,10 +152,10 @@ static int canup(int argc, char **argv) { } static int canstart(int argc, char **argv) { - // Start CAN driver xSemaphoreTake(can_mutex, portMAX_DELAY); - ESP_ERROR_CHECK(twai_start()); - printf("CAN driver started\n"); + esp_err_t res = twai_start(); + if (res == ESP_OK) print_w_clr_time("CAN driver started", LOG_COLOR_GREEN, false); + else print_w_clr_time("Driver is not in stopped state, or is not installed.", LOG_COLOR_RED, false); xSemaphoreGive(can_mutex); return 0; }