@@ -89,32 +89,27 @@ bool syscmd_is_num(const char* str)
8989
9090char syscmd_getc (void )
9191{
92- char ch [SERIAL_RB_BUFSZ ];
93- // struct finsh_shell* shell = finsh_get_shell();
94-
92+ char ch ;
9593 syscmd_flush ();
96-
9794 if (rt_sem_take (& shell -> rx_sem , RT_WAITING_FOREVER ) != RT_EOK )
9895 return -1 ;
96+ rt_device_read (shell -> device , RT_WAITING_NO , & ch , 1 );
97+ syscmd_flush ();
9998
100- rt_device_read (shell -> device , 0 , & ch , SERIAL_RB_BUFSZ );
101-
102- return ch [0 ];
99+ return ch ;
103100}
104101
105102bool syscmd_has_input (void )
106103{
107- // struct finsh_shell* shell = finsh_get_shell();
108-
109104 return rt_sem_trytake (& shell -> rx_sem ) == RT_EOK ;
110105}
111106
112107void syscmd_flush (void )
113108{
114- // struct finsh_shell* shell = finsh_get_shell() ;
109+ char buffer [ SERIAL_RB_BUFSZ ] ;
115110
116- char ch [ SERIAL_RB_BUFSZ ] ;
117- rt_device_read (shell -> device , 0 , & ch , SERIAL_RB_BUFSZ );
111+ rt_sem_trytake ( & shell -> rx_sem ) ;
112+ rt_device_read (shell -> device , RT_WAITING_NO , buffer , SERIAL_RB_BUFSZ );
118113}
119114
120115void syscmd_putc (const char c , int cnt )
@@ -252,7 +247,7 @@ int syscmd_process(int argc, char** argv, shell_handle_func func)
252247 opt_v [opt_cnt ].val = NULL ;
253248 }
254249
255- //console_printf("opt:%s val:%s\n", opt_v[opt_cnt].opt, opt_v[opt_cnt].val);
250+ // console_printf("opt:%s val:%s\n", opt_v[opt_cnt].opt, opt_v[opt_cnt].val);
256251
257252 opt_cnt ++ ;
258253 } else {
@@ -269,7 +264,7 @@ int syscmd_process(int argc, char** argv, shell_handle_func func)
269264 memcpy (arg_v [arg_cnt ], argv [i ], arg_len );
270265 arg_v [arg_cnt ][arg_len ] = '\0' ;
271266
272- //console_printf("arg:%s\n", arg_v[arg_cnt]);
267+ // console_printf("arg:%s\n", arg_v[arg_cnt]);
273268
274269 arg_cnt ++ ;
275270 }
0 commit comments