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 2021/11/30 12:38:10 UTC
[plc4x] 01/02: fix(plc4j/codegen): treat 0xff als valid value constant for byte
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
commit 5e6cc92778de9321cad08e7da78b1e5768bce708
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Nov 30 13:20:57 2021 +0100
fix(plc4j/codegen): treat 0xff als valid value constant for byte
---
.../org/apache/plc4x/java/spi/codegen/fields/FieldReaderVirtual.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderVirtual.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderVirtual.java
index 4468eff..07c9620 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderVirtual.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderVirtual.java
@@ -36,7 +36,8 @@ public class FieldReaderVirtual<T> implements FieldCommons {
} else if (type == byte.class) {
Number valueExpressionNumber = (Number) valueExpression;
long longValue = valueExpressionNumber.longValue();
- if ((byte) longValue != longValue) {
+ // 0xFF is a special case and a legit value for (unsigned) byte
+ if ((byte) longValue != longValue && longValue != 0xFF) {
throw new ArithmeticException("byte overflow");
}
return (T) (Byte) valueExpressionNumber.byteValue();