Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Nov 1999 16:04:56 +0900
From:      Shingo WATANABE / =?ISO-2022-JP?B?GyRCRU9KVRsoQiA=?= =?ISO-2022-JP?B?GyRCPy04YxsoQg==?= <nabe@mobile.icc.titech.ac.jp>
To:        freebsd-java@freebsd.org
Cc:        nabe@mobile.icc.titech.ac.jp
Subject:   patch for CommAPI
Message-ID:  <19991109160456A.nabe@suzuki-gw.mobile.icc.titech.ac.jp>

next in thread | raw e-mail | index | archive | help
----Next_Part(Tue_Nov__9_16:03:37_1999_518)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I write the patch for CommAPI(http://student.ulb.ac.be/~jdricot/commapi/)
and send it to the maintainer of the CommAPI page.

But I've got no response, so please test this patch and send the
comment to me. Please reply to me directly or keep my address in Cc
since I am not subscribed to the list.

This patch fixes:
    flow control
    character size
    set/clear RTS
    set/clear DTR
    and so on...

---
 Shingo WATANABE / nabe@mobile.icc.titech.ac.jp

----Next_Part(Tue_Nov__9_16:03:37_1999_518)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="CommAPI.diff"

diff -ur src.org/org/freebsd/io/comm/libSerial.c src/org/freebsd/io/comm/libSerial.c
--- src.org/org/freebsd/io/comm/libSerial.c	Mon Jul 19 17:45:04 1999
+++ src/org/freebsd/io/comm/libSerial.c	Mon Oct 18 03:55:48 1999
@@ -107,6 +107,12 @@
     /*
      * setup communications port for default of 9600, 8, 1, none
      */
+    if (tcgetattr (fd, &tty) < 0)
+    {
+        throw_exception (env, IOEXCEPTION, "tcgetattr ", strerror (errno));
+        return;
+    }
+
     tty.c_iflag = INPCK;
     tty.c_lflag = 0;
     tty.c_oflag = 0;
@@ -161,7 +167,8 @@
     switch ((int)i)
     {
         case 0:		/* SerialPort.FLOWCONTROL_NONE */
-            tty.c_cflag &= ~ (IXON | IXOFF | CRTSCTS);
+            tty.c_iflag &= ~ (IXON | IXOFF);
+            tty.c_cflag &= ~(CRTSCTS);
             break;
         case 1:		/* SerialPort.FLOWCONTROL_RTSCTS_IN */
             tty.c_cflag |= CRTS_IFLOW;
@@ -173,13 +180,13 @@
             tty.c_cflag |= CRTSCTS;
             break;
         case 4:		/* SerialPort.FLOWCONTROL_XONXOFF_IN */
-            tty.c_cflag |= IXOFF;
+            tty.c_iflag |= IXOFF;
             break;
         case 8:		/* SerialPort.FLOWCONTROL_XONXOFF_OUT */
-            tty.c_cflag |= IXON;
+            tty.c_iflag |= IXON;
             break;
         case 12:	/* SerialPort.FLOWCONTROL_XONXOFF_IN/OUT */
-            tty.c_cflag |= IXON | IXOFF;
+            tty.c_iflag |= (IXON | IXOFF);
             break;
     }
     if (tcsetattr ((int)sd, TCSAFLUSH, &tty) < 0)
@@ -315,27 +322,27 @@
 JNIEXPORT void JNICALL Java_org_freebsd_io_comm_FreebsdSerial_deviceSetDTR
   (JNIEnv *env, jobject jobj, jint sd, jboolean flag)
 {
-    struct termios tty;
+    int value;
     
     /* get termios structure for our serial port */
-    if (tcgetattr ((int)sd, &tty) < 0)
+    if (ioctl ((int)sd, TIOCMGET, &value) < 0)
     {
-        throw_exception (env, IOEXCEPTION, "tcgetattr ", strerror (errno));
+        throw_exception (env, IOEXCEPTION, "TIOCMGET ", strerror (errno));
         return;
     }
 
     if (flag == JNI_TRUE)
     {
-        tty.c_cflag |= CDTR_IFLOW;
+        value |= TIOCM_DTR;
     }
     else
     {
-        tty.c_cflag &= ~CDTR_IFLOW;
+        value &= ~TIOCM_DTR;
     }
 
-    if (tcsetattr ((int)sd, TCSAFLUSH, &tty) < 0)
+    if (ioctl ((int)sd, TIOCMSET, &value) < 0)
     {
-        throw_exception (env, IOEXCEPTION, "tcsetattr ", strerror (errno));
+        throw_exception (env, IOEXCEPTION, "TIOCMSET ", strerror (errno));
     }
     return;
 }
@@ -348,29 +355,29 @@
 JNIEXPORT void JNICALL Java_org_freebsd_io_comm_FreebsdSerial_deviceSetRTS
   (JNIEnv *env, jobject jobj, jint sd, jboolean flag)
 {
-    struct termios tty;
-                             
-    /* get termios structure for our serial port */
-    if (tcgetattr ((int)sd, &tty) < 0)
+    int value;
+    
+  /* get termios structure for our serial port */
+    if (ioctl ((int)sd, TIOCMGET, &value) < 0)
     {
-        throw_exception (env, IOEXCEPTION, "tcgetattr ", strerror (errno));
+        throw_exception (env, IOEXCEPTION, "TIOCMGET ", strerror (errno));
         return;
     }
- 
+
     if (flag == JNI_TRUE)
     {
-        tty.c_cflag |= CRTS_IFLOW;
+        value |= TIOCM_RTS;
     }
-    else    
+    else
     {
-        tty.c_cflag &= ~CRTS_IFLOW;
+        value &= ~TIOCM_RTS;
     }
-            
-    if (tcsetattr ((int)sd, TCSAFLUSH, &tty) < 0)
+
+    if (ioctl ((int)sd, TIOCMSET, &value) < 0)
     {
-        throw_exception (env, IOEXCEPTION, "tcsetattr ", strerror (errno));
+        throw_exception (env, IOEXCEPTION, "TIOCMSET ", strerror (errno));
     }
-    return;    
+    return;
 }
 
 /*
Only in src/org/freebsd/io/comm: libSerial.c.org

----Next_Part(Tue_Nov__9_16:03:37_1999_518)----


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991109160456A.nabe>