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 2022/06/21 20:08:55 UTC

[plc4x] branch develop updated: feat(plc4j/eip): Updated java CIP write dataSize to match read dataSize (#384) [PLC4X-341]

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

hutcheb 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 0489ec6d12 feat(plc4j/eip): Updated java CIP write dataSize to match read dataSize (#384) [PLC4X-341]
0489ec6d12 is described below

commit 0489ec6d12a05096675cfb96ebe208465cbef2d6
Author: AndyGrebe <10...@users.noreply.github.com>
AuthorDate: Tue Jun 21 16:08:50 2022 -0400

    feat(plc4j/eip): Updated java CIP write dataSize to match read dataSize (#384) [PLC4X-341]
    
    * EIP adding read/write for STRINGS and LINT
    
    Jira PLC4X-341
    
    * Removed unneeded output.
    
    * Updated writes to set dataLength like reads.
    
    Co-authored-by: Andy Grebe <an...@designedconveyor.com>
---
 .../plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
index 052f42bceb..6380a96f7d 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/protocol/EipProtocolLogic.java
@@ -447,12 +447,19 @@ public class EipProtocolLogic extends Plc4xProtocolBase<EipPacket> implements Ha
             //We need the size of the request in words (0x91, tagLength, ... tag + possible pad)
             // Taking half to get word size
             boolean isArray = false;
+            boolean isStruct = false;
             String tagIsolated = tag;
             if (tag.contains("[")) {
                 isArray = true;
                 tagIsolated = tag.substring(0, tag.indexOf("["));
             }
-            int dataLength = (tagIsolated.length() + 2 + (tagIsolated.length() % 2) + (isArray ? 2 : 0));
+
+            if (tag.contains(".")) {
+                isStruct = true;
+                tagIsolated = tagIsolated.replace(".", "");
+            }
+
+            int dataLength = (tagIsolated.length() + 2 + ((tagIsolated.length() % 2) * 2) + (isArray ? 2 : 0) + (isStruct ? 2 : 0));
             byte requestPathSize = (byte) (dataLength / 2);
             byte[] data = encodeValue(value, field.getType(), (short) elements);
             CipWriteRequest writeReq = new CipWriteRequest(requestPathSize, toAnsi(tag), field.getType(), elements, data, -1);