赞
踩
如果为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 即可。
树莓派需要手动下载源码安装
- cd /tmp
-
- wget http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7r2.zip
-
- unzip rxtx-2.1-7r2.zip
依次执行
-
- cd rxtx-2.1-7r2
-
- ./configure
-
- make
-
- make install
错误一:
/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.5"
4.14.5 为上一步中获得的版本号.
错误二:
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* 。
错误三:
configure: error: cannot guess build type; you must specify one
wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
wget -O config.sub 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
将新的配置文件替换原来第三库的config.guess和config.sub即可。
错误四
对于RawImp.c可能在编译中会找不到sys/io.h文件
可以将这个改成sys/uio.h就可以了
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/
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
下载地址
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。