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/03/15 11:55:18 UTC

[incubator-plc4x] branch master updated (933adbe -> b4c71ec)

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

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


    from 933adbe  fixed digest calculation due to short overflow
     new 7450252  simplified ADS Return code enum
     new bffaebe  suppress unused warnings for static defined constants
     new 9799a98  simplified AMSTcpPacket
     new b4c71ec  introduced new protocol layer ads2payload and removed dependency from serial to tcp

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/ads/api/commands/types/AdsReturnCode.java | 229 +++++++++++----------
 .../plc4x/java/ads/api/commands/types/Data.java    |   9 +
 .../java/ads/api/commands/types/IndexGroup.java    |   1 +
 .../java/ads/api/commands/types/IndexOffset.java   |   1 +
 .../plc4x/java/ads/api/generic/AmsPacket.java      |  11 -
 .../plc4x/java/ads/api/generic/types/AmsPort.java  |   1 +
 .../plc4x/java/ads/api/serial/AmsSerialFrame.java  |  20 +-
 .../plc4x/java/ads/api/serial/types/UserData.java  |   9 +
 .../plc4x/java/ads/api/tcp/AmsTCPPacket.java       |  50 ++---
 .../ads/api/{serial => tcp}/types/UserData.java    |  11 +-
 .../apache/plc4x/java/ads/api/util/ByteValue.java  |  12 +-
 .../ads/connection/AdsSerialPlcConnection.java     |   6 +-
 .../java/ads/connection/AdsTcpPlcConnection.java   |   6 +-
 ...s2TcpProtocol.java => Ads2PayloadProtocol.java} |  29 +--
 ...alProtocol.java => Payload2SerialProtocol.java} |  46 +----
 .../java/ads/protocol/Payload2TcpProtocol.java     |  58 ++++++
 ...ProtocolTest.java => AbstractProtocolTest.java} |  77 +------
 .../java/ads/protocol/Ads2PayloadProtocolTest.java |  99 +++++++++
 .../java/ads/protocol/Ads2TcpProtocolTest.java     | 203 ------------------
 .../ads/protocol/Payload2SerialProtocolTest.java   | 105 ++++++++++
 .../java/ads/protocol/Payload2TcpProtocolTest.java | 104 ++++++++++
 ...rotocolTest.java => Plc4x2AdsProtocolTest.java} |   4 +-
 22 files changed, 574 insertions(+), 517 deletions(-)
 copy plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/{serial => tcp}/types/UserData.java (86%)
 rename plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/{Ads2TcpProtocol.java => Ads2PayloadProtocol.java} (94%)
 rename plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/{Ads2SerialProtocol.java => Payload2SerialProtocol.java} (69%)
 create mode 100644 plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocol.java
 rename plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/{Ads2SerialProtocolTest.java => AbstractProtocolTest.java} (67%)
 create mode 100644 plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocolTest.java
 delete mode 100644 plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocolTest.java
 create mode 100644 plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocolTest.java
 create mode 100644 plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocolTest.java
 rename plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/{Plc4X2Ads2TcpProtocolTest.java => Plc4x2AdsProtocolTest.java} (99%)

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

[incubator-plc4x] 03/04: simplified AMSTcpPacket

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9799a98d13decfe82e4f0b09a209365444c8a241
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 12:05:29 2018 +0100

    simplified AMSTcpPacket
---
 .../java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java  | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
index 243852e..43512cf 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
@@ -19,7 +19,6 @@
 package org.apache.plc4x.java.ads.api.tcp;
 
 import io.netty.buffer.ByteBuf;
-import org.apache.plc4x.java.ads.api.generic.AdsData;
 import org.apache.plc4x.java.ads.api.generic.AmsHeader;
 import org.apache.plc4x.java.ads.api.generic.AmsPacket;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
@@ -33,14 +32,14 @@ public class AmsTCPPacket implements ByteReadable {
 
     private AmsTCPPacket(AmsTcpHeader amsTcpHeader, AmsPacket amsPacket) {
         this.amsTcpHeader = requireNonNull(amsTcpHeader);
-        this.amsPacket = amsPacket;
+        this.amsPacket = requireNonNull(amsPacket);
     }
 
     private AmsTCPPacket(AmsPacket amsPacket) {
-        this.amsPacket = amsPacket;
+        this.amsPacket = requireNonNull(amsPacket);
         // It is important that we wrap the ads data call as this will initialized in the constructor
         // so this value will be null if we call adsData now.
-        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(amsPacket.getAmsHeader()), () -> getAdsData().getCalculatedLength());
+        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(amsPacket.getAmsHeader()), amsPacket);
     }
 
     public AmsTcpHeader getAmsTcpHeader() {
@@ -55,10 +54,6 @@ public class AmsTCPPacket implements ByteReadable {
         return amsPacket.getAmsHeader();
     }
 
-    public AdsData getAdsData() {
-        return amsPacket.getAdsData();
-    }
-
     @Override
     public ByteBuf getByteBuf() {
         return buildByteBuff(amsTcpHeader, amsPacket);

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

[incubator-plc4x] 01/04: simplified ADS Return code enum

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7450252e9550283a981dc6dee40014c523c20462
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 11:55:29 2018 +0100

    simplified ADS Return code enum
---
 .../java/ads/api/commands/types/AdsReturnCode.java | 229 +++++++++++----------
 1 file changed, 118 insertions(+), 111 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsReturnCode.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsReturnCode.java
index 0040628..fa6cbaf 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsReturnCode.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsReturnCode.java
@@ -24,142 +24,141 @@ import static java.util.Objects.requireNonNull;
 /**
  * Based on spec from: https://infosys.beckhoff.com/content/1033/tcadscommon/html/ads_returncodes.htm
  */
-// TODO: give the codes useful names
 // Error codes: 0x000..., 0x500..., 0x700..., 0x1000..., 0x274C...
 public enum AdsReturnCode {
     // Global Error Codes
-    ADS_CODE_0(0x0, 0, "no error", "", ""),
-    ADS_CODE_1(0x1, 1, "Internal error", "", ""),
-    ADS_CODE_2(0x2, 2, "No Rtime", "", ""),
-    ADS_CODE_3(0x3, 3, "Allocation locked memory error", "", ""),
+    ADS_CODE_0(0x0, 0, "no error"),
+    ADS_CODE_1(0x1, 1, "Internal error"),
+    ADS_CODE_2(0x2, 2, "No Rtime"),
+    ADS_CODE_3(0x3, 3, "Allocation locked memory error"),
     ADS_CODE_4(0x4, 4, "Insert mailbox error", "No ADS mailbox was available to process this message.", "Reduce the number of ADS calls (e.g ADS-Sum commands or Max Delay Parameter)"),
-    ADS_CODE_5(0x5, 5, "Wrong receive HMSG", "", ""),
-    ADS_CODE_6(0x6, 6, "target port not foundADS ", "Server not started", ""),
-    ADS_CODE_7(0x7, 7, "target machine not found", "Missing ADS routes", ""),
-    ADS_CODE_8(0x8, 8, "Unknown command ID", "", ""),
-    ADS_CODE_9(0x9, 9, "Bad task ID", "", ""),
-    ADS_CODE_10(0xA, 10, "No IO", "", ""),
-    ADS_CODE_11(0xB, 11, "Unknown ADS command", "", ""),
-    ADS_CODE_12(0xC, 12, "Win 32 error", "", ""),
-    ADS_CODE_13(0xD, 13, "Port not connected", "", ""),
-    ADS_CODE_14(0xE, 14, "Invalid ADS length", "", ""),
-    ADS_CODE_15(0xF, 15, "Invalid ADS Net ID", "", ""),
-    ADS_CODE_16(0x10, 16, "Low Installation level", "", ""),
-    ADS_CODE_17(0x11, 17, "No debug available", "", ""),
-    ADS_CODE_18(0x12, 18, "Port disabled", "", ""),
-    ADS_CODE_19(0x13, 19, "Port already connected", "", ""),
-    ADS_CODE_20(0x14, 20, "ADS Sync Win32 error", "", ""),
-    ADS_CODE_21(0x15, 21, "ADS Sync Timeout", "", ""),
-    ADS_CODE_22(0x16, 22, "ADS Sync AMS error", "", ""),
-    ADS_CODE_23(0x17, 23, "ADS Sync no index map", "", ""),
-    ADS_CODE_24(0x18, 24, "Invalid ADS port", "", ""),
-    ADS_CODE_25(0x19, 25, "No memory", "", ""),
-    ADS_CODE_26(0x1A, 26, "TCP send error", "", ""),
-    ADS_CODE_27(0x1B, 27, "Host unreachable", "", ""),
-    ADS_CODE_28(0x1C, 28, "Invalid AMS fragment", "", ""),
+    ADS_CODE_5(0x5, 5, "Wrong receive HMSG"),
+    ADS_CODE_6(0x6, 6, "target port not foundADS ", "Server not started"),
+    ADS_CODE_7(0x7, 7, "target machine not found", "Missing ADS routes"),
+    ADS_CODE_8(0x8, 8, "Unknown command ID"),
+    ADS_CODE_9(0x9, 9, "Bad task ID"),
+    ADS_CODE_10(0xA, 10, "No IO"),
+    ADS_CODE_11(0xB, 11, "Unknown ADS command"),
+    ADS_CODE_12(0xC, 12, "Win 32 error"),
+    ADS_CODE_13(0xD, 13, "Port not connected"),
+    ADS_CODE_14(0xE, 14, "Invalid ADS length"),
+    ADS_CODE_15(0xF, 15, "Invalid ADS Net ID"),
+    ADS_CODE_16(0x10, 16, "Low Installation level"),
+    ADS_CODE_17(0x11, 17, "No debug available"),
+    ADS_CODE_18(0x12, 18, "Port disabled"),
+    ADS_CODE_19(0x13, 19, "Port already connected"),
+    ADS_CODE_20(0x14, 20, "ADS Sync Win32 error"),
+    ADS_CODE_21(0x15, 21, "ADS Sync Timeout"),
+    ADS_CODE_22(0x16, 22, "ADS Sync AMS error"),
+    ADS_CODE_23(0x17, 23, "ADS Sync no index map"),
+    ADS_CODE_24(0x18, 24, "Invalid ADS port"),
+    ADS_CODE_25(0x19, 25, "No memory"),
+    ADS_CODE_26(0x1A, 26, "TCP send error"),
+    ADS_CODE_27(0x1B, 27, "Host unreachable"),
+    ADS_CODE_28(0x1C, 28, "Invalid AMS fragment"),
 
 
     // Router Error Codes
-    ADS_CODE_1280(0x500, 1280, "ROUTERERR_NOLOCKEDMEMORY", "No locked memory can be allocated", ""),
-    ADS_CODE_1281(0x501, 1281, "ROUTERERR_RESIZEMEMORY", "The size of the  router memory could not be changed", ""),
+    ADS_CODE_1280(0x500, 1280, "ROUTERERR_NOLOCKEDMEMORY", "No locked memory can be allocated"),
+    ADS_CODE_1281(0x501, 1281, "ROUTERERR_RESIZEMEMORY", "The size of the  router memory could not be changed"),
     ADS_CODE_1282(0x502, 1282, "ROUTERERR_MAILBOXFULL", "The mailbox has reached the maximum number of possible messages. The current sent message was rejected", "Check the connection between the communication partners"),
     ADS_CODE_1283(0x503, 1283, "ROUTERERR_DEBUGBOXFULL ", "The mailbox has reached the maximum number of possible messages.The sent message will not be displayed in the debug monitor", "Check the connection to the debug monitor"),
-    ADS_CODE_1284(0x504, 1284, "ROUTERERR_UNKNOWNPORTTYPE ", "The port type is unknown", ""),
-    ADS_CODE_1285(0x505, 1285, "ROUTERERR_NOTINITIALIZED", "Router is not initialised", ""),
-    ADS_CODE_1286(0x506, 1286, "ROUTERERR_PORTALREADYINUSE ", "The desired port number is already assigned", ""),
-    ADS_CODE_1287(0x507, 1287, "ROUTERERR_NOTREGISTERED ", "Port not registered", ""),
-    ADS_CODE_1288(0x508, 1288, "ROUTERERR_NOMOREQUEUES", "The maximum number of Ports reached", ""),
-    ADS_CODE_1289(0x509, 1289, "ROUTERERR_INVALIDPORT ", "The port is invalid.", ""),
-    ADS_CODE_1290(0x50A, 1290, "ROUTERERR_NOTACTIVATED ", "TwinCAT Router not active", ""),
-    ADS_CODE_1291(0x50B, 1291, "ROUTERERR_FRAGMENTBOXFULL", "", ""),
-    ADS_CODE_1292(0x50C, 1292, "ROUTERERR_FRAGMENTTIMEOUT", "", ""),
-    ADS_CODE_1293(0x50D, 1293, "ROUTERERR_TOBEREMOVED", "", ""),
+    ADS_CODE_1284(0x504, 1284, "ROUTERERR_UNKNOWNPORTTYPE ", "The port type is unknown"),
+    ADS_CODE_1285(0x505, 1285, "ROUTERERR_NOTINITIALIZED", "Router is not initialised"),
+    ADS_CODE_1286(0x506, 1286, "ROUTERERR_PORTALREADYINUSE ", "The desired port number is already assigned"),
+    ADS_CODE_1287(0x507, 1287, "ROUTERERR_NOTREGISTERED ", "Port not registered"),
+    ADS_CODE_1288(0x508, 1288, "ROUTERERR_NOMOREQUEUES", "The maximum number of Ports reached"),
+    ADS_CODE_1289(0x509, 1289, "ROUTERERR_INVALIDPORT ", "The port is invalid."),
+    ADS_CODE_1290(0x50A, 1290, "ROUTERERR_NOTACTIVATED ", "TwinCAT Router not active"),
+    ADS_CODE_1291(0x50B, 1291, "ROUTERERR_FRAGMENTBOXFULL"),
+    ADS_CODE_1292(0x50C, 1292, "ROUTERERR_FRAGMENTTIMEOUT"),
+    ADS_CODE_1293(0x50D, 1293, "ROUTERERR_TOBEREMOVED"),
 
 
     // General ADS Error Codes
-    ADS_CODE_1792(0x700, 1792, "error class <device error>", "", ""),
-    ADS_CODE_1793(0x701, 1793, "Service is not supported by server", "", ""),
-    ADS_CODE_1794(0x702, 1794, "invalid index group", "", ""),
-    ADS_CODE_1795(0x703, 1795, "invalid index offset", "", ""),
-    ADS_CODE_1796(0x704, 1796, "reading/writing not permitted", "", ""),
-    ADS_CODE_1797(0x705, 1797, "parameter size not correct", "", ""),
-    ADS_CODE_1798(0x706, 1798, "invalid parameter value(s)", "", ""),
-    ADS_CODE_1799(0x707, 1799, "device is not in a ready state", "", ""),
-    ADS_CODE_1800(0x708, 1800, "device is busy", "", ""),
-    ADS_CODE_1801(0x709, 1801, "invalid context (must be in Windows)", "", ""),
-    ADS_CODE_1802(0x70A, 1802, "out of memory", "", ""),
-    ADS_CODE_1803(0x70B, 1803, "invalid parameter value(s)", "", ""),
-    ADS_CODE_1804(0x70C, 1804, "not found (files, ...)", "", ""),
-    ADS_CODE_1805(0x70D, 1805, "syntax error in command or file", "", ""),
-    ADS_CODE_1806(0x70E, 1806, "objects do not match", "", ""),
-    ADS_CODE_1807(0x70F, 1807, "object already exists", "", ""),
-    ADS_CODE_1808(0x710, 1808, "symbol not found", "", ""),
+    ADS_CODE_1792(0x700, 1792, "error class <device error>"),
+    ADS_CODE_1793(0x701, 1793, "Service is not supported by server"),
+    ADS_CODE_1794(0x702, 1794, "invalid index group"),
+    ADS_CODE_1795(0x703, 1795, "invalid index offset"),
+    ADS_CODE_1796(0x704, 1796, "reading/writing not permitted"),
+    ADS_CODE_1797(0x705, 1797, "parameter size not correct"),
+    ADS_CODE_1798(0x706, 1798, "invalid parameter value(s)"),
+    ADS_CODE_1799(0x707, 1799, "device is not in a ready state"),
+    ADS_CODE_1800(0x708, 1800, "device is busy"),
+    ADS_CODE_1801(0x709, 1801, "invalid context (must be in Windows)"),
+    ADS_CODE_1802(0x70A, 1802, "out of memory"),
+    ADS_CODE_1803(0x70B, 1803, "invalid parameter value(s)"),
+    ADS_CODE_1804(0x70C, 1804, "not found (files, ...)"),
+    ADS_CODE_1805(0x70D, 1805, "syntax error in command or file"),
+    ADS_CODE_1806(0x70E, 1806, "objects do not match"),
+    ADS_CODE_1807(0x70F, 1807, "object already exists"),
+    ADS_CODE_1808(0x710, 1808, "symbol not found"),
     ADS_CODE_1809(0x711, 1809, "symbol version invalid", "Onlinechange", "Release handle and get a new one"),
-    ADS_CODE_1810(0x712, 1810, "server is in invalid state", "", ""),
-    ADS_CODE_1811(0x713, 1811, "AdsTransMode not supported", "", ""),
+    ADS_CODE_1810(0x712, 1810, "server is in invalid state"),
+    ADS_CODE_1811(0x713, 1811, "AdsTransMode not supported"),
     ADS_CODE_1812(0x714, 1812, "Notification handle is invalid", "Onlinechange", "Release handle and get a new one"),
-    ADS_CODE_1813(0x715, 1813, "Notification client not registered", "", ""),
-    ADS_CODE_1814(0x716, 1814, "no more notification handles", "", ""),
-    ADS_CODE_1815(0x717, 1815, "size for watch too big", "", ""),
-    ADS_CODE_1816(0x718, 1816, "device not initialized", "", ""),
-    ADS_CODE_1817(0x719, 1817, "device has a timeout", "", ""),
-    ADS_CODE_1818(0x71A, 1818, "query interface failed", "", ""),
-    ADS_CODE_1819(0x71B, 1819, "wrong interface required", "", ""),
-    ADS_CODE_1820(0x71C, 1820, "class ID is invalid", "", ""),
-    ADS_CODE_1821(0x71D, 1821, "object ID is invalid", "", ""),
-    ADS_CODE_1822(0x71E, 1822, "request is pending", "", ""),
-    ADS_CODE_1823(0x71F, 1823, "request is aborted", "", ""),
-    ADS_CODE_1824(0x720, 1824, "signal warning", "", ""),
-    ADS_CODE_1825(0x721, 1825, "invalid array index", "", ""),
+    ADS_CODE_1813(0x715, 1813, "Notification client not registered"),
+    ADS_CODE_1814(0x716, 1814, "no more notification handles"),
+    ADS_CODE_1815(0x717, 1815, "size for watch too big"),
+    ADS_CODE_1816(0x718, 1816, "device not initialized"),
+    ADS_CODE_1817(0x719, 1817, "device has a timeout"),
+    ADS_CODE_1818(0x71A, 1818, "query interface failed"),
+    ADS_CODE_1819(0x71B, 1819, "wrong interface required"),
+    ADS_CODE_1820(0x71C, 1820, "class ID is invalid"),
+    ADS_CODE_1821(0x71D, 1821, "object ID is invalid"),
+    ADS_CODE_1822(0x71E, 1822, "request is pending"),
+    ADS_CODE_1823(0x71F, 1823, "request is aborted"),
+    ADS_CODE_1824(0x720, 1824, "signal warning"),
+    ADS_CODE_1825(0x721, 1825, "invalid array index"),
     ADS_CODE_1826(0x722, 1826, "symbol not active", "Onlinechange", "Release handle and get a new one"),
-    ADS_CODE_1827(0x723, 1827, "access denied", "", ""),
+    ADS_CODE_1827(0x723, 1827, "access denied"),
     ADS_CODE_1828(0x724, 1828, "missing license ", "", "Activate license for TwinCAT 3 function"),
     ADS_CODE_1836(0x72c, 1836, "exception occured during system start", "", "Check each device transistions"),
-    ADS_CODE_1856(0x740, 1856, "Error class <client error>", "", ""),
-    ADS_CODE_1857(0x741, 1857, "invalid parameter at service", "", ""),
-    ADS_CODE_1858(0x742, 1858, "polling list is empty", "", ""),
-    ADS_CODE_1859(0x743, 1859, "var connection already in use", "", ""),
-    ADS_CODE_1860(0x744, 1860, "invoke ID in use", "", ""),
-    ADS_CODE_1861(0x745, 1861, "timeout elapsedCheck ADS routes of sender and receiver and your  firewall setting", "", ""),
-    ADS_CODE_1862(0x746, 1862, "error in win32 subsystem", "", ""),
-    ADS_CODE_1863(0x747, 1863, "Invalid client timeout value", "", ""),
-    ADS_CODE_1864(0x748, 1864, "ads-port not opened", "", ""),
-    ADS_CODE_1872(0x750, 1872, "internal error in ads sync", "", ""),
-    ADS_CODE_1873(0x751, 1873, "hash table overflow", "", ""),
-    ADS_CODE_1874(0x752, 1874, "key not found in hash", "", ""),
-    ADS_CODE_1875(0x753, 1875, "no more symbols in cache", "", ""),
-    ADS_CODE_1876(0x754, 1876, "invalid response received", "", ""),
-    ADS_CODE_1877(0x755, 1877, "sync port is locked", "", ""),
+    ADS_CODE_1856(0x740, 1856, "Error class <client error>"),
+    ADS_CODE_1857(0x741, 1857, "invalid parameter at service"),
+    ADS_CODE_1858(0x742, 1858, "polling list is empty"),
+    ADS_CODE_1859(0x743, 1859, "var connection already in use"),
+    ADS_CODE_1860(0x744, 1860, "invoke ID in use"),
+    ADS_CODE_1861(0x745, 1861, "timeout elapsedCheck ADS routes of sender and receiver and your  firewall setting"),
+    ADS_CODE_1862(0x746, 1862, "error in win32 subsystem"),
+    ADS_CODE_1863(0x747, 1863, "Invalid client timeout value"),
+    ADS_CODE_1864(0x748, 1864, "ads-port not opened"),
+    ADS_CODE_1872(0x750, 1872, "internal error in ads sync"),
+    ADS_CODE_1873(0x751, 1873, "hash table overflow"),
+    ADS_CODE_1874(0x752, 1874, "key not found in hash"),
+    ADS_CODE_1875(0x753, 1875, "no more symbols in cache"),
+    ADS_CODE_1876(0x754, 1876, "invalid response received"),
+    ADS_CODE_1877(0x755, 1877, "sync port is locked"),
 
 
     // RTime Error Codes
-    ADS_CODE_4096(0x1000, 4096, "RTERR_INTERNAL ", "Internal fatal error in the TwinCAT real-time system", ""),
-    ADS_CODE_4097(0x1001, 4097, "RTERR_BADTIMERPERIODS", "Timer value not vaild", ""),
-    ADS_CODE_4098(0x1002, 4098, "RTERR_INVALIDTASKPTR", "Task pointer has the invalid value ZERO", ""),
-    ADS_CODE_4099(0x1003, 4099, "RTERR_INVALIDSTACKPTR", "Task stack pointer has the invalid value ZERO", ""),
-    ADS_CODE_4100(0x1004, 4100, "RTERR_PRIOEXISTS", "The demand task priority is already assigned", ""),
-    ADS_CODE_4101(0x1005, 4101, "RTERR_NOMORETCB", "No more free TCB (Task Control Block) available. Maximum number of TCBs is 64", ""),
-    ADS_CODE_4102(0x1006, 4102, "RTERR_NOMORESEMAS", "No more free semaphores available. Maximum number of semaphores is 64", ""),
-    ADS_CODE_4103(0x1007, 4103, "RTERR_NOMOREQUEUES", "No more free queue available. Maximum number of queue is 64", ""),
-    ADS_CODE_4104(0x1008, 4104, "TwinCAT ", "reserved.", ""),
-    ADS_CODE_4105(0x1009, 4105, "TwinCAT ", "reserved.", ""),
-    ADS_CODE_4106(0x100A, 4106, "TwinCAT ", "reserved.", ""),
-    ADS_CODE_4107(0x100B, 4107, "TwinCAT ", "reserved.", ""),
-    ADS_CODE_4108(0x100C, 4108, "TwinCAT ", "reserved.", ""),
-    ADS_CODE_4109(0x100D, 4109, "RTERR_EXTIRQALREADYDEF", "An external synchronisation interrupt is already applied", ""),
-    ADS_CODE_4110(0x100E, 4110, "RTERR_EXTIRQNOTDEF", "No external synchronsiation interrupt applied", ""),
-    ADS_CODE_4111(0x100F, 4111, "RTERR_EXTIRQINSTALLFAILED", "The apply of the external synchronisation interrupt failed", ""),
-    ADS_CODE_4112(0x1010, 4112, "RTERR_IRQLNOTLESSOREQUAL", "Call of a service function in the wrong context", ""),
-    ADS_CODE_4119(0x1017, 4119, "RTERR_VMXNOTSUPPORTED", "Intel VT-x extension is not supported.", ""),
-    ADS_CODE_4120(0x1018, 4120, "RTERR_VMXDISABLED", "Intel VT-x extension is not enabled in BIOS.", ""),
-    ADS_CODE_4121(0x1019, 4121, "RTERR_VMXCONTROLSMISSING", "Missing feature in Intel VT-x extension.", ""),
-    ADS_CODE_4122(0x101A, 4122, "RTERR_VMXENABLEFAILS", "Enabling Intel VT-x fails.", ""),
+    ADS_CODE_4096(0x1000, 4096, "RTERR_INTERNAL ", "Internal fatal error in the TwinCAT real-time system"),
+    ADS_CODE_4097(0x1001, 4097, "RTERR_BADTIMERPERIODS", "Timer value not vaild"),
+    ADS_CODE_4098(0x1002, 4098, "RTERR_INVALIDTASKPTR", "Task pointer has the invalid value ZERO"),
+    ADS_CODE_4099(0x1003, 4099, "RTERR_INVALIDSTACKPTR", "Task stack pointer has the invalid value ZERO"),
+    ADS_CODE_4100(0x1004, 4100, "RTERR_PRIOEXISTS", "The demand task priority is already assigned"),
+    ADS_CODE_4101(0x1005, 4101, "RTERR_NOMORETCB", "No more free TCB (Task Control Block) available. Maximum number of TCBs is 64"),
+    ADS_CODE_4102(0x1006, 4102, "RTERR_NOMORESEMAS", "No more free semaphores available. Maximum number of semaphores is 64"),
+    ADS_CODE_4103(0x1007, 4103, "RTERR_NOMOREQUEUES", "No more free queue available. Maximum number of queue is 64"),
+    ADS_CODE_4104(0x1008, 4104, "TwinCAT ", "reserved."),
+    ADS_CODE_4105(0x1009, 4105, "TwinCAT ", "reserved."),
+    ADS_CODE_4106(0x100A, 4106, "TwinCAT ", "reserved."),
+    ADS_CODE_4107(0x100B, 4107, "TwinCAT ", "reserved."),
+    ADS_CODE_4108(0x100C, 4108, "TwinCAT ", "reserved."),
+    ADS_CODE_4109(0x100D, 4109, "RTERR_EXTIRQALREADYDEF", "An external synchronisation interrupt is already applied"),
+    ADS_CODE_4110(0x100E, 4110, "RTERR_EXTIRQNOTDEF", "No external synchronsiation interrupt applied"),
+    ADS_CODE_4111(0x100F, 4111, "RTERR_EXTIRQINSTALLFAILED", "The apply of the external synchronisation interrupt failed"),
+    ADS_CODE_4112(0x1010, 4112, "RTERR_IRQLNOTLESSOREQUAL", "Call of a service function in the wrong context"),
+    ADS_CODE_4119(0x1017, 4119, "RTERR_VMXNOTSUPPORTED", "Intel VT-x extension is not supported."),
+    ADS_CODE_4120(0x1018, 4120, "RTERR_VMXDISABLED", "Intel VT-x extension is not enabled in BIOS."),
+    ADS_CODE_4121(0x1019, 4121, "RTERR_VMXCONTROLSMISSING", "Missing feature in Intel VT-x extension."),
+    ADS_CODE_4122(0x101A, 4122, "RTERR_VMXENABLEFAILS", "Enabling Intel VT-x fails."),
 
 
     // TCP Winsock Error Codes
     ADS_CODE_10060(0x274c, 10060, "A socket operation was attempted to an unreachable host", "Host unreachable", "Check network connection via ping"),
     ADS_CODE_10061(0x274d, 10061, "A connection attempt failed because the connected party did not properly respond after a period of time,or established connection failed because connected host has failed to respond.", "Host unreachable", "Check network connection via ping"),
-    ADS_CODE_10065(0x2751, 10065, "No connection could be made because the target machine actively refused it", "", ""),
+    ADS_CODE_10065(0x2751, 10065, "No connection could be made because the target machine actively refused it"),
     UNKNOWN(0, 0, "", "", "");
 
     private final long hex;
@@ -168,6 +167,14 @@ public enum AdsReturnCode {
     private final String possibleCauses;
     private final String solution;
 
+    AdsReturnCode(long hex, long dec, String description) {
+        this(hex, dec, description, "");
+    }
+
+    AdsReturnCode(long hex, long dec, String description, String possibleCauses) {
+        this(hex, dec, description, possibleCauses, "");
+    }
+
     AdsReturnCode(long hex, long dec, String description, String possibleCauses, String solution) {
         this.hex = hex;
         this.dec = dec;

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

[incubator-plc4x] 04/04: introduced new protocol layer ads2payload and removed dependency from serial to tcp

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b4c71ecd32ee711744cd4ee0a9197d5f0b1deddf
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 12:55:08 2018 +0100

    introduced new protocol layer ads2payload and removed dependency from
    serial to tcp
---
 .../plc4x/java/ads/api/commands/types/Data.java    |   9 +
 .../plc4x/java/ads/api/generic/AmsPacket.java      |  11 --
 .../plc4x/java/ads/api/serial/AmsSerialFrame.java  |  20 +-
 .../plc4x/java/ads/api/serial/types/UserData.java  |   9 +
 .../plc4x/java/ads/api/tcp/AmsTCPPacket.java       |  45 ++---
 .../ads/api/{serial => tcp}/types/UserData.java    |  11 +-
 .../apache/plc4x/java/ads/api/util/ByteValue.java  |  12 +-
 .../ads/connection/AdsSerialPlcConnection.java     |   6 +-
 .../java/ads/connection/AdsTcpPlcConnection.java   |   6 +-
 ...s2TcpProtocol.java => Ads2PayloadProtocol.java} |  29 +--
 ...alProtocol.java => Payload2SerialProtocol.java} |  46 +----
 .../java/ads/protocol/Payload2TcpProtocol.java     |  58 ++++++
 ...ProtocolTest.java => AbstractProtocolTest.java} |  77 +-------
 .../java/ads/protocol/Ads2PayloadProtocolTest.java |  99 ++++++++++
 .../java/ads/protocol/Ads2TcpProtocolTest.java     | 203 ---------------------
 .../ads/protocol/Payload2SerialProtocolTest.java   | 105 +++++++++++
 .../java/ads/protocol/Payload2TcpProtocolTest.java | 104 +++++++++++
 ...rotocolTest.java => Plc4x2AdsProtocolTest.java} |   4 +-
 18 files changed, 453 insertions(+), 401 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
index 12872e5..98c75e3 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
@@ -18,6 +18,7 @@
  */
 package org.apache.plc4x.java.ads.api.commands.types;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
 import java.nio.charset.Charset;
@@ -30,10 +31,18 @@ public class Data extends ByteValue {
         super(values);
     }
 
+    public Data(ByteBuf byteBuf) {
+        super(byteBuf);
+    }
+
     public static Data of(byte... values) {
         return new Data(values);
     }
 
+    public static Data of(ByteBuf byteBuf) {
+        return new Data(byteBuf);
+    }
+
     public static Data of(String value) {
         requireNonNull(value);
         return new Data(value.getBytes());
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AmsPacket.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AmsPacket.java
index 1ff6537..51e10ca 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AmsPacket.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AmsPacket.java
@@ -21,9 +21,6 @@ package org.apache.plc4x.java.ads.api.generic;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.commands.AdsCommandType;
 import org.apache.plc4x.java.ads.api.generic.types.*;
-import org.apache.plc4x.java.ads.api.serial.AmsSerialFrame;
-import org.apache.plc4x.java.ads.api.serial.types.FragmentNumber;
-import org.apache.plc4x.java.ads.api.tcp.AmsTCPPacket;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
 
 import static java.util.Objects.requireNonNull;
@@ -62,14 +59,6 @@ public abstract class AmsPacket implements ByteReadable {
         return () -> buildByteBuff(byteReadables);
     }
 
-    public AmsTCPPacket toAmstcpPacket() {
-        return AmsTCPPacket.of(this);
-    }
-
-    public AmsSerialFrame toAmsSerialFrame(byte fragmentNumber) {
-        return AmsSerialFrame.of(FragmentNumber.of(fragmentNumber), this);
-    }
-
     @Override
     public ByteBuf getByteBuf() {
         return buildByteBuff(amsHeader, getAdsData());
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialFrame.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialFrame.java
index c90b042..f121f01 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialFrame.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialFrame.java
@@ -19,7 +19,6 @@
 package org.apache.plc4x.java.ads.api.serial;
 
 import io.netty.buffer.ByteBuf;
-import org.apache.plc4x.java.ads.api.generic.AmsPacket;
 import org.apache.plc4x.java.ads.api.serial.types.*;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
 import org.apache.plc4x.java.ads.protocol.util.DigestUtil;
@@ -71,7 +70,6 @@ public class AmsSerialFrame implements ByteReadable {
     /**
      * The AMS packet to be sent.
      */
-    private AmsPacket amsPacket;
     private final UserData userData;
 
     private final CRC crc;
@@ -86,18 +84,17 @@ public class AmsSerialFrame implements ByteReadable {
         this.crc = crc;
     }
 
-    private AmsSerialFrame(FragmentNumber fragmentNumber, AmsPacket amsPacket) {
+    private AmsSerialFrame(FragmentNumber fragmentNumber, UserData userData) {
         this.magicCookie = MagicCookie.of(ID);
         this.transmitterAddress = TransmitterAddress.RS232_COMM_ADDRESS;
         this.receiverAddress = ReceiverAddress.RS232_COMM_ADDRESS;
         this.fragmentNumber = fragmentNumber;
-        long calculatedLength = amsPacket.getCalculatedLength();
+        long calculatedLength = userData.getCalculatedLength();
         if (calculatedLength > 255) {
             throw new IllegalArgumentException("Paket length must not exceed 255");
         }
         this.userDataLength = UserDataLength.of((byte) calculatedLength);
-        this.amsPacket = amsPacket;
-        byte[] amsPacketBytes = amsPacket.getBytes();
+        byte[] amsPacketBytes = userData.getBytes();
         this.userData = UserData.of(amsPacketBytes);
         this.crc = CRC.of(DigestUtil.calculateCrc16(() -> buildByteBuff(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength, userData)));
     }
@@ -106,12 +103,8 @@ public class AmsSerialFrame implements ByteReadable {
         return new AmsSerialFrame(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength, userData, crc);
     }
 
-    public static AmsSerialFrame of(FragmentNumber fragmentNumber, AmsPacket amsPacket) {
-        return new AmsSerialFrame(fragmentNumber, amsPacket);
-    }
-
-    public AmsPacket getAmsPacket() {
-        return amsPacket;
+    public static AmsSerialFrame of(FragmentNumber fragmentNumber, UserData userData) {
+        return new AmsSerialFrame(fragmentNumber, userData);
     }
 
     @Override
@@ -131,7 +124,6 @@ public class AmsSerialFrame implements ByteReadable {
         if (!receiverAddress.equals(that.receiverAddress)) return false;
         if (!fragmentNumber.equals(that.fragmentNumber)) return false;
         if (!userDataLength.equals(that.userDataLength)) return false;
-        if (!amsPacket.equals(that.amsPacket)) return false;
         if (!userData.equals(that.userData)) return false;
         return crc.equals(that.crc);
     }
@@ -143,7 +135,6 @@ public class AmsSerialFrame implements ByteReadable {
         result = 31 * result + receiverAddress.hashCode();
         result = 31 * result + fragmentNumber.hashCode();
         result = 31 * result + userDataLength.hashCode();
-        result = 31 * result + amsPacket.hashCode();
         result = 31 * result + userData.hashCode();
         result = 31 * result + crc.hashCode();
         return result;
@@ -157,7 +148,6 @@ public class AmsSerialFrame implements ByteReadable {
             ", receiverAddress=" + receiverAddress +
             ", fragmentNumber=" + fragmentNumber +
             ", userDataLength=" + userDataLength +
-            ", amsPacket=" + amsPacket +
             ", userData=" + userData +
             ", crc=" + crc +
             '}';
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java
index 7b99cf6..5a54490 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java
@@ -18,6 +18,7 @@
  */
 package org.apache.plc4x.java.ads.api.serial.types;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
 import java.nio.charset.Charset;
@@ -32,6 +33,10 @@ public class UserData extends ByteValue {
         super(values);
     }
 
+    public UserData(ByteBuf byteBuf) {
+        super(byteBuf);
+    }
+
     public static UserData of(byte... values) {
         return new UserData(values);
     }
@@ -46,6 +51,10 @@ public class UserData extends ByteValue {
         return new UserData(value.getBytes(charset));
     }
 
+    public static UserData of(ByteBuf byteBuf) {
+       return new UserData(byteBuf);
+    }
+
     @Override
     public String toString() {
         // TODO: maybe we could find a way to implement this to string
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
index 43512cf..2cfc60b 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
@@ -19,52 +19,45 @@
 package org.apache.plc4x.java.ads.api.tcp;
 
 import io.netty.buffer.ByteBuf;
-import org.apache.plc4x.java.ads.api.generic.AmsHeader;
-import org.apache.plc4x.java.ads.api.generic.AmsPacket;
+import org.apache.plc4x.java.ads.api.serial.types.UserData;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
 
 import static java.util.Objects.requireNonNull;
 
 public class AmsTCPPacket implements ByteReadable {
+    /**
+     * The ams - tcp to be sent.
+     */
     private final AmsTcpHeader amsTcpHeader;
 
-    private final AmsPacket amsPacket;
+    /**
+     * The AMS packet to be sent.
+     */
+    private final UserData userData;
 
-    private AmsTCPPacket(AmsTcpHeader amsTcpHeader, AmsPacket amsPacket) {
+    private AmsTCPPacket(AmsTcpHeader amsTcpHeader, UserData userData) {
         this.amsTcpHeader = requireNonNull(amsTcpHeader);
-        this.amsPacket = requireNonNull(amsPacket);
+        this.userData = requireNonNull(userData);
     }
 
-    private AmsTCPPacket(AmsPacket amsPacket) {
-        this.amsPacket = requireNonNull(amsPacket);
+    private AmsTCPPacket(UserData userData) {
+        this.userData = requireNonNull(userData);
         // It is important that we wrap the ads data call as this will initialized in the constructor
         // so this value will be null if we call adsData now.
-        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(amsPacket.getAmsHeader()), amsPacket);
+        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(userData));
     }
 
     public AmsTcpHeader getAmsTcpHeader() {
         return amsTcpHeader;
     }
 
-    public AmsPacket getAmsPacket() {
-        return amsPacket;
-    }
-
-    public AmsHeader getAmsHeader() {
-        return amsPacket.getAmsHeader();
-    }
-
     @Override
     public ByteBuf getByteBuf() {
-        return buildByteBuff(amsTcpHeader, amsPacket);
-    }
-
-    public static AmsTCPPacket of(AmsTcpHeader amsTcpHeader, AmsPacket amsPacket) {
-        return new AmsTCPPacket(amsTcpHeader, amsPacket);
+        return buildByteBuff(amsTcpHeader, userData);
     }
 
-    public static AmsTCPPacket of(AmsPacket amsPacket) {
-        return new AmsTCPPacket(amsPacket);
+    public static AmsTCPPacket of(UserData userData) {
+        return new AmsTCPPacket(userData);
     }
 
     @Override
@@ -75,13 +68,13 @@ public class AmsTCPPacket implements ByteReadable {
         AmsTCPPacket that = (AmsTCPPacket) o;
 
         if (!amsTcpHeader.equals(that.amsTcpHeader)) return false;
-        return amsPacket.equals(that.amsPacket);
+        return userData.equals(that.userData);
     }
 
     @Override
     public int hashCode() {
         int result = amsTcpHeader.hashCode();
-        result = 31 * result + amsPacket.hashCode();
+        result = 31 * result + userData.hashCode();
         return result;
     }
 
@@ -89,7 +82,7 @@ public class AmsTCPPacket implements ByteReadable {
     public String toString() {
         return "AmsTCPPacket{" +
             "amsTcpHeader=" + amsTcpHeader +
-            ", amsPacket=" + amsPacket +
+            ", amsPacket=" + userData +
             '}';
     }
 }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/types/UserData.java
similarity index 86%
copy from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java
copy to plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/types/UserData.java
index 7b99cf6..a30bdb1 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/types/UserData.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/types/UserData.java
@@ -16,8 +16,9 @@
  specific language governing permissions and limitations
  under the License.
  */
-package org.apache.plc4x.java.ads.api.serial.types;
+package org.apache.plc4x.java.ads.api.tcp.types;
 
+import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
 import java.nio.charset.Charset;
@@ -32,6 +33,10 @@ public class UserData extends ByteValue {
         super(values);
     }
 
+    public UserData(ByteBuf byteBuf) {
+        super(byteBuf);
+    }
+
     public static UserData of(byte... values) {
         return new UserData(values);
     }
@@ -46,6 +51,10 @@ public class UserData extends ByteValue {
         return new UserData(value.getBytes(charset));
     }
 
+    public static UserData of(ByteBuf byteBuf) {
+        return new UserData(byteBuf);
+    }
+
     @Override
     public String toString() {
         // TODO: maybe we could find a way to implement this to string
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteValue.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteValue.java
index 6149e36..d4d5b73 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteValue.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteValue.java
@@ -23,15 +23,21 @@ import io.netty.buffer.Unpooled;
 
 import java.math.BigInteger;
 import java.util.Arrays;
-import java.util.Objects;
+
+import static java.util.Objects.requireNonNull;
 
 public class ByteValue implements ByteReadable {
 
     protected final byte[] value;
 
     protected ByteValue(byte... value) {
-        Objects.requireNonNull(value);
-        this.value = value;
+        this.value = requireNonNull(value);
+    }
+
+    protected ByteValue(ByteBuf byteBuf) {
+        requireNonNull(byteBuf);
+        value = new byte[byteBuf.readableBytes()];
+        byteBuf.readBytes(value);
     }
 
     protected void assertLength(int length) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
index 1786e1a..8b68e6e 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsSerialPlcConnection.java
@@ -24,7 +24,8 @@ import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelPipeline;
 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.protocol.Ads2SerialProtocol;
+import org.apache.plc4x.java.ads.protocol.Ads2PayloadProtocol;
+import org.apache.plc4x.java.ads.protocol.Payload2SerialProtocol;
 import org.apache.plc4x.java.ads.protocol.Plc4x2AdsProtocol;
 import org.apache.plc4x.java.base.connection.SerialChannelFactory;
 
@@ -56,7 +57,8 @@ public class AdsSerialPlcConnection extends AdsAbstractPlcConnection {
                 // Build the protocol stack for communicating with the ads protocol.
                 ChannelPipeline pipeline = channel.pipeline();
                 pipeline.addLast(new Plc4x2AdsProtocol(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort));
-                pipeline.addLast(new Ads2SerialProtocol());
+                pipeline.addLast(new Ads2PayloadProtocol());
+                pipeline.addLast(new Payload2SerialProtocol());
             }
         };
     }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
index ad502c3..d25169d 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/connection/AdsTcpPlcConnection.java
@@ -24,7 +24,8 @@ import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelPipeline;
 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.protocol.Ads2TcpProtocol;
+import org.apache.plc4x.java.ads.protocol.Ads2PayloadProtocol;
+import org.apache.plc4x.java.ads.protocol.Payload2TcpProtocol;
 import org.apache.plc4x.java.ads.protocol.Plc4x2AdsProtocol;
 import org.apache.plc4x.java.base.connection.TcpSocketChannelFactory;
 
@@ -75,7 +76,8 @@ public class AdsTcpPlcConnection extends AdsAbstractPlcConnection {
                 // Build the protocol stack for communicating with the ads protocol.
                 ChannelPipeline pipeline = channel.pipeline();
                 pipeline.addLast(new Plc4x2AdsProtocol(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort));
-                pipeline.addLast(new Ads2TcpProtocol());
+                pipeline.addLast(new Ads2PayloadProtocol());
+                pipeline.addLast(new Payload2TcpProtocol());
             }
         };
     }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocol.java
similarity index 94%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocol.java
rename to plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocol.java
index 6e6ecf4..c2a3e94 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocol.java
@@ -26,8 +26,6 @@ import org.apache.plc4x.java.ads.api.commands.types.*;
 import org.apache.plc4x.java.ads.api.generic.AmsHeader;
 import org.apache.plc4x.java.ads.api.generic.AmsPacket;
 import org.apache.plc4x.java.ads.api.generic.types.*;
-import org.apache.plc4x.java.ads.api.tcp.AmsTcpHeader;
-import org.apache.plc4x.java.ads.api.tcp.types.TcpLength;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,21 +35,14 @@ import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-public class Ads2TcpProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
+public class Ads2PayloadProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2TcpProtocol.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2PayloadProtocol.class);
 
     private final ConcurrentMap<Invoke, AmsPacket> requests;
 
-    private final boolean ignoreBrokenPackages;
-
-    public Ads2TcpProtocol() {
-        this(false);
-    }
-
-    public Ads2TcpProtocol(boolean ignoreBrokenPackages) {
+    public Ads2PayloadProtocol() {
         this.requests = new ConcurrentHashMap<>();
-        this.ignoreBrokenPackages = ignoreBrokenPackages;
     }
 
     /**
@@ -67,20 +58,11 @@ public class Ads2TcpProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
         if (invokeId != Invoke.NONE) {
             requests.put(invokeId, amsPacket);
         }
-        out.add(amsPacket.toAmstcpPacket().getByteBuf());
+        out.add(amsPacket.getByteBuf());
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> out) throws Exception {
-        // Tcp decoding
-        // Reserved
-        byteBuf.skipBytes(AmsTcpHeader.Reserved.NUM_BYTES);
-        TcpLength packetLength = TcpLength.of(byteBuf);
-        AmsTcpHeader amsTcpHeader = AmsTcpHeader.of(packetLength);
-        LOGGER.debug("AMS TCP Header {}", amsTcpHeader);
-
-        // Ams decoding
         AmsNetId targetAmsNetId = AmsNetId.of(byteBuf);
         AmsPort targetAmsPort = AmsPort.of(byteBuf);
         AmsNetId sourceAmsNetId = AmsNetId.of(byteBuf);
@@ -138,7 +120,7 @@ public class Ads2TcpProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
         }
         out.add(amsPacket);
         LOGGER.trace("Set amsPacket {} to out", amsPacket);
-        if (!ignoreBrokenPackages && commandBuffer.readableBytes() > 0) {
+        if (commandBuffer.readableBytes() > 0) {
             commandBuffer.release();
             byteBuf.release();
             throw new IllegalStateException("Unread bytes left: " + commandBuffer.readableBytes());
@@ -147,6 +129,7 @@ public class Ads2TcpProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
         byteBuf.release();
     }
 
+
     private AmsPacket handleInvalidCommand(ByteBuf commandBuffer, AmsHeader amsHeader) {
         return UnknownCommand.of(amsHeader, commandBuffer);
     }
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
similarity index 69%
rename from plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocol.java
rename to plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
index eaeb39d..046a4bc 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
@@ -19,54 +19,26 @@
 package org.apache.plc4x.java.ads.protocol;
 
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToMessageCodec;
-import org.apache.plc4x.java.ads.api.generic.AmsPacket;
-import org.apache.plc4x.java.ads.api.generic.types.Invoke;
 import org.apache.plc4x.java.ads.api.serial.AmsSerialAcknowledgeFrame;
 import org.apache.plc4x.java.ads.api.serial.AmsSerialFrame;
 import org.apache.plc4x.java.ads.api.serial.AmsSerialResetFrame;
 import org.apache.plc4x.java.ads.api.serial.types.*;
-import org.apache.plc4x.java.ads.api.tcp.AmsTcpHeader;
 import org.apache.plc4x.java.ads.protocol.util.DigestUtil;
 import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
-public class Ads2SerialProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket> {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2TcpProtocol.class);
-
-    private final ConcurrentMap<Invoke, AmsPacket> requests;
-
-    private final Ads2TcpProtocol ads2TcpProtocol;
-
-    public Ads2SerialProtocol() {
-        this.requests = new ConcurrentHashMap<>();
-        this.ads2TcpProtocol = new Ads2TcpProtocol(true);
-    }
-
-    /**
-     * Resets this protocol and discard all send requests.
-     */
-    public void reset() {
-        requests.clear();
-    }
+public class Payload2SerialProtocol extends MessageToMessageCodec<ByteBuf, ByteBuf> {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Payload2TcpProtocol.class);
 
     @Override
-    protected void encode(ChannelHandlerContext channelHandlerContext, AmsPacket amsPacket, List<Object> out) throws Exception {
-        Invoke invokeId = amsPacket.getAmsHeader().getInvokeId();
-        if (invokeId != Invoke.NONE) {
-            requests.put(invokeId, amsPacket);
-        }
-        byte asLong = (byte) (invokeId.getAsLong() % 255);
-        out.add(amsPacket.toAmsSerialFrame(asLong).getByteBuf());
+    protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf amsPacket, List<Object> out) throws Exception {
+        out.add(AmsSerialFrame.of(FragmentNumber.of((byte) 0), UserData.of(amsPacket)).getByteBuf());
         // TODO: we need to remember the fragment and maybe even need to spilt up the package
         // TODO: if we exceed 255 byte
     }
@@ -92,15 +64,9 @@ public class Ads2SerialProtocol extends MessageToMessageCodec<ByteBuf, AmsPacket
         switch (magicCookie.getAsInt()) {
             case AmsSerialFrame.ID:
                 // This is a lazy implementation. we just reuse the tcp implementation
-                ByteBuf fakeTcpHeader = AmsTcpHeader.of(0).getByteBuf();
-                ads2TcpProtocol.decode(channelHandlerContext, Unpooled.wrappedBuffer(fakeTcpHeader, userData.getByteBuf()), out);
-                AmsPacket amsPacket = (AmsPacket) out.get(0);
-                AmsPacket correlatedAmsPacket = requests.remove(amsPacket.getAmsHeader().getInvokeId());
-                if (correlatedAmsPacket != null) {
-                    LOGGER.debug("Correlated packet received {}", correlatedAmsPacket);
-                }
-                AmsSerialFrame amsSerialFrame = amsPacket.toAmsSerialFrame(fragmentNumber.getBytes()[0]);
+                AmsSerialFrame amsSerialFrame = AmsSerialFrame.of(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength, userData, crc);
                 LOGGER.debug("Ams Serial Frame received {}", amsSerialFrame);
+                out.add(userData.getByteBuf());
                 break;
             case AmsSerialAcknowledgeFrame.ID:
                 AmsSerialAcknowledgeFrame amsSerialAcknowledgeFrame = AmsSerialAcknowledgeFrame.of(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength, crc);
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocol.java
new file mode 100644
index 0000000..8b723e8
--- /dev/null
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocol.java
@@ -0,0 +1,58 @@
+/*
+ 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.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToMessageCodec;
+import org.apache.plc4x.java.ads.api.serial.types.UserData;
+import org.apache.plc4x.java.ads.api.tcp.AmsTCPPacket;
+import org.apache.plc4x.java.ads.api.tcp.AmsTcpHeader;
+import org.apache.plc4x.java.ads.api.tcp.types.TcpLength;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class Payload2TcpProtocol extends MessageToMessageCodec<ByteBuf, ByteBuf> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Payload2TcpProtocol.class);
+
+    @Override
+    protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf amsPacket, List<Object> out) throws Exception {
+        out.add(AmsTCPPacket.of(UserData.of(amsPacket)).getByteBuf());
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> out) throws Exception {
+        // Reserved
+        byteBuf.skipBytes(AmsTcpHeader.Reserved.NUM_BYTES);
+        TcpLength packetLength = TcpLength.of(byteBuf);
+        AmsTcpHeader amsTcpHeader = AmsTcpHeader.of(packetLength);
+        LOGGER.debug("AMS TCP Header {}", amsTcpHeader);
+
+        int readableBytes = byteBuf.readableBytes();
+        if (readableBytes != packetLength.getAsLong()) {
+            throw new IllegalStateException("To many bytes to read: " + readableBytes + " bytes. Expected " + packetLength.getAsLong() + " bytes.");
+        }
+        out.add(byteBuf.readBytes(readableBytes));
+    }
+
+}
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
similarity index 67%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java
rename to plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
index 4a62eea..fed68ab 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2SerialProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
@@ -18,50 +18,20 @@
  */
 package org.apache.plc4x.java.ads.protocol;
 
-import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.commands.*;
 import org.apache.plc4x.java.ads.api.commands.types.*;
 import org.apache.plc4x.java.ads.api.generic.AmsPacket;
 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.api.serial.AmsSerialFrame;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+public class AbstractProtocolTest {
 
-@RunWith(Parameterized.class)
-public class Ads2SerialProtocolTest {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2SerialProtocolTest.class);
-
-    private Ads2SerialProtocol SUT;
-
-    @Parameterized.Parameter
-    public AmsSerialFrame amsSerialFrame;
-
-    @Parameterized.Parameter(1)
-    public String clazzName;
-
-    @Parameterized.Parameter(2)
-    public AmsPacket amsPacket;
-
-    @Parameterized.Parameters(name = "{index} {1}")
-    public static Collection<Object[]> data() {
+    public static Stream<AmsPacket> amsPacketStream() {
         AmsNetId targetAmsNetId = AmsNetId.of("1.2.3.4.5.6");
         AmsPort targetAmsPort = AmsPort.of(7);
         AmsNetId sourceAmsNetId = AmsNetId.of("8.9.10.11.12.13");
@@ -162,45 +132,6 @@ public class Ads2SerialProtocolTest {
                 targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, State.DEFAULT, invokeId,
                 Unpooled.wrappedBuffer(new byte[]{42})
             )*/
-        ).map(amsPacket -> new Object[]{amsPacket.toAmsSerialFrame((byte) 0), amsPacket.getClass().getSimpleName(), amsPacket}).collect(Collectors.toList());
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        SUT = new Ads2SerialProtocol();
-        byte[] bytes = amsSerialFrame.getBytes();
-        LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsSerialFrame, bytes.length, amsSerialFrame.dump());
-    }
-
-    @Test
-    public void encode() throws Exception {
-        ArrayList<Object> out = new ArrayList<>();
-        SUT.encode(null, amsSerialFrame.getAmsPacket(), out);
-        assertEquals(1, out.size());
-        assertThat(out, hasSize(1));
-    }
-
-    @Test
-    public void decode() throws Exception {
-        ArrayList<Object> out = new ArrayList<>();
-        SUT.decode(null, amsSerialFrame.getByteBuf(), out);
-        assertThat(out, hasSize(1));
-    }
-
-    @Test
-    public void roundTrip() throws Exception {
-        ArrayList<Object> outbound = new ArrayList<>();
-        SUT.encode(null, amsSerialFrame.getAmsPacket(), outbound);
-        assertEquals(1, outbound.size());
-        assertThat(outbound, hasSize(1));
-        assertThat(outbound.get(0), instanceOf(ByteBuf.class));
-        ByteBuf byteBuf = (ByteBuf) outbound.get(0);
-        ArrayList<Object> inbound = new ArrayList<>();
-        SUT.decode(null, byteBuf, inbound);
-        assertEquals(1, inbound.size());
-        assertThat(inbound, hasSize(1));
-        assertThat(inbound.get(0), instanceOf(AmsPacket.class));
-        AmsPacket inboundAmsPacket = (AmsPacket) inbound.get(0);
-        assertThat("inbound divers from outbound", this.amsSerialFrame, equalTo(inboundAmsPacket.toAmsSerialFrame((byte) 0)));
+        );
     }
-}
\ No newline at end of file
+}
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocolTest.java
new file mode 100644
index 0000000..87de9ea
--- /dev/null
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2PayloadProtocolTest.java
@@ -0,0 +1,99 @@
+/*
+ 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.protocol;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.plc4x.java.ads.api.generic.AmsPacket;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class Ads2PayloadProtocolTest extends AbstractProtocolTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2PayloadProtocolTest.class);
+
+    private Ads2PayloadProtocol SUT;
+
+    @Parameterized.Parameter
+    public AmsPacket amsPacket;
+
+    @Parameterized.Parameter(1)
+    public String clazzName;
+
+    @Parameterized.Parameters(name = "{index} {1}")
+    public static Collection<Object[]> data() {
+        return amsPacketStream()
+            .map(amsPacket -> new Object[]{
+                amsPacket,
+                amsPacket.getClass().getSimpleName()
+            })
+            .collect(Collectors.toList());
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        SUT = new Ads2PayloadProtocol();
+        byte[] bytes = amsPacket.getBytes();
+        LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsPacket, bytes.length, amsPacket.dump());
+    }
+
+    @Test
+    public void encode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.encode(null, amsPacket, out);
+        assertEquals(1, out.size());
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void decode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.decode(null, amsPacket.getByteBuf(), out);
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void roundTrip() throws Exception {
+        ArrayList<Object> outbound = new ArrayList<>();
+        SUT.encode(null, amsPacket, outbound);
+        assertEquals(1, outbound.size());
+        assertThat(outbound, hasSize(1));
+        assertThat(outbound.get(0), instanceOf(ByteBuf.class));
+        ByteBuf byteBuf = (ByteBuf) outbound.get(0);
+        ArrayList<Object> inbound = new ArrayList<>();
+        SUT.decode(null, byteBuf, inbound);
+        assertEquals(1, inbound.size());
+        assertThat(inbound, hasSize(1));
+        assertThat(inbound.get(0), instanceOf(AmsPacket.class));
+        AmsPacket inboundAmsPacket = (AmsPacket) inbound.get(0);
+        assertThat("inbound divers from outbound", this.amsPacket, equalTo(inboundAmsPacket));
+    }
+}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocolTest.java
deleted file mode 100644
index 7a23aa4..0000000
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Ads2TcpProtocolTest.java
+++ /dev/null
@@ -1,203 +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.protocol;
-
-import io.netty.buffer.ByteBuf;
-import org.apache.plc4x.java.ads.api.commands.*;
-import org.apache.plc4x.java.ads.api.commands.types.*;
-import org.apache.plc4x.java.ads.api.generic.AmsPacket;
-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.api.tcp.AmsTCPPacket;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-@RunWith(Parameterized.class)
-public class Ads2TcpProtocolTest {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2TcpProtocolTest.class);
-
-    private Ads2TcpProtocol SUT;
-
-    @Parameterized.Parameter
-    public AmsTCPPacket amsTCPPacket;
-
-    @Parameterized.Parameter(1)
-    public String clazzName;
-
-    @Parameterized.Parameters(name = "{index} {1}")
-    public static Collection<Object[]> data() {
-        AmsNetId targetAmsNetId = AmsNetId.of("1.2.3.4.5.6");
-        AmsPort targetAmsPort = AmsPort.of(7);
-        AmsNetId sourceAmsNetId = AmsNetId.of("8.9.10.11.12.13");
-        AmsPort sourceAmsPort = AmsPort.of(14);
-        Invoke invokeId = Invoke.of(15);
-        Data data = Data.of("Hello World!".getBytes());
-        return Stream.of(
-            AdsAddDeviceNotificationRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                IndexGroup.of(1), IndexOffset.of(1), Length.of(1), TransmissionMode.of(1), MaxDelay.of(1), CycleTime.of(1)).toAmstcpPacket(),
-            AdsAddDeviceNotificationResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0),
-                NotificationHandle.of(0)
-            ).toAmstcpPacket(),
-            AdsDeleteDeviceNotificationRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                NotificationHandle.of(0)
-            ).toAmstcpPacket(),
-            AdsDeleteDeviceNotificationResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0)
-            ).toAmstcpPacket(),
-            AdsDeviceNotificationRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Stamps.of(1),
-                Collections.singletonList(
-                    // Nano times need to be offset by (1.1.1970 - 1.1.1601) years in nanos
-                    AdsStampHeader.of(TimeStamp.of(new Date()),
-                        Collections.singletonList(
-                            AdsNotificationSample.of(NotificationHandle.of(0), data))
-                    )
-                )
-            ).toAmstcpPacket(),
-            AdsReadDeviceInfoRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId
-            ).toAmstcpPacket(),
-            AdsReadDeviceInfoResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0),
-                MajorVersion.of((byte) 1),
-                MinorVersion.of((byte) 2),
-                Version.of(3),
-                Device.of("Random DeviceId")
-            ).toAmstcpPacket(),
-            AdsReadRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                IndexGroup.of(0),
-                IndexOffset.of(0),
-                Length.of(1)
-            ).toAmstcpPacket(),
-            AdsReadResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0),
-                data
-            ).toAmstcpPacket(),
-            AdsReadStateRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId
-            ).toAmstcpPacket(),
-            AdsReadStateResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0)
-            ).toAmstcpPacket(),
-            AdsReadWriteRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                IndexGroup.of(0),
-                IndexOffset.of(0),
-                ReadLength.of(data.getCalculatedLength()),
-                data
-            ).toAmstcpPacket(),
-            AdsReadWriteResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0),
-                data
-            ).toAmstcpPacket(),
-            AdsWriteControlRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                AdsState.of(0xaffe),
-                DeviceState.of(0xaffe),
-                data
-            ).toAmstcpPacket(),
-            AdsWriteControlResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0)
-            ).toAmstcpPacket(),
-            AdsWriteRequest.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                IndexGroup.of(0),
-                IndexOffset.of(0),
-                data
-            ).toAmstcpPacket(),
-            AdsWriteResponse.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, invokeId,
-                Result.of(0)
-            ).toAmstcpPacket()
-            /*,
-            UnknownCommand.of(
-                targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, State.DEFAULT, invokeId,
-                Unpooled.wrappedBuffer(new byte[]{42})
-            )*/
-        ).map(amsTCPPacket -> new Object[]{amsTCPPacket, amsTCPPacket.getClass().getSimpleName()}).collect(Collectors.toList());
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        SUT = new Ads2TcpProtocol();
-        byte[] bytes = amsTCPPacket.getBytes();
-        LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsTCPPacket, bytes.length, amsTCPPacket.dump());
-    }
-
-    @Test
-    public void encode() throws Exception {
-        ArrayList<Object> out = new ArrayList<>();
-        SUT.encode(null, amsTCPPacket.getAmsPacket(), out);
-        assertEquals(1, out.size());
-        assertThat(out, hasSize(1));
-    }
-
-    @Test
-    public void decode() throws Exception {
-        ArrayList<Object> out = new ArrayList<>();
-        SUT.decode(null, amsTCPPacket.getByteBuf(), out);
-        assertThat(out, hasSize(1));
-    }
-
-    @Test
-    public void roundTrip() throws Exception {
-        ArrayList<Object> outbound = new ArrayList<>();
-        SUT.encode(null, amsTCPPacket.getAmsPacket(), outbound);
-        assertEquals(1, outbound.size());
-        assertThat(outbound, hasSize(1));
-        assertThat(outbound.get(0), instanceOf(ByteBuf.class));
-        ByteBuf byteBuf = (ByteBuf) outbound.get(0);
-        ArrayList<Object> inbound = new ArrayList<>();
-        SUT.decode(null, byteBuf, inbound);
-        assertEquals(1, inbound.size());
-        assertThat(inbound, hasSize(1));
-        assertThat(inbound.get(0), instanceOf(AmsPacket.class));
-        AmsPacket inboundAmsPacket = (AmsPacket) inbound.get(0);
-        assertThat("inbound divers from outbound", this.amsTCPPacket, equalTo(inboundAmsPacket.toAmstcpPacket()));
-    }
-}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocolTest.java
new file mode 100644
index 0000000..fe1a0fc
--- /dev/null
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocolTest.java
@@ -0,0 +1,105 @@
+/*
+ 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.protocol;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.plc4x.java.ads.api.serial.AmsSerialFrame;
+import org.apache.plc4x.java.ads.api.serial.types.FragmentNumber;
+import org.apache.plc4x.java.ads.api.serial.types.UserData;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class Payload2SerialProtocolTest extends AbstractProtocolTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Payload2SerialProtocolTest.class);
+
+    private Payload2SerialProtocol SUT;
+
+    @Parameterized.Parameter
+    public AmsSerialFrame amsSerialFrame;
+
+    @Parameterized.Parameter(1)
+    public String clazzName;
+
+    @Parameterized.Parameter(2)
+    public ByteBuf amsPacketByteBuf;
+
+    @Parameterized.Parameters(name = "{index} {1}")
+    public static Collection<Object[]> data() {
+        return amsPacketStream()
+            .map(amsPacket -> new Object[]{
+                AmsSerialFrame.of(FragmentNumber.of((byte) 0), UserData.of(amsPacket.getByteBuf())),
+                amsPacket.getClass().getSimpleName(),
+                amsPacket.getByteBuf()
+            })
+            .collect(Collectors.toList());
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        SUT = new Payload2SerialProtocol();
+        byte[] bytes = amsSerialFrame.getBytes();
+        LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsSerialFrame, bytes.length, amsSerialFrame.dump());
+    }
+
+    @Test
+    public void encode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.encode(null, amsPacketByteBuf, out);
+        assertEquals(1, out.size());
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void decode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.decode(null, amsSerialFrame.getByteBuf(), out);
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void roundTrip() throws Exception {
+        ArrayList<Object> outbound = new ArrayList<>();
+        SUT.encode(null, amsPacketByteBuf, outbound);
+        assertEquals(1, outbound.size());
+        assertThat(outbound, hasSize(1));
+        assertThat(outbound.get(0), instanceOf(ByteBuf.class));
+        ByteBuf byteBuf = (ByteBuf) outbound.get(0);
+        ArrayList<Object> inbound = new ArrayList<>();
+        SUT.decode(null, byteBuf, inbound);
+        assertEquals(1, inbound.size());
+        assertThat(inbound, hasSize(1));
+        assertThat(inbound.get(0), instanceOf(ByteBuf.class));
+        ByteBuf inboundAmsPacketByteBuf = (ByteBuf) inbound.get(0);
+        assertThat("inbound divers from outbound", this.amsPacketByteBuf, equalTo(inboundAmsPacketByteBuf));
+    }
+}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocolTest.java
new file mode 100644
index 0000000..32c8888
--- /dev/null
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocolTest.java
@@ -0,0 +1,104 @@
+/*
+ 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.protocol;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.plc4x.java.ads.api.serial.types.UserData;
+import org.apache.plc4x.java.ads.api.tcp.AmsTCPPacket;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Parameterized.class)
+public class Payload2TcpProtocolTest extends AbstractProtocolTest {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Payload2TcpProtocolTest.class);
+
+    private Payload2TcpProtocol SUT;
+
+    @Parameterized.Parameter
+    public AmsTCPPacket amsTCPPacket;
+
+    @Parameterized.Parameter(1)
+    public String clazzName;
+
+    @Parameterized.Parameter(2)
+    public ByteBuf amsPacketByteBuf;
+
+    @Parameterized.Parameters(name = "{index} {1}")
+    public static Collection<Object[]> data() {
+        return amsPacketStream()
+            .map(amsPacket -> new Object[]{
+                AmsTCPPacket.of(UserData.of(amsPacket.getByteBuf())),
+                amsPacket.getClass().getSimpleName(),
+                amsPacket.getByteBuf()
+            })
+            .collect(Collectors.toList());
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        SUT = new Payload2TcpProtocol();
+        byte[] bytes = amsTCPPacket.getBytes();
+        LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsTCPPacket, bytes.length, amsTCPPacket.dump());
+    }
+
+    @Test
+    public void encode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.encode(null, amsPacketByteBuf, out);
+        assertEquals(1, out.size());
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void decode() throws Exception {
+        ArrayList<Object> out = new ArrayList<>();
+        SUT.decode(null, amsTCPPacket.getByteBuf(), out);
+        assertThat(out, hasSize(1));
+    }
+
+    @Test
+    public void roundTrip() throws Exception {
+        ArrayList<Object> outbound = new ArrayList<>();
+        SUT.encode(null, amsPacketByteBuf, outbound);
+        assertEquals(1, outbound.size());
+        assertThat(outbound, hasSize(1));
+        assertThat(outbound.get(0), instanceOf(ByteBuf.class));
+        ByteBuf byteBuf = (ByteBuf) outbound.get(0);
+        ArrayList<Object> inbound = new ArrayList<>();
+        SUT.decode(null, byteBuf, inbound);
+        assertEquals(1, inbound.size());
+        assertThat(inbound, hasSize(1));
+        assertThat(inbound.get(0), instanceOf(ByteBuf.class));
+        ByteBuf inboundAmsPacket = (ByteBuf) inbound.get(0);
+        assertThat("inbound divers from outbound", this.amsPacketByteBuf, equalTo(inboundAmsPacket));
+    }
+}
\ No newline at end of file
diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4X2Ads2TcpProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
similarity index 99%
rename from plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4X2Ads2TcpProtocolTest.java
rename to plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
index 0de9738..4af7a4a 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4X2Ads2TcpProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/Plc4x2AdsProtocolTest.java
@@ -54,8 +54,8 @@ import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.assertThat;
 
 @RunWith(Parameterized.class)
-public class Plc4X2Ads2TcpProtocolTest {
-    private static final Logger LOGGER = LoggerFactory.getLogger(Ads2TcpProtocolTest.class);
+public class Plc4x2AdsProtocolTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Plc4x2AdsProtocolTest.class);
 
     public static final Calendar calenderInstance = Calendar.getInstance();
 

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

[incubator-plc4x] 02/04: suppress unused warnings for static defined constants

Posted by sr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bffaebe6a52d79147352d5045ef0ec74c7c90f88
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 11:57:34 2018 +0100

    suppress unused warnings for static defined constants
---
 .../java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java    | 1 +
 .../java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java   | 1 +
 .../main/java/org/apache/plc4x/java/ads/api/generic/types/AmsPort.java   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
index 473e344..1a84ebf 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexGroup.java
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.ads.api.commands.types;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.UnsignedIntLEByteValue;
 
+@SuppressWarnings("unused") // Due to predefined IndexGroups
 public class IndexGroup extends UnsignedIntLEByteValue {
 
     public static final int NUM_BYTES = UnsignedIntLEByteValue.UNSIGNED_INT_LE_NUM_BYTES;
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
index ca71ae1..0b8a4ed 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/IndexOffset.java
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.ads.api.commands.types;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.UnsignedIntLEByteValue;
 
+@SuppressWarnings("unused") // Due to predefined IndexOffsets
 public class IndexOffset extends UnsignedIntLEByteValue {
 
     public static final int NUM_BYTES = UnsignedIntLEByteValue.UNSIGNED_INT_LE_NUM_BYTES;
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 77ac13f..9346b9f 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
@@ -29,6 +29,7 @@ import java.util.regex.Pattern;
  *
  * @see <a href="https://infosys.beckhoff.com/content/1033/tcadscommon/html/tcadscommon_identadsdevice.htm?id=3991659524769593444">ADS device identification</a>
  */
+@SuppressWarnings("unused") // Due to predefined ports
 public class AmsPort extends ByteValue {
 
     public static final Pattern AMS_PORT_PATTERN = Pattern.compile("\\d+");

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