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/12/14 11:22:39 UTC
[plc4x] 01/02: feat(bacnet): implemented BVLCRegisterForeignDevice
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 52cd8ac8678eaeb9b47978a57616f1dda8a6f0d2
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Dec 14 11:26:03 2021 +0100
feat(bacnet): implemented BVLCRegisterForeignDevice
---
.../readwrite/model/BVLCRegisterForeignDevice.go | 23 +++++++++++++++++++++-
.../resources/protocols/bacnetip/bacnetip.mspec | 2 ++
.../plc4x/java/bacnetip/RandomPackagesTest.java | 21 +++++++++++++++++++-
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BVLCRegisterForeignDevice.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BVLCRegisterForeignDevice.go
index eba98f6..fc7c1d8 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BVLCRegisterForeignDevice.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BVLCRegisterForeignDevice.go
@@ -21,6 +21,7 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/plc4go/spi/utils"
+ "github.com/pkg/errors"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -28,6 +29,7 @@ import (
// The data-structure of this message
type BVLCRegisterForeignDevice struct {
*BVLC
+ Ttl uint16
}
// The corresponding interface
@@ -47,8 +49,9 @@ func (m *BVLCRegisterForeignDevice) BvlcFunction() uint8 {
func (m *BVLCRegisterForeignDevice) InitializeParent(parent *BVLC) {
}
-func NewBVLCRegisterForeignDevice() *BVLC {
+func NewBVLCRegisterForeignDevice(ttl uint16) *BVLC {
child := &BVLCRegisterForeignDevice{
+ Ttl: ttl,
BVLC: NewBVLC(),
}
child.Child = child
@@ -85,6 +88,9 @@ func (m *BVLCRegisterForeignDevice) LengthInBits() uint16 {
func (m *BVLCRegisterForeignDevice) LengthInBitsConditional(lastItem bool) uint16 {
lengthInBits := uint16(m.ParentLengthInBits())
+ // Simple field (ttl)
+ lengthInBits += 16
+
return lengthInBits
}
@@ -97,12 +103,20 @@ func BVLCRegisterForeignDeviceParse(readBuffer utils.ReadBuffer) (*BVLC, error)
return nil, pullErr
}
+ // Simple Field (ttl)
+ _ttl, _ttlErr := readBuffer.ReadUint16("ttl", 16)
+ if _ttlErr != nil {
+ return nil, errors.Wrap(_ttlErr, "Error parsing 'ttl' field")
+ }
+ ttl := _ttl
+
if closeErr := readBuffer.CloseContext("BVLCRegisterForeignDevice"); closeErr != nil {
return nil, closeErr
}
// Create a partially initialized instance
_child := &BVLCRegisterForeignDevice{
+ Ttl: ttl,
BVLC: &BVLC{},
}
_child.BVLC.Child = _child
@@ -115,6 +129,13 @@ func (m *BVLCRegisterForeignDevice) Serialize(writeBuffer utils.WriteBuffer) err
return pushErr
}
+ // Simple Field (ttl)
+ ttl := uint16(m.Ttl)
+ _ttlErr := writeBuffer.WriteUint16("ttl", 16, (ttl))
+ if _ttlErr != nil {
+ return errors.Wrap(_ttlErr, "Error serializing 'ttl' field")
+ }
+
if popErr := writeBuffer.PopContext("BVLCRegisterForeignDevice"); popErr != nil {
return popErr
}
diff --git a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
index 65ff1a4..a3c3657 100644
--- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
+++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
@@ -36,6 +36,7 @@
[simple NPDU('bvlcLength - 10') npdu ]
]
['0x05' BVLCRegisterForeignDevice
+ [simple uint 16 ttl]
]
['0x06' BVLCReadForeignDeviceTable
]
@@ -352,6 +353,7 @@
[simple BACnetContextTagPropertyIdentifier('1', 'BACnetDataType.BACNET_PROPERTY_IDENTIFIER') propertyIdentifier ]
// TODO: check if this is the right identifier type and size
[optional uint 32 arrayIndex 'propertyIdentifier.value == BACnetPropertyIdentifier.VALUE_SOURCE_ARRAY']
+ // TODO: here comes data always starting with a BACnetContextTag number 3, value 6, then the data depending on the type and then a termination by BACnetContextTag number 3, value 7
]
['0x0E' BACnetServiceAckReadPropertyMultiple
diff --git a/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/RandomPackagesTest.java b/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/RandomPackagesTest.java
index fb1913c..1ae6eaf 100644
--- a/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/RandomPackagesTest.java
+++ b/sandbox/test-java-bacnetip-driver/src/test/java/org/apache/plc4x/java/bacnetip/RandomPackagesTest.java
@@ -467,8 +467,27 @@ public class RandomPackagesTest {
assertEquals(0, baCnetServiceAckReadProperty.getObjectIdentifier().getInstanceNumber());
assertEquals(BACnetPropertyIdentifier.PRIORITY_ARRAY, baCnetServiceAckReadProperty.getPropertyIdentifier().getValue());
// TODO: here the array is missing
+ }),
+ DynamicTest.dynamicTest("BACnet Virtual Link Control BVLC Function Register-Foreign-Device",
+ () -> {
+ BVLC bvlc = pcapEvaluator.nextBVLC();
+ dump(bvlc);
+ BVLCRegisterForeignDevice bvlcRegisterForeignDevice = (BVLCRegisterForeignDevice) bvlc;
+ assertEquals(60000, bvlcRegisterForeignDevice.getTtl());
+ }),
+ DynamicTest.dynamicTest("Unconfirmed-REQ who-Is 12345 12345",
+ () -> {
+ // this is a repeat from the package above
+ pcapEvaluator.skipPackages(1);
+ }),
+ DynamicTest.dynamicTest("BACnet Virtual Link Control BVLC Function BVLC-Result",
+ () -> {
+ BVLC bvlc = pcapEvaluator.nextBVLC();
+ dump(bvlc);
+ BVLCRegisterForeignDevice bvlcRegisterForeignDevice = (BVLCRegisterForeignDevice) bvlc;
+ assertEquals(60000, bvlcRegisterForeignDevice.getTtl());
})
- );
+ );
}
@TestFactory