From 7e75c475d46f304d16fce7e95d0861eb73ae2da9 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 17 Dec 2022 03:33:15 +0800 Subject: [PATCH] arch/sim: Move '\n' process from tty_send to up_putc to avoid this special process happen twice Signed-off-by: Xiang Xiao --- arch/sim/src/sim/sim_uart.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/sim/src/sim/sim_uart.c b/arch/sim/src/sim/sim_uart.c index 7d8b4dc7bd..6ebf3d8d87 100644 --- a/arch/sim/src/sim/sim_uart.c +++ b/arch/sim/src/sim/sim_uart.c @@ -428,13 +428,6 @@ static void tty_send(struct uart_dev_s *dev, int ch) { struct tty_priv_s *priv = dev->priv; - /* For console device */ - - if (dev->isconsole && ch == '\n') - { - host_uart_putc(1, '\r'); - } - host_uart_putc(dev->isconsole ? 1 : priv->fd, ch); } @@ -567,6 +560,11 @@ void sim_uartloop(void) int up_putc(int ch) { #ifdef USE_DEVCONSOLE + if (ch == '\n') + { + tty_send(&g_console_dev, '\r'); + } + tty_send(&g_console_dev, ch); #endif return 0;