diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 824c60392d94c54d39a36eb5f5018c6cbbea7a52..3304733496bb5ace601fb67ce33349af9653d81e 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -168,8 +168,17 @@ int finsh_getchar(void) } while (rt_device_read(device, -1, &ch, 1) != 1) + { rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); - + if (shell->device != device) + { + device = shell->device; + if (device == RT_NULL) + { + return -1; + } + } + } return ch; #endif /* RT_USING_POSIX_STDIO */ #else