mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 07:23:34 +08:00
A couple of fixes to common and STM32 serial handling to fix some data overrun conditions
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4550 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user