From 7c60be19543238ffcfc767396594303dc00e052d Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 13 Nov 2008 01:02:56 +0000 Subject: [PATCH] Add comments; note potential bug git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1215 42af7a65-404d-4744-a932-0658087f49c3 --- drivers/serialirq.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/serialirq.c b/drivers/serialirq.c index fc9f59eb740..ba859c2efca 100644 --- a/drivers/serialirq.c +++ b/drivers/serialirq.c @@ -129,16 +129,30 @@ void uart_recvchars(FAR uart_dev_t *dev) nexthead = 0; } + /* Loop putting characters into the receive buffer until eithe: (1) the buffer + * is full, or (2) there are not further characters to add. + */ + while (nexthead != dev->recv.tail && uart_rxavailable(dev)) { + /* Add the character to the buffer */ + dev->recv.buffer[dev->recv.head] = uart_receive(dev, &status); + /* Increment the index */ + dev->recv.head = nexthead; if (++nexthead >= dev->recv.size) { nexthead = 0; } + /* A character was added... if there is a thread waiting for more data, then + * post the recvsem semaphore to wake it up. NOTE: There is a logic error in + * the above looping logic: If nexthead == dev->recv.tail on entry and + * recvwaiting is true, the recvsem will never get posted! + */ + if (dev->recvwaiting) { dev->recvwaiting = FALSE;