diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 0d416251843f99c55a0ce36efac2a10a76dc1947..7d7bce68b0345409bc15019e377897aec208625e 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 e6b1921c603db9e2104d8f283982843395032ed1..4a2cc765898fde40b44e52e9182d974138cd4203 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; diff --git a/components/libc/compilers/armlibc/stubs.c b/components/libc/compilers/armlibc/stubs.c index 5d9331ba17a9d436143aab6908cf22503bffde48..c6e7926a6bdd6e8345623644dee450a951d50ef2 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; } diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 6c184fbf43ed9d933b4fc08fca0b5506c4e8f360..7ea612342c42cbef41f3908f361bcdbd9a0d1a99 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; diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index 757fa5276c073b0c02247632f3ca52cf7aa09d82..c5fb53f8991cf66bb7f735417e79bbbe86363d50 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