# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000001800071cd, pid=9032, tid=5016
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [rxtxSerial.dll+0x71cd]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Jack\workspace\TestProject\hs_err_pid9032.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
public static void main(String[] args) throws Exception {
CommPortIdentifier com13PI = CommPortIdentifier
.getPortIdentifier("COM13");
CommPortIdentifier com1PI = CommPortIdentifier
.getPortIdentifier("COM1");
SerialPort com13 = (SerialPort) com13PI.open(main.class.getName(), 400);
SerialPort com1 = (SerialPort) com1PI.open(main.class.getName(), 400);
com13.close();
//com1.close();
com13PI = CommPortIdentifier.getPortIdentifier("COM13");
com13 = (SerialPort) com13PI.open(main.class.getName(), 400);
}
现在的做法是每次有串口需要变动时,都先关闭所有串口,再开启需要用到的多个目标串口,但这样灵活性不高,有谁知道如果解决该问题的,望指点下,谢谢!
1.借助空闲串口规避缺陷
2.使用rxtx的纯Java实现库purejavacomm
直接用JVM调C库,是比较容易出现JVM崩溃的问题;为了节约时间成本,最好不要这么做;
可以用ICE来实现Java和C++的相互调用,比较安全
楼主 我想问一下如何同时监听多个串口?我是获取串口列表可用的就给他添加一个监听,同时开启一个线程,但是我现在再开启线程时遇到问题了。