You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/03/08 14:03:05 UTC
[nuttx] branch master updated: driver/serial: Only enable tx interrupt if tx buffer is not empty
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new cfe6c4be8e driver/serial: Only enable tx interrupt if tx buffer is not empty
cfe6c4be8e is described below
commit cfe6c4be8e2ef6e5400502db640c1de3de0b2aee
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Wed Mar 8 15:10:41 2023 +0800
driver/serial: Only enable tx interrupt if tx buffer is not empty
Fix https://github.com/apache/nuttx/issues/8731
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
drivers/serial/serial.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 0f22ffb483..825e233601 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -776,6 +776,7 @@ static ssize_t uart_read(FAR struct file *filep,
#endif
irqstate_t flags;
ssize_t recvd = 0;
+ bool echoed = false;
int16_t tail;
char ch;
int ret;
@@ -924,6 +925,13 @@ static ssize_t uart_read(FAR struct file *filep,
}
uart_putxmitchar(dev, ch, true);
+
+ /* Mark the tx buffer have echoed content here,
+ * to avoid the tx buffer is empty such as special escape
+ * sequence received, but enable the tx interrupt.
+ */
+
+ echoed = true;
}
/* Skipping character count down */
@@ -1116,7 +1124,7 @@ static ssize_t uart_read(FAR struct file *filep,
}
}
- if (recvd > 0)
+ if (echoed)
{
#ifdef CONFIG_SERIAL_TXDMA
uart_dmatxavail(dev);