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/10/30 08:17:05 UTC

[incubator-nuttx-apps] branch releases/10.0 updated (432a8a5 -> eaeb551)

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

aguettouche pushed a change to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git.


    from 432a8a5  build.yml: Switch avr-mips-riscv-x86-xtensa.dat to other.dat
     new 501a09e  system/cu: do not exit directly from getopt loop, bad in flat builds
     new eaeb551  system/cu: do not reset baud rate to zero when parity options are used

The 2 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:
 system/cu/cu.h      |  5 +++--
 system/cu/cu_main.c | 49 ++++++++++++++++++++++++++++++-------------------
 2 files changed, 33 insertions(+), 21 deletions(-)


[incubator-nuttx-apps] 02/02: system/cu: do not reset baud rate to zero when parity options are used

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit eaeb5513c52e27c829d698745d316a5644ecf79a
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Mon Oct 19 18:43:55 2020 +0300

    system/cu: do not reset baud rate to zero when parity options are used
    
    cfsetspeed() now stores baud rate to c_cflag member of
    struct termios, so it must not be overridden later on.
    
    Signed-off-by: Juha Niskanen <ju...@haltian.com>
---
 system/cu/cu.h      |  2 +-
 system/cu/cu_main.c | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/system/cu/cu.h b/system/cu/cu.h
index 9ca6c78..f16aec1 100644
--- a/system/cu/cu.h
+++ b/system/cu/cu.h
@@ -70,7 +70,7 @@
 
 struct cu_globals_s
 {
-  int infd;            /* Incmoming data from serial port */
+  int infd;            /* Incoming data from serial port */
   int outfd;           /* Outgoing data to serial port */
   pthread_t listener;  /* Terminal listener thread */
 };
diff --git a/system/cu/cu_main.c b/system/cu/cu_main.c
index d914284..621088d 100644
--- a/system/cu/cu_main.c
+++ b/system/cu/cu_main.c
@@ -82,7 +82,7 @@ enum parity_mode
 
 static struct cu_globals_s g_cu;
 #ifdef CONFIG_SERIAL_TERMIOS
-int fd_std_tty;
+static int fd_std_tty;
 static struct termios g_tio_std;
 static struct termios g_tio_dev;
 #endif
@@ -144,13 +144,6 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
 
   tio = g_tio_dev;
 
-  /* set baudrate */
-
-  if (rate != 0)
-    {
-      cfsetspeed(&tio, rate);
-    }
-
   switch (parity)
     {
       case PARITY_EVEN:
@@ -165,6 +158,13 @@ static int set_termios(int fd, int rate, enum parity_mode parity,
         break;
     }
 
+  /* set baudrate */
+
+  if (rate != 0)
+    {
+      cfsetspeed(&tio, rate);
+    }
+
   if (rtscts)
     {
       tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;


[incubator-nuttx-apps] 01/02: system/cu: do not exit directly from getopt loop, bad in flat builds

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 501a09e309aec51aa1e6f5bf9ebc89f43758f2a3
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Mon Oct 19 18:43:09 2020 +0300

    system/cu: do not exit directly from getopt loop, bad in flat builds
    
    Signed-off-by: Juha Niskanen <ju...@haltian.com>
---
 system/cu/cu.h      |  3 ++-
 system/cu/cu_main.c | 33 ++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/system/cu/cu.h b/system/cu/cu.h
index d73e437..9ca6c78 100644
--- a/system/cu/cu.h
+++ b/system/cu/cu.h
@@ -49,7 +49,8 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
-/* Configuration ***********************************************************/
+
+/* Configuration ************************************************************/
 
 #ifndef CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
 #  define CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE "/dev/ttyS0"
diff --git a/system/cu/cu_main.c b/system/cu/cu_main.c
index b053d28..d914284 100644
--- a/system/cu/cu_main.c
+++ b/system/cu/cu_main.c
@@ -214,7 +214,7 @@ errout:
   return rc;
 }
 
-static int retrive_termios(int fd)
+static int retrieve_termios(int fd)
 {
   tcsetattr(fd, TCSANOW, &g_tio_dev);
   if (fd_std_tty >= 0)
@@ -241,10 +241,11 @@ static void print_help(void)
          " -?: This help\n",
 #ifdef CONFIG_SERIAL_TERMIOS
          CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE,
-         CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD);
+         CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
 #else
-         CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE);
+         CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
 #endif
+        );
 }
 
 static void print_escape_help(void)
@@ -300,6 +301,7 @@ int main(int argc, FAR char *argv[])
   int bcmd;
   int start_of_line = 1;
   int exitval = EXIT_FAILURE;
+  bool badarg = false;
 
   /* Initialize global data */
 
@@ -338,24 +340,33 @@ int main(int argc, FAR char *argv[])
             break;
 
           case 'c':
-              nocrlf = 1;
-              break;
+            nocrlf = 1;
+            break;
 #endif
 
           case 'f':
-              nobreak = 1;
-              break;
+            nobreak = 1;
+            break;
 
           case 'h':
           case '?':
             print_help();
-            return EXIT_SUCCESS;
+            badarg = true;
+            exitval = EXIT_SUCCESS;
+            break;
 
           default:
-            return EXIT_FAILURE;
+            badarg = true;
+            exitval = EXIT_FAILURE;
+            break;
         }
     }
 
+  if (badarg)
+    {
+      return exitval;
+    }
+
   /* Open the serial device for writing */
 
   g_cu.outfd = open(devname, O_WRONLY);
@@ -435,6 +446,7 @@ int main(int argc, FAR char *argv[])
 
   ret = pthread_create(&g_cu.listener, &attr,
                        cu_listener, (pthread_addr_t)0);
+  pthread_attr_destroy(&attr);
   if (ret != 0)
     {
       fprintf(stderr, "cu_main: Error in thread creation: %d\n", ret);
@@ -499,7 +511,6 @@ int main(int argc, FAR char *argv[])
     }
 
   pthread_cancel(g_cu.listener);
-  pthread_attr_destroy(&attr);
   exitval = EXIT_SUCCESS;
 
   /* Error exits */
@@ -508,7 +519,7 @@ errout_with_fds:
   close(g_cu.infd);
 #ifdef CONFIG_SERIAL_TERMIOS
 errout_with_outfd_retrieve:
-  retrive_termios(g_cu.outfd);
+  retrieve_termios(g_cu.outfd);
 #endif
 errout_with_outfd:
   close(g_cu.outfd);