From e01ac301154857dc4b1a1d6711e7ebeb87ea8e0c Mon Sep 17 00:00:00 2001 From: Riggin Date: Wed, 28 Jun 2023 17:26:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/port/flash.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/port/flash.md b/docs/zh/port/flash.md index 7823917..9242f91 100644 --- a/docs/zh/port/flash.md +++ b/docs/zh/port/flash.md @@ -36,7 +36,7 @@ ElogErrCode elog_flash_port_init(void) ### 3.2 Flash中的日志被读取后的输出接口 -将日志从Flash中读取后,调用`elog_flash_outout()`、`elog_flash_outout_all()`及`elog_flash_outout_recent()`进行输出展示时,将会调用此移植接口。可以在里面增加输出到终端、网络等功能。 +将日志从Flash中读取后,调用`elog_flash_output()`、`elog_flash_output_all()`及`elog_flash_output_recent()`进行输出展示时,将会调用此移植接口。可以在里面增加输出到终端、网络等功能。 ```C void elog_flash_port_output(const char *log, size_t size) @@ -75,7 +75,7 @@ void elog_flash_port_unlock(void) 配置时需要修改项目中的`elog_flash_cfg.h`文件,开启、关闭、修改对应的宏即可。 ### 4.1 缓冲模式 - + 开启后,需要写入Flash的日志会先存储至RAM缓冲区,当缓冲区满时,缓冲区中的所有日志将自动写入Flash。如果关闭,所有日志在输出时会立刻写入Flash。 - 默认状态:开启 From ad264f0df6c768937411711e628bf80c2059fea5 Mon Sep 17 00:00:00 2001 From: Riggin Date: Wed, 28 Jun 2023 17:39:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20elog=5Fraw()=20?= =?UTF-8?q?=E7=9A=84=E8=BE=93=E5=87=BA=E6=97=A0=E6=B3=95=E7=94=B1=20ELOG?= =?UTF-8?q?=5FOUTPUT=5FENABLE=E6=80=BB=E5=BC=80=E5=85=B3=20=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easylogger/inc/elog.h | 4 +++- easylogger/src/elog.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/easylogger/inc/elog.h b/easylogger/inc/elog.h index 719f4fb..978dbc4 100755 --- a/easylogger/inc/elog.h +++ b/easylogger/inc/elog.h @@ -73,6 +73,7 @@ extern "C" { #endif #ifndef ELOG_OUTPUT_ENABLE + #define elog_raw(...) #define elog_assert(tag, ...) #define elog_error(tag, ...) #define elog_warn(tag, ...) @@ -80,6 +81,7 @@ extern "C" { #define elog_debug(tag, ...) #define elog_verbose(tag, ...) #else /* ELOG_OUTPUT_ENABLE */ + #define elog_raw(...) elog_raw_output(__VA_ARGS__) #if ELOG_OUTPUT_LVL >= ELOG_LVL_ASSERT #define elog_assert(tag, ...) \ elog_output(ELOG_LVL_ASSERT, tag, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) @@ -191,7 +193,7 @@ void elog_set_filter_tag(const char *tag); void elog_set_filter_kw(const char *keyword); void elog_set_filter_tag_lvl(const char *tag, uint8_t level); uint8_t elog_get_filter_tag_lvl(const char *tag); -void elog_raw(const char *format, ...); +void elog_raw_output(const char *format, ...); void elog_output(uint8_t level, const char *tag, const char *file, const char *func, const long line, const char *format, ...); void elog_output_lock_enabled(bool enabled); diff --git a/easylogger/src/elog.c b/easylogger/src/elog.c index 1bc3b88..421a110 100755 --- a/easylogger/src/elog.c +++ b/easylogger/src/elog.c @@ -503,7 +503,7 @@ uint8_t elog_get_filter_tag_lvl(const char *tag) * @param format output format * @param ... args */ -void elog_raw(const char *format, ...) { +void elog_raw_output(const char *format, ...) { va_list args; size_t log_len = 0; int fmt_result; @@ -915,7 +915,7 @@ void elog_hexdump(const char *name, uint8_t width, const void *buf, uint16_t siz elog_async_output(ELOG_LVL_DEBUG, log_buf, log_len); #elif defined(ELOG_BUF_OUTPUT_ENABLE) extern void elog_buf_output(const char *log, size_t size); - elog_buf_output(log_buf, log_len); + elog_buf_output(log_buf, log_len); #else elog_port_output(log_buf, log_len); #endif From 8ea3ef9d3dbec7710ff8aa92249db7c418ec6db2 Mon Sep 17 00:00:00 2001 From: Riggin Date: Wed, 28 Jun 2023 17:47:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E8=BE=93=E5=87=BA=E6=A8=A1=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E4=B8=8D=E5=90=AF=E7=94=A8=20POSIX=20pthread=20?= =?UTF-8?q?=E5=BA=93=E6=97=B6=EF=BC=8C=E7=BC=96=E8=AF=91=E5=99=A8=E6=9C=89?= =?UTF-8?q?warning=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 警告信息 warning: 'thread_running' defined but not used [-Wunused-variable] --- easylogger/src/elog_async.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/easylogger/src/elog_async.c b/easylogger/src/elog_async.c index a8b7e2f..95db74b 100755 --- a/easylogger/src/elog_async.c +++ b/easylogger/src/elog_async.c @@ -80,8 +80,10 @@ static pthread_t async_output_thread; /* Initialize OK flag */ static bool init_ok = false; +#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD /* thread running flag */ static bool thread_running = false; +#endif /* asynchronous output mode enabled flag */ static bool is_enabled = false; /* asynchronous output mode's ring buffer */ From aee6f5c7430e2d400b2fc05d1da62cb6ed8513d3 Mon Sep 17 00:00:00 2001 From: Riggin Date: Wed, 28 Jun 2023 18:15:48 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=AD=A4demo=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=BC=82=E6=AD=A5=E8=BE=93=E5=87=BA=E5=8A=9F=E8=83=BD?= =?UTF-8?q?(//#define=20ELOG=5FASYNC=5FOUTPUT=5FENABLE)=EF=BC=8C=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E6=97=A5=E5=BF=97=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1,初始化时无需对两个信号量做释放操作。 2,修改elog_port_output()函数。 3,修改异步输出线程 void elog_entry(void *para)。 --- .../Components/EasyLogger_Port/elog_port.c | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/demo/os/cube-freertos/nucleo-g070rb/Components/EasyLogger_Port/elog_port.c b/demo/os/cube-freertos/nucleo-g070rb/Components/EasyLogger_Port/elog_port.c index f85d99e..1512a72 100644 --- a/demo/os/cube-freertos/nucleo-g070rb/Components/EasyLogger_Port/elog_port.c +++ b/demo/os/cube-freertos/nucleo-g070rb/Components/EasyLogger_Port/elog_port.c @@ -43,8 +43,6 @@ extern osSemaphoreId_t elog_dma_lockHandle; ElogErrCode elog_port_init(void) { ElogErrCode result = ELOG_NO_ERR; - osSemaphoreRelease(elog_dma_lockHandle); - osSemaphoreRelease(elog_lockHandle); /* add your code here */ return result; @@ -65,6 +63,7 @@ void elog_port_deinit(void) { */ void elog_port_output(const char *log, size_t size) { HAL_UART_Transmit_DMA(&huart2, (uint8_t *) log, size); + osSemaphoreAcquire(elog_dma_lockHandle, osWaitForever); } /** @@ -116,30 +115,28 @@ void elog_async_output_notice(void) { void elog_entry(void *para) { size_t get_log_size = 0; +#ifdef ELOG_ASYNC_LINE_OUTPUT static char poll_get_buf[ELOG_LINE_BUF_SIZE - 4]; - - if (elog_port_init() != ELOG_NO_ERR) { - goto fail; - } - - while (1) { - if (osOK == - osSemaphoreAcquire(elog_asyncHandle, osWaitForever)) { - while (1) { - if (osOK == - osSemaphoreAcquire(elog_dma_lockHandle, osWaitForever)) { - get_log_size = elog_async_get_line_log(poll_get_buf, sizeof(poll_get_buf)); - if (get_log_size) { - elog_port_output(poll_get_buf, get_log_size); - } else { - osSemaphoreRelease(elog_dma_lockHandle); - break; - } - } +#else + static char poll_get_buf[ELOG_ASYNC_OUTPUT_BUF_SIZE - 4]; +#endif + + for(;;) + { + /* waiting log */ + osSemaphoreAcquire(elog_asyncHandle, osWaitForever); + /* polling gets and outputs the log */ + while (1) { +#ifdef ELOG_ASYNC_LINE_OUTPUT + get_log_size = elog_async_get_line_log(poll_get_buf, sizeof(poll_get_buf)); +#else + get_log_size = elog_async_get_log(poll_get_buf, sizeof(poll_get_buf)); +#endif + if (get_log_size) { + elog_port_output(poll_get_buf, get_log_size); + } else { + break; } } } - - fail: - osThreadExit(); }