This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 3fd4ea8587a3e14977a84580bf4d9140917e379f
Author: raiden00pl <[email protected]>
AuthorDate: Tue Feb 7 14:14:38 2023 +0100

    nxscope/nxscope_iser.c: wait for device if CONFIG_SERIAL_REMOVALBE=y
---
 logging/nxscope/nxscope_iser.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/logging/nxscope/nxscope_iser.c b/logging/nxscope/nxscope_iser.c
index 35004dd95..61860abe8 100644
--- a/logging/nxscope/nxscope_iser.c
+++ b/logging/nxscope/nxscope_iser.c
@@ -177,10 +177,35 @@ int nxscope_ser_init(FAR struct nxscope_intf_s *intf,
       flags |= O_NONBLOCK;
     }
 
+#ifdef CONFIG_SERIAL_REMOVABLE
+  do
+    {
+      /* Try to open the console */
+
+      priv->fd = open(priv->cfg->path, flags);
+      if (priv->fd < 0)
+        {
+          /* ENOTCONN means that the USB device is not yet connected.
+           * Anything else is bad.
+           */
+
+          if (errno != ENOTCONN)
+            {
+              break;
+            }
+
+          /* Sleep a bit and try again */
+
+          sleep(1);
+        }
+    }
+  while (priv->fd < 0);
+#else
   priv->fd = open(priv->cfg->path, flags);
+#endif
   if (priv->fd < 0)
     {
-      _err("ERROR: failed to open %s\n", priv->cfg->path);
+      _err("ERROR: failed to open %s %d\n", priv->cfg->path, errno);
       ret = -errno;
       goto errout;
     }

Reply via email to