summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2015-11-10 10:24:35 +0800
committerBernard Xiong <[email protected]>2015-11-10 10:24:35 +0800
commit9d46ae69a724aeccf841a403e5bdee263728c482 (patch)
tree082deabeb97e4b4d2d8253f4d61db0836f3fae50 /components
parentdedc22379aebf4230e8d1183decb18f8257f9355 (diff)
[DeviceDrivers] fix the poll_rx issue in serial when there is no data.
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 3bae89c740..2cb298d7ff 100644
--- a/components/drivers/serial/serial.c
+++ b/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 --;