1
0
Эх сурвалжийг харах

[update] fix finsh bug (#5676)

* [update] fix finsh bug

* [update] format code
LiuKang 3 жил өмнө
parent
commit
aa80ba25d4
1 өөрчлөгдсөн 10 нэмэгдсэн , 1 устгасан
  1. 10 1
      components/finsh/shell.c

+ 10 - 1
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