sruehl commented on a change in pull request #25: PLC4X-57 Bugfix
URL: https://github.com/apache/incubator-plc4x/pull/25#discussion_r220877440
##########
File path:
plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
##########
@@ -420,22 +423,29 @@ private PlcResponse decodeReadResponse(S7ResponseMessage
responseMessage, PlcReq
FieldItem fieldItem = null;
ByteBuf data = Unpooled.wrappedBuffer(payloadItem.getData());
if (responseCode == PlcResponseCode.OK) {
+ // TODO 2018-09-27 jf: array returning only implemented for
BOOL, BYTE, INTEGERS, FP
+ // not for CHARS & STRINGS and not for all other bit-strings
except for BYTE
switch (field.getDataType()) {
// -----------------------------------------
// Bit
// -----------------------------------------
case BOOL: {
- byte byteValue = data.readByte();
- fieldItem = new
S7BooleanFieldItem(field.getDataType(),byteValue != 0x00);
+ Boolean[] booleans = readAllValues(field, i ->
data.readByte() != 0x00).toArray(new Boolean[field.getNumElements()]);
+ fieldItem = new
S7BooleanFieldItem(field.getDataType(),booleans);
break;
}
// -----------------------------------------
// Bit-strings
// -----------------------------------------
case BYTE: { // 1 byte
- BitSet bitSet = BitSet.valueOf(new
byte[]{data.readByte()});
- Boolean[] booleanValues = new Boolean[8];
- for(int i = 0; i < 8; i++) {
+ Byte[] bytes = readAllValues(field, i ->
data.readByte()).toArray(new Byte[field.getNumElements()]);
Review comment:
maybe we should check `data` if we can read this amount of bytes. This could
maybe be done generic if we pass the data variable and the method reference:
`data::readByte` or something like that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services