瀏覽代碼

[DeviceDrivers] fix the poll_rx issue in serial when there is no data.

Bernard Xiong 9 年之前
父節點
當前提交
9d46ae69a7
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      components/drivers/serial/serial.c

+ 3 - 0
components/drivers/serial/serial.c

@@ -29,6 +29,7 @@
  * 2014-12-31     bernard      use open_flag for poll_tx stream mode.
  * 2015-05-19     Quintin      fix DMA tx mod tx_dma->activated flag !=RT_FALSE BUG 
  *                             in open function.
+ * 2015-11-10     bernard      fix the poll rx issue when there is no data.
  */
 
 #include <rthw.h>
@@ -49,6 +50,8 @@ rt_inline int _serial_poll_rx(struct rt_serial_device *serial, rt_uint8_t *data,
     while (length)
     {
         ch = serial->ops->getc(serial);
+        if (ch == -1) break;
+
         *data = ch; 
         data ++; length --;