Skip to content

Commit

Permalink
[update] fix finsh bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liukangcc committed Mar 15, 2022
1 parent 75a7cb6 commit d99193e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,19 @@ int finsh_getchar(void)
RT_ASSERT(shell != RT_NULL);

device = shell->device;
if (device == RT_NULL)
{
return -1; /* EOF */
}

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
Expand Down

0 comments on commit d99193e

Please sign in to comment.