2017-01-21 6 views
1

Javaを使用してシリアルポートから読み取ろうとしています。私は、シリアルポートから読み取るためにそれを得たが、私はそれを閉じるために行くとき、私は、この致命的なエラーが発生しますJavaでrxtx lib segvエラーが発生しました

# 
# 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.jarlibrxtxSerial.jnilibの正しいバージョンを/Library/Java/Extensionsにコピーするか、アプリにネイティブバージョンをコピーしてください。問題を解決するかもしれない。私はlibrxtxSerial.jnilibの以降のバージョンを得たが、まだその不一致があった

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

はまた、出力を投稿してください。私はウェブサイトをチェックして、ファイルがどのように来るのかを言った。これで、Jarのバージョン= RXTX-2.2pre1ネイティブlibバージョン= RXTX-2.2pre2と表示されます。 –

+0

jarとlibの両方を2.2pre1に変更しましたが、一度実行すると致命的なエラーが表示されるようになりました –

関連する問題