You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/12/29 14:58:14 UTC

[GitHub] [incubator-nuttx] GUIDINGLI opened a new pull request #5114: serial: add CONFIG_TTY_LAUNCH support

GUIDINGLI opened a new pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114


   ## Summary
   
   serial: add CONFIG_TTY_LAUNCH support
   
   this allow user start new program from tty
   
   
   -  **TTY_LAUNCH** this depends on ``CONFIG_TTY_LAUNCH``, this feature
      allow user launch a new program with a special char input.
   
      e.g. use ctrl+R to start a nuttx shell.
      e.g. use ctrl+E to start user entry.
   
      You can use ``TTY_LAUNCH_CHAR`` to customize which speical char.
   
      You can choose launch method:
      ``TTY_LAUNCH_ENTRY`` or ``TTY_LAUNCH_FILE``,
      If``TTY_LAUNCH_ENTRY`` you can set program entery by ``TTY_LAUNCH_ENTRYPOINT``.
      If``TTY_LAUNCH_FILE`` you can set file path by ``TTY_LAUNCH_FILEPATH``.
   
      Also, you can customize:
      ``TTY_LAUNCH_ARGS`` ``TTY_LAUNCH_PRIORITY`` ``TTY_LAUNCH_STACKSIZE``
   
   ## Impact
   
   serial
   
   ## Testing
   
   vela
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#issuecomment-1002731015


   > @acassis to save the ram on the resource limited system, we let nsh exit after finish the initialization. This patch can bring nsh back in emerging case.
   
   Thank you @xiaoxiang781216 I think this feature should gain a guide documentation as well, not only the documentation about which things it supports, but how to use it. For example: setup your application as entry-point and run Ctrl+R to start the "nsh". 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] GUIDINGLI commented on a change in pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
GUIDINGLI commented on a change in pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#discussion_r776960661



##########
File path: drivers/serial/serial.c
##########
@@ -1609,6 +1625,58 @@ static int uart_poll(FAR struct file *filep,
   return ret;
 }
 
+/****************************************************************************
+ * Name: uart_nxsched_foreach_cb
+ ****************************************************************************/
+
+#ifdef CONFIG_TTY_LAUNCH
+static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME))
+#else
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH))
+#endif
+    {
+      *(int *)arg = 1;
+    }
+}
+
+static void uart_launch_worker(void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ARGS
+  FAR char *const argv[] =
+  {
+    CONFIG_TTY_LAUNCH_ARGS,
+    NULL,
+  };
+#else
+  FAR char *const *argv = NULL;
+#endif
+  int found = 0;
+
+  nxsched_foreach(uart_launch_foreach, &found);
+  if (!found)
+    {
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+      nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
+                    CONFIG_TTY_LAUNCH_PRIORITY,
+                    CONFIG_TTY_LAUNCH_STACKSIZE,
+                    (main_t)CONFIG_TTY_LAUNCH_ENTRYPOINT,
+                    argv);
+#else
+      posix_spawnattr_t attr;

Review comment:
       why?  No warning will gen here,   #ifdef #else #endif

##########
File path: drivers/serial/serial.c
##########
@@ -1609,6 +1625,58 @@ static int uart_poll(FAR struct file *filep,
   return ret;
 }
 
+/****************************************************************************
+ * Name: uart_nxsched_foreach_cb
+ ****************************************************************************/
+
+#ifdef CONFIG_TTY_LAUNCH
+static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME))
+#else
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH))
+#endif
+    {
+      *(int *)arg = 1;
+    }
+}
+
+static void uart_launch_worker(void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ARGS
+  FAR char *const argv[] =
+  {
+    CONFIG_TTY_LAUNCH_ARGS,
+    NULL,
+  };
+#else
+  FAR char *const *argv = NULL;
+#endif
+  int found = 0;
+
+  nxsched_foreach(uart_launch_foreach, &found);
+  if (!found)
+    {
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+      nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
+                    CONFIG_TTY_LAUNCH_PRIORITY,
+                    CONFIG_TTY_LAUNCH_STACKSIZE,
+                    (main_t)CONFIG_TTY_LAUNCH_ENTRYPOINT,
+                    argv);
+#else
+      posix_spawnattr_t attr;

Review comment:
       why? No warning will gen here, #ifdef #else #endif




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#issuecomment-1002640191






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#discussion_r776452544



##########
File path: Documentation/components/drivers/character/serial.rst
##########
@@ -19,6 +19,22 @@ Serial Device Drivers
    ``/dev/ttyS0``, ``/dev/ttyS1``, etc. See the
    ``uart_register()`` implementation in ``drivers/serial.c``.
 
+-  **TTY_LAUNCH** this depends on ``CONFIG_TTY_LAUNCH``, this feature
+   allow user launch a new program with a special char input.
+
+   e.g. use ctrl+R to start a nuttx shell.
+   e.g. use ctrl+E to start user entry.
+
+   You can use ``TTY_LAUNCH_CHAR`` to customize which speical char.

Review comment:
       speical -> special




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#issuecomment-1002640191


   @acassis to save the ram on the resource limited system, we let nsh exist after finish the initialization. This patch bring nsh back in emerging case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] GUIDINGLI commented on a change in pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
GUIDINGLI commented on a change in pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#discussion_r776960692



##########
File path: drivers/serial/serial.c
##########
@@ -1609,6 +1625,58 @@ static int uart_poll(FAR struct file *filep,
   return ret;
 }
 
+/****************************************************************************
+ * Name: uart_nxsched_foreach_cb
+ ****************************************************************************/
+
+#ifdef CONFIG_TTY_LAUNCH
+static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME))
+#else
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH))
+#endif
+    {
+      *(int *)arg = 1;
+    }
+}
+
+static void uart_launch_worker(void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ARGS
+  FAR char *const argv[] =
+  {
+    CONFIG_TTY_LAUNCH_ARGS,
+    NULL,
+  };
+#else
+  FAR char *const *argv = NULL;
+#endif
+  int found = 0;
+
+  nxsched_foreach(uart_launch_foreach, &found);
+  if (!found)
+    {
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+      nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
+                    CONFIG_TTY_LAUNCH_PRIORITY,
+                    CONFIG_TTY_LAUNCH_STACKSIZE,
+                    (main_t)CONFIG_TTY_LAUNCH_ENTRYPOINT,
+                    argv);
+#else
+      posix_spawnattr_t attr;

Review comment:
       why? No warning will gen here, #ifdef #else #endif




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#discussion_r777000462



##########
File path: drivers/serial/serial.c
##########
@@ -1609,6 +1625,58 @@ static int uart_poll(FAR struct file *filep,
   return ret;
 }
 
+/****************************************************************************
+ * Name: uart_nxsched_foreach_cb
+ ****************************************************************************/
+
+#ifdef CONFIG_TTY_LAUNCH
+static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME))
+#else
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH))
+#endif
+    {
+      *(int *)arg = 1;
+    }
+}
+
+static void uart_launch_worker(void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ARGS
+  FAR char *const argv[] =
+  {
+    CONFIG_TTY_LAUNCH_ARGS,
+    NULL,
+  };
+#else
+  FAR char *const *argv = NULL;
+#endif
+  int found = 0;
+
+  nxsched_foreach(uart_launch_foreach, &found);
+  if (!found)
+    {
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+      nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
+                    CONFIG_TTY_LAUNCH_PRIORITY,
+                    CONFIG_TTY_LAUNCH_STACKSIZE,
+                    (main_t)CONFIG_TTY_LAUNCH_ENTRYPOINT,
+                    argv);
+#else
+      posix_spawnattr_t attr;

Review comment:
       @acassis I think isn't necessary since attr is still the first statement from compiler perspective after the preprocess.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #5114: serial: add CONFIG_TTY_LAUNCH support

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #5114:
URL: https://github.com/apache/incubator-nuttx/pull/5114#discussion_r776455799



##########
File path: drivers/serial/serial.c
##########
@@ -1609,6 +1625,58 @@ static int uart_poll(FAR struct file *filep,
   return ret;
 }
 
+/****************************************************************************
+ * Name: uart_nxsched_foreach_cb
+ ****************************************************************************/
+
+#ifdef CONFIG_TTY_LAUNCH
+static void uart_launch_foreach(FAR struct tcb_s *tcb, FAR void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_ENTRYNAME))
+#else
+  if (!strcmp(tcb->name, CONFIG_TTY_LAUNCH_FILEPATH))
+#endif
+    {
+      *(int *)arg = 1;
+    }
+}
+
+static void uart_launch_worker(void *arg)
+{
+#ifdef CONFIG_TTY_LAUNCH_ARGS
+  FAR char *const argv[] =
+  {
+    CONFIG_TTY_LAUNCH_ARGS,
+    NULL,
+  };
+#else
+  FAR char *const *argv = NULL;
+#endif
+  int found = 0;
+
+  nxsched_foreach(uart_launch_foreach, &found);
+  if (!found)
+    {
+#ifdef CONFIG_TTY_LAUNCH_ENTRY
+      nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
+                    CONFIG_TTY_LAUNCH_PRIORITY,
+                    CONFIG_TTY_LAUNCH_STACKSIZE,
+                    (main_t)CONFIG_TTY_LAUNCH_ENTRYPOINT,
+                    argv);
+#else
+      posix_spawnattr_t attr;

Review comment:
       Move 'posix_spawnattr_t attr;' to line 1661




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org