This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch feature/implement-df1-driver in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 1e73e208c9bd96db506d4752d51b7711d36211b7 Merge: 376101d c495592 Author: Christofer Dutz <[email protected]> AuthorDate: Wed Aug 7 16:27:21 2019 +0200 Merge branch 'feature/implement-df1-driver' of github.com:vemmert/plc4x into feature/implement-df1-driver .../java/base/connection/SerialChannelFactory.java | 5 ++-- pom.xml | 2 +- sandbox/test-java-df1-driver/pom.xml | 17 ++++++++++- .../org/apache/plc4x/java/df1/DF1PlcDriver.java | 4 +-- .../java/org/apache/plc4x/java/df1/Df1Field.java | 33 ++++++++++++++++++++ .../plc4x/java/df1/protocol/Df1Protocol.java | 10 +++++++ .../plc4x/java/df1/protocol/Plc4XDf1Protocol.java | 30 +++++++++++++++++-- .../plc4x/java/df1/util/Df1FieldHandler.java | 3 +- .../apache/plc4x/java/df1/DF1PlcDriverTest.java | 26 ++++++++++++++++ .../plc4x/protocol/df1/BenchmarkManualDf1.java | 35 ++++++++++++---------- .../apache/plc4x/protocol/df1/EndToEndTest.java | 6 ++-- 11 files changed, 143 insertions(+), 28 deletions(-) diff --cc sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java index 31a9024,1015a7e..92ae07d --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java +++ b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java @@@ -50,14 -50,18 +50,18 @@@ public class Df1Protocol extends PlcByt } @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + } + + @Override protected void encode(ChannelHandlerContext ctx, DF1Symbol msg, ByteBuf out) throws Exception { // Remember the size of the request as we need this to decode the response. - if(msg instanceof DF1SymbolMessageFrameStart) { - DF1SymbolMessageFrameStart frameStart = (DF1SymbolMessageFrameStart) msg; - if(frameStart.getCommand() instanceof DF1ReadRequest) { - DF1ReadRequest readRequest = (DF1ReadRequest) frameStart.getCommand(); - int transactionCounter = readRequest.getTransactionCounter(); - readRequestSizes.put(transactionCounter, readRequest.getSize()); + if(msg instanceof DF1SymbolMessageFrame) { + DF1SymbolMessageFrame frame = (DF1SymbolMessageFrame) msg; + if(frame.getCommand() instanceof DF1UnprotectedReadRequest) { + DF1UnprotectedReadRequest unprotectedReadRequest = (DF1UnprotectedReadRequest) frame.getCommand(); + int transactionCounter = unprotectedReadRequest.getTransactionCounter(); + readRequestSizes.put(transactionCounter, unprotectedReadRequest.getSize()); } } diff --cc sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java index e35fcce,4a52437..08b7b89 --- a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java +++ b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java @@@ -24,10 -24,8 +24,9 @@@ import org.apache.plc4x.java.api.PlcCon import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.api.messages.PlcReadRequest; import org.apache.plc4x.java.api.messages.PlcReadResponse; +import org.junit.jupiter.api.Test; import java.util.concurrent.TimeUnit; - /** * TODO write comment * @@@ -36,11 -34,12 +35,12 @@@ */ public class EndToEndTest { - @org.junit.Test + @Test public void helloDf1() { - try (PlcConnection plcConnection = new PlcDriverManager().getConnection("df1:serial///dev/cu.usbserial-AL065SUZ")) { + try (PlcConnection plcConnection = new PlcDriverManager().getConnection("df1:serial:///COM4")) { PlcReadRequest request = plcConnection.readRequestBuilder() .addItem("erstes", "17:INTEGER") + .addItem("zweites", "17:INTEGER") .build(); PlcReadResponse response = request.execute().get(1, TimeUnit.SECONDS);
