diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-04-02 01:02:41 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-04-02 01:02:41 +0000 |
commit | dd4f93db606a1360efef7b59a97bd4a0bd8c6ad0 (patch) | |
tree | 09af0046e3d702c013359820c0115c36e370bdb6 /nuttx/drivers/serial | |
parent | 67a850ba575659cb195e67aa8357a70dece9c418 (diff) | |
download | px4-nuttx-dd4f93db606a1360efef7b59a97bd4a0bd8c6ad0.tar.gz px4-nuttx-dd4f93db606a1360efef7b59a97bd4a0bd8c6ad0.tar.bz2 px4-nuttx-dd4f93db606a1360efef7b59a97bd4a0bd8c6ad0.zip |
A couple of fixes to common and STM32 serial handling to fix some data overrun conditions
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4550 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/serial')
-rw-r--r-- | nuttx/drivers/serial/serial.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index 2fbd94cfd..7aa342d9d 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -321,11 +321,11 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen * data from the end of the buffer. */ - uart_disablerxint(dev); while (recvd < buflen) { /* Check if there is more data to return in the circular buffer */ + uart_disablerxint(dev); if (dev->recv.head != dev->recv.tail) { *buffer++ = dev->recv.buffer[dev->recv.tail]; @@ -335,6 +335,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen { dev->recv.tail = 0; } + uart_enablerxint(dev); } #ifdef CONFIG_DEV_SERIAL_FULLBLOCKS @@ -353,6 +354,8 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen { recvd = -EAGAIN; } + + uart_enablerxint(dev); break; } #else @@ -366,6 +369,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen * received up to the wait condition. */ + uart_enablerxint(dev); break; } @@ -379,6 +383,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen /* Break out of the loop returning -EAGAIN */ recvd = -EAGAIN; + uart_enablerxint(dev); break; } #endif @@ -395,12 +400,10 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen dev->recvwaiting = true; uart_enablerxint(dev); uart_takesem(&dev->recvsem); - uart_disablerxint(dev); irqrestore(flags); } } - uart_enablerxint(dev); uart_givesem(&dev->recv.sem); return recvd; } |