Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion arch/sim/src/sim/sim_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change fd to the non-blocking mode

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing to non-blocking requires rework of more logic, this is the minimal correct fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uart_nputs() won't work well with it. Simulated uarts never execute this path, sim console fd is always forced to host fd=0.

Another thing is that we will change default host fd 0 setting (we have to call fcntl(0, F_SETFL, O_NONBLOCK) ) which we should recover after nuttx simulator is closed or crash.

This fix is ​​a one-line fix, changing it to NONBLOCK is a rebuild of how the sim console works.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uart_nputs() won't work well with it. Simulated uarts never execute this path, sim console fd is always forced to host fd=0.

Another thing is that we will change default host fd 0 setting (we have to call fcntl(0, F_SETFL, O_NONBLOCK) )

yes, here is the change: #20032
we use internally more than half year without problem.

which we should recover after nuttx simulator is closed or crash.

why need? non-block is the property of file handle, not the terminal.

This fix is ​​a one-line fix, changing it to NONBLOCK is a rebuild of how the sim console works.

* 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)
Expand Down Expand Up @@ -800,6 +806,7 @@ void up_putc(int ch)
{
#ifdef USE_DEVCONSOLE
char c = ch;

up_nputs(&c, 1);
#endif
}
Loading