diff --git a/examples/pty_test/pty_test.c b/examples/pty_test/pty_test.c index 0b6ad3caa..1064d50b0 100644 --- a/examples/pty_test/pty_test.c +++ b/examples/pty_test/pty_test.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -242,6 +243,7 @@ int pty_test_main(int argc, char *argv[]) #endif { struct term_pair_s termpair; + struct termios tio; pthread_t si_thread; pthread_t so_thread; char buffer[16]; @@ -306,6 +308,25 @@ int pty_test_main(int argc, char *argv[]) goto error_serial; } + /* Enable \n -> \r\n conversion during write */ + + ret = tcgetattr(termpair.fd_uart, &tio); + if (ret) + { + fprintf(stderr, "en_crlf_conv: ERROR during tcgetattr(): %d\n", + errno); + goto error_serial; + } + + tio.c_oflag = OPOST | ONLCR; + ret = tcsetattr(termpair.fd_uart, TCSANOW, &tio); + if (ret) + { + fprintf(stderr, "en_crlf_conv: ERROR during tcsetattr(): %d\n", + errno); + goto error_serial; + } + printf("Starting a new NSH Session using %s\n", buffer); /* Close default stdin, stdout and stderr */