centos6.5系统 使用rxtx串口转USB收数据

来源:互联网 发布:linux ls 查找文件名 编辑:程序博客网 时间:2024/06/05 01:54

1、centos6.5 x64位系统,内核版本是2.6.32-696(安装时内核版本是2.6.32-432,需要升级),串口转usb线插上以后不可直接使用,需手动安装驱动;
安装驱动前
a. 首先要确认是否已安装kernel-devel(内核开发包,make命令):在/usr/src/kernels/
一定要注意系统内核版本和kernel的版本要一致

//安装kernel-devel#yum install kernel-devel

b. 其次要安装gcc:

//gcc安装:    yum -y install gcc    yum -y install gcc-c++     yum install make

2、安装好驱动以后,再安装minicom,设置好串口号(linux下一般用”/dev/ttyUSB0”)、波特率(波特率不一致可能导致数据乱码或收不到数据)、数据位、校验位和停止位。
先用dmesg ef|grep pl2303看串口是否已识别,若没有的话,用modprobe pl2303执行命令,确认已识别串口后用minicom看是否能收到数据。
3、在程序中使用rxtxcomm
查看cpu型号,从下载的组件中找到对应的.so文件
该组件下载地址:http://rxtx.qbang.org/pub/rxtx/rxtx-2.2pre2-bins.zip

这里写图片描述

我们已经把jdk目录命名为JAVAHOMElibrxtxParallel.solibrxtxSerial.so/usr/libRXTXcomm.jarJAVA_HOME/jre/lib/ext下。

**分隔符

问题**

直接在命令终端里读取数据正常,但是在使用这个组件的时候,读取到数据时eclipse会报错:

## A fatal error has been detected by the Java Runtime Environment:##  SIGSEGV (0xb) at pc=0x00007f85ff6f1462, pid=12801, tid=140213492819712## JRE version: Java(TM) SE Runtime Environment (7.0_80-b15) (build 1.7.0_80-b15)# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.80-b11 mixed mode linux-amd64 compressed oops)# Problematic frame:# C  [librxtxSerial.so+0x6462]  read_byte_array+0x52## Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again## If you would like to submit a bug report, please visit:#   http://bugreport.java.com/bugreport/crash.jsp# The crash happened outside the Java Virtual Machine in native code.# See problematic frame for where to report the bug.#---------------  T H R E A D  ---------------Current thread (0x00007f86000cf800):  JavaThread "Thread-0" [_thread_in_native, id=12817, stack(0x00007f85ff5ea000,0x00007f85ff6eb000)]siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0xffffffffff6e9718Registers:RAX=0xffffffffff6e9710, RBX=0xffffffffffffffff, RCX=0x0000000000000001, RDX=0x00007f8608db67f0RSP=0x00007f85ff6e8e00, RBP=0x00007f86000cf9e8, RSI=0x00007f85ff6f4e30, RDI=0x00007f85ff6f4d3eR8 =0x00007f85ff6e8d70, R9 =0x00000000daeb6120, R10=0x0000000000000002, R11=0x00007f8608dbade8R12=0x00000000ffffffff, R13=0x0000000000000000, R14=0x0000000000000006, R15=0x0000000000000000RIP=0x00007f85ff6f1462, EFLAGS=0x0000000000010202, CSGSFS=0x0000000000000033, ERR=0x0000000000000005  TRAPNO=0x000000000000000e

找了许多种方法均不能解决,最后想到可能是下载的组件有问题,我开始用的是rxtx-2.1.7,替换成上面的rxtx-2.2就不会报错了。

0 0
原创粉丝点击