From 7f03b1ac71dbdaae1cf5659d3515bf2febd05bd2 Mon Sep 17 00:00:00 2001 From: LiuYan Date: Fri, 2 Jun 2023 16:21:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=BD=93=E4=B8=8D=E5=90=AF=E7=94=A8=20RT?= =?UTF-8?q?=5FUSING=5FDEVICE=20=E6=97=B6=E4=B8=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E9=98=BB=E5=A1=9Eshell=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E5=8F=B7=E9=87=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/finsh/shell.c | 3 ++- components/finsh/shell.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 0d41625184..7d7bce68b0 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -883,8 +883,9 @@ int finsh_system_init(void) &finsh_thread_stack[0], sizeof(finsh_thread_stack), FINSH_THREAD_PRIORITY, 10); #endif /* RT_USING_HEAP */ - +#ifdef RT_USING_DEVICE rt_sem_init(&(shell->rx_sem), "shrx", 0, 0); +#endif finsh_set_prompt_mode(1); if (tid != NULL && result == RT_EOK) diff --git a/components/finsh/shell.h b/components/finsh/shell.h index e6b1921c60..4a2cc76589 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -60,7 +60,9 @@ enum input_stat }; struct finsh_shell { +#ifdef RT_USING_DEVICE struct rt_semaphore rx_sem; +#endif enum input_stat stat; -- Gitee From d718aff7308b4f3894da82b0eed9a11f8b1a61b4 Mon Sep 17 00:00:00 2001 From: LiuYan Date: Mon, 5 Jun 2023 17:26:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtp=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 6c184fbf43..7ea612342c 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -226,8 +226,8 @@ int gettimeofday(struct timeval *tp, void *ignore) tp->tv_usec = 0; } #else - tv->tv_sec = 0; - tv->tv_usec = 0; + tp->tv_sec = 0; + tp->tv_usec = 0; #endif return time; -- Gitee From d02b534dcc4b913a98017d84f38153ea0a72472a Mon Sep 17 00:00:00 2001 From: LiuYan Date: Tue, 6 Jun 2023 11:53:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=5Fsys=5Fwrite()=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BD=93=20RT=5FUSING=5FDEVICE=20=E6=9C=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=97=B6=20printf=20=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98;=20=E4=BD=BF=E7=94=A8=20rt=5Fkputs?= =?UTF-8?q?=20=E6=9B=BF=E6=8D=A2rt=5Fkprintf=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/armlibc/stubs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c index 5d9331ba17..c6e7926a6b 100644 --- a/components/libc/compilers/armlibc/stubs.c +++ b/components/libc/compilers/armlibc/stubs.c @@ -11,6 +11,9 @@ * in msh. * 2020-08-05 Meco Man fixed _sys_flen() compiling-warning when * RT_USING_DFS is not defined + * 2023-06-06 LiuYan 修改 _sys_write() 解决当 RT_USING_DEVICE 未 + * 定义时 printf 无效的问题;使用 rt_kputs 替换 + * rt_kprintf,优化速度。 */ #include @@ -179,7 +182,10 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) if ((fh == STDOUT) || (fh == STDERR)) { -#if !defined(RT_USING_CONSOLE) || !defined(RT_USING_DEVICE) +#if !defined(RT_USING_CONSOLE) + return 0; +#elif !defined(RT_USING_DEVICE) + rt_kputs((const char *)buf); return 0; #else #ifdef RT_USING_POSIX @@ -246,10 +252,10 @@ char *_sys_command_string(char *cmd, int len) void _ttywrch(int ch) { #ifdef RT_USING_CONSOLE - char c; + char c[2] = {0}; - c = (char)ch; - rt_kprintf(&c); + c[0] = (char)ch; + rt_kputs(c); #endif } @@ -315,7 +321,7 @@ int fputc(int c, FILE *f) char ch[2] = {0}; ch[0] = c; - rt_kprintf(&ch[0]); + rt_kputs(&ch[0]); return 1; } -- Gitee From 1c6872760b4c195b2c8fca55126f8b6fb6f27e45 Mon Sep 17 00:00:00 2001 From: LiuYan Date: Wed, 21 Jun 2023 16:53:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dulog=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=9C=AB=E5=B0=BE=E6=B2=A1=E6=9C=89=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E7=AC=A6=E7=9A=84BUG=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/utilities/ulog/ulog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index 757fa5276c..c5fb53f899 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -280,7 +280,7 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta log_buf[log_len + 1 + tick_len + 1] = '\0'; #endif /* ULOG_TIME_USING_TIMESTAMP */ - log_len += rt_strlen(log_buf + log_len); + log_len += rt_strlen(log_buf) + log_len; } #endif /* ULOG_OUTPUT_TIME */ @@ -368,6 +368,8 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta if (newline) { log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); + log_buf[log_len] = 0; + log_len++; } #ifdef ULOG_USING_COLOR -- Gitee