You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2021/03/15 18:09:33 UTC

[plc4x] 05/05: Fix troubles with padding, yet not perfect.

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

ldywicki pushed a commit to branch feature/profinet2
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit d8ddeb6aba0cd3e71449460972ad8b21e1a83a36
Author: Ɓukasz Dywicki <lu...@code-house.org>
AuthorDate: Mon Mar 15 19:09:09 2021 +0100

    Fix troubles with padding, yet not perfect.
---
 .../resources/protocols/profinet/profinet.dcp.mspec    |  2 +-
 sandbox/test-java-profinet-driver/pom.xml              | 18 ++++++++++++++++++
 .../plc4x/java/profinet/dcp/ProfinetDCPPlcDriver.java  |  8 --------
 .../dcp/protocol/ProfinetDCPProtocolLogic.java         |  2 +-
 .../src/test/resources/testsuite/ProfinetDCPFrame.xml  |  2 +-
 5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec b/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
index 6c9a941..c32e582 100644
--- a/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
+++ b/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
@@ -99,7 +99,7 @@
             [simple uint 8 'instanceHigh'        ]
         ]
     ]
-    [padding uint 8                 'pad' '0x00' '46 - length']
+    [padding uint 8                 'pad' '0x00' '(length % 2 == 0 ? 0 : 1)']
 ]
 
 
diff --git a/sandbox/test-java-profinet-driver/pom.xml b/sandbox/test-java-profinet-driver/pom.xml
index 7d8d07f..0d26ff2 100644
--- a/sandbox/test-java-profinet-driver/pom.xml
+++ b/sandbox/test-java-profinet-driver/pom.xml
@@ -57,6 +57,24 @@
   </build>
 
   <dependencies>
+    <!-- todo remove explicit dependency -->
+    <dependency>
+      <groupId>org.pcap4j</groupId>
+      <artifactId>pcap4j-core</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.pcap4j</groupId>
+      <artifactId>pcap4j-packetfactory-static</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <scope>compile</scope>
+    </dependency>
+
+    <!-- actual dependencies ;-) -->
     <dependency>
       <groupId>org.apache.plc4x</groupId>
       <artifactId>plc4j-api</artifactId>
diff --git a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/ProfinetDCPPlcDriver.java b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/ProfinetDCPPlcDriver.java
index b157427..5baa18e 100644
--- a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/ProfinetDCPPlcDriver.java
+++ b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/ProfinetDCPPlcDriver.java
@@ -20,8 +20,6 @@ package org.apache.plc4x.java.profinet.dcp;
 
 import java.util.function.Consumer;
 import java.util.function.ToIntFunction;
-import org.apache.plc4x.java.PlcDriverManager;
-import org.apache.plc4x.java.api.PlcConnection;
 import org.apache.plc4x.java.api.value.PlcValueHandler;
 import org.apache.plc4x.java.profinet.dcp.configuration.ProfinetConfiguration;
 import org.apache.plc4x.java.profinet.dcp.field.ProfinetFieldHandler;
@@ -101,10 +99,4 @@ public class ProfinetDCPPlcDriver extends GeneratedDriverBase<EthernetFrame> {
         }
     }
 
-
-    public static void main(String[] args) throws Exception {
-        PlcConnection connection = new PlcDriverManager().getConnection("profinet-dcp:raw://ens2f1?sender=00:10:18:6c:4c:e2");
-        //connection.connect();
-    }
-
 }
diff --git a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
index e4921f2..9348d2c 100644
--- a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
+++ b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
@@ -104,7 +104,7 @@ public class ProfinetDCPProtocolLogic extends Plc4xProtocolBase<EthernetFrame> i
                     }
                     if (block instanceof DeviceProperties) {
                         DeviceProperties properties = (DeviceProperties) block;
-                        logger.info("Device option: {}, value: {}", properties.getSubOption().name(), properties.getProperties().toPlcValue());
+                        logger.info("Device option: {}, value: {}", properties.getSubOption().name(), properties.getProperties());
                     }
                 }
             } else {
diff --git a/sandbox/test-java-profinet-driver/src/test/resources/testsuite/ProfinetDCPFrame.xml b/sandbox/test-java-profinet-driver/src/test/resources/testsuite/ProfinetDCPFrame.xml
index 44ba2d8..71c9c4c 100644
--- a/sandbox/test-java-profinet-driver/src/test/resources/testsuite/ProfinetDCPFrame.xml
+++ b/sandbox/test-java-profinet-driver/src/test/resources/testsuite/ProfinetDCPFrame.xml
@@ -23,7 +23,7 @@
 
   <testcase>
     <name>Profinet: DCP Identify Multicast</name>
-    <raw>fefe05000501000f00800004ffff0000000000000000000000000000000000000000000000000000000000000000</raw>
+    <raw>fefe05000501000f00800004ffff0000</raw>
     <root-type>ProfinetFrame</root-type>
     <xml>
       <ProfinetFrame className="org.apache.plc4x.java.profinet.dcp.readwrite.ProfinetFrame">