Skip to content

Commit

Permalink
Version 1.2.9.11. Update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
kochedykov committed Sep 19, 2024
1 parent 891f876 commit 6194787
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 17 deletions.
12 changes: 11 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The latest stable release.
<dependency>
<groupId>com.intelligt.modbus</groupId>
<artifactId>jlibmodbus</artifactId>
<version>1.2.9.9</version>
<version>1.2.9.11</version>
</dependency>

WEB SITE
Expand All @@ -45,6 +45,16 @@ http://users.frii.com/jarvi/rxtx/index.html
jserialcomm homepage:
https://github.com/Fazecast/jSerialComm

-----------------------------------------------------------------------------------------------------------
----Release version 1.2.9.11 -------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
* NEWS
* Update library dependencies. jSerialComm v2.10.4, jssc v2.9.6.
-----------------------------------------------------------------------------------------------------------
----Release version 1.2.9.10 -------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
* NEWS
* The release fixes issues #41, #64, #85, #91, 94
-----------------------------------------------------------------------------------------------------------
----Release version 1.2.9.9 -------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Mar 16 15:39:35 YEKT 2024
build.number=10
build.number=11
Binary file removed lib/jSerialComm-2.0.2.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.intelligt.modbus</groupId>
<artifactId>jlibmodbus</artifactId>
<version>1.2.9.10</version>
<version>1.2.9.11</version>
<name>JLibModbus</name>
<description>Implementation of the Modbus protocol in Java language</description>
<packaging>jar</packaging>
Expand Down Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.4.0</version>
<version>2.10.4</version>
</dependency>
<!-- Alternative serial library https://mvnrepository.com/artifact/com.github.purejavacomm/purejavacomm -->
<dependency>
Expand All @@ -49,9 +49,9 @@
</dependency>
<!-- https://mvnrepository.com/artifact/org.scream3r/jssc -->
<dependency>
<groupId>org.scream3r</groupId>
<groupId>io.github.java-native</groupId>
<artifactId>jssc</artifactId>
<version>2.8.0</version>
<version>2.9.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rxtx/rxtx -->
<dependency>
Expand Down
10 changes: 7 additions & 3 deletions src/com/intelligt/modbus/examples/ExampleRTU.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void close() throws SecurityException {
//do nothing
}
});
Modbus.setLogLevel(Modbus.LogLevel.LEVEL_DEBUG);
Modbus.setLogLevel(Modbus.LogLevel.LEVEL_RELEASE);
SerialParameters slaveSerialParameters = new SerialParameters();
SerialParameters masterSerialParameters = new SerialParameters();

Expand Down Expand Up @@ -101,10 +101,10 @@ public void close() throws SecurityException {
ModbusMaster master = ModbusMasterFactory.createModbusMasterRTU(masterSerialParameters);

master.setResponseTimeout(1000);
master.connect();

slave.setServerAddress(slaveId);
slave.setBroadcastEnabled(true);
slave.setReadTimeout(10000);
slave.setReadTimeout(1000);

/* CompletableFuture<ReadHoldingRegistersResponse> future =
master.sendRequest(new ReadHoldingRegistersRequest(0, 10), 0);*/
Expand Down Expand Up @@ -138,6 +138,8 @@ public void frameReceivedEvent(FrameEvent event) {

slave.listen();

Thread.sleep(1000);

master.connect();

//prepare request
Expand Down Expand Up @@ -168,6 +170,8 @@ public void frameReceivedEvent(FrameEvent event) {
e.printStackTrace();
} catch (SerialPortException e) {
e.printStackTrace();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
21 changes: 14 additions & 7 deletions src/com/intelligt/modbus/examples/ExampleTCP.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.intelligt.modbus.examples;

import com.intelligt.modbus.jlibmodbus.Modbus;
import com.intelligt.modbus.jlibmodbus.data.ModbusCoils;
import com.intelligt.modbus.jlibmodbus.data.ModbusHoldingRegisters;
import com.intelligt.modbus.jlibmodbus.exception.ModbusIOException;
import com.intelligt.modbus.jlibmodbus.exception.ModbusNumberException;
import com.intelligt.modbus.jlibmodbus.exception.ModbusProtocolException;
import com.intelligt.modbus.jlibmodbus.master.ModbusMaster;
import com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory;
import com.intelligt.modbus.jlibmodbus.msg.request.ReadCoilsRequest;
import com.intelligt.modbus.jlibmodbus.msg.request.ReadHoldingRegistersRequest;
import com.intelligt.modbus.jlibmodbus.msg.response.ReadCoilsResponse;
import com.intelligt.modbus.jlibmodbus.msg.response.ReadHoldingRegistersResponse;
import com.intelligt.modbus.jlibmodbus.slave.ModbusSlaveFactory;
import com.intelligt.modbus.jlibmodbus.slave.ModbusSlaveTCP;
Expand Down Expand Up @@ -106,6 +109,7 @@ public void clientDisconnected(TcpClientInfo info) {
slave.addObserver(o);

ModbusHoldingRegisters holdingRegisters = new ModbusHoldingRegisters(1000);
ModbusCoils coils = new ModbusCoils(1000);

for (int i = 0; i < holdingRegisters.getQuantity(); i++) {
//fill
Expand All @@ -116,6 +120,7 @@ public void clientDisconnected(TcpClientInfo info) {
holdingRegisters.setFloat64At(0, Math.PI);

slave.getDataHolder().setHoldingRegisters(holdingRegisters);
slave.getDataHolder().setCoils(coils);

Modbus.setAutoIncrementTransactionId(true);

Expand All @@ -124,20 +129,22 @@ public void clientDisconnected(TcpClientInfo info) {
master.connect();

//prepare request
ReadHoldingRegistersRequest request = new ReadHoldingRegistersRequest();
ReadCoilsRequest request = new ReadCoilsRequest();
request.setServerAddress(Modbus.TCP_DEFAULT_ID);
request.setStartAddress(0);
request.setQuantity(10);
ReadHoldingRegistersResponse response = (ReadHoldingRegistersResponse) request.getResponse();
request.setQuantity(123);
ReadCoilsResponse response = (ReadCoilsResponse) request.getResponse();

master.processRequest(request);
ModbusHoldingRegisters registers = response.getHoldingRegisters();
for (int r : registers) {
ModbusCoils registers = response.getModbusCoils();
for (boolean r : registers) {
System.out.println(r);
}

registers.get(120);
//get float
System.out.println("PI is approximately equal to " + registers.getFloat64At(0));
System.out.println();
//System.out.println("PI is approximately equal to " + registers.getFloat64At(0));
System.out.println(registers.get(120));

master.disconnect();
slave.shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/com/intelligt/modbus/jlibmodbus/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
class Version {

private static final String version = "1.2.9.10";
private static final String version = "1.2.9.11";
/**
* returns the current version of the JLibModbus library
*
Expand Down

0 comments on commit 6194787

Please sign in to comment.