|
|
@ -27,14 +27,14 @@ |
|
|
* Radkil fixed in 20260313 |
|
|
* Radkil fixed in 20260313 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
#include "elog.h" |
|
|
#include "../common/include/elog.h" |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
#ifdef ELOG_ASYNC_OUTPUT_ENABLE |
|
|
#ifdef ELOG_ASYNC_OUTPUT_ENABLE |
|
|
|
|
|
|
|
|
#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD |
|
|
#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD |
|
|
#include <sched.h> |
|
|
#include "../common/include/rd_thread.h" |
|
|
#include <semaphore.h> |
|
|
#include "../../../Drivers/CMSIS/RTOS2/include/cmsis_os2.h" |
|
|
/* thread default stack size */ |
|
|
/* thread default stack size */ |
|
|
#ifndef ELOG_ASYNC_OUTPUT_PTHREAD_STACK_SIZE |
|
|
#ifndef ELOG_ASYNC_OUTPUT_PTHREAD_STACK_SIZE |
|
|
#if PTHREAD_STACK_MIN > 4*1024 |
|
|
#if PTHREAD_STACK_MIN > 4*1024 |
|
|
@ -61,7 +61,7 @@ |
|
|
/* asynchronous output log notice */ |
|
|
/* asynchronous output log notice */ |
|
|
static Rd_sem_t output_notice; |
|
|
static Rd_sem_t output_notice; |
|
|
/* asynchronous output pthread thread */ |
|
|
/* asynchronous output pthread thread */ |
|
|
static pthread_t async_output_thread; |
|
|
//static pthread_t async_output_thread;
|
|
|
#endif /* ELOG_ASYNC_OUTPUT_USING_PTHREAD */ |
|
|
#endif /* ELOG_ASYNC_OUTPUT_USING_PTHREAD */ |
|
|
|
|
|
|
|
|
/* the highest output level for async mode, other level will sync output */ |
|
|
/* the highest output level for async mode, other level will sync output */ |
|
|
@ -289,7 +289,7 @@ void elog_async_output_notice(void) { |
|
|
Rd_SemPost(&output_notice, __func__, NULL); |
|
|
Rd_SemPost(&output_notice, __func__, NULL); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void *async_output(void *arg) { |
|
|
static void async_output(void *arg) { |
|
|
size_t get_log_size = 0; |
|
|
size_t get_log_size = 0; |
|
|
static char poll_get_buf[ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE]; |
|
|
static char poll_get_buf[ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE]; |
|
|
|
|
|
|
|
|
@ -312,7 +312,7 @@ static void *async_output(void *arg) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return NULL; |
|
|
return; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
@ -339,21 +339,17 @@ ElogErrCode elog_async_init(void) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD |
|
|
#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD |
|
|
pthread_attr_t thread_attr; |
|
|
|
|
|
struct sched_param thread_sched_param; |
|
|
|
|
|
|
|
|
|
|
|
Rd_SemInit(&output_notice, 0, 0); |
|
|
Rd_SemInit(&output_notice, 0, 0); |
|
|
|
|
|
|
|
|
thread_running = true; |
|
|
thread_running = true; |
|
|
|
|
|
|
|
|
pthread_attr_init(&thread_attr); |
|
|
const osThreadAttr_t log_output_attributes = { |
|
|
//pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
|
|
|
.name = "log_output", |
|
|
pthread_attr_setstacksize(&thread_attr, ELOG_ASYNC_OUTPUT_PTHREAD_STACK_SIZE); |
|
|
.stack_size = ELOG_ASYNC_OUTPUT_PTHREAD_STACK_SIZE, |
|
|
pthread_attr_setschedpolicy(&thread_attr, SCHED_RR); |
|
|
.priority = 12, |
|
|
thread_sched_param.sched_priority = ELOG_ASYNC_OUTPUT_PTHREAD_PRIORITY; |
|
|
}; |
|
|
pthread_attr_setschedparam(&thread_attr, &thread_sched_param); |
|
|
(void)osThreadNew(async_output, NULL, &log_output_attributes); |
|
|
pthread_create(&async_output_thread, &thread_attr, async_output, NULL); |
|
|
|
|
|
pthread_attr_destroy(&thread_attr); |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
init_ok = true; |
|
|
init_ok = true; |
|
|
@ -375,9 +371,9 @@ void elog_async_deinit(void) { |
|
|
|
|
|
|
|
|
elog_async_output_notice(); |
|
|
elog_async_output_notice(); |
|
|
|
|
|
|
|
|
pthread_join(async_output_thread, NULL); |
|
|
// pthread_join(async_output_thread, NULL);
|
|
|
|
|
|
|
|
|
sem_destroy(&output_notice); |
|
|
// sem_destroy(&output_notice);
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
init_ok = false; |
|
|
init_ok = false; |
|
|
|