[update] fix finsh bug (#5676)

* [update] fix finsh bug

* [update] format code
This commit is contained in:
LiuKang 2022-03-15 16:56:59 +08:00 committed by GitHub
parent 75a7cb6929
commit aa80ba25d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,8 +168,17 @@ int finsh_getchar(void)
} }
while (rt_device_read(device, -1, &ch, 1) != 1) while (rt_device_read(device, -1, &ch, 1) != 1)
{
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
if (shell->device != device)
{
device = shell->device;
if (device == RT_NULL)
{
return -1;
}
}
}
return ch; return ch;
#endif /* RT_USING_POSIX_STDIO */ #endif /* RT_USING_POSIX_STDIO */
#else #else