diff --git a/arch/sim/src/sim/sim_uart.c b/arch/sim/src/sim/sim_uart.c index 98e5ed53c65ff..0aa4df58291c6 100644 --- a/arch/sim/src/sim/sim_uart.c +++ b/arch/sim/src/sim/sim_uart.c @@ -293,6 +293,7 @@ static void uart_nputs(int fd, const char *buf, size_t size) while (size > 0) { int ret = host_uart_puts(fd, buf, size); + if (ret < 0) { continue; @@ -622,7 +623,12 @@ static void tty_dmareceive(struct uart_dev_s *dev) { xfer->nbytes = ret; - if (ret == xfer->length && xfer->nlength > 0) + /* The console fd is blocking, so only continue into the wrapped + * part of the circular buffer if there is really more data. + */ + + if (ret == xfer->length && xfer->nlength > 0 && + host_uart_checkin(priv->fd)) { ret = host_uart_gets(priv->fd, xfer->nbuffer, xfer->nlength); if (ret > 0) @@ -800,6 +806,7 @@ void up_putc(int ch) { #ifdef USE_DEVCONSOLE char c = ch; + up_nputs(&c, 1); #endif }