You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/06/15 20:22:26 UTC
[incubator-nuttx-apps] branch master updated (853439f -> db338bf)
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git.
from 853439f composite: nxstyle fixes
new b888f5f pty: pause() instead of sleep for long time
new f88e4af pty: support waiting for underlying serial device to appear, useful for pty over USBDEV serial device
new db338bf pty: nxstyle fixes
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
examples/pty_test/Kconfig | 8 ++++++++
examples/pty_test/pty_test.c | 40 ++++++++++++++++++++++++++++++++++------
2 files changed, 42 insertions(+), 6 deletions(-)
[incubator-nuttx-apps] 01/03: pty: pause() instead of sleep for
long time
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit b888f5f5e654896cefb1dc898a3b8e41e5f2a7cb
Author: Matias Nitsche <mn...@dc.uba.ar>
AuthorDate: Mon Jun 15 12:26:21 2020 -0300
pty: pause() instead of sleep for long time
---
examples/pty_test/pty_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/pty_test/pty_test.c b/examples/pty_test/pty_test.c
index a4d90ef..262e576 100644
--- a/examples/pty_test/pty_test.c
+++ b/examples/pty_test/pty_test.c
@@ -394,7 +394,7 @@ int main(int argc, FAR char *argv[])
{
/* Nothing to do, then sleep to avoid eating all cpu time */
- usleep(10000);
+ pause();
}
return EXIT_SUCCESS;
[incubator-nuttx-apps] 02/03: pty: support waiting for underlying
serial device to appear, useful for pty over USBDEV serial device
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit f88e4af8afe4b1cac0e7c369d60e206b3718607e
Author: Matias Nitsche <mn...@dc.uba.ar>
AuthorDate: Mon Jun 15 12:27:13 2020 -0300
pty: support waiting for underlying serial device to appear, useful for pty over USBDEV serial device
---
examples/pty_test/Kconfig | 8 ++++++++
examples/pty_test/pty_test.c | 28 +++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/examples/pty_test/Kconfig b/examples/pty_test/Kconfig
index 8448693..1f3921c 100644
--- a/examples/pty_test/Kconfig
+++ b/examples/pty_test/Kconfig
@@ -40,4 +40,12 @@ config EXAMPLES_PTYTEST_DAEMONPRIO
int "PTY_Test daemon task priority"
default 100
+config EXAMPLES_PTYTEST_WAIT_CONNECTED
+ bool "Keep retrying open serial device"
+ ---help---
+ For USB based serial devices, open will fail
+ if the other end is not connected (USB cable unplugged).
+ Enabling this option will retry the open() call every second
+ until connected.
+
endif
diff --git a/examples/pty_test/pty_test.c b/examples/pty_test/pty_test.c
index 262e576..8a285fd 100644
--- a/examples/pty_test/pty_test.c
+++ b/examples/pty_test/pty_test.c
@@ -315,9 +315,35 @@ int main(int argc, FAR char *argv[])
O_RDWR | O_NONBLOCK);
if (termpair.fd_uart < 0)
{
- fprintf(stderr, "Failed to open %s: %\n",
+#ifdef CONFIG_EXAMPLES_PTYTEST_WAIT_CONNECTED
+ /* if ENOTCONN is received, re-attempt to open periodically */
+
+ if (errno == ENOTCONN)
+ {
+ fprintf(stderr, "ERROR: device not connected, will continue trying\n");
+ }
+
+ while (termpair.fd_uart < 0 && errno == ENOTCONN)
+ {
+ sleep(1);
+
+ termpair.fd_uart = open(CONFIG_EXAMPLES_PTYTEST_SERIALDEV,
+ O_RDWR | O_NONBLOCK);
+ }
+
+ /* if we exited due to an error different than ENOTCONN */
+
+ if (termpair.fd_uart < 0)
+ {
+ fprintf(stderr, "Failed to open %s: %i\n",
+ CONFIG_EXAMPLES_PTYTEST_SERIALDEV, errno);
+ goto error_serial;
+ }
+#else
+ fprintf(stderr, "Failed to open %s: %i\n",
CONFIG_EXAMPLES_PTYTEST_SERIALDEV, errno);
goto error_serial;
+#endif
}
#ifdef CONFIG_SERIAL_TERMIOS
[incubator-nuttx-apps] 03/03: pty: nxstyle fixes
Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit db338bfbb2ac34f36c381abd76d9c2ca0d432612
Author: Matias Nitsche <mn...@dc.uba.ar>
AuthorDate: Mon Jun 15 15:20:29 2020 -0300
pty: nxstyle fixes
---
examples/pty_test/pty_test.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/examples/pty_test/pty_test.c b/examples/pty_test/pty_test.c
index 8a285fd..5d17e37 100644
--- a/examples/pty_test/pty_test.c
+++ b/examples/pty_test/pty_test.c
@@ -115,7 +115,7 @@ static void serial_in(struct term_pair_s *tp)
/* Run forever */
- for (;;)
+ while (true)
{
#ifdef CONFIG_EXAMPLES_PTYTEST_POLL
ret = poll((struct pollfd *)&fdp, 1, POLL_TIMEOUT);
@@ -194,7 +194,7 @@ static void serial_out(struct term_pair_s *tp)
/* Run forever */
- for (;;)
+ while (true)
{
#ifdef CONFIG_EXAMPLES_PTYTEST_POLL
ret = poll((struct pollfd *)&fdp, 1, POLL_TIMEOUT);
@@ -320,7 +320,8 @@ int main(int argc, FAR char *argv[])
if (errno == ENOTCONN)
{
- fprintf(stderr, "ERROR: device not connected, will continue trying\n");
+ fprintf(stderr, "ERROR: device not connected, will continue"
+ " trying\n");
}
while (termpair.fd_uart < 0 && errno == ENOTCONN)
@@ -382,7 +383,8 @@ int main(int argc, FAR char *argv[])
/* Create a new console using this /dev/pts/N */
pid = task_create("NSH Console", CONFIG_EXAMPLES_PTYTEST_DAEMONPRIO,
- CONFIG_EXAMPLES_PTYTEST_STACKSIZE, nsh_consolemain, NULL);
+ CONFIG_EXAMPLES_PTYTEST_STACKSIZE, nsh_consolemain,
+ NULL);
if (pid < 0)
{
/* Can't do output because stdout and stderr are redirected */
@@ -416,7 +418,7 @@ int main(int argc, FAR char *argv[])
/* Stay here to keep the threads running */
- for (;;)
+ while (true)
{
/* Nothing to do, then sleep to avoid eating all cpu time */