Skip to content

Commit 8b58577

Browse files
authored
[ulog][rtc][time][bug] solve the interference when enable the ulog timestamp (#5687)
* [ulog] 解决ulog开启时间戳后与libc time以及rtc驱动相关函数干涉的问题 * ulog:当发生递归输出时,后续递归想要输出的内容可能会因为防范递归的判断而无法输出 因此修改输出规则,在发生递归时,采用简单的,无格式的方式直接输出。这样既保证不会发生递归输出,也可以保证递归输出的部分可以正常输出。 * [ulog] size_t->rt_size_t NULL->RT_NULL
1 parent fba060e commit 8b58577

File tree

7 files changed

+97
-81
lines changed

7 files changed

+97
-81
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_rtc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static rt_err_t stm32_rtc_get_secs(void *args)
249249
struct timeval tv;
250250
get_rtc_timeval(&tv);
251251
*(rt_uint32_t *) args = tv.tv_sec;
252-
LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args);
252+
LOG_D("RTC: get rtc_time %x", *(rt_uint32_t *)args);
253253

254254
return RT_EOK;
255255
}
@@ -262,7 +262,7 @@ static rt_err_t stm32_rtc_set_secs(void *args)
262262
{
263263
result = -RT_ERROR;
264264
}
265-
LOG_D("RTC: set rtc_time %x\n", *(rt_uint32_t *)args);
265+
LOG_D("RTC: set rtc_time %x", *(rt_uint32_t *)args);
266266

267267
return result;
268268
}

components/libc/compilers/common/time.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,14 @@ static rt_err_t get_timeval(struct timeval *tv)
113113
}
114114
else
115115
{
116-
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
117-
rt_kprintf(_WARNING_NO_RTC);
116+
LOG_W(_WARNING_NO_RTC);
118117
return -RT_ENOSYS;
119118
}
120119

121120
return rst;
122121

123122
#else
124-
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
125-
rt_kprintf(_WARNING_NO_RTC);
123+
LOG_W(_WARNING_NO_RTC);
126124
return -RT_ENOSYS;
127125
#endif /* RT_USING_RTC */
128126
}

components/utilities/ulog/backend/console_be.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2021, RT-Thread Development Team
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -20,7 +20,7 @@
2020
static struct ulog_backend console = { 0 };
2121

2222
void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw,
23-
const char *log, size_t len)
23+
const char *log, rt_size_t len)
2424
{
2525
#ifdef RT_USING_DEVICE
2626
rt_device_t dev = rt_console_get_device();

components/utilities/ulog/syslog/syslog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2021, RT-Thread Development Team
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -170,7 +170,7 @@ static const char *get_month_str(uint8_t month)
170170

171171
RT_WEAK rt_size_t syslog_formater(char *log_buf, int level, const char *tag, rt_bool_t newline, const char *format, va_list args)
172172
{
173-
extern size_t ulog_strcpy(size_t cur_len, char *dst, const char *src);
173+
extern rt_size_t ulog_strcpy(rt_size_t cur_len, char *dst, const char *src);
174174

175175
rt_size_t log_len = 0, newline_len = rt_strlen(ULOG_NEWLINE_SIGN);
176176
int fmt_result;

0 commit comments

Comments
 (0)