You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2019/01/16 16:09:23 UTC
[incubator-plc4x] branch rel/0.3 updated: Fixed failing Test.
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch rel/0.3
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/rel/0.3 by this push:
new fd7842f Fixed failing Test.
fd7842f is described below
commit fd7842f13ae183635215894f88baee018851fbc4
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Wed Jan 16 17:03:41 2019 +0100
Fixed failing Test.
---
.../src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java | 4 +++-
.../groovy/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolSpec.groovy | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
index 201b69f..d64ed82 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
@@ -195,7 +195,9 @@ public class Plc4XS7Protocol extends PlcMessageToMessageCodec<S7Message, PlcRequ
// The number of elements provided in the request must match the number defined in the field, or
// bad things are going to happen.
- if (writeRequest.getNumberOfValues(fieldName) != s7Field.getNumElements()) {
+ // An exception is STRINGS, as they are implemented as byte arrays
+ if (s7Field.getDataType() != TransportSize.STRING &&
+ writeRequest.getNumberOfValues(fieldName) != s7Field.getNumElements()) {
throw new PlcException("The number of values provided doesn't match the number specified by the field.");
}
VarParameterItem varParameterItem = new S7AnyVarParameterItem(
diff --git a/plc4j/protocols/s7/src/test/groovy/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolSpec.groovy b/plc4j/protocols/s7/src/test/groovy/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolSpec.groovy
index 75f7835..b6b5a7f 100644
--- a/plc4j/protocols/s7/src/test/groovy/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolSpec.groovy
+++ b/plc4j/protocols/s7/src/test/groovy/org/apache/plc4x/java/s7/netty/Plc4XS7ProtocolSpec.groovy
@@ -138,7 +138,7 @@ class Plc4XS7ProtocolSpec extends Specification {
"%Q3:ULINT" | (long) 4223123 || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.ULINT
"%Q3:REAL" | (float) 42.312 || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.REAL
"%Q3:LREAL" | (double) 42.32 || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.LREAL
- "%Q3:STRING" | "foo" || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.STRING
+ "%Q3:STRING" | "foo" || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 256 | TransportSize.STRING
"%Q3:WSTRING" | "bar" || true | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.WSTRING
//"%Q3:DATE_AND_TIME" | LocalDateTime.now() || false | MemoryArea.OUTPUTS | 0 | 3 | 0 | 1 | TransportSize.DATE_AND_TIME
}