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 15:38:32 UTC

[incubator-plc4x] branch master updated (f79137e -> bf6bac3)

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 f79137e  fixed Benchmark
     new ee30eef  added length constraint for UserData on serial communication
     new 93154f8  removed obsolete comment
     new 856878a  proberly release used bytebuffers
     new 9a2c27e  fixed crc left-overs
     new bf6bac3  refactored protocol tests

The 5 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:
 .../ads/api/serial/AmsSerialAcknowledgeFrame.java  | 21 ++-----------------
 .../java/ads/api/serial/AmsSerialResetFrame.java   | 21 ++-----------------
 .../plc4x/java/ads/api/serial/types/UserData.java  | 12 ++++++++++-
 .../java/ads/protocol/Payload2SerialProtocol.java  |  2 +-
 .../java/ads/protocol/Payload2TcpProtocol.java     |  1 +
 .../java/ads/protocol/AbstractProtocolTest.java    | 12 +++++++++++
 .../ads/protocol/Payload2SerialProtocolTest.java   | 24 ++++++++++++++--------
 .../java/ads/protocol/Payload2TcpProtocolTest.java | 24 ++++++++++++++--------
 8 files changed, 61 insertions(+), 56 deletions(-)

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

[incubator-plc4x] 04/05: fixed crc left-overs

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 9a2c27e396d407358904cd38113b4e170cf14b15
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 16:36:03 2018 +0100

    fixed crc left-overs
---
 .../ads/api/serial/AmsSerialAcknowledgeFrame.java   | 21 ++-------------------
 .../java/ads/api/serial/AmsSerialResetFrame.java    | 21 ++-------------------
 2 files changed, 4 insertions(+), 38 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialAcknowledgeFrame.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialAcknowledgeFrame.java
index 812eb1b..98bfd79 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialAcknowledgeFrame.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialAcknowledgeFrame.java
@@ -21,10 +21,7 @@ package org.apache.plc4x.java.ads.api.serial;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.serial.types.*;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
+import org.apache.plc4x.java.ads.protocol.util.DigestUtil;
 
 /**
  * If an AMS serial frame has been received and the frame is OK (magic cookie OK, CRC OK, correct fragment number etc.),
@@ -82,21 +79,7 @@ public class AmsSerialAcknowledgeFrame implements ByteReadable {
         this.receiverAddress = receiverAddress;
         this.fragmentNumber = fragmentNumber;
         this.userDataLength = UserDataLength.of((byte) 0);
-        MessageDigest messageDigest;
-        try {
-            messageDigest = MessageDigest.getInstance("CRC-16");
-        } catch (NoSuchAlgorithmException e) {
-            throw new PlcRuntimeException(e);
-        }
-        messageDigest.update(magicCookie.getBytes());
-        messageDigest.update(transmitterAddress.getBytes());
-        messageDigest.update(receiverAddress.getBytes());
-        messageDigest.update(fragmentNumber.getBytes());
-        byte[] digest = messageDigest.digest(userDataLength.getBytes());
-        if (digest.length > 2) {
-            throw new PlcRuntimeException("Digest length too great " + digest.length);
-        }
-        this.crc = CRC.of(digest[0], digest[1]);
+        this.crc = CRC.of(DigestUtil.calculateCrc16(() -> buildByteBuff(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength)));
     }
 
     public static AmsSerialAcknowledgeFrame of(MagicCookie magicCookie, TransmitterAddress transmitterAddress, ReceiverAddress receiverAddress, FragmentNumber fragmentNumber, UserDataLength userDataLength, CRC crc) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialResetFrame.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialResetFrame.java
index b05f023..e337eda 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialResetFrame.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/serial/AmsSerialResetFrame.java
@@ -21,10 +21,7 @@ package org.apache.plc4x.java.ads.api.serial;
 import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.serial.types.*;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
+import org.apache.plc4x.java.ads.protocol.util.DigestUtil;
 
 /**
  * In case the transmitter does not receive a valid acknowledgement after multiple transmission, then a reset frame is
@@ -81,21 +78,7 @@ public class AmsSerialResetFrame implements ByteReadable {
         this.receiverAddress = receiverAddress;
         this.fragmentNumber = FragmentNumber.of((byte) 0);
         this.userDataLength = UserDataLength.of((byte) 0);
-        MessageDigest messageDigest;
-        try {
-            messageDigest = MessageDigest.getInstance("CRC-16");
-        } catch (NoSuchAlgorithmException e) {
-            throw new PlcRuntimeException(e);
-        }
-        messageDigest.update(magicCookie.getBytes());
-        messageDigest.update(transmitterAddress.getBytes());
-        messageDigest.update(receiverAddress.getBytes());
-        messageDigest.update(fragmentNumber.getBytes());
-        byte[] digest = messageDigest.digest(userDataLength.getBytes());
-        if (digest.length > 2) {
-            throw new PlcRuntimeException("Digest length too great " + digest.length);
-        }
-        this.crc = CRC.of(digest[0], digest[1]);
+        this.crc = CRC.of(DigestUtil.calculateCrc16(() -> buildByteBuff(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength)));
     }
 
     public static AmsSerialResetFrame of(MagicCookie magicCookie, TransmitterAddress transmitterAddress, ReceiverAddress receiverAddress, FragmentNumber fragmentNumber, UserDataLength userDataLength, CRC crc) {

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

[incubator-plc4x] 01/05: added length constraint for UserData on serial communication

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 ee30eef068057a4bf3b0104157525ca23701b82b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 15:27:30 2018 +0100

    added length constraint for UserData on serial communication
---
 .../org/apache/plc4x/java/ads/api/serial/types/UserData.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

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 5a54490..cf65dd7 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
@@ -27,14 +27,24 @@ import static java.util.Objects.requireNonNull;
 
 public class UserData extends ByteValue {
 
+    public static final int MAX_LENGTH = 255;
+
     public static final UserData EMPTY = UserData.of();
 
     private UserData(byte... values) {
         super(values);
+        assertMaxLength();
     }
 
     public UserData(ByteBuf byteBuf) {
         super(byteBuf);
+        assertMaxLength();
+    }
+
+    protected void assertMaxLength() {
+        if (value.length > MAX_LENGTH) {
+            throw new IllegalArgumentException("Max length " + MAX_LENGTH + " bytes exceeded by " + (value.length - MAX_LENGTH) + " bytes");
+        }
     }
 
     public static UserData of(byte... values) {
@@ -52,7 +62,7 @@ public class UserData extends ByteValue {
     }
 
     public static UserData of(ByteBuf byteBuf) {
-       return new UserData(byteBuf);
+        return new UserData(byteBuf);
     }
 
     @Override

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

[incubator-plc4x] 05/05: refactored protocol tests

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 bf6bac343afbd0157676d4a28792c27a6f7856d3
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 16:36:26 2018 +0100

    refactored protocol tests
---
 .../java/ads/protocol/AbstractProtocolTest.java    | 12 +++++++++++
 .../ads/protocol/Payload2SerialProtocolTest.java   | 24 ++++++++++++++--------
 .../java/ads/protocol/Payload2TcpProtocolTest.java | 24 ++++++++++++++--------
 3 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
index fed68ab..e9ba236 100644
--- a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
+++ b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/protocol/AbstractProtocolTest.java
@@ -18,6 +18,7 @@
  */
 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;
@@ -29,6 +30,9 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.stream.Stream;
 
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
 public class AbstractProtocolTest {
 
     public static Stream<AmsPacket> amsPacketStream() {
@@ -134,4 +138,12 @@ public class AbstractProtocolTest {
             )*/
         );
     }
+
+    public void assertByteBufferEquals(ByteBuf expected, ByteBuf actual) {
+        byte[] expectedBytes = new byte[expected.readableBytes()];
+        expected.readBytes(expectedBytes);
+        byte[] actualBytes = new byte[actual.readableBytes()];
+        actual.readBytes(actualBytes);
+        assertThat(expectedBytes, equalTo(actualBytes));
+    }
 }
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
index fe1a0fc..91ba572 100644
--- 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
@@ -19,6 +19,8 @@
 package org.apache.plc4x.java.ads.protocol;
 
 import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
 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;
@@ -33,9 +35,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.stream.Collectors;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
 
 @RunWith(Parameterized.class)
 public class Payload2SerialProtocolTest extends AbstractProtocolTest {
@@ -44,6 +49,8 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
 
     private Payload2SerialProtocol SUT;
 
+    private ChannelHandlerContext channelHandlerContextMock;
+
     @Parameterized.Parameter
     public AmsSerialFrame amsSerialFrame;
 
@@ -51,7 +58,7 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
     public String clazzName;
 
     @Parameterized.Parameter(2)
-    public ByteBuf amsPacketByteBuf;
+    public byte[] amsPacketBytes;
 
     @Parameterized.Parameters(name = "{index} {1}")
     public static Collection<Object[]> data() {
@@ -59,7 +66,7 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
             .map(amsPacket -> new Object[]{
                 AmsSerialFrame.of(FragmentNumber.of((byte) 0), UserData.of(amsPacket.getByteBuf())),
                 amsPacket.getClass().getSimpleName(),
-                amsPacket.getByteBuf()
+                amsPacket.getBytes()
             })
             .collect(Collectors.toList());
     }
@@ -67,6 +74,7 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
     @Before
     public void setUp() throws Exception {
         SUT = new Payload2SerialProtocol();
+        channelHandlerContextMock = mock(ChannelHandlerContext.class, RETURNS_DEEP_STUBS);
         byte[] bytes = amsSerialFrame.getBytes();
         LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsSerialFrame, bytes.length, amsSerialFrame.dump());
     }
@@ -74,7 +82,7 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
     @Test
     public void encode() throws Exception {
         ArrayList<Object> out = new ArrayList<>();
-        SUT.encode(null, amsPacketByteBuf, out);
+        SUT.encode(channelHandlerContextMock, Unpooled.wrappedBuffer(amsPacketBytes), out);
         assertEquals(1, out.size());
         assertThat(out, hasSize(1));
     }
@@ -82,24 +90,24 @@ public class Payload2SerialProtocolTest extends AbstractProtocolTest {
     @Test
     public void decode() throws Exception {
         ArrayList<Object> out = new ArrayList<>();
-        SUT.decode(null, amsSerialFrame.getByteBuf(), out);
+        SUT.decode(channelHandlerContextMock, amsSerialFrame.getByteBuf(), out);
         assertThat(out, hasSize(1));
     }
 
     @Test
     public void roundTrip() throws Exception {
         ArrayList<Object> outbound = new ArrayList<>();
-        SUT.encode(null, amsPacketByteBuf, outbound);
+        SUT.encode(channelHandlerContextMock, Unpooled.wrappedBuffer(amsPacketBytes), 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);
+        SUT.decode(channelHandlerContextMock, 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));
+        assertByteBufferEquals(Unpooled.wrappedBuffer(this.amsPacketBytes), 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
index 32c8888..336253e 100644
--- 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
@@ -19,6 +19,8 @@
 package org.apache.plc4x.java.ads.protocol;
 
 import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
 import org.apache.plc4x.java.ads.api.serial.types.UserData;
 import org.apache.plc4x.java.ads.api.tcp.AmsTCPPacket;
 import org.junit.Before;
@@ -32,9 +34,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.stream.Collectors;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
 
 @RunWith(Parameterized.class)
 public class Payload2TcpProtocolTest extends AbstractProtocolTest {
@@ -43,6 +48,8 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
 
     private Payload2TcpProtocol SUT;
 
+    private ChannelHandlerContext channelHandlerContextMock;
+
     @Parameterized.Parameter
     public AmsTCPPacket amsTCPPacket;
 
@@ -50,7 +57,7 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
     public String clazzName;
 
     @Parameterized.Parameter(2)
-    public ByteBuf amsPacketByteBuf;
+    public byte[] amsPacketBytes;
 
     @Parameterized.Parameters(name = "{index} {1}")
     public static Collection<Object[]> data() {
@@ -58,7 +65,7 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
             .map(amsPacket -> new Object[]{
                 AmsTCPPacket.of(UserData.of(amsPacket.getByteBuf())),
                 amsPacket.getClass().getSimpleName(),
-                amsPacket.getByteBuf()
+                amsPacket.getBytes()
             })
             .collect(Collectors.toList());
     }
@@ -66,6 +73,7 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
     @Before
     public void setUp() throws Exception {
         SUT = new Payload2TcpProtocol();
+        channelHandlerContextMock = mock(ChannelHandlerContext.class, RETURNS_DEEP_STUBS);
         byte[] bytes = amsTCPPacket.getBytes();
         LOGGER.info("amsPacket:\n{} has \n{}bytes\nHexDump:\n{}", amsTCPPacket, bytes.length, amsTCPPacket.dump());
     }
@@ -73,7 +81,7 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
     @Test
     public void encode() throws Exception {
         ArrayList<Object> out = new ArrayList<>();
-        SUT.encode(null, amsPacketByteBuf, out);
+        SUT.encode(channelHandlerContextMock, Unpooled.wrappedBuffer(amsPacketBytes), out);
         assertEquals(1, out.size());
         assertThat(out, hasSize(1));
     }
@@ -81,24 +89,24 @@ public class Payload2TcpProtocolTest extends AbstractProtocolTest {
     @Test
     public void decode() throws Exception {
         ArrayList<Object> out = new ArrayList<>();
-        SUT.decode(null, amsTCPPacket.getByteBuf(), out);
+        SUT.decode(channelHandlerContextMock, amsTCPPacket.getByteBuf(), out);
         assertThat(out, hasSize(1));
     }
 
     @Test
     public void roundTrip() throws Exception {
         ArrayList<Object> outbound = new ArrayList<>();
-        SUT.encode(null, amsPacketByteBuf, outbound);
+        SUT.encode(channelHandlerContextMock, Unpooled.wrappedBuffer(amsPacketBytes), 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);
+        SUT.decode(channelHandlerContextMock, 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));
+        assertByteBufferEquals(Unpooled.wrappedBuffer(this.amsPacketBytes), inboundAmsPacket);
     }
 }
\ No newline at end of file

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

[incubator-plc4x] 03/05: proberly release used bytebuffers

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 856878a253b8f7548a125629d3b68959281bb2dd
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 15:48:19 2018 +0100

    proberly release used bytebuffers
---
 .../java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java  | 1 +
 .../java/org/apache/plc4x/java/ads/protocol/Payload2TcpProtocol.java     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
index 5f1d04b..30a166c 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
@@ -41,6 +41,7 @@ public class Payload2SerialProtocol extends MessageToMessageCodec<ByteBuf, ByteB
         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
+        amsPacket.release();
     }
 
     @Override
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
index 8b723e8..a12c867 100644
--- 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
@@ -37,6 +37,7 @@ public class Payload2TcpProtocol extends MessageToMessageCodec<ByteBuf, ByteBuf>
     @Override
     protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf amsPacket, List<Object> out) throws Exception {
         out.add(AmsTCPPacket.of(UserData.of(amsPacket)).getByteBuf());
+        amsPacket.release();
     }
 
     @SuppressWarnings("unchecked")

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

[incubator-plc4x] 02/05: removed obsolete comment

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 93154f85383ca7eb51c8782a742dbaf939e4f3aa
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 15:30:21 2018 +0100

    removed obsolete comment
---
 .../java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java  | 1 -
 1 file changed, 1 deletion(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
index 046a4bc..5f1d04b 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/protocol/Payload2SerialProtocol.java
@@ -63,7 +63,6 @@ public class Payload2SerialProtocol extends MessageToMessageCodec<ByteBuf, ByteB
 
         switch (magicCookie.getAsInt()) {
             case AmsSerialFrame.ID:
-                // This is a lazy implementation. we just reuse the tcp implementation
                 AmsSerialFrame amsSerialFrame = AmsSerialFrame.of(magicCookie, transmitterAddress, receiverAddress, fragmentNumber, userDataLength, userData, crc);
                 LOGGER.debug("Ams Serial Frame received {}", amsSerialFrame);
                 out.add(userData.getByteBuf());

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