目前我正在尝试从他的视频(https://youtu.be/rCyJ-TFFxWA)中复制“GeorgeNotFound”的 MinecraftShocker 插件,但我收到此错误,这意味着没有找到 Arduino 对吗?
我已经检查了 Arduino Uno 是否连接到“COM3”,并且我已经在 Arduino 上安装了 Firmata。
我正在使用 Maven 添加库。
我将我正在使用的 jar 从 slf4j-log4j12.jar 更改为 slf4j-jdk14.jar,现在我得到了一个不同的错误。
添加了文本以指示它一直失败的位置。
使所有早期的编辑斜体以提高可读性。
我不再使用slf4j-jdk14.jar
了,而是删除了 in 的依赖项org.scream3r:jssc:2.8.0
并com.github.kurbatov:firmata4j:2.3.8
单独安装io.github.java-native:jssc:2.9.2
(所以它现在不再使用 2.8.0 作为默认版本,而是使用固定的 2.9.2 版本;))瞧,它正在工作
错误:
Connecting...
Connected
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=9764, tid=1144
#
# JRE version: OpenJDK Runtime Environment (15.0+36) (build 15+36-1562)
# Java VM: OpenJDK 64-Bit Server VM (15+36-1562, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C [jSSC-2.8_x86_64.dll+0xb5db]
#
# 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:
# C:\Users\Lucky 56\IdeaProjects\Shocker\hs_err_pid9764.log
#
# If you would like to submit a bug report, please visit:
# https://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.
#
Process finished with exit code 1
代码:
package me.lucky56.shocker;
import org.firmata4j.IODevice;
import org.firmata4j.Pin;
import org.firmata4j.firmata.FirmataDevice;
import java.io.IOException;
public class Main
{
public static void main(String[] args) throws IOException, InterruptedException {
System.out.println("Connecting...");
IODevice device = new FirmataDevice("COM3");
System.out.println("Connected");
device.start();
device.ensureInitializationIsDone();
System.out.println("Connected Successfully");
for (int i = 0; i < 5; i++)
{
turnOn(device);
System.out.println("On");
Thread.sleep(250);
System.out.println("Off");
turnOff(device);
Thread.sleep(1000);
}
device.stop();
}
static void turnOn(IODevice device)
{
try
{
device.getPin(7).setMode(Pin.Mode.OUTPUT);
device.getPin(7).setValue(350);
device.getPin(13).setMode(Pin.Mode.INPUT);
} catch (IOException e)
{
e.printStackTrace();
}
}
static void turnOff(IODevice device)
{
try
{
device.getPin(7).setMode(Pin.Mode.INPUT);
} catch (IOException e)
{
e.printStackTrace();
}
}
}