zengfr / easymodbus4j

easymodbus4j是一个高性能和易用的 Modbus 协议的 Java 实现,基于 Netty 开发,可用于 Modbus协议的Java客户端和服务器开发, A high-performance and ease-of-use implementation of the Modbus protocol written in Java netty support for modbus 4 mode..

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java 11 Serial Port RTU支持么?

lichangyuan1993 opened this issue · comments

我用了modbus4j仅支持jdk8,使用jdk11,master可以发送数据,接收数据jvm报错。

我用了modbus4j仅支持jdk8,使用jdk11,master可以发送数据,接收数据jvm报错。

你好 错误发来看下 或截图

@zengfr

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180005b00, pid=12208, tid=4156
#
# JRE version: OpenJDK Runtime Environment (11.0.9.1+1) (build 11.0.9.1+1-LTS)
# Java VM: OpenJDK 64-Bit Server VM (11.0.9.1+1-LTS, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [rxtxSerial.dll+0x5b00]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# 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.
#

---------------  S U M M A R Y ------------

Command Line: -Djava.library.path=D:\Workspaces-Learning\sshx-ktzl\lib -javaagent:C:\Users\clayton\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\202.7660.26\lib\idea_rt.jar=58732:C:\Users\clayton\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\202.7660.26\bin -Dfile.encoding=UTF-8 com.mytest.serial.SerialPortTest

Host: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 4 cores, 15G,  Windows 10 , 64 bit Build 19041 (10.0.19041.546)
Time: Fri Nov 20 15:49:19 2020 �й���׼ʱ�� elapsed time: 12.366819 seconds (0d 0h 0m 12s)

@zengfr
I use jssc-2.9.2 , modbus4j-3.0.3 solved the problem. But, I don't quite understand yet
at the very start, I have problems with rxtx-2.2pre2 , modbus4j-3.0.3 .

        <dependency>
            <groupId>io.github.java-native</groupId>
            <artifactId>jssc</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>com.infiniteautomation</groupId>
            <artifactId>modbus4j</artifactId>
            <version>3.0.5</version>
        </dependency>

@zengfr
I use jssc-2.9.2 , modbus4j-3.0.3 solved the problem. But, I don't quite understand yet
at the very start, I have problems with rxtx-2.2pre2 , modbus4j-3.0.3 .

        <dependency>
            <groupId>io.github.java-native</groupId>
            <artifactId>jssc</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>com.infiniteautomation</groupId>
            <artifactId>modbus4j</artifactId>
            <version>3.0.5</version>
        </dependency>

EXCEPTION_ACCESS_VIOLATION

@zengfr
I use jssc-2.9.2 , modbus4j-3.0.3 solved the problem. But, I don't quite understand yet
at the very start, I have problems with rxtx-2.2pre2 , modbus4j-3.0.3 .

        <dependency>
            <groupId>io.github.java-native</groupId>
            <artifactId>jssc</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>com.infiniteautomation</groupId>
            <artifactId>modbus4j</artifactId>
            <version>3.0.5</version>
        </dependency>

一、 [rxtxSerial.dll+0x5b00] EXCEPTION_ACCESS_VIOLATION
win10下可能出现。和 easymodbus4j无关,尝试下以下方法:
1、win10系统补丁 以及 最新Java 11 以及确认都是64位。
2、dll 放置正确的目录位置 调用的是正确的64位版本
3、添加serialPort.addEventListener(eventListener);解决
二、easymodbus4j 只支持基于TcpIp的 tcp/rtu协议。
不支持直接接串口的RTU。串口的RTU 需硬件接 转tcp的RTU或TCP硬件模块(几十块钱 透明转换)。