From owner-freebsd-java Mon Nov 8 23: 5: 8 1999 Delivered-To: freebsd-java@freebsd.org Received: from suzuki-gw.mobile.icc.titech.ac.jp (suzuki-gw.mobile.icc.titech.ac.jp [131.112.96.21]) by hub.freebsd.org (Postfix) with ESMTP id 980C014E93 for ; Mon, 8 Nov 1999 23:05:01 -0800 (PST) (envelope-from nabe@mobile.icc.titech.ac.jp) Received: from localhost by suzuki-gw.mobile.icc.titech.ac.jp (3.7W-99061420) id QAA04908; Tue, 9 Nov 1999 16:04:56 +0900 (JST) To: freebsd-java@freebsd.org Cc: nabe@mobile.icc.titech.ac.jp Subject: patch for CommAPI X-Mailer: Mew version 1.94 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Tue_Nov__9_16:03:37_1999_518)--" Content-Transfer-Encoding: 7bit Message-Id: <19991109160456A.nabe@suzuki-gw.mobile.icc.titech.ac.jp> Date: Tue, 09 Nov 1999 16:04:56 +0900 From: Shingo WATANABE / =?ISO-2022-JP?B?GyRCRU9KVRsoQiA=?= =?ISO-2022-JP?B?GyRCPy04YxsoQg==?= X-Dispatcher: imput version 990905(IM130) Lines: 150 Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org ----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