2017-12-02 16 views
1

Eclipse IDE에서 Arduino와 인터페이스 할 때 문제가 있습니다. 나는 Arduino와 Eclipse IDE 사이의 통신 (Rxtx.jar을 설치하고 경로를 빌드 한 다음 Eclipse 작업 공간 폴더에서 serial.dll 및 parallel.dll 파일을 복사하는 등)에 필요한 모든 절차를 수행했습니다.Java Runtime Environment에서 치명적인 오류가 감지되었습니다. Eclipse IDE가 Arduino와 인터페이스 할 때

I ' 또한 Arduino IDE와 Eclipse 코드에서 Arduino COM 포트 구성을 확인했습니다.

하지만 여전히 Eclipse 콘솔에서 이러한 종류의 메시지가 표시됩니다.


WARNING: RXTX Version mismatch 
    Jar version = RXTX-2.2pre1 
    native lib Version = RXTX-2.2pre2 
Started 
# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180003990, pid=7556, tid=4696 
# 
# JRE version: Java(TM) SE Runtime Environment (9.0+11) (build 9.0.1+11) 
# Java VM: Java HotSpot(TM) 64-Bit Server VM (9.0.1+11, mixed mode, tiered, compressed oops, g1 gc, windows-amd64) 
# Problematic frame: 
# C [rxtxSerial.dll+0x3990] 
# 
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows 
# 
# An error report file with more information is saved as: 
# D:\Educational\Study\Softwares\JAVA\Eclipse EE Oxygen for Web Devlopers\workspace\RxTxDemo\hs_err_pid7556.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. 
# 

다음과 같이

내 이클립스 IDE 자바 코드는 다음과 같습니다 이 (내 아두 이노 포트가 COM5 및 Windows 10 64 비트를 사용.)

import java.io.BufferedReader; 
import java.io.InputStreamReader; 
import java.io.OutputStream; 
import gnu.io.CommPortIdentifier; 
import gnu.io.SerialPort; 
import gnu.io.SerialPortEvent; 
import gnu.io.SerialPortEventListener; 
import java.util.Enumeration; 


public class SerialTest implements SerialPortEventListener { 
    SerialPort serialPort; 
     /** The port we're normally going to use. */ 
    private static final String PORT_NAMES[] = { 
      "/dev/tty.usbserial-A9007UX1", // Mac OS X 
         "/dev/ttyACM0", // Raspberry Pi 
      "/dev/ttyUSB0", // Linux 
      "COM5", // Windows 
    }; 
    /** 
    * A BufferedReader which will be fed by a InputStreamReader 
    * converting the bytes into characters 
    * making the displayed results codepage independent 
    */ 
    private BufferedReader input; 
    /** The output stream to the port */ 
    private OutputStream output; 
    /** Milliseconds to block while waiting for port open */ 
    private static final int TIME_OUT = 2000; 
    /** Default bits per second for COM port. */ 
    private static final int DATA_RATE = 9600; 

    public void initialize() { 
       // the next line is for Raspberry Pi and 
       // gets us into the while loop and was suggested here was suggested http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=32186 
       // System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/ttyACM0"); 

     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(); 
      for (String portName : PORT_NAMES) { 
       if (currPortId.getName().equals(portName)) { 
        portId = currPortId; 
        break; 
       } 
      } 
     } 
     if (portId == null) { 
      System.out.println("Could not find COM port."); 
      return; 
     } 

     try { 
      // open serial port, and use class name for the appName. 
      serialPort = (SerialPort) portId.open(this.getClass().getName(), 
        TIME_OUT); 

      // set port parameters 
      serialPort.setSerialPortParams(DATA_RATE, 
        SerialPort.DATABITS_8, 
        SerialPort.STOPBITS_1, 
        SerialPort.PARITY_NONE); 

      // open the streams 
      input = new BufferedReader(new InputStreamReader(serialPort.getInputStream())); 
      output = serialPort.getOutputStream(); 

      // add event listeners 
      serialPort.addEventListener(this); 
      serialPort.notifyOnDataAvailable(true); 
     } catch (Exception e) { 
      System.err.println(e.toString()); 
     } 
    } 

    /** 
    * 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 { 
     SerialTest main = new SerialTest(); 
     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"); 
    } 

그리고 내 간단한 Arduino 코드는 다음과 같습니다.

void setup(){ 
    Serial.begin(9600); 
} 

void loop(){ 
    Serial.println("Hello world"); 
    delay(1000); 
} 

이 문제를 해결할 수있는 제안을 보내주십시오.

감사합니다.

+0

64 비트 Java 용으로 올바른 DLL을 갖고 계십니까? http://rxtx.qbang.org/wiki/index.php/Download#x64_Binaries – howlger

+0

추천 링크를 보내 주셔서 감사합니다 ... rxtx.jar 파일과 DLL을 다운로드하고 작업 영역에서 바꿉니다. RXTX 불일치에 대한 경고 메시지가 표시되지 않습니다. 좋은 일이지만 .... 여전히 전체 오류 메시지의 나머지 부분은 그대로입니다 ... !! –

답변

1

Java 9에서 동일한 문제가 있으며 Java 8로 다시 변경하면 작동합니다. 또 다른 해결책은 http://fazecast.github.io/jSerialComm/을 사용하십시오 ...

+0

예, JDK8에서 작동합니다. 감사합니다. –