changeset 231:2c895d546686

8136170: UART/index.html#GetFlowControl[testValidCombinations] fails Summary: Clear c_iflag and c_cflag prior to new flags assigment Reviewed-by: alkonsta
author snazarki
date Tue, 15 Sep 2015 12:49:10 +0300
parents f30bd71ed3b0
children d1ca95955562
files src/share/linux/native/com/oracle/dio/uart/uart.c
diffstat 1 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/uart/uart.c	Thu Sep 10 18:10:19 2015 +0300
+++ b/src/share/linux/native/com/oracle/dio/uart/uart.c	Tue Sep 15 12:49:10 2015 +0300
@@ -410,11 +410,14 @@
     if(getTermios(handle, &term) != JAVACALL_OK){
         return JAVACALL_DIO_FAIL;
     }
+
+    term.c_cflag &=  ~CSIZE;
+
     //IMPL_NOTE: linux PI 7 and 8 supported
     switch(bitsPerChar){
-        case BITS_PER_CHAR_7: term.c_cflag = (term.c_cflag & ~CSIZE) | CS7;
+        case BITS_PER_CHAR_7: term.c_cflag |= CS7;
             break;
-        case BITS_PER_CHAR_8: term.c_cflag = (term.c_cflag & ~CSIZE) | CS8;
+        case BITS_PER_CHAR_8: term.c_cflag |= CS8;
             break;
         case BITS_PER_CHAR_5:
         case BITS_PER_CHAR_6:
@@ -475,22 +478,20 @@
         return JAVACALL_DIO_UNSUPPORTED_OPERATION;
     }
 
-    if(mode & FLOWCONTROL_NONE){
-        term.c_iflag &= ~(IXON | IXOFF);
-        term.c_cflag &= ~(CRTSCTS);
-    }else{
-        if(mode & FLOWCONTROL_RTSCTS_IN){
-            term.c_cflag |= CRTSCTS;
-        }
-        if(mode & FLOWCONTROL_RTSCTS_OUT){
-            term.c_cflag |= CRTSCTS;
-        }
-        if(mode & FLOWCONTROL_XONXOFF_IN){
-            term.c_iflag |= IXON;
-        }
-        if(mode & FLOWCONTROL_XONXOFF_OUT){
-            term.c_iflag |= IXOFF;
-        }
+    term.c_iflag &= ~(IXON | IXOFF);
+    term.c_cflag &= ~(CRTSCTS);
+
+    if(mode & FLOWCONTROL_RTSCTS_IN){
+        term.c_cflag |= CRTSCTS;
+    }
+    if(mode & FLOWCONTROL_RTSCTS_OUT){
+        term.c_cflag |= CRTSCTS;
+    }
+    if(mode & FLOWCONTROL_XONXOFF_IN){
+        term.c_iflag |= IXON;
+    }
+    if(mode & FLOWCONTROL_XONXOFF_OUT){
+        term.c_iflag |= IXOFF;
     }
 
     return javacall_result2dio_result(setTermios(handle, &term));