You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2020/12/23 17:16:14 UTC

[plc4x] 02/02: Fixed Hello Ack Response parsing.

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

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

commit 40a629170e821f249a30994033c45447b4f6eeca
Author: hutcheb <be...@gmail.com>
AuthorDate: Wed Dec 23 12:14:15 2020 -0500

    Fixed Hello Ack Response parsing.
---
 .../src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java  | 2 +-
 .../org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java   | 2 +-
 .../main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java | 2 +-
 .../java/org/apache/plc4x/java/spi/generation/WriteBuffer.java     | 6 +-----
 protocols/opcua/src/main/resources/protocols/opcua/opcua.mspec     | 7 ++++---
 5 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java
index c38a148..cb1e8ef 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java
@@ -121,7 +121,7 @@ public class OpcuaPlcDriver extends GeneratedDriverBase<OpcuaAPU> {
     protected ProtocolStackConfigurer<OpcuaAPU> getStackConfigurer() {
         return SingleProtocolStackConfigurer.builder(OpcuaAPU.class, OpcuaAPUIO.class)
             .withProtocol(OpcuaProtocolLogic.class)
-            .withPacketSizeEstimator(ByteLengthEstimator.class)
+            //.withPacketSizeEstimator(ByteLengthEstimator.class)
             // Every incoming message is to be treated as a response.
             .withParserArgs(true)
             .littleEndian()
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
index 8447e4b..1e6e98b 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
@@ -87,7 +87,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> {
 
         OpcUAMessageHelloRequest hello = null;
         //try {
-            hello = new OpcUAMessageHelloRequest("F", 63, 0, 65535, 65535, 2097152, 64,  new String("opc.tcp://127.0.0.1:12687/plc4x"));
+            hello = new OpcUAMessageHelloRequest("F", 63, 0, 65535, 65535, 2097152, 64, 31, new String("opc.tcp://127.0.0.1:12687/plc4x"));
         //} catch (UnsupportedEncodingException e) {
         //    LOGGER.info("Excpetion Occurred.");
         //}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
index 1beef09..9635c3a 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
@@ -298,7 +298,7 @@ public class ReadBuffer {
     public String readString(int bitLength, String encoding) {
         byte[] strBytes = new byte[bitLength / 8];
         for (int i = 0; (i < (bitLength / 8)) && hasMore(8); i++) {
-            try {
+            try {                
                 strBytes[i] = readByte(8);
             } catch (Exception e) {
                 throw new PlcRuntimeException(e);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
index 79285ea..a4424cf 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
@@ -190,11 +190,7 @@ public class WriteBuffer {
         }
     }
 
-    public void writeInt(int bitLength, int value) throws ParseException {
-        System.out.println(bitLength);
-        System.out.println(value);
-        System.out.println(getData().length);
-        System.out.println(getPos());
+    public void writeInt(int bitLength, int value) throws ParseException {        
         if(bitLength <= 0) {
             throw new ParseException("int must contain at least 1 bit");
         }
diff --git a/protocols/opcua/src/main/resources/protocols/opcua/opcua.mspec b/protocols/opcua/src/main/resources/protocols/opcua/opcua.mspec
index 96b521b..d1b779b 100644
--- a/protocols/opcua/src/main/resources/protocols/opcua/opcua.mspec
+++ b/protocols/opcua/src/main/resources/protocols/opcua/opcua.mspec
@@ -35,11 +35,12 @@
             [simple          int 32             'sendBufferSize']
             [simple          int 32             'maxMessageSize']
             [simple          int 32             'maxChunkCount']
+            [simple          int 32             'stringLength']
             [simple          string 256         'endpoint']
         ]
-        // HEL Response
-        ['HEL','true'     OpcUAMessageHelloResponse
-            [simple          string 1            'chunk']
+        // ACK Response
+        ['ACK','true'     OpcUAMessageHelloResponse
+            [simple          string 8            'chunk']
             [simple          int 32             'messageSize']
             [simple          int 32             'version']
             [simple          int 32             'receiveBufferSize']