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

chrisdutz 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 bc6a3649a5 fix(plc4j/eip): fix ConnectionManager (#2673)
bc6a3649a5 is described below

commit bc6a3649a58bab0d40a642d8fb533c6b8bf40f2f
Author: Anderson Vasconcelos Pires <[email protected]>
AuthorDate: Mon Aug 10 03:07:05 2026 -0300

    fix(plc4j/eip): fix ConnectionManager (#2673)
    
    connectionSerialNumber is out of range to establish connection
    add missing encoding for unsigned integers to reading tags
---
 .../apache/plc4x/java/eip/base/EipTcpConnection.java  | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git 
a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EipTcpConnection.java
 
b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EipTcpConnection.java
index a2a920bbbd..3cc402e109 100644
--- 
a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EipTcpConnection.java
+++ 
b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EipTcpConnection.java
@@ -29,10 +29,8 @@ import 
org.apache.plc4x.java.eip.base.configuration.EIPConfiguration;
 import org.apache.plc4x.java.eip.base.tag.EipTag;
 import org.apache.plc4x.java.eip.base.tag.EipTagHandler;
 import org.apache.plc4x.java.eip.readwrite.*;
-import org.apache.plc4x.java.spi.buffers.api.WithOption;
 import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;
 import org.apache.plc4x.java.spi.buffers.bytebased.ReadBufferByteBased;
-import org.apache.plc4x.java.spi.buffers.bytebased.WithByteBasedOption;
 import org.apache.plc4x.java.spi.buffers.bytebased.WriteBufferByteBased;
 import 
org.apache.plc4x.java.utils.subscriptionemulation.PollingSubscriptionConnectionBase;
 import org.apache.plc4x.java.spi.drivers.exceptions.MessageCodecException;
@@ -93,7 +91,7 @@ public class EipTcpConnection extends 
PollingSubscriptionConnectionBase<EIPConfi
     private final NullAddressItem nullAddressItem = new NullAddressItem();
     private final List<PathSegment> routingAddress = new ArrayList<>();
     private short connectionPathSize = 0;
-    private final int connectionSerialNumber = 
ThreadLocalRandom.current().nextInt();
+    private final int connectionSerialNumber = 
ThreadLocalRandom.current().nextInt(1, 0xFFFF);
 
     public EipTcpConnection(EIPConfiguration configuration, 
TransportInstance<?> transportInstance, AuditLog auditLog) {
         this(configuration, transportInstance, auditLog, 
configuration.isBigEndian());
@@ -749,7 +747,7 @@ public class EipTcpConnection extends 
PollingSubscriptionConnectionBase<EIPConfi
     // Encoders / decoders
     
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private static byte[] toAnsi(String tag) throws BufferException {
+    private byte[] toAnsi(String tag) throws BufferException {
         Pattern resourcePattern = 
Pattern.compile("([.\\[\\]])*([A-Za-z_0-9]+)");
         Matcher matcher = resourcePattern.matcher(tag);
         List<PathSegment> segments = new LinkedList<>();
@@ -767,12 +765,7 @@ public class EipTcpConnection extends 
PollingSubscriptionConnectionBase<EIPConfi
             segments.add(newSegment);
             lengthBytes += newSegment.getLengthInBytes();
         }
-        WriteBufferByteBased buffer = new WriteBufferByteBased(new 
byte[lengthBytes],
-            WithByteBasedOption.WithByteOrder("LITTLE_ENDIAN"),
-            WithOption.WithUnsignedIntegerEncoding("unsigned-binary"),
-            WithOption.WithSignedIntegerEncoding("twos-complement"),
-            WithOption.WithFloatEncoding("IEEE754"),
-            WithOption.WithStringEncoding("UTF8"));
+        WriteBufferByteBased buffer = 
messageCodec.createWriteBuffer(lengthBytes);
         for (PathSegment segment : segments) {
             segment.serialize(buffer);
         }
@@ -795,8 +788,7 @@ public class EipTcpConnection extends 
PollingSubscriptionConnectionBase<EIPConfi
             List<CipService> arr = new ArrayList<>(nb);
             try {
                 byte[] servicesData = responses.getServicesData();
-                ReadBufferByteBased read = new 
ReadBufferByteBased(servicesData,
-                    WithByteBasedOption.WithByteOrder("LITTLE_ENDIAN"));
+                ReadBufferByteBased read = 
messageCodec.createReadBuffer(servicesData);
                 int total = servicesData.length;
                 for (int i = 0; i < nb; i++) {
                     int offset = responses.getOffsets().get(i) - 
responses.getOffsets().getFirst();
@@ -934,8 +926,7 @@ public class EipTcpConnection extends 
PollingSubscriptionConnectionBase<EIPConfi
             List<CipService> arr = new ArrayList<>(nb);
             try {
                 byte[] servicesData = resp.getServicesData();
-                ReadBufferByteBased read = new 
ReadBufferByteBased(servicesData,
-                    WithByteBasedOption.WithByteOrder("LITTLE_ENDIAN"));
+                ReadBufferByteBased read = 
messageCodec.createReadBuffer(servicesData);
                 int total = servicesData.length;
                 for (int i = 0; i < nb; i++) {
                     int offset = resp.getOffsets().get(i);

Reply via email to