2017-01-21 14 views
1

Я пытаюсь прочитать из последовательного порта с использованием Java. Я получил его читать из последовательного порта, но когда я иду, чтобы закрыть его я получаю эту фатальную ошибкуОшибка Java rxtx lib segv на mac

# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0x000000010dbb612f, pid=510, tid=5891 
# 
# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15) 
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode bsd-amd64 compressed oops) 
# Problematic frame: 
# C [librxtxSerial.jnilib+0x312f] Java_gnu_io_RXTXPort_interruptEventLoop+0x6b 
# 
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again 
# 
# An error report file with more information is saved as: 
# /Users/daxloy/Documents/workspace/VexUART/hs_err_pid510.log 
# 
# 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. 

Это код, я использую

Основной класс: импорт java.util.Scanner ; Класс

public class Main { 

    public static void main(String[] args) { 
     System.out.println("What TeleTypeWriter port is it on?"); 
     Scanner s = new Scanner(System.in); 
     TwoWaySerialComm TWSC = new TwoWaySerialComm(s.nextLine()); 
     s.close(); 
     try{ 
      TWSC.connect(); 
     }catch(Exception e){ 
      e.printStackTrace(); 
     } 

    } 

} 

TwoWaySerialComm:

import gnu.io.CommPort; 
import gnu.io.CommPortIdentifier; 
import gnu.io.SerialPort; 

import java.io.IOException; 
import java.io.InputStream; 
import java.io.OutputStream; 

public class TwoWaySerialComm { 


    String portName; 

    public TwoWaySerialComm(String pn){ 
     //Sets the portName it has been passed 
     portName = pn; 
    } 

    public void connect() throws Exception{ 
     //Creates the portId to have the port 

     CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); 
     //Checks if it is currently owned so we do not have an issue with over writing anything 
     if(portId .isCurrentlyOwned()){ 
      System.out.println("Port is already owned!"); 
     }else{ 
      //timeout for the communication 
      System.out.println("Port not owned"); 
      int timeout = 2000; 
      //opens the port for communication 
      CommPort commPort = portId.open(this.getClass().getName(), timeout); 
      System.out.println("Casted as CommPort"); 

      if(commPort instanceof SerialPort){ 
       System.out.println("commPort is an instance of SerialPort"); 
       //changes the commPort to the serialPort 
       SerialPort serialPort = (SerialPort)commPort; 
       //Sets the Baud rate, total bits of transfer, the stopping bits, and the parity for the serial port 
       serialPort.setSerialPortParams(230400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); 

       InputStream in = serialPort.getInputStream(); //Creates the input for the serial port 
       OutputStream out = serialPort.getOutputStream(); //Creates the output for the serial port 

       //Starts threads for both input and output now 
       communication(in, out); 
       Thread.sleep(20); 
       commPort.close(); 

      }else{ 
       System.out.println("Port is not a Serial Port!"); 
      } 
     } 
    } 

    public void communication(InputStream in, OutputStream out) throws IOException{ 
     System.out.println("Starting communication"); 
     int counter = 0; 
     int inInt = 0; 
     int previousint = -1; 
     boolean close = false; 

     while(!close){ 
      inInt = in.read(); 
      if(inInt != previousint){ 
       System.out.println(inInt); 
       counter++; 
       if(counter == 5){ 
        close = true; 
       } 
      } 

     } 
    } 


} 

Полный выход пультовой:

What TeleTypeWriter port is it on? 
/dev/cu.usbserial 
Stable Library 
========================================= 
Native lib Version = RXTX-2.2pre2 
Java lib Version = RXTX-2.1-7 
WARNING: RXTX Version mismatch 
    Jar version = RXTX-2.1-7 
    native lib Version = RXTX-2.2pre2 
Port not owned 
Casted as CommPort 
commPort is an instance of SerialPort 
Starting communication 
76 
76 
76 
76 
76 
# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0x000000010dbb612f, pid=510, tid=5891 
# 
# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15) 
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode bsd-amd64 compressed oops) 
# Problematic frame: 
# C [librxtxSerial.jnilib+0x312f] Java_gnu_io_RXTXPort_interruptEventLoop+0x6b 
# 
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again 
# 
# An error report file with more information is saved as: 
# /Users/daxloy/Documents/workspace/VexUART/hs_err_pid510.log 
# 
# 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. 
# 

EDIT:

Вот часть системы журнала, так как полный журнал был слишком велик, чтобы здесь

--------------- S Y S T E M --------------- 

OS:Bsduname:Darwin 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64 
rlimit: STACK 8192k, CORE 0k, NPROC 709, NOFILE 10240, AS infinity 
load average:9.08 4.20 1.71 

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 69 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, erms, ht, tsc, tscinvbit 

Memory: 4k page, physical 4194304k(1048576k free) 

/proc/meminfo: 


vm_info: Java HotSpot(TM) 64-Bit Server VM (24.79-b02) for bsd-amd64 JRE (1.7.0_79-b15), built on Apr 10 2015 11:35:04 by "java_re" with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) 

time: Sat Jan 21 17:49:06 2017 
elapsed time: 16 seconds 

ответ

0

Проблема достаточно ясно, как указано в консоли вывода:

Native lib Version = RXTX-2.2pre2 
Java lib Version = RXTX-2.1-7 
WARNING: RXTX Version mismatch 
    Jar version = RXTX-2.1-7 
    native lib Version = RXTX-2.2pre2 

RXTXComm.jar является несовпадающими и librxtxSerial.jnilib ожидает другую версию. Скорее всего, вы можете скопировать правильные версии RXTEXComm.jar и librxtxSerial.jnilib в /Library/Java/Extensions или скопировать родную версию в приложение; это может решить проблему.

Также пожалуйста, напишите вывод:

# /Users/daxloy/Documents/workspace/VexUART/hs_err_pid510.log 
+0

Я получил позднюю версию librxtxSerial.jnilib, но все-таки было, что несоответствие. Я проверил на веб-сайте, и он сказал, что так поступают файлы. Теперь он говорит Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2pre2. Он по-прежнему имеет ту же ошибку, хотя –

+0

Я только что изменил jar и lib на 2.2pre1, но теперь он дает мне фатальную ошибку, как только я ее запустил –