sim/up_uart.c: fix losting uart data when user paste long cmd

N/A

Change-Id: I66c01c0789fc83ae8f6db522d61ff8ab63cd9211
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-02-02 17:50:56 +08:00 committed by Xiang Xiao
parent f423403dfa
commit d009074ed5
2 changed files with 26 additions and 0 deletions

View file

@ -79,6 +79,7 @@ config ARCH_SIM
select ALARM_ARCH
select ONESHOT
select SERIAL_CONSOLE
select SERIAL_IFLOWCONTROL
---help---
Linux/Cygwin user-mode simulation.

View file

@ -81,6 +81,8 @@ static int tty_ioctl(FAR struct file *filep, int cmd,
static int tty_receive(FAR struct uart_dev_s *dev, uint32_t *status);
static void tty_rxint(FAR struct uart_dev_s *dev, bool enable);
static bool tty_rxavailable(FAR struct uart_dev_s *dev);
static bool tty_rxflowcontrol(FAR struct uart_dev_s *dev,
unsigned int nbuffered, bool upper);
static void tty_send(FAR struct uart_dev_s *dev, int ch);
static void tty_txint(FAR struct uart_dev_s *dev, bool enable);
static bool tty_txready(FAR struct uart_dev_s *dev);
@ -100,6 +102,7 @@ static const struct uart_ops_s g_tty_ops =
.receive = tty_receive,
.rxint = tty_rxint,
.rxavailable = tty_rxavailable,
.rxflowcontrol = tty_rxflowcontrol,
.send = tty_send,
.txint = tty_txint,
.txready = tty_txready,
@ -415,6 +418,28 @@ static bool tty_rxavailable(struct uart_dev_s *dev)
return simuart_checkc(dev->isconsole ? 0 : priv->fd);
}
/****************************************************************************
* Name: tty_rxflowcontrol
*
* Description:
* Return true if UART activated RX flow control to block more incoming
* data.
*
****************************************************************************/
static bool tty_rxflowcontrol(FAR struct uart_dev_s *dev,
unsigned int nbuffered, bool upper)
{
FAR struct uart_buffer_s *rxbuf = &dev->recv;
if (nbuffered == rxbuf->size)
{
return true;
}
return false;
}
/****************************************************************************
* Name: tty_send
*