使用RXTX Java从串行监视器读取数据时出错

使用RXTX Java从串行监视器读取数据时出错,java,serial-port,rxtx,Java,Serial Port,Rxtx,我有一个Arduino草图,可以将数据打印到串行监视器。 我试图使用RXTX库从Java代码中读取这些数据 但我得到了一个错误,说: Java运行时环境检测到致命错误: 在pc=0x00007f8b985ccd9d、pid=23812、tid=0x00007f8b985c5700时的SIGSEGV(0xb) JRE版本:Java(TM)SE运行时环境(8.0_181-b13)(build 1.8.0_181-b13) Java虚拟机:Java热点(TM)64位服务器虚拟机(25.181-b13混

我有一个Arduino草图,可以将数据打印到串行监视器。
我试图使用RXTX库从Java代码中读取这些数据

但我得到了一个错误,说:

Java运行时环境检测到致命错误:
在pc=0x00007f8b985ccd9d、pid=23812、tid=0x00007f8b985c5700时的SIGSEGV(0xb)
JRE版本:Java(TM)SE运行时环境(8.0_181-b13)(build 1.8.0_181-b13)
Java虚拟机:Java热点(TM)64位服务器虚拟机(25.181-b13混合模式linux-amd64压缩oops)
有问题的框架:
C[librxtxSerial.so+0x6d9d]读取字节数组+0x3d
无法写入核心转储。核心转储已被禁用。要启用核心转储,请在再次启动Java之前尝试“ulimit-c unlimited”
包含详细信息的错误报告文件另存为:
/home/user1/javaprograms/IoTData/hs_err_pid23812.log
如果您想提交错误报告,请访问:
http://bugreport.java.com/bugreport/crash.jsp
崩溃发生在Java虚拟机外部的本机代码中。
有关报告错误的位置,请参见问题框。
我还尝试了
ulimit
命令,即使它不起作用。我的串行测试代码如下:

public void initialize() {

    CommPortIdentifier portId = null;
    Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

    //First, Find an instance of serial port as set in PORT_NAMES.
    while (portEnum.hasMoreElements()) {
        CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
        if(currPortId.getName().equals("/dev/ttyUSB0")) {
            System.out.println("PortID: "+ currPortId.getName());
            try {
                SerialPort port= (SerialPort) currPortId.open("PortListOpen",20);
                System.out.println("Port Opened Successfully");
                try {
                    int baudRate= 9600;
                    port.setSerialPortParams(baudRate, SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_EVEN);
                    port.setDTR(true);
                    System.out.println("Properties are set");
                    input = new BufferedReader(new InputStreamReader(port.getInputStream()));
                    output = port.getOutputStream();
                    // add event listeners
                    port.addEventListener(this);
                    port.notifyOnDataAvailable(true);
                }catch(UnsupportedCommOperationException e) {
                    System.out.println(e);
                }
            }catch(Exception e) {
                System.out.println("In exception: "+ e);
            }
        }
    }
}

/**
 * This should be called when you stop using the port.
 * This will prevent port locking on platforms like Linux.
 */
public synchronized void close() {
    if (serialPort != null) {
        serialPort.removeEventListener();
        serialPort.close();
    }
}

/**
 * Handle an event on the serial port. Read the data and print it.
 */
public synchronized void serialEvent(SerialPortEvent oEvent) {
    if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
        try {
            String inputLine=input.readLine();
            System.out.println(inputLine);
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }
    // Ignore all the other eventTypes, but you should consider the other ones.
}

public static void main(String[] args) throws Exception {
    SerialData main = new SerialData();
    main.initialize();
    Thread t=new Thread() {
        public void run() {
            //the following line will keep this app alive for 1000 seconds,
            //waiting for events to occur and responding to them (printing incoming messages to console).
            try {Thread.sleep(1000000);} catch (InterruptedException ie) {}
        }
    };
    t.start();
    System.out.println("Started");
}
请在这方面帮助我,为什么会发生堆芯转储