Code Monkey home page Code Monkey logo

modbusmechanic's Introduction

Modbus Mechanic

Cross platform GUI tool for reading and testing MODBUS TCP and RTU instruments Screenshot

More screenshots

Overview

Frustrated by the lack of GUI Modbus testing tools available that could interpret data types (float, unsigned int) I built this application on top of the JLibModbus library.

Modbus Mechanic aims to be a tool that can quickly read a float32, unsigned int16, unsigned int32, or raw hex from an instrument without the need for anything other than the dependant jar files, and the java runtime environment. It also aims to be 100% driverless. It is a work in progress.

This is a project that is evolving, so suggestions to improve coding conventions are welcome. I'm sure there are opportunities for improvement within my code.

My testing capabilities are limited, so if you notice a problem, please open an issue.

JlibModbus is a seperate, independant project that this application depends on.

Quickstart

If you don't have Java installed, head to adoptopenjdk.net to download and install the Java runtime. Then, download & extract the latest release and double click ModbusMechanic.jar.

Register scanner

Register scanner

The register scanner tool allows input and holding register ranges to be scanned for values. Nonexistant registers are excluded frm the results and there is an option to hide zero values. This tool may be able to help identify register ranges when they are not known. Note that full range scans can take some time as there are 65536 possible registers to scan in each of the holding register and input register groups.

RTU scanner

The RTU scanner tool allows scanning of the entire RTU network for active nodes. This is useful if there is a slave device on the network for which the address is not known. For best results, the scanner should be the only master on the network.

Gateway

The gateway function allows exposing an RTU network to a TCP network. TCP master devices can send Modbus transactions to the machine running ModbusMechanic, and ModbusMechanic will obtain a response from the RTU network if possible.

Running Gateway in GUI

The gateway function is available from the GUI in the tools menu.

Running the Gateway on a headless box

The gateway can be run on a headless machine by specifying a config file. A config file may be generated one of two ways.

  1. Using the GUI - Go to the tools menu and select Gateway. Specify the settings and click Save Settings. The cfg file will be generated.
  2. Manually - Create a file in the following format. comport must be specified. Other parameters may be omited if defaults are acceptable.
comport=COM1
tcpport=502
baud=19200
parity=0
databits=8
stopbits=1
allowmonitor=0
Attribute Descrtiption Default
comport The name of the com port. On Linux this is the name of the serial port in the /dev directory, not the full path. Nothing
tcpport Port on which the TCP slave of the Gateway will be accessible. 502
baud Baud rate for the serial port. 9600
parity Parity for the serial port. 0=None 1=Odd 2=Even 3=Mark 4=Space 0
databits Data bits for serial port. 5-8 are acceptible. 8
stopbits Stop bits for serial port. 1=1 2=2 3=1.5 1
allowmonitor Allow remote frame monitor via telnet 0=no 1=yes 0
  1. Launch ModbusMechanic with the -gateway argument followed by the path to the config file. Example on Linux for config file named "gateway.cfg".
$ java -jar ModbusMechanic.jar -gateway gateway.cfg

Monitoring frames on a headless gateway

Enable remote frame monitoring (see above) and connect to the gateway's IP address with a telnet client. You will be able to see frames as they would be displayed in the watch window.

Bridging to other protocols

This functionality is still available in ModbusMechanic, but is being moved to a stand alone project ProtocolWhisperer

My language localizations are wrong, how can I report errors?

I am using automated translation to do localizations and am not a native speaker of all localizations. As a result, the terms in certain languages describing certain functions may be wrong. If you run across lingustic errors and would like to report them, please open an issue.

Dependencies

This project depends on the JLibModbus library and the PureJavaComm library for serial functionality. It depends on EtherIP for CIP functionality.

https://github.com/kochedykov/jlibmodbus

https://github.com/nyholku/purejavacomm

https://github.com/EPICSTools/etherip

Building from source

This is a NetBeans project. It can be built by pulling it in the NetBeans IDE or manually compiling. The project requires the JLibModbus jar. Serial functionality requires the PureJavaComm and JNA libraries.

Guide

https://scifidryer.github.io/ModbusMechanic/

Debugging

To obtain verbose debugging information start ModbusMechanic with the debug option.

$ java -jar ModbusMechanic.jar -debug

Latest release

ModbusMechanic.v3.0.zip

Completed features and planned features in GUI

  • Read holding registers
  • Read input registers
  • Read coils
  • Read discretes
  • Write holding registers
  • Write coils
  • Slave stress test with custom packet crafter
  • Data interpreter
  • Word and byte swapper
  • RTU bus monitor
  • Gateway
  • Bookmarks
  • Master simulator
  • Slave simulator

modbusmechanic's People

Contributors

barreiroleo avatar scifidryer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modbusmechanic's Issues

Display error message when serial port fails to open on RTU scanner function

Describe the bug
It would be great to add some information or try to handle the case when a user is not in dialout group.

To Reproduce
Steps to reproduce the behavior:

  1. check that you are not in dialout group: $ groups
  2. $ java -jar ModbusMechanic.jar -debug
  3. Tools-> RTU Scanner, click 'Scan'
  4. See error in console:
    purejavacomm.PortInUseException: errno() == 13
    at purejavacomm.PureJavaSerialPort.(PureJavaSerialPort.java:1090)
    at purejavacomm.CommPortIdentifier.open(CommPortIdentifier.java:159)
    at modbusmechanic.RTUScannerThread.run(RTUScannerThread.java:49)

Expected behavior
To fix that you need to do: sudo usermod -a -G dialout $USER

Screenshots
There are no any errors on UI.

Desktop (please complete the following information):

  • OS: Linux, Ubuntu
  • Version: lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.6 LTS
    Release: 18.04
    Codename: bionic

Java Runtime Version
java -version
openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-118.04)
OpenJDK Server VM (build 17.0.4+8-Ubuntu-118.04, mixed mode, sharing)

Additional context
Advanced Modbus Module User Manual
Serial Device Access Privileges
Next, the ignition user account (or whatever user runs the Ignition gateway service) must be added to the
group controlling access to these devices. On most Linux distributions, this is the dialout group. This
will work in most cases (executed as root):
adduser ignition dialout
Be sure to restart Ignition after changing group membership—it doesn’t take immediate effect.

Thanks,
Vlad

Add signed int data types

Dont know, if this is still actively maintained, but as I was having trouble using the GUI itself (#12) noticed the limited data value types.
I was wondering if it would be possible to implement other data value types, for example such as signed16/32/64?

RTU slave simulator device not known and exception

Describe the bug

I do not know to what serial device to connect when using slave simulator and end up with an exception when sending a payload.

To Reproduce
Steps to reproduce the behavior:

Start slave simulator RTU, it is not know what virtual device comes up that can be connected to.

image

It is not known on what serial port the slave simulator is running. when simply setting rtu and sending a modbus payload i get an exception:

om.intelligt.modbus.jlibmodbus.exception.ModbusIOException: com.intelligt.modbus.jlibmodbus.serial.SerialPortException: purejavacomm.PureJavaIllegalStateException: JTermios call returned -1 at class purejavacomm.PureJavaSerialPort line 1106
	at com.intelligt.modbus.jlibmodbus.net.ModbusConnectionSerial.openImpl(ModbusConnectionSerial.java:62)
	at com.intelligt.modbus.jlibmodbus.net.ModbusConnection.open(ModbusConnection.java:45)
	at com.intelligt.modbus.jlibmodbus.master.ModbusMaster.connectImpl(ModbusMaster.java:74)
	at com.intelligt.modbus.jlibmodbus.master.ModbusMaster.connect(ModbusMaster.java:88)
	at modbusmechanic.ModbusMechanic.generateModbusMessage(ModbusMechanic.java:353)
	at modbusmechanic.ModbusMechanic.generateModbusRTURequest(ModbusMechanic.java:314)
	at modbusmechanic.PacketFrame.transmitPacket(PacketFrame.java:815)
	at modbusmechanic.PacketFrame.transmitPacketButtonActionPerformed(PacketFrame.java:677)
	at modbusmechanic.PacketFrame.access$1500(PacketFrame.java:31)
	at modbusmechanic.PacketFrame$16.actionPerformed(PacketFrame.java:448)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6400)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: com.intelligt.modbus.jlibmodbus.serial.SerialPortException: purejavacomm.PureJavaIllegalStateException: JTermios call returned -1 at class purejavacomm.PureJavaSerialPort line 1106
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortPJC.open(SerialPortPJC.java:102)
	at com.intelligt.modbus.jlibmodbus.net.ModbusConnectionSerial.openImpl(ModbusConnectionSerial.java:60)
	... 44 more
Caused by: purejavacomm.PureJavaIllegalStateException: JTermios call returned -1 at class purejavacomm.PureJavaSerialPort line 1106
	at purejavacomm.PureJavaSerialPort.checkReturnCode(PureJavaSerialPort.java:1307)
	at purejavacomm.PureJavaSerialPort.<init>(PureJavaSerialPort.java:1106)
	at purejavacomm.CommPortIdentifier.open(CommPortIdentifier.java:159)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortPJC.open(SerialPortPJC.java:83)
	... 45 more

Can you clarify to what serial port i have to connect or is this a bug?

Thanks a lot and sorry if i simply dont get it.

regards

Michael

[RTU] Allow for higher baud

Describe the bug
I'm using 115200 baud rate, which is not possible to set in ModbusMechanic

To Reproduce
Steps to reproduce the behavior:

  1. Go to ModbusMechanic
  2. Click on Baud
  3. Scroll down
  4. See 57600 as max baud

Expected behavior
See higher baud settings
Screenshots
obraz

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version 22.04

Java Runtime Version
11.0.18

Additional context
n/a

TimeoutException when using Slave ID other than 1

I am trying to add functionality to my communication (as the master) with inverters (the slaves) via a corporate Modbus implementation (from SMA Solar Technologies), without actually connecting to the hardware all the time. Id hoped, that this tool might ease things for me.

However so far, I could not even get it to run with itself.
I thought I tried the simpliest queries I already managed to implement in my own communication.
Reading Input Registers with FunctionCode 0x04 at Register 30843. Unsigned32 (2 Registers) at SlaveID 3 and of course ProtocolID 0.

But all I got is a TimeoutException (see screenshot below).
Is there anything I could check or read up on to figure out where things went wrong?

PS: I am running a Debian Bookworm system with OpenJDK 17.0.5+8-2 using Hotspot JIT. Maybe I should mention, that if I am running the .jar without sudo and trying to connect to 127.0.0.1 it says java.net.ConnecException: Connection Refused.

image

Linux - show only active ports

Hi,

i just want to inform, it's working on linux.
linux mint 19.3 Cinnamon.

some enhancements can be made, such as listing only active serial (ttyS* is all listed).

thank you for the software.

RTU Slave Simulator doesn't update watch window

First of all: Thank you very much for sharing this useful software!
It helps a lot developing some Modbus Master and Slave Devices (ESP32+Max487 Hardware with eModbus Library as Master and Attiny85+Max487 as Slave with tinnymodbus Software).
I mainly use Modbus RTU on a Linux Machine and it is a great tool to analyze and test modbus traffic.

I just wanted to know if the Modbus Slave Simulation should work with RTU too? (i have tested it successfully with Modbus TCP when running as root).
eg. i have a Modbus RTU Master which regularly polls some registers and i want ModbusMechanic to answer to this polls. (aka act as a virtual Sensor)
Dont know if this is not Implemented, a bug or a User Error from my side :)

Also when i open the Serial Monitor, i do not see any Traffic, and cannot send Packets any more ("cannot open serial port ttyUSB0") until i close the Serial Monitor Window again..

$java -version                                                                                                                                                                                                ✔ 
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10)
OpenJDK 64-Bit Server VM (build 11.0.18+10, mixed mode)
$
$uname -r                                                                                                                                                                                                     ✔ 
5.15.89-1-MANJARO

Anyways i am very happy with the core feature of this tool!

Cheers,
Stefan

Feature Request: Write single register (0x06)

Thanks for this tool which is really helpful in simulating and explaining Modbus communication, in my case for configuring filters in OT-firewalls.

For illustration purposes, it would come in handy to also have the possibility to write a single register directly (0x06).

As I don't know about all the dependencies inside your project, I don't want to fork this right away. But if you can tell me about the positions where this might have an impact, I can write these few Java lines by myself as well.

(btw. I'll fix the German translation as well then)

java.jang.UnsatisfiedLinkError in macOS Monterey (Apple Silicon)

Describe the bug

Double-clicking (after right-click > open for first time launch) crashes with an error asking to look at console.

Executing from CLI:

java -jar ~/Downloads/ModbusMechanic/ModbusMechanic.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/tb/dc9bcxw57mlf9_5s6ffd1kx80000gn/T/jna--87988168/jna12023659475483233029.tmp
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
	at java.base/java.lang.Runtime.load0(Runtime.java:785)
	at java.base/java.lang.System.load(System.java:1979)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
	at com.sun.jna.Native.<clinit>(Native.java:131)
	at jtermios.macosx.JTermiosImpl.<clinit>(JTermiosImpl.java:55)
	at jtermios.JTermios.<clinit>(JTermios.java:317)
	at purejavacomm.CommPortIdentifier$1.<init>(CommPortIdentifier.java:200)
	at purejavacomm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:193)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortFactoryPJC.getPortIdentifiersImpl(SerialPortFactoryPJC.java:45)
	at com.intelligt.modbus.jlibmodbus.serial.SerialPortAbstractFactory.getPortIdentifiers(SerialPortAbstractFactory.java:55)
	at com.intelligt.modbus.jlibmodbus.serial.SerialUtils.getPortIdentifiers(SerialUtils.java:67)
	at modbusmechanic.ModbusMechanic.getPortNames(ModbusMechanic.java:131)
	at modbusmechanic.PacketFrame.getPortNames(PacketFrame.java:1662)
	at modbusmechanic.PacketFrame.initComponents(PacketFrame.java:239)
	at modbusmechanic.PacketFrame.<init>(PacketFrame.java:74)
	at modbusmechanic.ModbusMechanic.main(ModbusMechanic.java:114)

Setting class path explicitly to the included lib directory does not change the error.

To Reproduce

I merely unzipped the latest release, and then as above.

Expected behavior

App launches

Screenshots

The pop-up macOS gave about looking at console only happened on first launching via right-click > Open and confirming. Unfortunately it doesn't pop up again so I can't get a screenshot

Desktop (please complete the following information):

  • OS: macOS
  • Version: Monterey (12.4)
  • Arch: M1 Max (Apple Silicon)

Java Runtime Version

Additional context

❯ java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Homebrew (build 18.0.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.1+0, mixed mode, sharing)

Using hide zero option also hides negative Float entries

In the register scanner when you select the 'Hide Zero Value Registers' option not only Zero value registers are hidden but also some registers where the value is negative. See attached screenshots, the Float with negative values are hidden.
Screenshot (5)
Screenshot (4)

Not work RTU mode when press "Transmit packet" button

Describe the bug
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:662)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at modbusmechanic.PacketFrame.transmitPacketButtonActionPerformed(PacketFrame.java:700)
at modbusmechanic.PacketFrame.access$1300(PacketFrame.java:31)
at modbusmechanic.PacketFrame$14.actionPerformed(PacketFrame.java:423)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6400)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Desktop (please complete the following information):

  • OS: linux mint
  • Version 20.3

Java Runtime Version

  • Open JDK Runtime 11

USB serial ports Linux

I have a USB modbus stick that places the tty file in /dev/serial. When I select RTU and want to select the correct serial port, I only get to chose from the ones listed under /dev/, so my USB dongle is not detected.

When using my USB dongle with it's file under /dev/serial in Domoticz, it has no problems being recognised.

java.lang.ArrayIndexOutOfBoundsException: 0 >= 0

Describe the bug
Scanning registers from 40000 to 40001 it shows no result and the logging system traces a java.lang.ArrayIndexOutOfBoundsException: 0 >= 0

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Tools->Registry Scanner'
  2. Start register: 40000; End register: 4100
  3. Press 'Scan'
  4. Pop-up shows the progress
  5. At the end nothing happens and the console show an Exception

Screenshots
bug

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.2 LTS Desktop Edition

Java Runtime Version
openjdk 11.0.19 2023-04-18 64-bit

Stack Trace

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
	at java.base/java.util.Vector.elementAt(Vector.java:497)
	at java.desktop/javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:295)
	at java.desktop/javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(BasicTableHeaderUI.java:756)
	at java.desktop/javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(BasicTableHeaderUI.java:788)
	at java.desktop/javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:819)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
	at java.desktop/javax.swing.table.JTableHeader.getPreferredSize(JTableHeader.java:447)
	at java.desktop/javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:98)
	at java.desktop/java.awt.Container.preferredSize(Container.java:1823)
	at java.desktop/java.awt.Container.getPreferredSize(Container.java:1807)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1682)
	at java.desktop/javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:728)
	at java.desktop/java.awt.Container.layout(Container.java:1537)
	at java.desktop/java.awt.Container.doLayout(Container.java:1526)
	at java.desktop/java.awt.Container.validateTree(Container.java:1722)
	at java.desktop/java.awt.Container.validate(Container.java:1657)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.java:745)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.java:743)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:742)
	at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1889)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

(Preset) Write Single Register (6) incorrect value transmission

I was trying to see if my FunctionCode 0x06 works alright, but realised that the implementation in Modbusmechanic v2.5 seems to be a little bit faulty?

When I setup the simulator as Holding Register 50000 (UINT16), no swaps, I am not able to overwrite this value with FnC 0x06 correctly. No matter what I want to write, it always defaults to 0. Attached youl find screenshots of the WireShark capture of different write requests, always with the same data value.

ModbusMechanic client with 0x06 request and value=5.
grafik

WireShark Output for my own implementation, same settings.
grafik

ModbusMechanic client with 0x10 request and value=5 seems to work okay...
grafik
... but as far as I understand simply writing one register (u16) should be possible with 0x06 as well?

Sorry in advance, if I missed something.
EDIT: My understandings in this are based on "MODBUS APPLICATION PROTOCOL SPECIFICATION
V1.1b3" from Modbus.org but might be oudated.
grafik
grafik

Status update in slave simulator

This is a great software, I've been using it for educational purposes. The slave simulator function is really handy, however as a "standalone" slave simulator I found an issue with Modbus Mechanic. It seems that when running it as a slave simulator towards other Modbus Master (software) the slave simulator GUI does not refresh its status on coils and holding registers when receiving write requests from Master. I'm not sure if this mode of operation is the original intension of this slave simulator, although it would be a great feature to be able to simulate slave devices across a network.

(It's running on Windows 10 and Modbus TCP).

It works fine along with the Modbus Master in Modbus Mechanic, however.

Register scan returns inconsistent results

While using the register scanner I noticed that values I expected would jump around between the registers on almost every scan.

To Reproduce
Open up the register scanner and scan a node using tcp and note a value.
Scan again and then note that the value you are looking for moved to a new registery

Running on Fedora 38

$ java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (Red_Hat-17.0.7.0.7-4.fc38) (build 17.0.7+7)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.7.0.7-4.fc38) (build 17.0.7+7, mixed mode, sharing)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.