You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/05/07 19:35:48 UTC

[incubator-nuttx] branch master updated: libc/termios: Implement TCSADRAIN and TCSAFLUSH for tcsetattr

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b8ed17b  libc/termios: Implement TCSADRAIN and TCSAFLUSH for tcsetattr
b8ed17b is described below

commit b8ed17b9dad515309f59154fb3c0e0a99fbbf6ac
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 7 00:39:08 2021 -0700

    libc/termios: Implement TCSADRAIN and TCSAFLUSH for tcsetattr
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: If87a4931cd5a55e064f58c19a22c7ce13f538000
---
 libs/libc/termios/lib_tcsetattr.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libs/libc/termios/lib_tcsetattr.c b/libs/libc/termios/lib_tcsetattr.c
index e93bf58..cde1c06 100644
--- a/libs/libc/termios/lib_tcsetattr.c
+++ b/libs/libc/termios/lib_tcsetattr.c
@@ -83,10 +83,15 @@
 
 int tcsetattr(int fd, int options, FAR const struct termios *termiosp)
 {
-  if (options == TCSANOW)
+  if (options != TCSANOW)
     {
-      return ioctl(fd, TCSETS, (unsigned long)termiosp);
+      tcdrain(fd);
     }
 
-  return -ENOSYS;
+  if (options == TCSAFLUSH)
+    {
+      tcflush(fd, TCIFLUSH);
+    }
+
+  return ioctl(fd, TCSETS, (unsigned long)termiosp);
 }