一:
如果为windows系统,则使用rxtx比较简单,到http://fizzed.com/oss/rxtx-for-java下载对用的压缩包.然后将对应的文件拷贝到JDK指定目录下即可.
rxtxParallel.dll\rxtxSerial.dll拷贝到$JAVA_HOME\jre\bin;
RXTXcomm.jar拷贝到$JAVA_HOME\jre\lib\ext 即可.
ARM系统在使用RXTX框架时,并未找到与ARM系统对应的框架版本。
故只能在系统中重新编译安装RXTX源码
以下对安装过程进行整合.
1. 获取源码包
cd /tmp
wget http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7r2.zip
unzip rxtx-2.1-7r2.zip
2. 编译源码
cd rxtx-2.1-7r2
sudo -i
sh ./configure
make
make install
3. 编译过程中可能遇到的问题
错误一:
/tmp/rxtx-2.1-7r2/./src/RS485Imp.c:96:25: error: 'UTS_RELEASE' undeclared (first use in this function)
if(strcmp(name.release,UTS_RELEASE)!=0)
这是由于 version.h 中缺少 UTS_RELEASE 信息,需要手工添加。先获取当前系统的版本信息:
uname -r
然后在 /usr/include/linux/version.h 中添加
#define UTS_RELEASE "4.14.34-v7+"
4.14.34-v7+ 为上一步中获得的版本号.
错误二:
libtool: install: armv6l-unknown-linux-gnu/librxtxRS485.la’ is not a directory
这个错误会出现在JDK1.6及以上的运行环境下,需要对configure文件进行修改。在configure文件中找到所有的 1.2*|1.3*|1.4*|1.5* ,将现有的JDK版本加入进去即可.如:改成 1.2*|1.3*|1.4*|1.5*|1.6*|1.7*|1.8* .
完成以上两项, make install 成功.
4.安装成功后,会显示如下信息
Libraries have been installed in:
/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm
.....----------------------------------------------------------------------
/usr/bin/install -c RXTXcomm.jar /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext/
5.验证安装目录文件
root@raspberrypi:/# cd /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm
root@raspberrypi:/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm# ls -l|grep librxtx-rwxr-xr-x 1 root root 70024 May 29 19:24 librxtxI2C-2.1-7.so-rwxr-xr-x 1 root root 857 May 29 19:24 librxtxI2C.la
lrwxrwxrwx 1 root root 19 May 29 19:24 librxtxI2C.so -> librxtxI2C-2.1-7.so-rwxr-xr-x 1 root root 47636 May 29 19:24 librxtxParallel-2.1-7.so-rwxr-xr-x 1 root root 887 May 29 19:24 librxtxParallel.la
lrwxrwxrwx 1 root root 24 May 29 19:24 librxtxParallel.so -> librxtxParallel-2.1-7.so-rwxr-xr-x 1 root root 71400 May 29 19:24 librxtxRaw-2.1-7.so-rwxr-xr-x 1 root root 857 May 29 19:24 librxtxRaw.la
lrwxrwxrwx 1 root root 19 May 29 19:24 librxtxRaw.so -> librxtxRaw-2.1-7.so-rwxr-xr-x 1 root root 70628 May 29 19:24 librxtxRS485-2.1-7.so-rwxr-xr-x 1 root root 869 May 29 19:24 librxtxRS485.la
lrwxrwxrwx 1 root root 21 May 29 19:24 librxtxRS485.so -> librxtxRS485-2.1-7.so-rwxr-xr-x 1 root root 166880 May 29 19:24 librxtxSerial-2.1-7.so-rwxr-xr-x 1 root root 875 May 29 19:24 librxtxSerial.la
lrwxrwxrwx 1 root root 22 May 29 19:24 librxtxSerial.so -> librxtxSerial-2.1-7.so
root@raspberrypi:/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm# cd /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext/
root@raspberrypi:/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext# ls -l|grep RXTX-rwxr-xr-x 1 root root 59356 May 29 19:24 RXTXcomm.jar
至此安装完成