You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/03/16 10:12:40 UTC

[plc4x] branch develop updated: feat(modbus): Adjusted the modbus discovery to work with the renamed modbus-tcp driver

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9ae4a55  feat(modbus): Adjusted the modbus discovery to work with the renamed modbus-tcp driver
9ae4a55 is described below

commit 9ae4a55faf8b2804987aa7f1a6d31ce7b539b4e7
Author: cdutz <ch...@c-ware.de>
AuthorDate: Wed Mar 16 11:12:32 2022 +0100

    feat(modbus): Adjusted the modbus discovery to work with the renamed modbus-tcp driver
---
 .../apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java   | 4 ++--
 .../java/org/apache/plc4x/java/modbus/ManualModbusDiscoveryTest.java  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
index 2b89ea3..70ca55c 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
@@ -188,11 +188,11 @@ public class ModbusPlcDiscoverer implements PlcDiscoverer {
                     if (responseBytes != null) {
                         ReadBuffer readBuffer = new ReadBufferByteBased(responseBytes);
                         try {
-                            ModbusTcpADU response = (ModbusTcpADU) ModbusTcpADU.staticParse(readBuffer, true);
+                            ModbusTcpADU response = (ModbusTcpADU) ModbusTcpADU.staticParse(readBuffer, DriverType.MODBUS_TCP, true);
                             PlcDiscoveryItem discoveryItem;
                             if (!response.getPdu().getErrorFlag()) {
                                 discoveryItem = new DefaultPlcDiscoveryItem(
-                                    "modbus", "tcp", possibleAddress.getHostAddress(), Collections.singletonMap("unit-identifier", Integer.toString(unitIdentifier)), "unknown");
+                                    "modbus-tcp", "tcp", possibleAddress.getHostAddress(), Collections.singletonMap("unit-identifier", Integer.toString(unitIdentifier)), "unknown");
                                 discoveryItems.add(discoveryItem);
 
                                 // Give a handler the chance to react on the found device.
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDiscoveryTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDiscoveryTest.java
index c346ae3..383d2d1 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDiscoveryTest.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDiscoveryTest.java
@@ -25,7 +25,7 @@ import org.apache.plc4x.java.api.messages.PlcDiscoveryResponse;
 public class ManualModbusDiscoveryTest {
 
     public static void main(String[] args) throws Exception {
-        final PlcDriver modbusDriver = new PlcDriverManager().getDriver("modbus");
+        final PlcDriver modbusDriver = new PlcDriverManager().getDriver("modbus-tcp");
         final PlcDiscoveryResponse plcDiscoveryResponse = modbusDriver.discoveryRequestBuilder().build().execute().get();
         System.out.println(plcDiscoveryResponse);
     }