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 2022/07/21 09:22:24 UTC
[plc4x] 03/05: fix(cbus): fixed issue with GAVValuesCurrent, GAVValuesStored and GAVPhysicalAddress
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 e90fdc65b4741423b84bd3cee10ef8e569761a62
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Jul 20 11:41:43 2022 +0200
fix(cbus): fixed issue with GAVValuesCurrent, GAVValuesStored and GAVPhysicalAddress
---
.../model/IdentifyReplyCommandGAVPhysicalAddresses.go | 2 +-
.../model/IdentifyReplyCommandGAVValuesCurrent.go | 2 +-
.../readwrite/model/IdentifyReplyCommandGAVValuesStored.go | 2 +-
.../org/apache/plc4x/java/cbus/RandomPackagesTest.java | 14 ++++++++++++++
.../c-bus/src/main/resources/protocols/cbus/c-bus.mspec | 6 +++---
5 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVPhysicalAddresses.go b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVPhysicalAddresses.go
index 2654d0189..94f2fe69f 100644
--- a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVPhysicalAddresses.go
+++ b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVPhysicalAddresses.go
@@ -135,7 +135,7 @@ func IdentifyReplyCommandGAVPhysicalAddressesParse(readBuffer utils.ReadBuffer,
currentPos := positionAware.GetPos()
_ = currentPos
// Byte Array field (values)
- numberOfBytesvalues := int(uint16(16))
+ numberOfBytesvalues := int(numBytes)
values, _readArrayErr := readBuffer.ReadByteArray("values", numberOfBytesvalues)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'values' field of IdentifyReplyCommandGAVPhysicalAddresses")
diff --git a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesCurrent.go b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesCurrent.go
index 5f9a02fd4..160384f03 100644
--- a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesCurrent.go
+++ b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesCurrent.go
@@ -135,7 +135,7 @@ func IdentifyReplyCommandGAVValuesCurrentParse(readBuffer utils.ReadBuffer, attr
currentPos := positionAware.GetPos()
_ = currentPos
// Byte Array field (values)
- numberOfBytesvalues := int(uint16(16))
+ numberOfBytesvalues := int(numBytes)
values, _readArrayErr := readBuffer.ReadByteArray("values", numberOfBytesvalues)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'values' field of IdentifyReplyCommandGAVValuesCurrent")
diff --git a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesStored.go b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesStored.go
index e26147ea6..5ef0d99d9 100644
--- a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesStored.go
+++ b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandGAVValuesStored.go
@@ -135,7 +135,7 @@ func IdentifyReplyCommandGAVValuesStoredParse(readBuffer utils.ReadBuffer, attri
currentPos := positionAware.GetPos()
_ = currentPos
// Byte Array field (values)
- numberOfBytesvalues := int(uint16(16))
+ numberOfBytesvalues := int(numBytes)
values, _readArrayErr := readBuffer.ReadByteArray("values", numberOfBytesvalues)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'values' field of IdentifyReplyCommandGAVValuesStored")
diff --git a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
index 93caab331..2025ca754 100644
--- a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
+++ b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
@@ -357,4 +357,18 @@ public class RandomPackagesTest {
assertMessageMatches(bytes, msg);
}
+ @Test
+ void gavValuesCurrentReply() throws Exception {
+ byte[] bytes = "w.860C02008A08000000C8000000000012\r\n".getBytes(StandardCharsets.UTF_8);
+ ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+ cBusOptions = new CBusOptions(false, false, false, false, false, false, false, false, true);
+ requestContext = new RequestContext(false, false, true);
+ CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
+ assertThat(msg).isNotNull();
+ System.out.println(msg);
+ System.out.println(((ReplyEncodedReply) ((ReplyOrConfirmationReply) ((ReplyOrConfirmationConfirmation) ((CBusMessageToClient) msg).getReply()).getEmbeddedReply()).getReply()).getEncodedReply());
+
+ assertMessageMatches(bytes, msg);
+ }
+
}
diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
index 878493db8..70fc1962c 100644
--- a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
+++ b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
@@ -1034,13 +1034,13 @@
[const byte v 0x56 ]
]
['GAVValuesCurrent' IdentifyReplyCommandGAVValuesCurrent
- [array byte values count '16' ] // TODO: check datatype
+ [array byte values count 'numBytes' ] // TODO: check datatype
]
['GAVValuesStored' IdentifyReplyCommandGAVValuesStored
- [array byte values count '16' ] // TODO: check datatype
+ [array byte values count 'numBytes' ] // TODO: check datatype
]
['GAVPhysicalAddresses' IdentifyReplyCommandGAVPhysicalAddresses
- [array byte values count '16' ] // TODO: check datatype
+ [array byte values count 'numBytes' ] // TODO: check datatype
]
['LogicalAssignment' IdentifyReplyCommandLogicalAssignment
[array LogicAssignment logicAssigment count 'numBytes' ]