/*------------------------------------------------------------------------- | RXTX License v 2.1 - LGPL v 2.1 + Linking Over Controlled Interface. | RXTX is a native interface to serial ports in java. | Copyright 1997-2007 by Trent Jarvi tjarvi@qbang.org and others who | actually wrote it. See individual source files for more information. | | A copy of the LGPL v 2.1 may be found at | http://www.gnu.org/licenses/lgpl.txt on March 4th 2007. A copy is | here for your convenience. | | This library is free software; you can redistribute it and/or | modify it under the terms of the GNU Lesser General Public | License as published by the Free Software Foundation; either | version 2.1 of the License, or (at your option) any later version. | | This library is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | Lesser General Public License for more details. | | An executable that contains no derivative of any portion of RXTX, but | is designed to work with RXTX by being dynamically linked with it, | is considered a "work that uses the Library" subject to the terms and | conditions of the GNU Lesser General Public License. | | The following has been added to the RXTX License to remove | any confusion about linking to RXTX. We want to allow in part what | section 5, paragraph 2 of the LGPL does not permit in the special | case of linking over a controlled interface. The intent is to add a | Java Specification Request or standards body defined interface in the | future as another exception but one is not currently available. | | http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface | | As a special exception, the copyright holders of RXTX give you | permission to link RXTX with independent modules that communicate with | RXTX solely through the Sun Microsytems CommAPI interface version 2, | regardless of the license terms of these independent modules, and to copy | and distribute the resulting combined work under terms of your choice, | provided that every copy of the combined work is accompanied by a complete | copy of the source code of RXTX (the version of RXTX used to produce the | combined work), being distributed under the terms of the GNU Lesser General | Public License plus this exception. An independent module is a | module which is not derived from or based on RXTX. | | Note that people who make modified versions of RXTX are not obligated | to grant this special exception for their modified versions; it is | their choice whether to do so. The GNU Lesser General Public License | gives permission to release a modified version without this exception; this | exception also makes it possible to release a modified version which | carries forward this exception. | | You should have received a copy of the GNU Lesser General Public | License along with this library; if not, write to the Free | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | All trademarks belong to their respective owners. --------------------------------------------------------------------------*/ This is README Wed Feb 19 06:33:17 EST 2003 STATUS: 1) OS's The library has been tested on redhat 8.0 glinux write writes and read reads. Little else has been tested but things should work. 2) TODO: - test on other Unix Like systems - bring termios.c over to give win32 support - autoconf to determine include files INTRODUCTION CNI is a new way of mixing Java and native code used by the GNU gcj compiler. The CNI is a faster way to have native and Java code interact. One can build fast, stand alone applications using this code. Possible applications include low latency, embeded and use with other native projects. This directory contains an initial hack at getting rxtx (www.rxtx.org) working with the the GNU gcj using the CNI. Links: http://www.rxtx.org http://gcc.gnu.org/java http://gcc.gnu.org/java/papers/cni/t1.html BUILDING There isn't much here besides the library. To get started, make sure you have gcj installed. make # build the library and Simple -- a small application ./Simple runs the test application. If there is a loopback on /dev/ttyS1, The Simple application will write to the port and then read back the data. If you get "undefined reference to `function_name' you are missing a library EXAMPLE Script started on Wed Feb 19 06:16:07 2003 [root@servertrent CNI]# make rm -f Simple.java gcj -d . -C *.java for i in gnu/io/*.class;do gcjh -d . `echo $i|sed s/.class//g`;done g++ -Wall -g -O2 -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -O2 -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -I . -c SerialImp.c SerialImp.c: In member function `void gnu::io::RXTXPort::writeArray(JArray*, __java_int, __java_int, __java_boolean)': SerialImp.c:1376: warning: label `fail' defined but not used g++ -Wall -g -O2 -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -O2 -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -I . -c fuserImp.c (cd gnu/io && gcj -g -classpath ../.. -d gnu/io -c *.class ) g++ -g -shared gnu/io/*.o *.o -lpthread -Wl,-soname -Wl,librxtx-0.0-1.so -o librxtx-0.0-1.so rm -f librxtx.so && ln -s librxtx-0.0-1.so librxtx.so ar rs librxtx.a gnu/io/*.o *.o g++ -g -Wall test.c -static -L. -lrxtx -lgcj -lpthread -ldl -lz -o test #gcj *.o librxtx.a -static -lgcj -lpthread -ldl -lz -o Simple --main=Simple ln -s Simple.Java Simple.java gcj --classpath RXTX.jar -d . -C Simple.java rm Simple.java gcj -g -classpath RXTX.jar -d . -c Simple.class gcj -g *.o gnu/io/*.o -static -lgcj -lpthread -ldl -lz -o Simple --main=Simple [root@servertrent CNI]# ./Simple Getting PortIdentifiers Devel Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyS1 writing output Got Data Available Printing read() results 123456789 [root@servertrent CNI]# file Simple Simple: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped [root@servertrent CNI]# exit exit Script done on Wed Feb 19 06:16:35 2003 -- Trent Jarvi taj@www.linux.org.uk