You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/02/07 14:51:05 UTC

[incubator-plc4x] branch feature/Beckhoff_ADS_protocol updated: + progress on Plc4XADSProtocol

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

sruehl pushed a commit to branch feature/Beckhoff_ADS_protocol
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/feature/Beckhoff_ADS_protocol by this push:
     new d2b6709  + progress on Plc4XADSProtocol
d2b6709 is described below

commit d2b670968d3b9631d65a770f43dab80e5e531745
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Feb 7 15:51:01 2018 +0100

    + progress on Plc4XADSProtocol
---
 .../types/InvalidationNotificationHandle.java      | 26 ----------
 .../plc4x/java/ads/api/commands/types/Length.java  |  2 +-
 .../java/ads/api/commands/types/ReadLength.java    |  2 +-
 .../java/ads/api/commands/types/SampleSize.java    |  2 +-
 .../plc4x/java/ads/api/commands/types/Samples.java |  2 +-
 .../java/ads/api/commands/types/WriteLength.java   |  2 +-
 .../plc4x/java/ads/api/generic/types/AMSPort.java  |  2 +-
 .../java/ads/api/generic/types/DataLength.java     |  2 +-
 .../plc4x/java/ads/api/generic/types/Length.java   |  2 +-
 .../java/ads/connection/ADSPlcConnection.java      | 13 +----
 .../apache/plc4x/java/ads/model/ADSAddress.java    | 45 ++++++++++++++---
 .../apache/plc4x/java/ads/netty/ADSProtocol.java   |  1 +
 .../plc4x/java/ads/netty/Plc4XADSProtocol.java     | 58 +++++++++++++++++++---
 .../java/ads/api/commands/types/LengthTest.java    |  6 +--
 .../ads/api/commands/types/ReadLengthTest.java     |  6 +--
 .../ads/api/commands/types/SampleSizeTest.java     |  6 +--
 .../java/ads/api/commands/types/SamplesTest.java   |  6 +--
 .../ads/api/commands/types/WriteLengthTest.java    |  6 +--
 .../java/ads/api/generic/types/AMSPortTest.java    |  4 +-
 .../java/ads/api/generic/types/DataLengthTest.java |  6 +--
 .../java/ads/api/generic/types/LengthTest.java     |  6 +--
 .../java/ads/connection/ADSPlcConnectionTests.java | 17 +++----
 22 files changed, 132 insertions(+), 90 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/InvalidationNotificationHandle.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/InvalidationNotificationHandle.java
deleted file mode 100644
index 7c5afce..0000000
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/InvalidationNotificationHandle.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.plc4x.java.ads.api.commands.types;
-
-/**
- * Notice: If your handle becomes invalid, one notification without data will be send once as advice.
- */
-public class InvalidationNotificationHandle extends NotificationHandle {
-    public static final InvalidationNotificationHandle INSTANCE = new InvalidationNotificationHandle();
-}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
index 606f432..a68fe8d 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Length.java
@@ -52,6 +52,6 @@ public class Length extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
index bf2a06f..679e33a 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/ReadLength.java
@@ -52,6 +52,6 @@ public class ReadLength extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
index 55e1306..7f2f272 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/SampleSize.java
@@ -52,6 +52,6 @@ public class SampleSize extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
index 4ebfddb..e2d9269 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Samples.java
@@ -52,6 +52,6 @@ public class Samples extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
index 4e593c0..2ca0206 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/WriteLength.java
@@ -52,6 +52,6 @@ public class WriteLength extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
index 906a456..ee14b83 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/AMSPort.java
@@ -56,6 +56,6 @@ public class AMSPort extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 8 | getBytes()[1]);
+        return "" + (getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
index 0f56d2f..35dcac2 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/DataLength.java
@@ -52,6 +52,6 @@ public class DataLength extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
index 14da90e..28b8e47 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/types/Length.java
@@ -52,6 +52,6 @@ public class Length extends ByteValue {
 
     @Override
     public String toString() {
-        return "" + (getBytes()[0] << 24 | getBytes()[1] << 16 | getBytes()[2] << 8 | getBytes()[3]);
+        return "" + (getBytes()[3] << 24 | getBytes()[2] << 16 | getBytes()[1] << 8 | getBytes()[0]);
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java
index dde99d9..2ddb8aa 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/ADSPlcConnection.java
@@ -38,8 +38,6 @@ import org.apache.plc4x.java.api.model.Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.concurrent.CompletableFuture;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader, PlcWriter {
 
@@ -119,7 +117,7 @@ public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader
                 protected void initChannel(Channel channel) throws Exception {
                     // Build the protocol stack for communicating with the ads protocol.
                     ChannelPipeline pipeline = channel.pipeline();
-                    pipeline.addLast(new Plc4XADSProtocol());
+                    pipeline.addLast(new Plc4XADSProtocol(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort));
                     pipeline.addLast(new ADSProtocol());
                 }
             });
@@ -143,14 +141,7 @@ public class ADSPlcConnection extends AbstractPlcConnection implements PlcReader
 
     @Override
     public Address parseAddress(String addressString) throws PlcException {
-        Matcher matcher = Pattern.compile("(?<targetAmsNetId>" + AMSNetId.AMS_NET_ID_PATTERN + "):(?<targetAmsPort>" + AMSPort.AMS_PORT_PATTERN + ")").matcher(addressString);
-        if (!matcher.matches()) {
-            throw new PlcConnectionException(
-                "Address string doesn't match the format '{targetAmsNetId}:{targetAmsPort}'");
-        }
-        AMSNetId targetAmsNetId = AMSNetId.of(matcher.group("targetAmsNetId"));
-        AMSPort targetAmsPort = AMSPort.of(matcher.group("targetAmsPort"));
-        return new ADSAddress(targetAmsNetId, targetAmsPort);
+        return ADSAddress.of(addressString);
     }
 
     @Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/ADSAddress.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/ADSAddress.java
index 66bb617..b6892e3 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/ADSAddress.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/model/ADSAddress.java
@@ -18,16 +18,47 @@
  */
 package org.apache.plc4x.java.ads.model;
 
-import org.apache.plc4x.java.ads.api.generic.types.AMSNetId;
-import org.apache.plc4x.java.ads.api.generic.types.AMSPort;
+import org.apache.plc4x.java.ads.api.util.ByteValue;
 import org.apache.plc4x.java.api.model.Address;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 public class ADSAddress implements Address {
-    public final AMSNetId targetAmsNetId;
-    public final AMSPort targetAmsPort;
+    private static final Pattern RESSOURCE_ADDRESS_PATTERN = Pattern.compile("^(?<indexGroup>\\d+)/(?<indexOffset>\\d+)");
+
+    private final long indexGroup;
+
+    private final long indexOffset;
+
+    protected ADSAddress(long indexGroup, long indexOffset) {
+        ByteValue.checkUnsignedBounds(indexGroup, 4);
+        this.indexGroup = indexGroup;
+        ByteValue.checkUnsignedBounds(indexOffset, 4);
+        this.indexOffset = indexOffset;
+    }
+
+    public static ADSAddress of(long indexGroup, long indexOffset) {
+        return new ADSAddress(indexGroup, indexOffset);
+    }
+
+    public static ADSAddress of(String address) {
+        Matcher matcher = RESSOURCE_ADDRESS_PATTERN.matcher(address);
+        if (!matcher.matches()) {
+            throw new IllegalArgumentException(
+                "address " + address + " doesn't match '{indexGroup}/{indexOffset}' RAW:" + RESSOURCE_ADDRESS_PATTERN);
+        }
+        String indexGroup = matcher.group("indexGroup");
+        String indexOffset = matcher.group("indexOffset");
+
+        return new ADSAddress(Long.parseLong(indexGroup), Long.parseLong(indexOffset));
+    }
+
+    public long getIndexGroup() {
+        return indexGroup;
+    }
 
-    public ADSAddress(AMSNetId targetAmsNetId, AMSPort targetAmsPort) {
-        this.targetAmsNetId = targetAmsNetId;
-        this.targetAmsPort = targetAmsPort;
+    public long getIndexOffset() {
+        return indexOffset;
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/ADSProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/ADSProtocol.java
index a5e7227..215c80f 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/ADSProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/ADSProtocol.java
@@ -220,6 +220,7 @@ public class ADSProtocol extends MessageToMessageCodec<ByteBuf, AMSTCPPaket> {
                             if (sampleSizeLong > Integer.MAX_VALUE) {
                                 throw new IllegalStateException("Overflow in datalength: " + sampleSizeLong);
                             }
+                            // TODO: do we need a special marker class for: Notice: If your handle becomes invalid, one notification without data will be send once as advice.
                             Data data = Data.of(adsDeviceNotificationBuffer.readBytes((int) sampleSizeLong).array());
                             AdsNotificationSample adsNotificationSample = AdsNotificationSample.of(notificationHandle, sampleSize, data);
                             adsNotificationSamples.add(adsNotificationSample);
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocol.java
index 5172909..daa93d2 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/netty/Plc4XADSProtocol.java
@@ -18,10 +18,19 @@ under the License.
 */
 package org.apache.plc4x.java.ads.netty;
 
-import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToMessageCodec;
+import org.apache.plc4x.java.ads.api.commands.ADSReadRequest;
+import org.apache.plc4x.java.ads.api.commands.ADSWriteRequest;
+import org.apache.plc4x.java.ads.api.commands.types.Data;
+import org.apache.plc4x.java.ads.api.commands.types.IndexGroup;
+import org.apache.plc4x.java.ads.api.commands.types.IndexOffset;
+import org.apache.plc4x.java.ads.api.commands.types.Length;
 import org.apache.plc4x.java.ads.api.generic.AMSTCPPaket;
+import org.apache.plc4x.java.ads.api.generic.types.AMSNetId;
+import org.apache.plc4x.java.ads.api.generic.types.AMSPort;
+import org.apache.plc4x.java.ads.api.generic.types.Invoke;
+import org.apache.plc4x.java.ads.model.ADSAddress;
 import org.apache.plc4x.java.api.exceptions.PlcException;
 import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
 import org.apache.plc4x.java.api.messages.PlcReadRequest;
@@ -30,6 +39,7 @@ import org.apache.plc4x.java.api.messages.PlcRequestContainer;
 import org.apache.plc4x.java.api.messages.PlcWriteRequest;
 import org.apache.plc4x.java.api.messages.items.ReadRequestItem;
 import org.apache.plc4x.java.api.messages.items.WriteRequestItem;
+import org.apache.plc4x.java.api.model.Address;
 
 import java.util.HashMap;
 import java.util.List;
@@ -42,7 +52,16 @@ public class Plc4XADSProtocol extends MessageToMessageCodec<AMSTCPPaket, PlcRequ
 
     private Map<Short, PlcRequestContainer> requests;
 
-    public Plc4XADSProtocol() {
+    private final AMSNetId targetAmsNetId;
+    private final AMSPort targetAmsPort;
+    private final AMSNetId sourceAmsNetId;
+    private final AMSPort sourceAmsPort;
+
+    public Plc4XADSProtocol(AMSNetId targetAmsNetId, AMSPort targetAmsPort, AMSNetId sourceAmsNetId, AMSPort sourceAmsPort) {
+        this.targetAmsNetId = targetAmsNetId;
+        this.targetAmsPort = targetAmsPort;
+        this.sourceAmsNetId = sourceAmsNetId;
+        this.sourceAmsPort = sourceAmsPort;
         this.requests = new HashMap<>();
     }
 
@@ -58,7 +77,7 @@ public class Plc4XADSProtocol extends MessageToMessageCodec<AMSTCPPaket, PlcRequ
 
     @Override
     protected void decode(ChannelHandlerContext channelHandlerContext, AMSTCPPaket amstcpPaket, List<Object> out) throws Exception {
-
+        // TODO: implement me
     }
 
     private void encodeWriteRequest(PlcRequestContainer msg, List<Object> out) throws PlcException {
@@ -67,8 +86,22 @@ public class Plc4XADSProtocol extends MessageToMessageCodec<AMSTCPPaket, PlcRequ
             throw new PlcProtocolException("Only one item supported");
         }
         WriteRequestItem<?> writeRequestItem = writeRequest.getRequestItems().get(0);
-
-        out.add(Unpooled.buffer());
+        Address address = writeRequestItem.getAddress();
+        if (!(address instanceof ADSAddress)) {
+            throw new PlcProtocolException("Address not of type ADSAddress: " + address.getClass());
+        }
+        ADSAddress adsAddress = (ADSAddress) address;
+        // TODO: we need a long parser her
+        Invoke invokeId = Invoke.of((byte) correlationBuilder.incrementAndGet());
+        // TODO: we need a long parser her
+        IndexGroup indexGroup = IndexGroup.of((byte) adsAddress.getIndexGroup());
+        // TODO: we need a long parser her
+        IndexOffset indexOffset = IndexOffset.of((byte) adsAddress.getIndexOffset());
+        // TODO: how to get length and data. Serialization of plc is the problem here
+        Length length = Length.of(1);
+        Data data = Data.of(new byte[]{0x42});
+        AMSTCPPaket amstcpPaket = new ADSWriteRequest(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, indexGroup, indexOffset, length, data);
+        out.add(amstcpPaket);
     }
 
     private void encodeReadRequest(PlcRequestContainer msg, List<Object> out) throws PlcException {
@@ -78,7 +111,20 @@ public class Plc4XADSProtocol extends MessageToMessageCodec<AMSTCPPaket, PlcRequ
             throw new PlcProtocolException("Only one item supported");
         }
         ReadRequestItem<?> readRequestItem = readRequest.getRequestItems().get(0);
-        out.add(Unpooled.buffer());
+        Address address = readRequestItem.getAddress();
+        if (!(address instanceof ADSAddress)) {
+            throw new PlcProtocolException("Address not of type ADSAddress: " + address.getClass());
+        }
+        ADSAddress adsAddress = (ADSAddress) address;
+        // TODO: we need a long parser her
+        Invoke invokeId = Invoke.of((byte) correlationBuilder.incrementAndGet());
+        // TODO: we need a long parser her
+        IndexGroup indexGroup = IndexGroup.of((byte) adsAddress.getIndexGroup());
+        // TODO: we need a long parser her
+        IndexOffset indexOffset = IndexOffset.of((byte) adsAddress.getIndexOffset());
+        Length length = Length.of(readRequestItem.getSize());
+        AMSTCPPaket amstcpPaket = new ADSReadRequest(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId, indexGroup, indexOffset, length);
+        out.add(amstcpPaket);
     }
 
 }
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/LengthTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/LengthTest.java
index fe08e9a..c44cad4 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/LengthTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/LengthTest.java
@@ -34,15 +34,15 @@ class LengthTest {
 
     @Test
     void ofLong() {
-        assertByte(Length.of(1), "0x00000001");
-        assertByte(Length.of(65535), "0x0000ffff");
+        assertByte(Length.of(1), "0x01000000");
+        assertByte(Length.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> Length.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> Length.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(Length.of("1"), "0x00000001");
+        assertByte(Length.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/ReadLengthTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/ReadLengthTest.java
index d6693e9..a1a2442 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/ReadLengthTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/ReadLengthTest.java
@@ -33,15 +33,15 @@ class ReadLengthTest {
 
     @Test
     void ofLong() {
-        assertByte(ReadLength.of(1), "0x00000001");
-        assertByte(ReadLength.of(65535), "0x0000ffff");
+        assertByte(ReadLength.of(1), "0x01000000");
+        assertByte(ReadLength.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> ReadLength.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> ReadLength.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(ReadLength.of("1"), "0x00000001");
+        assertByte(ReadLength.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SampleSizeTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SampleSizeTest.java
index 1f7bcee..a80a28a 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SampleSizeTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SampleSizeTest.java
@@ -34,15 +34,15 @@ class SampleSizeTest {
 
     @Test
     void ofLong() {
-        assertByte(SampleSize.of(1), "0x00000001");
-        assertByte(SampleSize.of(65535), "0x0000ffff");
+        assertByte(SampleSize.of(1), "0x01000000");
+        assertByte(SampleSize.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> SampleSize.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> SampleSize.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(SampleSize.of("1"), "0x00000001");
+        assertByte(SampleSize.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SamplesTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SamplesTest.java
index 04579b7..49ef8d2 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SamplesTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/SamplesTest.java
@@ -34,15 +34,15 @@ class SamplesTest {
 
     @Test
     void ofLong() {
-        assertByte(Samples.of(1), "0x00000001");
-        assertByte(Samples.of(65535), "0x0000ffff");
+        assertByte(Samples.of(1), "0x01000000");
+        assertByte(Samples.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> Samples.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> Samples.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(Samples.of("1"), "0x00000001");
+        assertByte(Samples.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/WriteLengthTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/WriteLengthTest.java
index 9f78ff8..d6780e2 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/WriteLengthTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/commands/types/WriteLengthTest.java
@@ -34,15 +34,15 @@ class WriteLengthTest {
 
     @Test
     void ofLong() {
-        assertByte(WriteLength.of(1), "0x00000001");
-        assertByte(WriteLength.of(65535), "0x0000ffff");
+        assertByte(WriteLength.of(1), "0x01000000");
+        assertByte(WriteLength.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> WriteLength.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> WriteLength.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(WriteLength.of("1"), "0x00000001");
+        assertByte(WriteLength.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/AMSPortTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/AMSPortTest.java
index 7cf79b8..1845349 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/AMSPortTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/AMSPortTest.java
@@ -34,7 +34,7 @@ class AMSPortTest {
 
     @Test
     void ofInt() {
-        assertByte(AMSPort.of(1), "0x0001");
+        assertByte(AMSPort.of(1), "0x0100");
         assertByte(AMSPort.of(65535), "0xffff");
         Assertions.assertThrows(IllegalArgumentException.class, () -> AMSPort.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> AMSPort.of(65536));
@@ -42,7 +42,7 @@ class AMSPortTest {
 
     @Test
     void ofString() {
-        assertByte(AMSPort.of("1"), "0x0001");
+        assertByte(AMSPort.of("1"), "0x0100");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/DataLengthTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/DataLengthTest.java
index e45cfc5..aafab4a 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/DataLengthTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/DataLengthTest.java
@@ -35,15 +35,15 @@ class DataLengthTest {
 
     @Test
     void ofLong() {
-        assertByte(DataLength.of(1), "0x00000001");
-        assertByte(DataLength.of(65535), "0x0000ffff");
+        assertByte(DataLength.of(1), "0x01000000");
+        assertByte(DataLength.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> DataLength.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> DataLength.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(DataLength.of("1"), "0x00000001");
+        assertByte(DataLength.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/LengthTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/LengthTest.java
index b4fa27e..97dab3f 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/LengthTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/api/generic/types/LengthTest.java
@@ -34,15 +34,15 @@ class LengthTest {
 
     @Test
     void ofLong() {
-        assertByte(Length.of(1), "0x00000001");
-        assertByte(Length.of(65535), "0x0000ffff");
+        assertByte(Length.of(1), "0x01000000");
+        assertByte(Length.of(65535), "0xffff0000");
         Assertions.assertThrows(IllegalArgumentException.class, () -> Length.of(-1));
         Assertions.assertThrows(IllegalArgumentException.class, () -> Length.of(4294967296L));
     }
 
     @Test
     void ofString() {
-        assertByte(Length.of("1"), "0x00000001");
+        assertByte(Length.of("1"), "0x01000000");
     }
 
     @Test
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/ADSPlcConnectionTests.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/ADSPlcConnectionTests.java
index 8bb0d73..78d2813 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/ADSPlcConnectionTests.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/connection/ADSPlcConnectionTests.java
@@ -22,7 +22,6 @@ package org.apache.plc4x.java.ads.connection;
 import org.apache.plc4x.java.ads.api.generic.types.AMSNetId;
 import org.apache.plc4x.java.ads.api.generic.types.AMSPort;
 import org.apache.plc4x.java.ads.model.ADSAddress;
-import org.apache.plc4x.java.api.exceptions.PlcException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -51,21 +50,21 @@ class ADSPlcConnectionTests {
     }
 
     @Test
-    void emptyParseAddress() {
+    void emptyParseAddress() throws Exception {
         try {
             adsPlcConnection.parseAddress("");
-        } catch (PlcException exception) {
-            assertTrue(exception.getMessage().startsWith("Address string doesn't match"), "Unexpected exception");
+        } catch (IllegalArgumentException exception) {
+            assertTrue(exception.getMessage().startsWith("address  doesn't match "), "Unexpected exception");
         }
     }
 
     @Test
-    void parseAddress() {
+    void parseAddress() throws Exception {
         try {
-            ADSAddress address = (ADSAddress) adsPlcConnection.parseAddress("0.0.0.0.0.0:13");
-            assertEquals(address.targetAmsNetId.toString(), "0.0.0.0.0.0");
-            assertEquals(address.targetAmsPort.toString(), "13");
-        } catch (PlcException exception) {
+            ADSAddress address = (ADSAddress) adsPlcConnection.parseAddress("1/1");
+            assertEquals(address.getIndexGroup(), 1);
+            assertEquals(address.getIndexOffset(), 1);
+        } catch (IllegalArgumentException exception) {
             fail("valid data block address");
         }
     }

-- 
To stop receiving notification emails like this one, please contact
sruehl@apache.org.