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/12 15:10:12 UTC
[plc4x] 02/03: fix(c-bus): fixed cal/sal data chaining
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 e94abebf9c5d44a662c44b9eba45db3818a5d9eb
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Jul 12 17:07:23 2022 +0200
fix(c-bus): fixed cal/sal data chaining
- fixed several smaller issues
---
.../cbus/readwrite/model/CALCommandType.go | 34 ++--
.../readwrite/model/CALCommandTypeContainer.go | 48 +++++
plc4go/protocols/cbus/readwrite/model/CALData.go | 71 +++++++-
.../cbus/readwrite/model/CALDataAcknowledge.go | 7 +-
.../cbus/readwrite/model/CALDataGetStatus.go | 7 +-
.../cbus/readwrite/model/CALDataIdentify.go | 7 +-
.../cbus/readwrite/model/CALDataIdentifyReply.go | 7 +-
.../cbus/readwrite/model/CALDataRecall.go | 7 +-
.../protocols/cbus/readwrite/model/CALDataReply.go | 7 +-
.../protocols/cbus/readwrite/model/CALDataReset.go | 7 +-
.../cbus/readwrite/model/CALDataStatus.go | 7 +-
.../cbus/readwrite/model/CALDataStatusExtended.go | 7 +-
.../model/CBusPointToMultiPointCommand.go | 62 ++++++-
.../model/CBusPointToMultiPointCommandStatus.go | 60 +-----
.../model/CBusPointToPointToMultipointCommand.go | 62 ++++++-
.../CBusPointToPointToMultipointCommandNormal.go | 61 +------
.../CBusPointToPointToMultipointCommandStatus.go | 60 +-----
plc4go/protocols/cbus/readwrite/model/Normal.go | 60 +-----
plc4go/protocols/cbus/readwrite/model/SALData.go | 69 ++++++-
.../protocols/cbus/readwrite/model/SALDataOff.go | 7 +-
plc4go/protocols/cbus/readwrite/model/SALDataOn.go | 7 +-
.../cbus/readwrite/model/SALDataRampToLevel.go | 7 +-
.../cbus/readwrite/model/SALDataTerminateRamp.go | 7 +-
.../protocols/cbus/readwrite/model/StaticHelper.go | 25 ++-
.../internal/cbusanalyzer/analyzer.go | 5 +
.../java/cbus/readwrite/utils/StaticHelper.java | 29 ++-
.../apache/plc4x/java/cbus/RandomPackagesTest.java | 201 ++++++++++-----------
.../c-bus/src/test/resources/logback-test.xml | 32 ++++
.../src/main/resources/protocols/cbus/c-bus.mspec | 40 ++--
29 files changed, 584 insertions(+), 426 deletions(-)
diff --git a/plc4go/protocols/cbus/readwrite/model/CALCommandType.go b/plc4go/protocols/cbus/readwrite/model/CALCommandType.go
index 724c35c5f..389441eaa 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALCommandType.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALCommandType.go
@@ -35,13 +35,13 @@ type ICALCommandType interface {
const (
CALCommandType_RESET CALCommandType = 0x0
- CALCommandType_RECALL CALCommandType = 0x0
- CALCommandType_IDENTIFY CALCommandType = 0x1
- CALCommandType_GET_STATUS CALCommandType = 0x2
- CALCommandType_REPLY CALCommandType = 0x3
- CALCommandType_ACKNOWLEDGE CALCommandType = 0x4
- CALCommandType_STATUS CALCommandType = 0x5
- CALCommandType_STATUS_EXTENDED CALCommandType = 0x5
+ CALCommandType_RECALL CALCommandType = 0x1
+ CALCommandType_IDENTIFY CALCommandType = 0x2
+ CALCommandType_GET_STATUS CALCommandType = 0x3
+ CALCommandType_REPLY CALCommandType = 0x4
+ CALCommandType_ACKNOWLEDGE CALCommandType = 0x5
+ CALCommandType_STATUS CALCommandType = 0x6
+ CALCommandType_STATUS_EXTENDED CALCommandType = 0x7
)
var CALCommandTypeValues []CALCommandType
@@ -65,15 +65,19 @@ func CALCommandTypeByValue(value uint8) CALCommandType {
case 0x0:
return CALCommandType_RESET
case 0x1:
- return CALCommandType_IDENTIFY
+ return CALCommandType_RECALL
case 0x2:
- return CALCommandType_GET_STATUS
+ return CALCommandType_IDENTIFY
case 0x3:
- return CALCommandType_REPLY
+ return CALCommandType_GET_STATUS
case 0x4:
- return CALCommandType_ACKNOWLEDGE
+ return CALCommandType_REPLY
case 0x5:
+ return CALCommandType_ACKNOWLEDGE
+ case 0x6:
return CALCommandType_STATUS
+ case 0x7:
+ return CALCommandType_STATUS_EXTENDED
}
return 0
}
@@ -83,6 +87,8 @@ func CALCommandTypeByName(value string) (enum CALCommandType, ok bool) {
switch value {
case "RESET":
enum = CALCommandType_RESET
+ case "RECALL":
+ enum = CALCommandType_RECALL
case "IDENTIFY":
enum = CALCommandType_IDENTIFY
case "GET_STATUS":
@@ -93,6 +99,8 @@ func CALCommandTypeByName(value string) (enum CALCommandType, ok bool) {
enum = CALCommandType_ACKNOWLEDGE
case "STATUS":
enum = CALCommandType_STATUS
+ case "STATUS_EXTENDED":
+ enum = CALCommandType_STATUS_EXTENDED
default:
enum = 0
ok = false
@@ -144,6 +152,8 @@ func (e CALCommandType) PLC4XEnumName() string {
switch e {
case CALCommandType_RESET:
return "RESET"
+ case CALCommandType_RECALL:
+ return "RECALL"
case CALCommandType_IDENTIFY:
return "IDENTIFY"
case CALCommandType_GET_STATUS:
@@ -154,6 +164,8 @@ func (e CALCommandType) PLC4XEnumName() string {
return "ACKNOWLEDGE"
case CALCommandType_STATUS:
return "STATUS"
+ case CALCommandType_STATUS_EXTENDED:
+ return "STATUS_EXTENDED"
}
return ""
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CALCommandTypeContainer.go b/plc4go/protocols/cbus/readwrite/model/CALCommandTypeContainer.go
index b0ea24eb9..ddf8c3434 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALCommandTypeContainer.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALCommandTypeContainer.go
@@ -40,6 +40,7 @@ const (
CALCommandTypeContainer_CALCommandRecall CALCommandTypeContainer = 0x1A
CALCommandTypeContainer_CALCommandIdentify CALCommandTypeContainer = 0x21
CALCommandTypeContainer_CALCommandGetStatus CALCommandTypeContainer = 0x2A
+ CALCommandTypeContainer_CALCommandReply_0Bytes CALCommandTypeContainer = 0x80
CALCommandTypeContainer_CALCommandReply_1Bytes CALCommandTypeContainer = 0x81
CALCommandTypeContainer_CALCommandReply_2Bytes CALCommandTypeContainer = 0x82
CALCommandTypeContainer_CALCommandReply_3Bytes CALCommandTypeContainer = 0x83
@@ -72,6 +73,7 @@ const (
CALCommandTypeContainer_CALCommandReply_30Bytes CALCommandTypeContainer = 0x9E
CALCommandTypeContainer_CALCommandReply_31Bytes CALCommandTypeContainer = 0x9F
CALCommandTypeContainer_CALCommandAcknowledge CALCommandTypeContainer = 0x32
+ CALCommandTypeContainer_CALCommandStatus_0Bytes CALCommandTypeContainer = 0xC0
CALCommandTypeContainer_CALCommandStatus_1Bytes CALCommandTypeContainer = 0xC1
CALCommandTypeContainer_CALCommandStatus_2Bytes CALCommandTypeContainer = 0xC2
CALCommandTypeContainer_CALCommandStatus_3Bytes CALCommandTypeContainer = 0xC3
@@ -103,6 +105,7 @@ const (
CALCommandTypeContainer_CALCommandStatus_29Bytes CALCommandTypeContainer = 0xDD
CALCommandTypeContainer_CALCommandStatus_30Bytes CALCommandTypeContainer = 0xDE
CALCommandTypeContainer_CALCommandStatus_31Bytes CALCommandTypeContainer = 0xDF
+ CALCommandTypeContainer_CALCommandStatusExtended_0Bytes CALCommandTypeContainer = 0xE0
CALCommandTypeContainer_CALCommandStatusExtended_1Bytes CALCommandTypeContainer = 0xE1
CALCommandTypeContainer_CALCommandStatusExtended_2Bytes CALCommandTypeContainer = 0xE1
CALCommandTypeContainer_CALCommandStatusExtended_3Bytes CALCommandTypeContainer = 0xE3
@@ -145,6 +148,7 @@ func init() {
CALCommandTypeContainer_CALCommandRecall,
CALCommandTypeContainer_CALCommandIdentify,
CALCommandTypeContainer_CALCommandGetStatus,
+ CALCommandTypeContainer_CALCommandReply_0Bytes,
CALCommandTypeContainer_CALCommandReply_1Bytes,
CALCommandTypeContainer_CALCommandReply_2Bytes,
CALCommandTypeContainer_CALCommandReply_3Bytes,
@@ -177,6 +181,7 @@ func init() {
CALCommandTypeContainer_CALCommandReply_30Bytes,
CALCommandTypeContainer_CALCommandReply_31Bytes,
CALCommandTypeContainer_CALCommandAcknowledge,
+ CALCommandTypeContainer_CALCommandStatus_0Bytes,
CALCommandTypeContainer_CALCommandStatus_1Bytes,
CALCommandTypeContainer_CALCommandStatus_2Bytes,
CALCommandTypeContainer_CALCommandStatus_3Bytes,
@@ -208,6 +213,7 @@ func init() {
CALCommandTypeContainer_CALCommandStatus_29Bytes,
CALCommandTypeContainer_CALCommandStatus_30Bytes,
CALCommandTypeContainer_CALCommandStatus_31Bytes,
+ CALCommandTypeContainer_CALCommandStatusExtended_0Bytes,
CALCommandTypeContainer_CALCommandStatusExtended_1Bytes,
CALCommandTypeContainer_CALCommandStatusExtended_2Bytes,
CALCommandTypeContainer_CALCommandStatusExtended_3Bytes,
@@ -264,6 +270,10 @@ func (e CALCommandTypeContainer) NumBytes() uint8 {
{ /* '0x32' */
return 0
}
+ case 0x80:
+ { /* '0x80' */
+ return 0
+ }
case 0x81:
{ /* '0x81' */
return 1
@@ -388,6 +398,10 @@ func (e CALCommandTypeContainer) NumBytes() uint8 {
{ /* '0x9F' */
return 31
}
+ case 0xC0:
+ { /* '0xC0' */
+ return 0
+ }
case 0xC1:
{ /* '0xC1' */
return 1
@@ -512,6 +526,10 @@ func (e CALCommandTypeContainer) NumBytes() uint8 {
{ /* '0xDF' */
return 31
}
+ case 0xE0:
+ { /* '0xE0' */
+ return 0
+ }
case 0xE1:
{ /* '0xE1' */
return 1
@@ -670,6 +688,10 @@ func (e CALCommandTypeContainer) CommandType() CALCommandType {
{ /* '0x32' */
return CALCommandType_ACKNOWLEDGE
}
+ case 0x80:
+ { /* '0x80' */
+ return CALCommandType_REPLY
+ }
case 0x81:
{ /* '0x81' */
return CALCommandType_REPLY
@@ -794,6 +816,10 @@ func (e CALCommandTypeContainer) CommandType() CALCommandType {
{ /* '0x9F' */
return CALCommandType_REPLY
}
+ case 0xC0:
+ { /* '0xC0' */
+ return CALCommandType_STATUS
+ }
case 0xC1:
{ /* '0xC1' */
return CALCommandType_STATUS
@@ -918,6 +944,10 @@ func (e CALCommandTypeContainer) CommandType() CALCommandType {
{ /* '0xDF' */
return CALCommandType_STATUS
}
+ case 0xE0:
+ { /* '0xE0' */
+ return CALCommandType_STATUS_EXTENDED
+ }
case 0xE1:
{ /* '0xE1' */
return CALCommandType_STATUS_EXTENDED
@@ -1065,6 +1095,8 @@ func CALCommandTypeContainerByValue(value uint8) CALCommandTypeContainer {
return CALCommandTypeContainer_CALCommandGetStatus
case 0x32:
return CALCommandTypeContainer_CALCommandAcknowledge
+ case 0x80:
+ return CALCommandTypeContainer_CALCommandReply_0Bytes
case 0x81:
return CALCommandTypeContainer_CALCommandReply_1Bytes
case 0x82:
@@ -1127,6 +1159,8 @@ func CALCommandTypeContainerByValue(value uint8) CALCommandTypeContainer {
return CALCommandTypeContainer_CALCommandReply_30Bytes
case 0x9F:
return CALCommandTypeContainer_CALCommandReply_31Bytes
+ case 0xC0:
+ return CALCommandTypeContainer_CALCommandStatus_0Bytes
case 0xC1:
return CALCommandTypeContainer_CALCommandStatus_1Bytes
case 0xC2:
@@ -1189,6 +1223,8 @@ func CALCommandTypeContainerByValue(value uint8) CALCommandTypeContainer {
return CALCommandTypeContainer_CALCommandStatus_30Bytes
case 0xDF:
return CALCommandTypeContainer_CALCommandStatus_31Bytes
+ case 0xE0:
+ return CALCommandTypeContainer_CALCommandStatusExtended_0Bytes
case 0xE1:
return CALCommandTypeContainer_CALCommandStatusExtended_1Bytes
case 0xE3:
@@ -1266,6 +1302,8 @@ func CALCommandTypeContainerByName(value string) (enum CALCommandTypeContainer,
enum = CALCommandTypeContainer_CALCommandGetStatus
case "CALCommandAcknowledge":
enum = CALCommandTypeContainer_CALCommandAcknowledge
+ case "CALCommandReply_0Bytes":
+ enum = CALCommandTypeContainer_CALCommandReply_0Bytes
case "CALCommandReply_1Bytes":
enum = CALCommandTypeContainer_CALCommandReply_1Bytes
case "CALCommandReply_2Bytes":
@@ -1328,6 +1366,8 @@ func CALCommandTypeContainerByName(value string) (enum CALCommandTypeContainer,
enum = CALCommandTypeContainer_CALCommandReply_30Bytes
case "CALCommandReply_31Bytes":
enum = CALCommandTypeContainer_CALCommandReply_31Bytes
+ case "CALCommandStatus_0Bytes":
+ enum = CALCommandTypeContainer_CALCommandStatus_0Bytes
case "CALCommandStatus_1Bytes":
enum = CALCommandTypeContainer_CALCommandStatus_1Bytes
case "CALCommandStatus_2Bytes":
@@ -1390,6 +1430,8 @@ func CALCommandTypeContainerByName(value string) (enum CALCommandTypeContainer,
enum = CALCommandTypeContainer_CALCommandStatus_30Bytes
case "CALCommandStatus_31Bytes":
enum = CALCommandTypeContainer_CALCommandStatus_31Bytes
+ case "CALCommandStatusExtended_0Bytes":
+ enum = CALCommandTypeContainer_CALCommandStatusExtended_0Bytes
case "CALCommandStatusExtended_1Bytes":
enum = CALCommandTypeContainer_CALCommandStatusExtended_1Bytes
case "CALCommandStatusExtended_3Bytes":
@@ -1509,6 +1551,8 @@ func (e CALCommandTypeContainer) PLC4XEnumName() string {
return "CALCommandGetStatus"
case CALCommandTypeContainer_CALCommandAcknowledge:
return "CALCommandAcknowledge"
+ case CALCommandTypeContainer_CALCommandReply_0Bytes:
+ return "CALCommandReply_0Bytes"
case CALCommandTypeContainer_CALCommandReply_1Bytes:
return "CALCommandReply_1Bytes"
case CALCommandTypeContainer_CALCommandReply_2Bytes:
@@ -1571,6 +1615,8 @@ func (e CALCommandTypeContainer) PLC4XEnumName() string {
return "CALCommandReply_30Bytes"
case CALCommandTypeContainer_CALCommandReply_31Bytes:
return "CALCommandReply_31Bytes"
+ case CALCommandTypeContainer_CALCommandStatus_0Bytes:
+ return "CALCommandStatus_0Bytes"
case CALCommandTypeContainer_CALCommandStatus_1Bytes:
return "CALCommandStatus_1Bytes"
case CALCommandTypeContainer_CALCommandStatus_2Bytes:
@@ -1633,6 +1679,8 @@ func (e CALCommandTypeContainer) PLC4XEnumName() string {
return "CALCommandStatus_30Bytes"
case CALCommandTypeContainer_CALCommandStatus_31Bytes:
return "CALCommandStatus_31Bytes"
+ case CALCommandTypeContainer_CALCommandStatusExtended_0Bytes:
+ return "CALCommandStatusExtended_0Bytes"
case CALCommandTypeContainer_CALCommandStatusExtended_1Bytes:
return "CALCommandStatusExtended_1Bytes"
case CALCommandTypeContainer_CALCommandStatusExtended_3Bytes:
diff --git a/plc4go/protocols/cbus/readwrite/model/CALData.go b/plc4go/protocols/cbus/readwrite/model/CALData.go
index dfd0cc5a8..e029223bb 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALData.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALData.go
@@ -22,6 +22,8 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
+ "github.com/rs/zerolog/log"
+ "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -32,6 +34,8 @@ type CALData interface {
utils.Serializable
// GetCommandTypeContainer returns CommandTypeContainer (property field)
GetCommandTypeContainer() CALCommandTypeContainer
+ // GetAdditionalData returns AdditionalData (property field)
+ GetAdditionalData() CALData
// GetCommandType returns CommandType (virtual field)
GetCommandType() CALCommandType
// GetSendIdentifyRequestBefore returns SendIdentifyRequestBefore (virtual field)
@@ -49,6 +53,7 @@ type CALDataExactly interface {
type _CALData struct {
_CALDataChildRequirements
CommandTypeContainer CALCommandTypeContainer
+ AdditionalData CALData
// Arguments.
RequestContext RequestContext
@@ -67,7 +72,7 @@ type CALDataParent interface {
type CALDataChild interface {
utils.Serializable
- InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer)
+ InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData)
GetParent() *CALData
GetTypeName() string
@@ -83,6 +88,10 @@ func (m *_CALData) GetCommandTypeContainer() CALCommandTypeContainer {
return m.CommandTypeContainer
}
+func (m *_CALData) GetAdditionalData() CALData {
+ return m.AdditionalData
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
@@ -93,10 +102,14 @@ func (m *_CALData) GetCommandTypeContainer() CALCommandTypeContainer {
///////////////////////
func (m *_CALData) GetCommandType() CALCommandType {
+ additionalData := m.AdditionalData
+ _ = additionalData
return CastCALCommandType(m.GetCommandTypeContainer().CommandType())
}
func (m *_CALData) GetSendIdentifyRequestBefore() bool {
+ additionalData := m.AdditionalData
+ _ = additionalData
return bool(utils.InlineIf(bool((m.RequestContext) != (nil)), func() interface{} { return bool(m.RequestContext.GetSendIdentifyRequestBefore()) }, func() interface{} { return bool(bool(false)) }).(bool))
}
@@ -106,8 +119,8 @@ func (m *_CALData) GetSendIdentifyRequestBefore() bool {
///////////////////////////////////////////////////////////
// NewCALData factory function for _CALData
-func NewCALData(commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALData {
- return &_CALData{CommandTypeContainer: commandTypeContainer, RequestContext: requestContext}
+func NewCALData(commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALData {
+ return &_CALData{CommandTypeContainer: commandTypeContainer, AdditionalData: additionalData, RequestContext: requestContext}
}
// Deprecated: use the interface for direct cast
@@ -135,6 +148,11 @@ func (m *_CALData) GetParentLengthInBits() uint16 {
// A virtual field doesn't have any in- or output.
+ // Optional Field (additionalData)
+ if m.AdditionalData != nil {
+ lengthInBits += m.AdditionalData.GetLengthInBits()
+ }
+
return lengthInBits
}
@@ -151,6 +169,11 @@ func CALDataParse(readBuffer utils.ReadBuffer, requestContext RequestContext) (C
currentPos := positionAware.GetPos()
_ = currentPos
+ // Validation
+ if !(KnowsCALCommandTypeContainer(readBuffer)) {
+ return nil, errors.WithStack(utils.ParseAssertError{"no command type could be found"})
+ }
+
// Simple Field (commandTypeContainer)
if pullErr := readBuffer.PullContext("commandTypeContainer"); pullErr != nil {
return nil, errors.Wrap(pullErr, "Error pulling for commandTypeContainer")
@@ -177,7 +200,7 @@ func CALDataParse(readBuffer utils.ReadBuffer, requestContext RequestContext) (C
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
type CALDataChildSerializeRequirement interface {
CALData
- InitializeParent(CALData, CALCommandTypeContainer)
+ InitializeParent(CALData, CALCommandTypeContainer, CALData)
GetParent() CALData
}
var _childTemp interface{}
@@ -210,12 +233,34 @@ func CALDataParse(readBuffer utils.ReadBuffer, requestContext RequestContext) (C
}
_child = _childTemp.(CALDataChildSerializeRequirement)
+ // Optional Field (additionalData) (Can be skipped, if a given expression evaluates to false)
+ var additionalData CALData = nil
+ {
+ currentPos = positionAware.GetPos()
+ if pullErr := readBuffer.PullContext("additionalData"); pullErr != nil {
+ return nil, errors.Wrap(pullErr, "Error pulling for additionalData")
+ }
+ _val, _err := CALDataParse(readBuffer, requestContext)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'additionalData' field of CALData")
+ default:
+ additionalData = _val.(CALData)
+ if closeErr := readBuffer.CloseContext("additionalData"); closeErr != nil {
+ return nil, errors.Wrap(closeErr, "Error closing for additionalData")
+ }
+ }
+ }
+
if closeErr := readBuffer.CloseContext("CALData"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CALData")
}
// Finish initializing
- _child.InitializeParent(_child, commandTypeContainer)
+ _child.InitializeParent(_child, commandTypeContainer, additionalData)
return _child, nil
}
@@ -254,6 +299,22 @@ func (pm *_CALData) SerializeParent(writeBuffer utils.WriteBuffer, child CALData
return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field")
}
+ // Optional Field (additionalData) (Can be skipped, if the value is null)
+ var additionalData CALData = nil
+ if m.GetAdditionalData() != nil {
+ if pushErr := writeBuffer.PushContext("additionalData"); pushErr != nil {
+ return errors.Wrap(pushErr, "Error pushing for additionalData")
+ }
+ additionalData = m.GetAdditionalData()
+ _additionalDataErr := writeBuffer.WriteSerializable(additionalData)
+ if popErr := writeBuffer.PopContext("additionalData"); popErr != nil {
+ return errors.Wrap(popErr, "Error popping for additionalData")
+ }
+ if _additionalDataErr != nil {
+ return errors.Wrap(_additionalDataErr, "Error serializing 'additionalData' field")
+ }
+ }
+
if popErr := writeBuffer.PopContext("CALData"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CALData")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataAcknowledge.go b/plc4go/protocols/cbus/readwrite/model/CALDataAcknowledge.go
index fb4a6684a..0bee65789 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataAcknowledge.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataAcknowledge.go
@@ -61,8 +61,9 @@ type _CALDataAcknowledge struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataAcknowledge) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataAcknowledge) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataAcknowledge) GetParent() CALData {
@@ -88,11 +89,11 @@ func (m *_CALDataAcknowledge) GetCode() uint8 {
///////////////////////////////////////////////////////////
// NewCALDataAcknowledge factory function for _CALDataAcknowledge
-func NewCALDataAcknowledge(paramNo uint8, code uint8, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataAcknowledge {
+func NewCALDataAcknowledge(paramNo uint8, code uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataAcknowledge {
_result := &_CALDataAcknowledge{
ParamNo: paramNo,
Code: code,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go b/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
index 4ee255839..8fd7e4b06 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
@@ -61,8 +61,9 @@ type _CALDataGetStatus struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataGetStatus) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataGetStatus) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataGetStatus) GetParent() CALData {
@@ -88,11 +89,11 @@ func (m *_CALDataGetStatus) GetCount() uint8 {
///////////////////////////////////////////////////////////
// NewCALDataGetStatus factory function for _CALDataGetStatus
-func NewCALDataGetStatus(paramNo uint8, count uint8, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataGetStatus {
+func NewCALDataGetStatus(paramNo uint8, count uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataGetStatus {
_result := &_CALDataGetStatus{
ParamNo: paramNo,
Count: count,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataIdentify.go b/plc4go/protocols/cbus/readwrite/model/CALDataIdentify.go
index fd4e57d1f..3ac91b61f 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataIdentify.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataIdentify.go
@@ -58,8 +58,9 @@ type _CALDataIdentify struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataIdentify) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataIdentify) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataIdentify) GetParent() CALData {
@@ -81,10 +82,10 @@ func (m *_CALDataIdentify) GetAttribute() Attribute {
///////////////////////////////////////////////////////////
// NewCALDataIdentify factory function for _CALDataIdentify
-func NewCALDataIdentify(attribute Attribute, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataIdentify {
+func NewCALDataIdentify(attribute Attribute, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataIdentify {
_result := &_CALDataIdentify{
Attribute: attribute,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataIdentifyReply.go b/plc4go/protocols/cbus/readwrite/model/CALDataIdentifyReply.go
index 8a0eb2ab9..5988db38f 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataIdentifyReply.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataIdentifyReply.go
@@ -61,8 +61,9 @@ type _CALDataIdentifyReply struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataIdentifyReply) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataIdentifyReply) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataIdentifyReply) GetParent() CALData {
@@ -88,11 +89,11 @@ func (m *_CALDataIdentifyReply) GetIdentifyReplyCommand() IdentifyReplyCommand {
///////////////////////////////////////////////////////////
// NewCALDataIdentifyReply factory function for _CALDataIdentifyReply
-func NewCALDataIdentifyReply(attribute Attribute, identifyReplyCommand IdentifyReplyCommand, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataIdentifyReply {
+func NewCALDataIdentifyReply(attribute Attribute, identifyReplyCommand IdentifyReplyCommand, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataIdentifyReply {
_result := &_CALDataIdentifyReply{
Attribute: attribute,
IdentifyReplyCommand: identifyReplyCommand,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go b/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
index fda37e060..66058394a 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
@@ -61,8 +61,9 @@ type _CALDataRecall struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataRecall) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataRecall) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataRecall) GetParent() CALData {
@@ -88,11 +89,11 @@ func (m *_CALDataRecall) GetCount() uint8 {
///////////////////////////////////////////////////////////
// NewCALDataRecall factory function for _CALDataRecall
-func NewCALDataRecall(paramNo uint8, count uint8, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataRecall {
+func NewCALDataRecall(paramNo uint8, count uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataRecall {
_result := &_CALDataRecall{
ParamNo: paramNo,
Count: count,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataReply.go b/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
index e2d0ae376..dd8bcabf8 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
@@ -61,8 +61,9 @@ type _CALDataReply struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataReply) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataReply) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataReply) GetParent() CALData {
@@ -88,11 +89,11 @@ func (m *_CALDataReply) GetData() []byte {
///////////////////////////////////////////////////////////
// NewCALDataReply factory function for _CALDataReply
-func NewCALDataReply(paramNumber uint8, data []byte, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataReply {
+func NewCALDataReply(paramNumber uint8, data []byte, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataReply {
_result := &_CALDataReply{
ParamNumber: paramNumber,
Data: data,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataReset.go b/plc4go/protocols/cbus/readwrite/model/CALDataReset.go
index 3d7bc86fd..05920e739 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataReset.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataReset.go
@@ -55,8 +55,9 @@ type _CALDataReset struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataReset) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataReset) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataReset) GetParent() CALData {
@@ -64,9 +65,9 @@ func (m *_CALDataReset) GetParent() CALData {
}
// NewCALDataReset factory function for _CALDataReset
-func NewCALDataReset(commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataReset {
+func NewCALDataReset(commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataReset {
_result := &_CALDataReset{
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
index 355a7020d..eb9f62b47 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
@@ -64,8 +64,9 @@ type _CALDataStatus struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataStatus) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataStatus) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataStatus) GetParent() CALData {
@@ -95,12 +96,12 @@ func (m *_CALDataStatus) GetData() []byte {
///////////////////////////////////////////////////////////
// NewCALDataStatus factory function for _CALDataStatus
-func NewCALDataStatus(application ApplicationIdContainer, blockStart uint8, data []byte, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataStatus {
+func NewCALDataStatus(application ApplicationIdContainer, blockStart uint8, data []byte, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataStatus {
_result := &_CALDataStatus{
Application: application,
BlockStart: blockStart,
Data: data,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
index 9665cc4aa..b678fe2fd 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
@@ -67,8 +67,9 @@ type _CALDataStatusExtended struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CALDataStatusExtended) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer) {
+func (m *_CALDataStatusExtended) InitializeParent(parent CALData, commandTypeContainer CALCommandTypeContainer, additionalData CALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.AdditionalData = additionalData
}
func (m *_CALDataStatusExtended) GetParent() CALData {
@@ -102,13 +103,13 @@ func (m *_CALDataStatusExtended) GetData() []byte {
///////////////////////////////////////////////////////////
// NewCALDataStatusExtended factory function for _CALDataStatusExtended
-func NewCALDataStatusExtended(encoding uint8, application ApplicationIdContainer, blockStart uint8, data []byte, commandTypeContainer CALCommandTypeContainer, requestContext RequestContext) *_CALDataStatusExtended {
+func NewCALDataStatusExtended(encoding uint8, application ApplicationIdContainer, blockStart uint8, data []byte, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataStatusExtended {
_result := &_CALDataStatusExtended{
Encoding: encoding,
Application: application,
BlockStart: blockStart,
Data: data,
- _CALData: NewCALData(commandTypeContainer, requestContext),
+ _CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go
index 1c27c8333..426e6e77f 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go
@@ -22,6 +22,8 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
+ "github.com/rs/zerolog/log"
+ "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -32,6 +34,8 @@ type CBusPointToMultiPointCommand interface {
utils.Serializable
// GetPeekedApplication returns PeekedApplication (property field)
GetPeekedApplication() byte
+ // GetCrc returns Crc (property field)
+ GetCrc() Checksum
}
// CBusPointToMultiPointCommandExactly can be used when we want exactly this type and not a type which fulfills CBusPointToMultiPointCommand.
@@ -45,6 +49,7 @@ type CBusPointToMultiPointCommandExactly interface {
type _CBusPointToMultiPointCommand struct {
_CBusPointToMultiPointCommandChildRequirements
PeekedApplication byte
+ Crc Checksum
// Arguments.
CBusOptions CBusOptions
@@ -63,7 +68,7 @@ type CBusPointToMultiPointCommandParent interface {
type CBusPointToMultiPointCommandChild interface {
utils.Serializable
- InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte)
+ InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, crc Checksum)
GetParent() *CBusPointToMultiPointCommand
GetTypeName() string
@@ -79,14 +84,18 @@ func (m *_CBusPointToMultiPointCommand) GetPeekedApplication() byte {
return m.PeekedApplication
}
+func (m *_CBusPointToMultiPointCommand) GetCrc() Checksum {
+ return m.Crc
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToMultiPointCommand factory function for _CBusPointToMultiPointCommand
-func NewCBusPointToMultiPointCommand(peekedApplication byte, cBusOptions CBusOptions) *_CBusPointToMultiPointCommand {
- return &_CBusPointToMultiPointCommand{PeekedApplication: peekedApplication, CBusOptions: cBusOptions}
+func NewCBusPointToMultiPointCommand(peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_CBusPointToMultiPointCommand {
+ return &_CBusPointToMultiPointCommand{PeekedApplication: peekedApplication, Crc: crc, CBusOptions: cBusOptions}
}
// Deprecated: use the interface for direct cast
@@ -107,6 +116,11 @@ func (m *_CBusPointToMultiPointCommand) GetTypeName() string {
func (m *_CBusPointToMultiPointCommand) GetParentLengthInBits() uint16 {
lengthInBits := uint16(0)
+ // Optional Field (crc)
+ if m.Crc != nil {
+ lengthInBits += m.Crc.GetLengthInBits()
+ }
+
return lengthInBits
}
@@ -135,7 +149,7 @@ func CBusPointToMultiPointCommandParse(readBuffer utils.ReadBuffer, cBusOptions
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
type CBusPointToMultiPointCommandChildSerializeRequirement interface {
CBusPointToMultiPointCommand
- InitializeParent(CBusPointToMultiPointCommand, byte)
+ InitializeParent(CBusPointToMultiPointCommand, byte, Checksum)
GetParent() CBusPointToMultiPointCommand
}
var _childTemp interface{}
@@ -154,12 +168,34 @@ func CBusPointToMultiPointCommandParse(readBuffer utils.ReadBuffer, cBusOptions
}
_child = _childTemp.(CBusPointToMultiPointCommandChildSerializeRequirement)
+ // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
+ var crc Checksum = nil
+ if cBusOptions.GetSrchk() {
+ currentPos = positionAware.GetPos()
+ if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
+ return nil, errors.Wrap(pullErr, "Error pulling for crc")
+ }
+ _val, _err := ChecksumParse(readBuffer)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'crc' field of CBusPointToMultiPointCommand")
+ default:
+ crc = _val.(Checksum)
+ if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
+ return nil, errors.Wrap(closeErr, "Error closing for crc")
+ }
+ }
+ }
+
if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommand"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommand")
}
// Finish initializing
- _child.InitializeParent(_child, peekedApplication)
+ _child.InitializeParent(_child, peekedApplication, crc)
return _child, nil
}
@@ -178,6 +214,22 @@ func (pm *_CBusPointToMultiPointCommand) SerializeParent(writeBuffer utils.Write
return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field")
}
+ // Optional Field (crc) (Can be skipped, if the value is null)
+ var crc Checksum = nil
+ if m.GetCrc() != nil {
+ if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
+ return errors.Wrap(pushErr, "Error pushing for crc")
+ }
+ crc = m.GetCrc()
+ _crcErr := writeBuffer.WriteSerializable(crc)
+ if popErr := writeBuffer.PopContext("crc"); popErr != nil {
+ return errors.Wrap(popErr, "Error popping for crc")
+ }
+ if _crcErr != nil {
+ return errors.Wrap(_crcErr, "Error serializing 'crc' field")
+ }
+ }
+
if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommand"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommand")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
index 48a763b16..fce5b662e 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
- "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -35,8 +34,6 @@ type CBusPointToMultiPointCommandStatus interface {
CBusPointToMultiPointCommand
// GetStatusRequest returns StatusRequest (property field)
GetStatusRequest() StatusRequest
- // GetCrc returns Crc (property field)
- GetCrc() Checksum
}
// CBusPointToMultiPointCommandStatusExactly can be used when we want exactly this type and not a type which fulfills CBusPointToMultiPointCommandStatus.
@@ -50,7 +47,6 @@ type CBusPointToMultiPointCommandStatusExactly interface {
type _CBusPointToMultiPointCommandStatus struct {
*_CBusPointToMultiPointCommand
StatusRequest StatusRequest
- Crc Checksum
}
///////////////////////////////////////////////////////////
@@ -63,8 +59,9 @@ type _CBusPointToMultiPointCommandStatus struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CBusPointToMultiPointCommandStatus) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte) {
+func (m *_CBusPointToMultiPointCommandStatus) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, crc Checksum) {
m.PeekedApplication = peekedApplication
+ m.Crc = crc
}
func (m *_CBusPointToMultiPointCommandStatus) GetParent() CBusPointToMultiPointCommand {
@@ -80,21 +77,16 @@ func (m *_CBusPointToMultiPointCommandStatus) GetStatusRequest() StatusRequest {
return m.StatusRequest
}
-func (m *_CBusPointToMultiPointCommandStatus) GetCrc() Checksum {
- return m.Crc
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToMultiPointCommandStatus factory function for _CBusPointToMultiPointCommandStatus
-func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, crc Checksum, peekedApplication byte, cBusOptions CBusOptions) *_CBusPointToMultiPointCommandStatus {
+func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_CBusPointToMultiPointCommandStatus {
_result := &_CBusPointToMultiPointCommandStatus{
StatusRequest: statusRequest,
- Crc: crc,
- _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, cBusOptions),
+ _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, crc, cBusOptions),
}
_result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result
return _result
@@ -131,11 +123,6 @@ func (m *_CBusPointToMultiPointCommandStatus) GetLengthInBitsConditional(lastIte
// Simple field (statusRequest)
lengthInBits += m.StatusRequest.GetLengthInBits()
- // Optional Field (crc)
- if m.Crc != nil {
- lengthInBits += m.Crc.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -193,28 +180,6 @@ func CBusPointToMultiPointCommandStatusParse(readBuffer utils.ReadBuffer, cBusOp
return nil, errors.Wrap(closeErr, "Error closing for statusRequest")
}
- // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
- var crc Checksum = nil
- if cBusOptions.GetSrchk() {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for crc")
- }
- _val, _err := ChecksumParse(readBuffer)
- switch {
- case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
- log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
- readBuffer.Reset(currentPos)
- case _err != nil:
- return nil, errors.Wrap(_err, "Error parsing 'crc' field of CBusPointToMultiPointCommandStatus")
- default:
- crc = _val.(Checksum)
- if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for crc")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommandStatus"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommandStatus")
}
@@ -222,7 +187,6 @@ func CBusPointToMultiPointCommandStatusParse(readBuffer utils.ReadBuffer, cBusOp
// Create a partially initialized instance
_child := &_CBusPointToMultiPointCommandStatus{
StatusRequest: statusRequest,
- Crc: crc,
_CBusPointToMultiPointCommand: &_CBusPointToMultiPointCommand{
CBusOptions: cBusOptions,
},
@@ -267,22 +231,6 @@ func (m *_CBusPointToMultiPointCommandStatus) Serialize(writeBuffer utils.WriteB
return errors.Wrap(_statusRequestErr, "Error serializing 'statusRequest' field")
}
- // Optional Field (crc) (Can be skipped, if the value is null)
- var crc Checksum = nil
- if m.GetCrc() != nil {
- if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for crc")
- }
- crc = m.GetCrc()
- _crcErr := writeBuffer.WriteSerializable(crc)
- if popErr := writeBuffer.PopContext("crc"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for crc")
- }
- if _crcErr != nil {
- return errors.Wrap(_crcErr, "Error serializing 'crc' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommandStatus"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommandStatus")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go
index ad8d6fcd9..ef8ad5cf8 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go
@@ -22,6 +22,8 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
+ "github.com/rs/zerolog/log"
+ "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -36,6 +38,8 @@ type CBusPointToPointToMultipointCommand interface {
GetNetworkRoute() NetworkRoute
// GetPeekedApplication returns PeekedApplication (property field)
GetPeekedApplication() byte
+ // GetCrc returns Crc (property field)
+ GetCrc() Checksum
}
// CBusPointToPointToMultipointCommandExactly can be used when we want exactly this type and not a type which fulfills CBusPointToPointToMultipointCommand.
@@ -51,6 +55,7 @@ type _CBusPointToPointToMultipointCommand struct {
BridgeAddress BridgeAddress
NetworkRoute NetworkRoute
PeekedApplication byte
+ Crc Checksum
// Arguments.
CBusOptions CBusOptions
@@ -69,7 +74,7 @@ type CBusPointToPointToMultipointCommandParent interface {
type CBusPointToPointToMultipointCommandChild interface {
utils.Serializable
- InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte)
+ InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum)
GetParent() *CBusPointToPointToMultipointCommand
GetTypeName() string
@@ -93,14 +98,18 @@ func (m *_CBusPointToPointToMultipointCommand) GetPeekedApplication() byte {
return m.PeekedApplication
}
+func (m *_CBusPointToPointToMultipointCommand) GetCrc() Checksum {
+ return m.Crc
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToPointToMultipointCommand factory function for _CBusPointToPointToMultipointCommand
-func NewCBusPointToPointToMultipointCommand(bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommand {
- return &_CBusPointToPointToMultipointCommand{BridgeAddress: bridgeAddress, NetworkRoute: networkRoute, PeekedApplication: peekedApplication, CBusOptions: cBusOptions}
+func NewCBusPointToPointToMultipointCommand(bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommand {
+ return &_CBusPointToPointToMultipointCommand{BridgeAddress: bridgeAddress, NetworkRoute: networkRoute, PeekedApplication: peekedApplication, Crc: crc, CBusOptions: cBusOptions}
}
// Deprecated: use the interface for direct cast
@@ -127,6 +136,11 @@ func (m *_CBusPointToPointToMultipointCommand) GetParentLengthInBits() uint16 {
// Simple field (networkRoute)
lengthInBits += m.NetworkRoute.GetLengthInBits()
+ // Optional Field (crc)
+ if m.Crc != nil {
+ lengthInBits += m.Crc.GetLengthInBits()
+ }
+
return lengthInBits
}
@@ -181,7 +195,7 @@ func CBusPointToPointToMultipointCommandParse(readBuffer utils.ReadBuffer, cBusO
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
type CBusPointToPointToMultipointCommandChildSerializeRequirement interface {
CBusPointToPointToMultipointCommand
- InitializeParent(CBusPointToPointToMultipointCommand, BridgeAddress, NetworkRoute, byte)
+ InitializeParent(CBusPointToPointToMultipointCommand, BridgeAddress, NetworkRoute, byte, Checksum)
GetParent() CBusPointToPointToMultipointCommand
}
var _childTemp interface{}
@@ -200,12 +214,34 @@ func CBusPointToPointToMultipointCommandParse(readBuffer utils.ReadBuffer, cBusO
}
_child = _childTemp.(CBusPointToPointToMultipointCommandChildSerializeRequirement)
+ // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
+ var crc Checksum = nil
+ if cBusOptions.GetSrchk() {
+ currentPos = positionAware.GetPos()
+ if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
+ return nil, errors.Wrap(pullErr, "Error pulling for crc")
+ }
+ _val, _err := ChecksumParse(readBuffer)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'crc' field of CBusPointToPointToMultipointCommand")
+ default:
+ crc = _val.(Checksum)
+ if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
+ return nil, errors.Wrap(closeErr, "Error closing for crc")
+ }
+ }
+ }
+
if closeErr := readBuffer.CloseContext("CBusPointToPointToMultipointCommand"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToPointToMultipointCommand")
}
// Finish initializing
- _child.InitializeParent(_child, bridgeAddress, networkRoute, peekedApplication)
+ _child.InitializeParent(_child, bridgeAddress, networkRoute, peekedApplication, crc)
return _child, nil
}
@@ -248,6 +284,22 @@ func (pm *_CBusPointToPointToMultipointCommand) SerializeParent(writeBuffer util
return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field")
}
+ // Optional Field (crc) (Can be skipped, if the value is null)
+ var crc Checksum = nil
+ if m.GetCrc() != nil {
+ if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
+ return errors.Wrap(pushErr, "Error pushing for crc")
+ }
+ crc = m.GetCrc()
+ _crcErr := writeBuffer.WriteSerializable(crc)
+ if popErr := writeBuffer.PopContext("crc"); popErr != nil {
+ return errors.Wrap(popErr, "Error popping for crc")
+ }
+ if _crcErr != nil {
+ return errors.Wrap(_crcErr, "Error serializing 'crc' field")
+ }
+ }
+
if popErr := writeBuffer.PopContext("CBusPointToPointToMultipointCommand"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToPointToMultipointCommand")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandNormal.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandNormal.go
index 292b994f7..da98c6ee2 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandNormal.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandNormal.go
@@ -22,8 +22,6 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
- "github.com/rs/zerolog/log"
- "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -37,8 +35,6 @@ type CBusPointToPointToMultipointCommandNormal interface {
GetApplication() ApplicationIdContainer
// GetSalData returns SalData (property field)
GetSalData() SALData
- // GetCrc returns Crc (property field)
- GetCrc() Checksum
}
// CBusPointToPointToMultipointCommandNormalExactly can be used when we want exactly this type and not a type which fulfills CBusPointToPointToMultipointCommandNormal.
@@ -53,7 +49,6 @@ type _CBusPointToPointToMultipointCommandNormal struct {
*_CBusPointToPointToMultipointCommand
Application ApplicationIdContainer
SalData SALData
- Crc Checksum
}
///////////////////////////////////////////////////////////
@@ -66,10 +61,11 @@ type _CBusPointToPointToMultipointCommandNormal struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CBusPointToPointToMultipointCommandNormal) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte) {
+func (m *_CBusPointToPointToMultipointCommandNormal) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum) {
m.BridgeAddress = bridgeAddress
m.NetworkRoute = networkRoute
m.PeekedApplication = peekedApplication
+ m.Crc = crc
}
func (m *_CBusPointToPointToMultipointCommandNormal) GetParent() CBusPointToPointToMultipointCommand {
@@ -89,22 +85,17 @@ func (m *_CBusPointToPointToMultipointCommandNormal) GetSalData() SALData {
return m.SalData
}
-func (m *_CBusPointToPointToMultipointCommandNormal) GetCrc() Checksum {
- return m.Crc
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToPointToMultipointCommandNormal factory function for _CBusPointToPointToMultipointCommandNormal
-func NewCBusPointToPointToMultipointCommandNormal(application ApplicationIdContainer, salData SALData, crc Checksum, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommandNormal {
+func NewCBusPointToPointToMultipointCommandNormal(application ApplicationIdContainer, salData SALData, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommandNormal {
_result := &_CBusPointToPointToMultipointCommandNormal{
Application: application,
SalData: salData,
- Crc: crc,
- _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, cBusOptions),
+ _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, crc, cBusOptions),
}
_result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result
return _result
@@ -138,11 +129,6 @@ func (m *_CBusPointToPointToMultipointCommandNormal) GetLengthInBitsConditional(
// Simple field (salData)
lengthInBits += m.SalData.GetLengthInBits()
- // Optional Field (crc)
- if m.Crc != nil {
- lengthInBits += m.Crc.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -185,28 +171,6 @@ func CBusPointToPointToMultipointCommandNormalParse(readBuffer utils.ReadBuffer,
return nil, errors.Wrap(closeErr, "Error closing for salData")
}
- // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
- var crc Checksum = nil
- if cBusOptions.GetSrchk() {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for crc")
- }
- _val, _err := ChecksumParse(readBuffer)
- switch {
- case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
- log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
- readBuffer.Reset(currentPos)
- case _err != nil:
- return nil, errors.Wrap(_err, "Error parsing 'crc' field of CBusPointToPointToMultipointCommandNormal")
- default:
- crc = _val.(Checksum)
- if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for crc")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToPointToMultipointCommandNormal"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToPointToMultipointCommandNormal")
}
@@ -215,7 +179,6 @@ func CBusPointToPointToMultipointCommandNormalParse(readBuffer utils.ReadBuffer,
_child := &_CBusPointToPointToMultipointCommandNormal{
Application: application,
SalData: salData,
- Crc: crc,
_CBusPointToPointToMultipointCommand: &_CBusPointToPointToMultipointCommand{
CBusOptions: cBusOptions,
},
@@ -256,22 +219,6 @@ func (m *_CBusPointToPointToMultipointCommandNormal) Serialize(writeBuffer utils
return errors.Wrap(_salDataErr, "Error serializing 'salData' field")
}
- // Optional Field (crc) (Can be skipped, if the value is null)
- var crc Checksum = nil
- if m.GetCrc() != nil {
- if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for crc")
- }
- crc = m.GetCrc()
- _crcErr := writeBuffer.WriteSerializable(crc)
- if popErr := writeBuffer.PopContext("crc"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for crc")
- }
- if _crcErr != nil {
- return errors.Wrap(_crcErr, "Error serializing 'crc' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToPointToMultipointCommandNormal"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToPointToMultipointCommandNormal")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandStatus.go
index e7a18fe62..d41cfbd7c 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommandStatus.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
- "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -35,8 +34,6 @@ type CBusPointToPointToMultipointCommandStatus interface {
CBusPointToPointToMultipointCommand
// GetStatusRequest returns StatusRequest (property field)
GetStatusRequest() StatusRequest
- // GetCrc returns Crc (property field)
- GetCrc() Checksum
}
// CBusPointToPointToMultipointCommandStatusExactly can be used when we want exactly this type and not a type which fulfills CBusPointToPointToMultipointCommandStatus.
@@ -50,7 +47,6 @@ type CBusPointToPointToMultipointCommandStatusExactly interface {
type _CBusPointToPointToMultipointCommandStatus struct {
*_CBusPointToPointToMultipointCommand
StatusRequest StatusRequest
- Crc Checksum
}
///////////////////////////////////////////////////////////
@@ -63,10 +59,11 @@ type _CBusPointToPointToMultipointCommandStatus struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CBusPointToPointToMultipointCommandStatus) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte) {
+func (m *_CBusPointToPointToMultipointCommandStatus) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum) {
m.BridgeAddress = bridgeAddress
m.NetworkRoute = networkRoute
m.PeekedApplication = peekedApplication
+ m.Crc = crc
}
func (m *_CBusPointToPointToMultipointCommandStatus) GetParent() CBusPointToPointToMultipointCommand {
@@ -82,21 +79,16 @@ func (m *_CBusPointToPointToMultipointCommandStatus) GetStatusRequest() StatusRe
return m.StatusRequest
}
-func (m *_CBusPointToPointToMultipointCommandStatus) GetCrc() Checksum {
- return m.Crc
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToPointToMultipointCommandStatus factory function for _CBusPointToPointToMultipointCommandStatus
-func NewCBusPointToPointToMultipointCommandStatus(statusRequest StatusRequest, crc Checksum, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommandStatus {
+func NewCBusPointToPointToMultipointCommandStatus(statusRequest StatusRequest, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_CBusPointToPointToMultipointCommandStatus {
_result := &_CBusPointToPointToMultipointCommandStatus{
StatusRequest: statusRequest,
- Crc: crc,
- _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, cBusOptions),
+ _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, crc, cBusOptions),
}
_result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result
return _result
@@ -130,11 +122,6 @@ func (m *_CBusPointToPointToMultipointCommandStatus) GetLengthInBitsConditional(
// Simple field (statusRequest)
lengthInBits += m.StatusRequest.GetLengthInBits()
- // Optional Field (crc)
- if m.Crc != nil {
- lengthInBits += m.Crc.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -178,28 +165,6 @@ func CBusPointToPointToMultipointCommandStatusParse(readBuffer utils.ReadBuffer,
return nil, errors.Wrap(closeErr, "Error closing for statusRequest")
}
- // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
- var crc Checksum = nil
- if cBusOptions.GetSrchk() {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for crc")
- }
- _val, _err := ChecksumParse(readBuffer)
- switch {
- case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
- log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
- readBuffer.Reset(currentPos)
- case _err != nil:
- return nil, errors.Wrap(_err, "Error parsing 'crc' field of CBusPointToPointToMultipointCommandStatus")
- default:
- crc = _val.(Checksum)
- if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for crc")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToPointToMultipointCommandStatus"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToPointToMultipointCommandStatus")
}
@@ -207,7 +172,6 @@ func CBusPointToPointToMultipointCommandStatusParse(readBuffer utils.ReadBuffer,
// Create a partially initialized instance
_child := &_CBusPointToPointToMultipointCommandStatus{
StatusRequest: statusRequest,
- Crc: crc,
_CBusPointToPointToMultipointCommand: &_CBusPointToPointToMultipointCommand{
CBusOptions: cBusOptions,
},
@@ -244,22 +208,6 @@ func (m *_CBusPointToPointToMultipointCommandStatus) Serialize(writeBuffer utils
return errors.Wrap(_statusRequestErr, "Error serializing 'statusRequest' field")
}
- // Optional Field (crc) (Can be skipped, if the value is null)
- var crc Checksum = nil
- if m.GetCrc() != nil {
- if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for crc")
- }
- crc = m.GetCrc()
- _crcErr := writeBuffer.WriteSerializable(crc)
- if popErr := writeBuffer.PopContext("crc"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for crc")
- }
- if _crcErr != nil {
- return errors.Wrap(_crcErr, "Error serializing 'crc' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToPointToMultipointCommandStatus"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToPointToMultipointCommandStatus")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/Normal.go b/plc4go/protocols/cbus/readwrite/model/Normal.go
index 34fe54a52..d458d1dfc 100644
--- a/plc4go/protocols/cbus/readwrite/model/Normal.go
+++ b/plc4go/protocols/cbus/readwrite/model/Normal.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
- "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -37,8 +36,6 @@ type Normal interface {
GetApplication() ApplicationIdContainer
// GetSalData returns SalData (property field)
GetSalData() SALData
- // GetCrc returns Crc (property field)
- GetCrc() Checksum
}
// NormalExactly can be used when we want exactly this type and not a type which fulfills Normal.
@@ -53,7 +50,6 @@ type _Normal struct {
*_CBusPointToMultiPointCommand
Application ApplicationIdContainer
SalData SALData
- Crc Checksum
}
///////////////////////////////////////////////////////////
@@ -66,8 +62,9 @@ type _Normal struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_Normal) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte) {
+func (m *_Normal) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, crc Checksum) {
m.PeekedApplication = peekedApplication
+ m.Crc = crc
}
func (m *_Normal) GetParent() CBusPointToMultiPointCommand {
@@ -87,22 +84,17 @@ func (m *_Normal) GetSalData() SALData {
return m.SalData
}
-func (m *_Normal) GetCrc() Checksum {
- return m.Crc
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewNormal factory function for _Normal
-func NewNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekedApplication byte, cBusOptions CBusOptions) *_Normal {
+func NewNormal(application ApplicationIdContainer, salData SALData, peekedApplication byte, crc Checksum, cBusOptions CBusOptions) *_Normal {
_result := &_Normal{
Application: application,
SalData: salData,
- Crc: crc,
- _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, cBusOptions),
+ _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, crc, cBusOptions),
}
_result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result
return _result
@@ -139,11 +131,6 @@ func (m *_Normal) GetLengthInBitsConditional(lastItem bool) uint16 {
// Simple field (salData)
lengthInBits += m.SalData.GetLengthInBits()
- // Optional Field (crc)
- if m.Crc != nil {
- lengthInBits += m.Crc.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -200,28 +187,6 @@ func NormalParse(readBuffer utils.ReadBuffer, cBusOptions CBusOptions) (Normal,
return nil, errors.Wrap(closeErr, "Error closing for salData")
}
- // Optional Field (crc) (Can be skipped, if a given expression evaluates to false)
- var crc Checksum = nil
- if cBusOptions.GetSrchk() {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("crc"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for crc")
- }
- _val, _err := ChecksumParse(readBuffer)
- switch {
- case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
- log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
- readBuffer.Reset(currentPos)
- case _err != nil:
- return nil, errors.Wrap(_err, "Error parsing 'crc' field of Normal")
- default:
- crc = _val.(Checksum)
- if closeErr := readBuffer.CloseContext("crc"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for crc")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("Normal"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for Normal")
}
@@ -230,7 +195,6 @@ func NormalParse(readBuffer utils.ReadBuffer, cBusOptions CBusOptions) (Normal,
_child := &_Normal{
Application: application,
SalData: salData,
- Crc: crc,
_CBusPointToMultiPointCommand: &_CBusPointToMultiPointCommand{
CBusOptions: cBusOptions,
},
@@ -279,22 +243,6 @@ func (m *_Normal) Serialize(writeBuffer utils.WriteBuffer) error {
return errors.Wrap(_salDataErr, "Error serializing 'salData' field")
}
- // Optional Field (crc) (Can be skipped, if the value is null)
- var crc Checksum = nil
- if m.GetCrc() != nil {
- if pushErr := writeBuffer.PushContext("crc"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for crc")
- }
- crc = m.GetCrc()
- _crcErr := writeBuffer.WriteSerializable(crc)
- if popErr := writeBuffer.PopContext("crc"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for crc")
- }
- if _crcErr != nil {
- return errors.Wrap(_crcErr, "Error serializing 'crc' field")
- }
- }
-
if popErr := writeBuffer.PopContext("Normal"); popErr != nil {
return errors.Wrap(popErr, "Error popping for Normal")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/SALData.go b/plc4go/protocols/cbus/readwrite/model/SALData.go
index b8500c1a7..3819ab9f0 100644
--- a/plc4go/protocols/cbus/readwrite/model/SALData.go
+++ b/plc4go/protocols/cbus/readwrite/model/SALData.go
@@ -22,6 +22,8 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/pkg/errors"
+ "github.com/rs/zerolog/log"
+ "io"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -32,6 +34,8 @@ type SALData interface {
utils.Serializable
// GetCommandTypeContainer returns CommandTypeContainer (property field)
GetCommandTypeContainer() SALCommandTypeContainer
+ // GetSalData returns SalData (property field)
+ GetSalData() SALData
// GetCommandType returns CommandType (virtual field)
GetCommandType() SALCommandType
}
@@ -47,6 +51,7 @@ type SALDataExactly interface {
type _SALData struct {
_SALDataChildRequirements
CommandTypeContainer SALCommandTypeContainer
+ SalData SALData
}
type _SALDataChildRequirements interface {
@@ -62,7 +67,7 @@ type SALDataParent interface {
type SALDataChild interface {
utils.Serializable
- InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer)
+ InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer, salData SALData)
GetParent() *SALData
GetTypeName() string
@@ -78,6 +83,10 @@ func (m *_SALData) GetCommandTypeContainer() SALCommandTypeContainer {
return m.CommandTypeContainer
}
+func (m *_SALData) GetSalData() SALData {
+ return m.SalData
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
@@ -88,6 +97,8 @@ func (m *_SALData) GetCommandTypeContainer() SALCommandTypeContainer {
///////////////////////
func (m *_SALData) GetCommandType() SALCommandType {
+ salData := m.SalData
+ _ = salData
return CastSALCommandType(m.GetCommandTypeContainer().CommandType())
}
@@ -97,8 +108,8 @@ func (m *_SALData) GetCommandType() SALCommandType {
///////////////////////////////////////////////////////////
// NewSALData factory function for _SALData
-func NewSALData(commandTypeContainer SALCommandTypeContainer) *_SALData {
- return &_SALData{CommandTypeContainer: commandTypeContainer}
+func NewSALData(commandTypeContainer SALCommandTypeContainer, salData SALData) *_SALData {
+ return &_SALData{CommandTypeContainer: commandTypeContainer, SalData: salData}
}
// Deprecated: use the interface for direct cast
@@ -124,6 +135,11 @@ func (m *_SALData) GetParentLengthInBits() uint16 {
// A virtual field doesn't have any in- or output.
+ // Optional Field (salData)
+ if m.SalData != nil {
+ lengthInBits += m.SalData.GetLengthInBits()
+ }
+
return lengthInBits
}
@@ -140,6 +156,11 @@ func SALDataParse(readBuffer utils.ReadBuffer) (SALData, error) {
currentPos := positionAware.GetPos()
_ = currentPos
+ // Validation
+ if !(KnowsSALCommandTypeContainer(readBuffer)) {
+ return nil, errors.WithStack(utils.ParseAssertError{"no command type could be found"})
+ }
+
// Simple Field (commandTypeContainer)
if pullErr := readBuffer.PullContext("commandTypeContainer"); pullErr != nil {
return nil, errors.Wrap(pullErr, "Error pulling for commandTypeContainer")
@@ -161,7 +182,7 @@ func SALDataParse(readBuffer utils.ReadBuffer) (SALData, error) {
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
type SALDataChildSerializeRequirement interface {
SALData
- InitializeParent(SALData, SALCommandTypeContainer)
+ InitializeParent(SALData, SALCommandTypeContainer, SALData)
GetParent() SALData
}
var _childTemp interface{}
@@ -184,12 +205,34 @@ func SALDataParse(readBuffer utils.ReadBuffer) (SALData, error) {
}
_child = _childTemp.(SALDataChildSerializeRequirement)
+ // Optional Field (salData) (Can be skipped, if a given expression evaluates to false)
+ var salData SALData = nil
+ {
+ currentPos = positionAware.GetPos()
+ if pullErr := readBuffer.PullContext("salData"); pullErr != nil {
+ return nil, errors.Wrap(pullErr, "Error pulling for salData")
+ }
+ _val, _err := SALDataParse(readBuffer)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ log.Debug().Err(_err).Msg("Resetting position because optional threw an error")
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'salData' field of SALData")
+ default:
+ salData = _val.(SALData)
+ if closeErr := readBuffer.CloseContext("salData"); closeErr != nil {
+ return nil, errors.Wrap(closeErr, "Error closing for salData")
+ }
+ }
+ }
+
if closeErr := readBuffer.CloseContext("SALData"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for SALData")
}
// Finish initializing
- _child.InitializeParent(_child, commandTypeContainer)
+ _child.InitializeParent(_child, commandTypeContainer, salData)
return _child, nil
}
@@ -224,6 +267,22 @@ func (pm *_SALData) SerializeParent(writeBuffer utils.WriteBuffer, child SALData
return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field")
}
+ // Optional Field (salData) (Can be skipped, if the value is null)
+ var salData SALData = nil
+ if m.GetSalData() != nil {
+ if pushErr := writeBuffer.PushContext("salData"); pushErr != nil {
+ return errors.Wrap(pushErr, "Error pushing for salData")
+ }
+ salData = m.GetSalData()
+ _salDataErr := writeBuffer.WriteSerializable(salData)
+ if popErr := writeBuffer.PopContext("salData"); popErr != nil {
+ return errors.Wrap(popErr, "Error popping for salData")
+ }
+ if _salDataErr != nil {
+ return errors.Wrap(_salDataErr, "Error serializing 'salData' field")
+ }
+ }
+
if popErr := writeBuffer.PopContext("SALData"); popErr != nil {
return errors.Wrap(popErr, "Error popping for SALData")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/SALDataOff.go b/plc4go/protocols/cbus/readwrite/model/SALDataOff.go
index 2fed40417..3553fcaf9 100644
--- a/plc4go/protocols/cbus/readwrite/model/SALDataOff.go
+++ b/plc4go/protocols/cbus/readwrite/model/SALDataOff.go
@@ -58,8 +58,9 @@ type _SALDataOff struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_SALDataOff) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer) {
+func (m *_SALDataOff) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer, salData SALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.SalData = salData
}
func (m *_SALDataOff) GetParent() SALData {
@@ -81,10 +82,10 @@ func (m *_SALDataOff) GetGroup() byte {
///////////////////////////////////////////////////////////
// NewSALDataOff factory function for _SALDataOff
-func NewSALDataOff(group byte, commandTypeContainer SALCommandTypeContainer) *_SALDataOff {
+func NewSALDataOff(group byte, commandTypeContainer SALCommandTypeContainer, salData SALData) *_SALDataOff {
_result := &_SALDataOff{
Group: group,
- _SALData: NewSALData(commandTypeContainer),
+ _SALData: NewSALData(commandTypeContainer, salData),
}
_result._SALData._SALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/SALDataOn.go b/plc4go/protocols/cbus/readwrite/model/SALDataOn.go
index 60566ed23..16f5703d6 100644
--- a/plc4go/protocols/cbus/readwrite/model/SALDataOn.go
+++ b/plc4go/protocols/cbus/readwrite/model/SALDataOn.go
@@ -58,8 +58,9 @@ type _SALDataOn struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_SALDataOn) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer) {
+func (m *_SALDataOn) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer, salData SALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.SalData = salData
}
func (m *_SALDataOn) GetParent() SALData {
@@ -81,10 +82,10 @@ func (m *_SALDataOn) GetGroup() byte {
///////////////////////////////////////////////////////////
// NewSALDataOn factory function for _SALDataOn
-func NewSALDataOn(group byte, commandTypeContainer SALCommandTypeContainer) *_SALDataOn {
+func NewSALDataOn(group byte, commandTypeContainer SALCommandTypeContainer, salData SALData) *_SALDataOn {
_result := &_SALDataOn{
Group: group,
- _SALData: NewSALData(commandTypeContainer),
+ _SALData: NewSALData(commandTypeContainer, salData),
}
_result._SALData._SALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/SALDataRampToLevel.go b/plc4go/protocols/cbus/readwrite/model/SALDataRampToLevel.go
index 410e40622..916491277 100644
--- a/plc4go/protocols/cbus/readwrite/model/SALDataRampToLevel.go
+++ b/plc4go/protocols/cbus/readwrite/model/SALDataRampToLevel.go
@@ -61,8 +61,9 @@ type _SALDataRampToLevel struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_SALDataRampToLevel) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer) {
+func (m *_SALDataRampToLevel) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer, salData SALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.SalData = salData
}
func (m *_SALDataRampToLevel) GetParent() SALData {
@@ -88,11 +89,11 @@ func (m *_SALDataRampToLevel) GetLevel() byte {
///////////////////////////////////////////////////////////
// NewSALDataRampToLevel factory function for _SALDataRampToLevel
-func NewSALDataRampToLevel(group byte, level byte, commandTypeContainer SALCommandTypeContainer) *_SALDataRampToLevel {
+func NewSALDataRampToLevel(group byte, level byte, commandTypeContainer SALCommandTypeContainer, salData SALData) *_SALDataRampToLevel {
_result := &_SALDataRampToLevel{
Group: group,
Level: level,
- _SALData: NewSALData(commandTypeContainer),
+ _SALData: NewSALData(commandTypeContainer, salData),
}
_result._SALData._SALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/SALDataTerminateRamp.go b/plc4go/protocols/cbus/readwrite/model/SALDataTerminateRamp.go
index 1da0b9b31..c178426b8 100644
--- a/plc4go/protocols/cbus/readwrite/model/SALDataTerminateRamp.go
+++ b/plc4go/protocols/cbus/readwrite/model/SALDataTerminateRamp.go
@@ -58,8 +58,9 @@ type _SALDataTerminateRamp struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_SALDataTerminateRamp) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer) {
+func (m *_SALDataTerminateRamp) InitializeParent(parent SALData, commandTypeContainer SALCommandTypeContainer, salData SALData) {
m.CommandTypeContainer = commandTypeContainer
+ m.SalData = salData
}
func (m *_SALDataTerminateRamp) GetParent() SALData {
@@ -81,10 +82,10 @@ func (m *_SALDataTerminateRamp) GetGroup() byte {
///////////////////////////////////////////////////////////
// NewSALDataTerminateRamp factory function for _SALDataTerminateRamp
-func NewSALDataTerminateRamp(group byte, commandTypeContainer SALCommandTypeContainer) *_SALDataTerminateRamp {
+func NewSALDataTerminateRamp(group byte, commandTypeContainer SALCommandTypeContainer, salData SALData) *_SALDataTerminateRamp {
_result := &_SALDataTerminateRamp{
Group: group,
- _SALData: NewSALData(commandTypeContainer),
+ _SALData: NewSALData(commandTypeContainer, salData),
}
_result._SALData._SALDataChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
index 25545ae37..61a9c0890 100644
--- a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
+++ b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
@@ -127,10 +127,11 @@ func writeToHex(logicalName string, writeBuffer utils.WriteBuffer, serializable
if err != nil {
return errors.Wrap(err, "Error serializing")
}
- hexBytes := make([]byte, hex.EncodedLen(len(wbbb.GetBytes())))
+ bytesToWrite := wbbb.GetBytes()
+ hexBytes := make([]byte, hex.EncodedLen(len(bytesToWrite)))
// usually you use hex.Encode but we want the encoding in uppercase
//n := hex.Encode(hexBytes, wbbb.GetBytes())
- n := encodeHexUpperCase(hexBytes, wbbb.GetBytes())
+ n := encodeHexUpperCase(hexBytes, bytesToWrite)
log.Debug().Msgf("%d bytes encoded", n)
return writeBuffer.WriteByteArray(logicalName, hexBytes)
}
@@ -146,3 +147,23 @@ func encodeHexUpperCase(dst, src []byte) int {
}
return len(src) * 2
}
+
+func KnowsCALCommandTypeContainer(readBuffer utils.ReadBuffer) bool {
+ oldPos := readBuffer.GetPos()
+ defer readBuffer.Reset(oldPos)
+ readUint8, err := readBuffer.ReadUint8("", 8)
+ if err != nil {
+ return false
+ }
+ return CALCommandTypeContainerKnows(readUint8)
+}
+
+func KnowsSALCommandTypeContainer(readBuffer utils.ReadBuffer) bool {
+ oldPos := readBuffer.GetPos()
+ defer readBuffer.Reset(oldPos)
+ readUint8, err := readBuffer.ReadUint8("", 8)
+ if err != nil {
+ return false
+ }
+ return SALCommandTypeContainerKnows(readUint8)
+}
diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go b/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
index f7d55f704..180394e79 100644
--- a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
+++ b/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
@@ -129,6 +129,8 @@ func (a *Analyzer) PrettyPrint(message interface{}) {
switch request := message.GetRequest().(type) {
case model.RequestDirectCommandAccessExactly:
fmt.Printf("%v\n", request.GetCalDataOrSetParameter())
+ case model.RequestObsoleteExactly:
+ fmt.Printf("%v\n", request.GetCalDataOrSetParameter())
case model.RequestCommandExactly:
fmt.Printf("%v\n", request.GetCbusCommand())
}
@@ -142,6 +144,9 @@ func (a *Analyzer) PrettyPrint(message interface{}) {
case model.ReplyCALReplyExactly:
// We print this a second time as the first print contains only the hex part
fmt.Printf("%v\n", reply.GetCalReply())
+ case model.MonitoredSALReplyExactly:
+ // We print this a second time as the first print contains only the hex part
+ fmt.Printf("%v\n", reply.GetMonitoredSAL())
}
}
case model.ReplyOrConfirmationReplyExactly:
diff --git a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/readwrite/utils/StaticHelper.java b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/readwrite/utils/StaticHelper.java
index 9d2dd2c50..582586bca 100644
--- a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/readwrite/utils/StaticHelper.java
+++ b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/readwrite/utils/StaticHelper.java
@@ -104,11 +104,36 @@ public class StaticHelper {
}
private static void writeToHex(String logicalName, WriteBuffer writeBuffer, Serializable serializable, int lengthInBytes) throws SerializationException {
- // TODO: maybe we use a writebuffer hex based
+ // TODO: maybe we use a writeBuffer hex based
WriteBufferByteBased payloadWriteBuffer = new WriteBufferByteBased(lengthInBytes * 2);
serializable.serialize(payloadWriteBuffer);
- byte[] hexBytes = Hex.encodeHexString(payloadWriteBuffer.getBytes()).getBytes(StandardCharsets.UTF_8);
+ byte[] hexBytes = Hex.encodeHexString(payloadWriteBuffer.getBytes(), false).getBytes(StandardCharsets.UTF_8);
writeBuffer.writeByteArray(logicalName, hexBytes);
}
+ public static boolean knowsCALCommandTypeContainer(ReadBuffer readBuffer) {
+ int oldPos = readBuffer.getPos();
+ try {
+ return CALCommandTypeContainer.isDefined(readBuffer.readUnsignedShort(8));
+ } catch (ParseException ignore) {
+ return false;
+ } finally {
+ readBuffer.reset(oldPos);
+ }
+ }
+
+ public static boolean knowsSALCommandTypeContainer(ReadBuffer readBuffer) {
+ int oldPos = readBuffer.getPos();
+ try {
+ return SALCommandTypeContainer.isDefined(readBuffer.readUnsignedShort(8));
+ } catch (ParseException ignore) {
+ return false;
+ } finally {
+ readBuffer.reset(oldPos);
+ }
+ }
+
+ public static boolean moreThanOneByteLeft(ReadBuffer readBuffer) {
+ return readBuffer.hasMore(16);
+ }
}
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 7771d1a8c..79dc2b0f6 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
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.cbus;
import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.cbus.readwrite.*;
import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
+import org.apache.plc4x.java.spi.generation.WriteBufferByteBased;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
@@ -53,8 +54,7 @@ public class RandomPackagesTest {
byte[] bytes = new byte[]{0x03};
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusHeader msg = CBusHeader.staticParse(readBufferByteBased);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -63,8 +63,7 @@ public class RandomPackagesTest {
byte[] bytes = new byte[]{0x05};
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusHeader msg = CBusHeader.staticParse(readBufferByteBased);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -73,8 +72,7 @@ public class RandomPackagesTest {
byte[] bytes = new byte[]{0x06};
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusHeader msg = CBusHeader.staticParse(readBufferByteBased);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -90,8 +88,7 @@ public class RandomPackagesTest {
byte[] bytes = "~\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -102,8 +99,7 @@ public class RandomPackagesTest {
byte[] bytes = "AB0123?9876\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -113,8 +109,7 @@ public class RandomPackagesTest {
byte[] bytes = "\r|\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -126,8 +121,7 @@ public class RandomPackagesTest {
byte[] bytes = "AB0123n9876\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -137,8 +131,7 @@ public class RandomPackagesTest {
byte[] bytes = "@2102\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CALData calData = ((CALDataOrSetParameterValue) ((RequestDirectCommandAccess) ((CBusMessageToServer) msg).getRequest()).getCalDataOrSetParameter()).getCalData();
System.out.println(calData);
@@ -152,8 +145,7 @@ public class RandomPackagesTest {
byte[] bytes = "~2102\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CALData calData = ((CALDataOrSetParameterValue) ((RequestDirectCommandAccess) ((CBusMessageToServer) msg).getRequest()).getCalDataOrSetParameter()).getCalData();
System.out.println(calData);
@@ -170,8 +162,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0603002102D4\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -182,8 +173,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\06420903210289\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -199,8 +189,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0538000108BA\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -211,8 +200,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\05FF007A38004A\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -227,8 +215,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\03420938010871\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -243,8 +230,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0605002102\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -253,8 +239,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("8902312E322E363620200A");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CALReply msg = CALReplyShort.staticParse(readBufferByteBased, cBusOptions, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -263,8 +248,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("860593008902312E322E363620207F");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CALReply msg = CALReplyLong.staticParse(readBufferByteBased, cBusOptions, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
}
@@ -277,8 +261,7 @@ public class RandomPackagesTest {
byte[] bytes = "0503380079083F\r\n".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
MonitoredSAL monitoredSAL = ((MonitoredSALReply) ((ReplyOrConfirmationReply) msg).getReply()).getMonitoredSAL();
System.out.println(monitoredSAL);
@@ -293,8 +276,7 @@ public class RandomPackagesTest {
byte[] bytes = "g.".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -303,8 +285,7 @@ public class RandomPackagesTest {
byte[] bytes = "g#".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -313,8 +294,7 @@ public class RandomPackagesTest {
byte[] bytes = "g$".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -323,8 +303,7 @@ public class RandomPackagesTest {
byte[] bytes = "g%".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -333,8 +312,7 @@ public class RandomPackagesTest {
byte[] bytes = "g'".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ReplyOrConfirmation msg = ReplyOrConfirmation.staticParse(readBufferByteBased, cBusOptions, bytes.length, requestContext);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
}
@@ -345,8 +323,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("D8380068AA0140550550001000000014000000000000000000CF");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -355,8 +332,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("D838580000000000000000000000000000000000000000000098");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -365,8 +341,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("D638B000000000FF00000000000000000000000000000043");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -376,8 +351,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("F9073800AAAA000095990000000005555000000000005555555548");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ExtendedFormatStatusReply msg = ExtendedFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -386,8 +360,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("F907380B0000000000005555000000000000000000000000000013");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ExtendedFormatStatusReply msg = ExtendedFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -396,8 +369,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("f70738160000000000000000000000000000000000000000B4");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
ExtendedFormatStatusReply msg = ExtendedFormatStatusReply.staticParse(readBufferByteBased, false);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -410,8 +382,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0538000114AE\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -421,8 +392,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\05FF007A38004A\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -433,8 +403,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -447,8 +416,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -461,8 +429,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -475,8 +442,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -490,8 +456,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -504,8 +469,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(false, true, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
StandardFormatStatusReply reply = ((ReplyStandardFormatStatusReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getReply();
System.out.println(reply);
@@ -521,8 +485,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0604001A3001AB\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -532,8 +495,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(true, false, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -548,8 +510,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\03421B53643801149C\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusCommand cbusCommand = ((RequestCommand) ((CBusMessageToServer) msg).getRequest()).getCbusCommand();
System.out.println(cbusCommand);
@@ -561,8 +522,7 @@ public class RandomPackagesTest {
byte[] bytes = Hex.decodeHex("0565380354432101148E");
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusCommand msg = CBusCommand.staticParse(readBufferByteBased, cBusOptions);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -574,8 +534,7 @@ public class RandomPackagesTest {
byte[] bytes = "~@A3300019\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -585,8 +544,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\05380001210122012301240A25010A2601D4\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -596,8 +554,7 @@ public class RandomPackagesTest {
byte[] bytes = "@A3470011\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -607,8 +564,7 @@ public class RandomPackagesTest {
byte[] bytes = "A3470011\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CALDataOrSetParameterSetParameter calDataOrSetParameter = (CALDataOrSetParameterSetParameter) ((RequestObsolete) ((CBusMessageToServer) msg).getRequest()).getCalDataOrSetParameter();
@@ -625,8 +581,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0538007902D4\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -641,8 +596,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\3436303230303231303167\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -651,8 +605,7 @@ public class RandomPackagesTest {
byte[] bytes = "@1A2001\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
}
@@ -661,8 +614,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0538000100g\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToServer msgToServer = (CBusMessageToServer) msg;
RequestCommand requestCommand = (RequestCommand) msgToServer.getRequest();
@@ -677,8 +629,7 @@ public class RandomPackagesTest {
// We know we send an identify command so we set the cal flag
requestContext = new RequestContext(true, false, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToClient messageToClient = (CBusMessageToClient) msg;
ReplyOrConfirmationConfirmation confirmationReply = (ReplyOrConfirmationConfirmation) messageToClient.getReply();
@@ -693,8 +644,7 @@ public class RandomPackagesTest {
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
requestContext = new RequestContext(true, false, false);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToClient messageToClient = (CBusMessageToClient) msg;
ReplyOrConfirmationConfirmation confirmationReply = (ReplyOrConfirmationConfirmation) messageToClient.getReply();
@@ -708,8 +658,7 @@ public class RandomPackagesTest {
byte[] bytes = "\\0538000100g\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToServer messageToServer = (CBusMessageToServer) msg;
RequestCommand requestCommand = (RequestCommand) messageToServer.getRequest();
@@ -722,8 +671,7 @@ public class RandomPackagesTest {
byte[] bytes = "21021A2102i\r".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToServer messageToServer = (CBusMessageToServer) msg;
RequestObsolete requestObsolete = (RequestObsolete) messageToServer.getRequest();
@@ -738,13 +686,50 @@ public class RandomPackagesTest {
// We know we send an identify command so we set the cal flag
requestContext = new RequestContext(true, false, true);
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
- assertThat(msg)
- .isNotNull();
+ assertThat(msg).isNotNull();
System.out.println(msg);
CBusMessageToClient messageToClient = (CBusMessageToClient) msg;
ReplyOrConfirmationConfirmation confirmationReply = (ReplyOrConfirmationConfirmation) messageToClient.getReply();
ReplyOrConfirmationReply normalReply = (ReplyOrConfirmationReply) confirmationReply.getEmbeddedReply();
System.out.println(((ReplyCALReply) normalReply.getReply()).getCalReply());
}
+
+ @Test
+ void recall() throws Exception {
+ byte[] bytes = "@1A2001\r".getBytes(StandardCharsets.UTF_8);
+ ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+ CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, requestContext, cBusOptions, bytes.length);
+ assertThat(msg).isNotNull();
+ System.out.println(msg);
+ CBusMessageToServer messageToServer = (CBusMessageToServer) msg;
+ RequestDirectCommandAccess requestDirectCommandAccess = (RequestDirectCommandAccess) messageToServer.getRequest();
+ CALDataOrSetParameter calDataOrSetParameter = requestDirectCommandAccess.getCalDataOrSetParameter();
+ System.out.println(calDataOrSetParameter);
+
+ WriteBufferByteBased writeBuffer = new WriteBufferByteBased(bytes.length);
+ msg.serialize(writeBuffer);
+ assertThat(writeBuffer.getBytes()).isEqualTo(bytes);
+ }
+
+ @Test
+ void identifyTypeReply() throws Exception {
+ byte[] bytes = "h.890150435F434E49454421\r\n".getBytes(StandardCharsets.UTF_8);
+ ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+ requestContext = new RequestContext(true, false, true);
+ cBusOptions = new CBusOptions(false, false, false, false, false, false, false, false, true);
+ CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions, bytes.length);
+ assertThat(msg).isNotNull();
+ System.out.println(msg);
+ CBusMessageToClient messageToClient = (CBusMessageToClient) msg;
+ ReplyOrConfirmationConfirmation confirmationReply = (ReplyOrConfirmationConfirmation) messageToClient.getReply();
+ ReplyOrConfirmationReply normalReply = (ReplyOrConfirmationReply) confirmationReply.getEmbeddedReply();
+ ReplyCALReply calReplyReply = (ReplyCALReply) normalReply.getReply();
+ System.out.println(calReplyReply.getCalReply());
+
+ WriteBufferByteBased writeBuffer = new WriteBufferByteBased(bytes.length);
+ msg.serialize(writeBuffer);
+ byte[] bytes1 = writeBuffer.getBytes();
+ assertThat(bytes1).isEqualTo(bytes);
+ }
}
}
diff --git a/plc4j/drivers/c-bus/src/test/resources/logback-test.xml b/plc4j/drivers/c-bus/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..a6e23373c
--- /dev/null
+++ b/plc4j/drivers/c-bus/src/test/resources/logback-test.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="ERROR">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
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 6e98dfa78..21df37684 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
@@ -236,15 +236,14 @@
[reserved byte '0xFF' ]
[reserved byte '0x00' ]
[simple StatusRequest statusRequest ]
- [optional Checksum crc 'cBusOptions.srchk' ] // checksum is optional but mspec checksum isn't
]
[ *Normal
[simple ApplicationIdContainer application ]
[reserved byte '0x00' ]
[simple SALData salData ]
- [optional Checksum crc 'cBusOptions.srchk' ] // crc is optional but mspec crc isn't
]
]
+ [optional Checksum crc 'cBusOptions.srchk' ] // checksum is optional but mspec checksum isn't
]
[discriminatedType CBusPointToPointToMultipointCommand(CBusOptions cBusOptions)
@@ -255,14 +254,13 @@
['0xFF' *Status
[reserved byte '0xFF' ]
[simple StatusRequest statusRequest ]
- [optional Checksum crc 'cBusOptions.srchk' ] // crc is optional but mspec crc isn't
]
[* *Normal
[simple ApplicationIdContainer application ]
[simple SALData salData ]
- [optional Checksum crc 'cBusOptions.srchk' ] // crc is optional but mspec crc isn't
]
]
+ [optional Checksum crc 'cBusOptions.srchk' ] // checksum is optional but mspec checksum isn't
]
/*
@@ -574,9 +572,9 @@
]
[type CALData(RequestContext requestContext)
+ //TODO: golang doesn't like checking for null so we use that static call to check that the enum is known
+ [validation 'STATIC_CALL("knowsCALCommandTypeContainer", readBuffer)' "no command type could be found" shouldFail=false]
[simple CALCommandTypeContainer commandTypeContainer ]
- //TODO: golang doesn't like checking for 0
- //[validation 'commandTypeContainer!=null' "no command type could be found" ]
[virtual CALCommandType commandType 'commandTypeContainer.commandType']
[virtual bit sendIdentifyRequestBefore 'requestContext!=null?requestContext.sendIdentifyRequestBefore:false']
[typeSwitch commandType, sendIdentifyRequestBefore
@@ -617,9 +615,8 @@
[array byte data count 'commandTypeContainer.numBytes' ]
]
]
- // TODO: validate that this is the intention of 7.1
- // FIXME: as long as golang doesn't use pointer here we can't check if a value is known...
- //[optional CALData('requestContext') additionalData]
+ // TODO: we need to check that we don't read the crc by accident
+ [optional CALData('requestContext') additionalData]
]
[enum uint 8 Attribute(uint 8 bytesReturned)
@@ -757,6 +754,7 @@
['0x1A' CALCommandRecall ['RECALL', '0']]
['0x21' CALCommandIdentify ['IDENTIFY', '0']]
['0x2A' CALCommandGetStatus ['GET_STATUS', '0']]
+ ['0x80' CALCommandReply_0Bytes ['REPLY', '0']]
['0x81' CALCommandReply_1Bytes ['REPLY', '1']]
['0x82' CALCommandReply_2Bytes ['REPLY', '2']]
['0x83' CALCommandReply_3Bytes ['REPLY', '3']]
@@ -789,6 +787,7 @@
['0x9E' CALCommandReply_30Bytes ['REPLY', '30']]
['0x9F' CALCommandReply_31Bytes ['REPLY', '31']]
['0x32' CALCommandAcknowledge ['ACKNOWLEDGE', '0']]
+ ['0xC0' CALCommandStatus_0Bytes ['STATUS', '0']]
['0xC1' CALCommandStatus_1Bytes ['STATUS', '1']]
['0xC2' CALCommandStatus_2Bytes ['STATUS', '2']]
['0xC3' CALCommandStatus_3Bytes ['STATUS', '3']]
@@ -820,6 +819,7 @@
['0xDD' CALCommandStatus_29Bytes ['STATUS', '29']]
['0xDE' CALCommandStatus_30Bytes ['STATUS', '30']]
['0xDF' CALCommandStatus_31Bytes ['STATUS', '31']]
+ ['0xE0' CALCommandStatusExtended_0Bytes ['STATUS_EXTENDED', '0']]
['0xE1' CALCommandStatusExtended_1Bytes ['STATUS_EXTENDED', '1']]
['0xE1' CALCommandStatusExtended_2Bytes ['STATUS_EXTENDED', '2']]
['0xE3' CALCommandStatusExtended_3Bytes ['STATUS_EXTENDED', '3']]
@@ -855,15 +855,15 @@
[enum uint 4 CALCommandType
// Request
- ['0x0' RESET ] //00001000
- ['0x0' RECALL ] //00011010
- ['0x1' IDENTIFY ] //00100001
- ['0x2' GET_STATUS ] //01000001
+ ['0x0' RESET ]
+ ['0x1' RECALL ]
+ ['0x2' IDENTIFY ]
+ ['0x3' GET_STATUS ]
// Response
- ['0x3' REPLY ] //100xxxxx
- ['0x4' ACKNOWLEDGE ] //00110010
- ['0x5' STATUS ] //110xxxxx
- ['0x5' STATUS_EXTENDED] //111xxxxx
+ ['0x4' REPLY ]
+ ['0x5' ACKNOWLEDGE ]
+ ['0x6' STATUS ]
+ ['0x7' STATUS_EXTENDED]
]
[type StatusRequest
@@ -892,6 +892,8 @@
]
[type SALData
+ //TODO: golang doesn't like checking for null so we use that static call to check that the enum is known
+ [validation 'STATIC_CALL("knowsSALCommandTypeContainer", readBuffer)' "no command type could be found" shouldFail=false]
[simple SALCommandTypeContainer commandTypeContainer ]
[virtual SALCommandType commandType 'commandTypeContainer.commandType']
[typeSwitch commandType
@@ -909,8 +911,8 @@
[simple byte group ]
]
]
- // TODO: According to spec this could be recursive
- //[optional SALData salData 'what decides if this is present?']
+ // TODO: we need to check that we don't read the crc by accident
+ [optional SALData salData ]
]
[enum uint 8 SALCommandTypeContainer(SALCommandType commandType)