This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 531aba9 plc4j: fixed build
531aba9 is described below
commit 531aba92b4cce51eb704139c68e63ab07261a29a
Author: Sebastian Rühl <[email protected]>
AuthorDate: Tue Apr 20 09:32:47 2021 +0200
plc4j: fixed build
---
.../src/main/resources/templates/go/model-template.go.ftlh | 6 ++++--
.../main/resources/templates/java/io-template.java.ftlh | 6 ++++--
go.mod | 2 +-
go.sum | 2 ++
.../apache/plc4x/java/bacnetip/ManualBacNetDecoder.java | 3 ++-
.../org/apache/plc4x/java/df1/protocol/Df1Protocol.java | 7 ++++---
.../main/java/org/apache/plc4x/java/df1/util/DF1Utils.java | 14 +++++++-------
.../test/java/org/apache/plc4x/protocol/df1/IOTest.java | 5 +++--
.../enrich/knxnetip/ets5/Ets5DataEnrichment.java | 3 ++-
9 files changed, 29 insertions(+), 19 deletions(-)
diff --git
a/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
b/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
index e659504..b6b222c 100644
---
a/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
+++
b/build-utils/language-go/src/main/resources/templates/go/model-template.go.ftlh
@@ -608,7 +608,8 @@ func ${type.name}Parse(io utils.ReadBuffer<#if
type.parserArguments?has_content>
{
checksum =
${helper.getNullValueForTypeReference(checksumField.type)}
// Create an array of all the bytes read in this message
element so far.
- checksumRawData := io.getBytes(startPos,
io.GetPos())<@emitImport import="io" />
+ <#--TODO: we need a buffered reader so we can rewind here. ATM
casting to an byteBasedReader but this will break on non buffered -->
+ checksumRawData := io.(ReadBufferByteBased).getBytes(startPos,
io.GetPos())<@emitImport import="io" />
checksumRef, _checksumRefErr :=
${helper.getReadBufferReadMethodCall("checksum", simpleTypeReference)}
if _checksumRefErr != nil {
return nil, errors.Wrap(_checksumRefErr, "Error parsing
'checksum' field")<@emitImport import="github.com/pkg/errors" />
@@ -961,7 +962,8 @@ func (m *${type.name}) Serialize(io utils.WriteBuffer<#if
helper.getSerializerAr
{
_checksum :=
${helper.getLanguageTypeNameForField(field)}(${helper.getNullValueForTypeReference(checksumField.type)})
// Create an array of all the bytes written in this message
element so far.
- checksumRawData []uint8 = io.getBytes(startPos,
io.GetPos())<@emitImport import="io" />
+ <#--TODO: we need a buffered writer so we can rewind here. ATM
casting to an byteBasedReader but this will break on non buffered -->
+ checksumRawData []uint8 =
io.(utils.WriteBufferByteBased).getBytes(startPos, io.GetPos())<@emitImport
import="io" />
_checksum =
${helper.getLanguageTypeNameForField(field)}(${helper.toSerializationExpression(checksumField,
checksumField.checksumExpression, type.parserArguments)})
_checksumErr :=
${helper.getWriteBufferWriteMethodCall("checksum", simpleTypeReference,
"(_checksum)", field)}
if _elementErr != nil {
diff --git
a/build-utils/language-java/src/main/resources/templates/java/io-template.java.ftlh
b/build-utils/language-java/src/main/resources/templates/java/io-template.java.ftlh
index 68c0865..7c10357 100644
---
a/build-utils/language-java/src/main/resources/templates/java/io-template.java.ftlh
+++
b/build-utils/language-java/src/main/resources/templates/java/io-template.java.ftlh
@@ -228,7 +228,8 @@ public class ${type.name}IO implements <#if outputFlavor !=
"passive">MessageIO<
{
${helper.getLanguageTypeNameForField(field)} checksum =
${helper.getNullValueForTypeReference(checksumField.type)};
// Create an array of all the bytes read in this message element
so far.
- byte[] checksumRawData = io.getBytes(startPos, io.getPos());
+ <#--TODO: we need a buffered reader so we can rewind here. ATM
casting to an byteBasedReader but this will break on non buffered -->
+ byte[] checksumRawData =
((ReadBufferByteBased)io).getBytes(startPos, io.getPos());
${helper.getLanguageTypeNameForField(field)} checksumRef =
${helper.getReadBufferReadMethodCall("checksum", simpleTypeReference, "",
checksumField)};
checksum = (${helper.getLanguageTypeNameForField(field)})
(${helper.toParseExpression(checksumField, checksumField.checksumExpression,
type.parserArguments)});
if(checksum != checksumRef) {
@@ -470,7 +471,8 @@ public class ${type.name}IO implements <#if outputFlavor !=
"passive">MessageIO<
{
${helper.getLanguageTypeNameForField(field)} _checksum =
${helper.getNullValueForTypeReference(checksumField.type)};
// Create an array of all the bytes written in this message
element so far.
- byte[] checksumRawData = io.getBytes(startPos, io.getPos());
+ <#--TODO: we need a buffered writer so we can rewind here. ATM
casting to an byteBasedReader but this will break on non buffered -->
+ byte[] checksumRawData =
((WriteBufferByteBased)io).getBytes(startPos, io.getPos());
_checksum = (${helper.getLanguageTypeNameForField(field)})
(${helper.toSerializationExpression(checksumField,
checksumField.checksumExpression, type.parserArguments)});
${helper.getWriteBufferWriteMethodCall("checksum",
simpleTypeReference, "(_checksum)", field)};
}
diff --git a/go.mod b/go.mod
index cab7d85..96b3e97 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,6 @@ module github.com/apache/plc4x
go 1.15
require (
- github.com/apache/plc4x/plc4go v0.0.0-20210419161206-de2ecac62cce //
indirect
+ github.com/apache/plc4x/plc4go v0.0.0-20210419213911-a28fac5a883e //
indirect
github.com/sirupsen/logrus v1.7.0 // indirect
)
diff --git a/go.sum b/go.sum
index 25fb7d0..8be0f96 100644
--- a/go.sum
+++ b/go.sum
@@ -92,6 +92,8 @@ github.com/apache/plc4x/plc4go
v0.0.0-20210419100902-f62f7dd9c377 h1:fFZl6lI4JFM
github.com/apache/plc4x/plc4go v0.0.0-20210419100902-f62f7dd9c377/go.mod
h1:d7O6kgWHhwFxXbMbl1DSu55qCYcQz9uwjdsSSJOEA/4=
github.com/apache/plc4x/plc4go v0.0.0-20210419161206-de2ecac62cce
h1:6niN+3NLO6jQxXPhr6R9YBAloipJzajur6GVlGAhvBg=
github.com/apache/plc4x/plc4go v0.0.0-20210419161206-de2ecac62cce/go.mod
h1:NqpWaMMhsu3sTm418XwsUWgmY7e2zjgpRMyddBUwmGk=
+github.com/apache/plc4x/plc4go v0.0.0-20210419213911-a28fac5a883e
h1:RH0AQ+AnzYJKzGXUUTlA6BhpoaZehtyI0gxUp+FUZeU=
+github.com/apache/plc4x/plc4go v0.0.0-20210419213911-a28fac5a883e/go.mod
h1:NqpWaMMhsu3sTm418XwsUWgmY7e2zjgpRMyddBUwmGk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod
h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.1/go.mod
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnephin/pflag v1.0.7/go.mod
h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
diff --git
a/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/ManualBacNetDecoder.java
b/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/ManualBacNetDecoder.java
index 3a1fa2b..0292b2c 100644
---
a/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/ManualBacNetDecoder.java
+++
b/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/ManualBacNetDecoder.java
@@ -22,12 +22,13 @@ import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.bacnetip.readwrite.BVLC;
import org.apache.plc4x.java.bacnetip.readwrite.io.BVLCIO;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
+import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
public class ManualBacNetDecoder {
public static void main(String[] args) throws Exception {
final byte[] bytes =
Hex.decodeHex("810a002b01040205790109011c020000142c000002f93a06b24e09552e44434a00002f096f2e8204002f4f");
- ReadBuffer readBuffer = new ReadBuffer(bytes);
+ ReadBuffer readBuffer = new ReadBufferByteBased(bytes);
final BVLC packet = BVLCIO.staticParse(readBuffer);
System.out.println(packet);
}
diff --git
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
index f8272fc..2ceb82c 100644
---
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
@@ -28,7 +28,8 @@ import org.apache.plc4x.java.df1.readwrite.DF1Symbol;
import org.apache.plc4x.java.df1.readwrite.DF1SymbolMessageFrame;
import org.apache.plc4x.java.df1.readwrite.io.DF1SymbolIO;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
-import org.apache.plc4x.java.spi.generation.WriteBuffer;
+import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
+import org.apache.plc4x.java.spi.generation.WriteBufferByteBased;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +61,7 @@ public class Df1Protocol extends
ByteToMessageCodec<DF1Command> {
DF1SymbolMessageFrame frame = new DF1SymbolMessageFrame(remoteAddr,
localAddr, msg);
// Serialize the message
- WriteBuffer writeBuffer = new WriteBuffer(frame.getLengthInBytes(),
false);
+ WriteBufferByteBased writeBuffer = new
WriteBufferByteBased(frame.getLengthInBytes(), false);
DF1SymbolIO.staticSerialize(writeBuffer, frame);
byte[] data = writeBuffer.getData();
@@ -138,7 +139,7 @@ public class Df1Protocol extends
ByteToMessageCodec<DF1Command> {
// Parse the message received from the DF1 device
byte[] data = new byte[in.readableBytes()];
in.readBytes(data);
- ReadBuffer readBuffer = new ReadBuffer(data, false);
+ ReadBuffer readBuffer = new ReadBufferByteBased(data, false);
resp = DF1SymbolIO.staticParse(readBuffer);
diff --git
a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/util/DF1Utils.java
b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/util/DF1Utils.java
index 91b41e8..49b8063 100644
---
a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/util/DF1Utils.java
+++
b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/util/DF1Utils.java
@@ -21,9 +21,7 @@ package org.apache.plc4x.java.df1.util;
import org.apache.plc4x.java.df1.readwrite.DF1Command;
import org.apache.plc4x.java.df1.readwrite.DF1UnprotectedReadRequest;
import org.apache.plc4x.java.df1.readwrite.DF1UnprotectedReadResponse;
-import org.apache.plc4x.java.spi.generation.ParseException;
-import org.apache.plc4x.java.spi.generation.ReadBuffer;
-import org.apache.plc4x.java.spi.generation.WriteBuffer;
+import org.apache.plc4x.java.spi.generation.*;
public class DF1Utils {
@@ -36,7 +34,7 @@ public class DF1Utils {
if(command instanceof DF1UnprotectedReadRequest) {
try {
DF1UnprotectedReadRequest unprotectedReadRequest =
(DF1UnprotectedReadRequest) command;
- WriteBuffer writeBuffer = new WriteBuffer(10, false);
+ WriteBufferByteBased writeBuffer = new
WriteBufferByteBased(10, false);
writeBuffer.writeUnsignedShort(8, destinationAddress);
writeBuffer.writeUnsignedShort(8, sourceAddress);
writeBuffer.writeUnsignedShort(8, command.getCommandCode());
@@ -56,7 +54,7 @@ public class DF1Utils {
DF1UnprotectedReadResponse unprotectedReadResponseCommand =
(DF1UnprotectedReadResponse) command;
try {
// TODO: size has to be dependent on actual size requested
- WriteBuffer writeBuffer = new WriteBuffer(10, false);
+ WriteBufferByteBased writeBuffer = new
WriteBufferByteBased(10, false);
writeBuffer.writeUnsignedShort(8, destinationAddress);
writeBuffer.writeUnsignedShort(8, sourceAddress);
writeBuffer.writeUnsignedShort(8, command.getCommandCode());
@@ -87,10 +85,11 @@ public class DF1Utils {
}
public static boolean dataTerminate(ReadBuffer io) {
+ ReadBufferByteBased rbbb = (ReadBufferByteBased)io;
try {
// The byte sequence 0x10 followed by 0x03 indicates the end of
the message,
// so if we would read this, we abort the loop and stop reading
data.
- if ((io.peekByte(0) == (byte) 0x10) && (io.peekByte(1) == (byte)
0x03)) {
+ if ((rbbb.peekByte(0) == (byte) 0x10) && (rbbb.peekByte(1) ==
(byte) 0x03)) {
return true;
}
} catch (ParseException e) {
@@ -100,10 +99,11 @@ public class DF1Utils {
}
public static short readData(ReadBuffer io) {
+ ReadBufferByteBased rbbb = (ReadBufferByteBased)io;
try {
// If we read a 0x10, this has to be followed by another 0x10,
which is how
// this value is escaped in DF1, so if we encounter two 0x10, we
simply ignore the first.
- if ((io.peekByte(0) == (byte) 0x10) && (io.peekByte(1) == 0x10)) {
+ if ((rbbb.peekByte(0) == (byte) 0x10) && (rbbb.peekByte(1) ==
0x10)) {
io.readByte(8);
}
return io.readUnsignedShort(8);
diff --git
a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/IOTest.java
b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/IOTest.java
index 5f8a7b7..c6cf5f7 100644
---
a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/IOTest.java
+++
b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/IOTest.java
@@ -25,6 +25,7 @@ import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.df1.readwrite.DF1Symbol;
import org.apache.plc4x.java.df1.readwrite.io.DF1SymbolIO;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
+import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
import org.junit.jupiter.api.Test;
public class IOTest {
@@ -33,7 +34,7 @@ public class IOTest {
public void testXml() throws Exception {
byte[] rData = Hex.decodeHex("10020900010001001100021003546F");
ObjectMapper mapper = new XmlMapper().enableDefaultTyping();
- ReadBuffer rBuf = new ReadBuffer(rData, false);
+ ReadBuffer rBuf = new ReadBufferByteBased(rData, false);
DF1Symbol symbol = new DF1SymbolIO().parse(rBuf);
String xml =
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(symbol);
System.out.println(xml);
@@ -45,7 +46,7 @@ public class IOTest {
public void testJson() throws Exception {
byte[] rData = Hex.decodeHex("10020A0941000100FFFF1003DFB9");
ObjectMapper mapper = new ObjectMapper().enableDefaultTyping();
- ReadBuffer rBuf = new ReadBuffer(rData, false);
+ ReadBuffer rBuf = new ReadBufferByteBased(rData, false);
DF1Symbol symbol = new DF1SymbolIO().parse(rBuf);
String json =
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(symbol);
System.out.println(json);
diff --git
a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/enrich/knxnetip/ets5/Ets5DataEnrichment.java
b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/enrich/knxnetip/ets5/Ets5DataEnrichment.java
index 8756b70..44e6026 100644
---
a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/enrich/knxnetip/ets5/Ets5DataEnrichment.java
+++
b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/enrich/knxnetip/ets5/Ets5DataEnrichment.java
@@ -27,6 +27,7 @@ import org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress;
import org.apache.plc4x.java.knxnetip.readwrite.io.KnxDatapointIO;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
+import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
import org.apache.streampipes.model.runtime.Event;
import org.apache.streampipes.wrapper.context.EventProcessorRuntimeContext;
import org.apache.streampipes.wrapper.routing.SpOutputCollector;
@@ -62,7 +63,7 @@ public class Ets5DataEnrichment implements
EventProcessor<Ets5DataEnrichmentPara
String hexEncodedRawData =
event.getFieldBySelector(this.payloadIdFieldName).getAsPrimitive().getAsString();
// Convert the HEX-encoded data back to byte[]
byte[] rawData = Hex.decodeHex(hexEncodedRawData);
- ReadBuffer rawDataReader = new ReadBuffer(rawData);
+ ReadBuffer rawDataReader = new ReadBufferByteBased(rawData);
if (groupAddress != null) {
// Decode the raw data.