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 2020/08/13 17:47:18 UTC

[GitHub] [incubator-nuttx-apps] lukegluke opened a new pull request #364: system/cu: refactor, add option -c to disable \n -> \r\n conversion

lukegluke opened a new pull request #364:
URL: https://github.com/apache/incubator-nuttx-apps/pull/364


   option -c will disable \n -> \r\n conversion both fore serial device and console if it is a tty
   
   refactor: use only one function to set termios parameters, use termious related code and options only if CONFIG_SERIAL_TERMIOS is defined
   
   This options is handy (and very vital) to interact with serial devices with binary protocol together with option '-f' (endless mode without escape sequence) introduced in df5d4cd033167c775fd69692446a146fe3453a0f.
   
   due to ifdef construction nxstyle complains
   `cu_main.c:246:44: error: Unmatched right parentheses`
   should I (and how) eliminate this?
   
   I've builded and tested this as cherry pick to 8.2 and only with CONFIG_SERIAL_TERMIOS defined. Haven't built it without this.


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx-apps] Ouss4 commented on a change in pull request #364: system/cu: refactor, add option -c to disable \n -> \r\n conversion

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #364:
URL: https://github.com/apache/incubator-nuttx-apps/pull/364#discussion_r470213210



##########
File path: system/cu/cu_main.c
##########
@@ -342,8 +366,37 @@ int main(int argc, FAR char *argv[])
       goto errout_with_devinit;
     }
 
-  enable_crlf_conversion(g_cu.outfd);
-  set_baudrate(g_cu.outfd, baudrate, parity, rtscts);
+#ifdef CONFIG_SERIAL_TERMIOS
+  /* remember serial device termios attributes */
+
+  ret = tcgetattr(g_cu.outfd, &g_tio_dev);
+  if (ret)
+    {
+      fprintf(stderr, "cu_main: ERROR during tcgetattr(): %d\n", errno);
+      goto errout_with_outfd;
+    }
+
+  /* remember std termios attributes if it is a tty. Try to select
+   * right descriptor that is used to refer to tty
+   */
+
+  if (isatty(fileno(stderr)))
+    fd_std_tty = fileno(stderr);
+  else if (isatty(fileno(stdout)))
+    fd_std_tty = fileno(stdout);
+  else if (isatty(fileno(stdin)))
+    fd_std_tty = fileno(stdin);
+  else
+    fd_std_tty = -1;
+
+  if (fd_std_tty >= 0)
+    tcgetattr(fd_std_tty, &g_tio_std);

Review comment:
       Curly brackets are required even for one-line/empty if/for/while statements.




----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx-apps] Ouss4 merged pull request #364: system/cu: refactor, add option -c to disable \n -> \r\n conversion

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


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-nuttx-apps] patacongo commented on a change in pull request #364: system/cu: refactor, add option -c to disable \n -> \r\n conversion

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #364:
URL: https://github.com/apache/incubator-nuttx-apps/pull/364#discussion_r470231376



##########
File path: system/cu/cu_main.c
##########
@@ -342,8 +366,37 @@ int main(int argc, FAR char *argv[])
       goto errout_with_devinit;
     }
 
-  enable_crlf_conversion(g_cu.outfd);
-  set_baudrate(g_cu.outfd, baudrate, parity, rtscts);
+#ifdef CONFIG_SERIAL_TERMIOS
+  /* remember serial device termios attributes */
+
+  ret = tcgetattr(g_cu.outfd, &g_tio_dev);
+  if (ret)
+    {
+      fprintf(stderr, "cu_main: ERROR during tcgetattr(): %d\n", errno);
+      goto errout_with_outfd;
+    }
+
+  /* remember std termios attributes if it is a tty. Try to select
+   * right descriptor that is used to refer to tty
+   */
+
+  if (isatty(fileno(stderr)))
+    fd_std_tty = fileno(stderr);
+  else if (isatty(fileno(stdout)))
+    fd_std_tty = fileno(stdout);
+  else if (isatty(fileno(stdin)))
+    fd_std_tty = fileno(stdin);
+  else
+    fd_std_tty = -1;
+
+  if (fd_std_tty >= 0)
+    tcgetattr(fd_std_tty, &g_tio_std);

Review comment:
       Coding Standard:  https://cwiki.apache.org/confluence/display/NUTTX/Coding+Standard#ifthenelse




----------------------------------------------------------------
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.

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