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/08/04 09:35:44 UTC
[plc4x] 02/02: fix(cbus): fixed ParameterValues respecting the additional data
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 86d2ee35f75215d966ecb6e51e955101ae1cab4f
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Aug 4 11:35:33 2022 +0200
fix(cbus): fixed ParameterValues respecting the additional data
---
plc4go/internal/cbus/Connection.go | 8 ++---
.../model/ParameterValueApplicationAddress1.go | 30 ++++++++++++++--
.../model/ParameterValueApplicationAddress2.go | 40 ++++++++++++++++++----
.../model/ParameterValueBaudRateSelector.go | 30 ++++++++++++++--
.../model/ParameterValueInterfaceOptions1.go | 30 ++++++++++++++--
...rameterValueInterfaceOptions1PowerUpSettings.go | 2 +-
.../model/ParameterValueInterfaceOptions2.go | 30 ++++++++++++++--
.../model/ParameterValueInterfaceOptions3.go | 30 ++++++++++++++--
.../readwrite/model/ParameterValueSerialNumber.go | 30 ++++++++++++++--
.../src/main/resources/protocols/cbus/c-bus.mspec | 32 ++++++++++++-----
10 files changed, 229 insertions(+), 33 deletions(-)
diff --git a/plc4go/internal/cbus/Connection.go b/plc4go/internal/cbus/Connection.go
index 84e3daaf9..e45928470 100644
--- a/plc4go/internal/cbus/Connection.go
+++ b/plc4go/internal/cbus/Connection.go
@@ -232,11 +232,11 @@ func (c *Connection) setupConnection(ch chan plc4go.PlcConnectionConnectResult)
}
{
log.Debug().Msg("Set application filter to all")
- applicationAddress1 := readWriteModel.NewParameterValueApplicationAddress1(readWriteModel.NewApplicationAddress1(0xFF), 1)
+ applicationAddress1 := readWriteModel.NewParameterValueApplicationAddress1(readWriteModel.NewApplicationAddress1(0xFF), nil, 1)
if !c.sendCalDataWrite(ch, readWriteModel.Parameter_APPLICATION_ADDRESS_1, applicationAddress1, requestContext, cbusOptions) {
return
}
- applicationAddress2 := readWriteModel.NewParameterValueApplicationAddress2(readWriteModel.NewApplicationAddress2(0xFF), 1)
+ applicationAddress2 := readWriteModel.NewParameterValueApplicationAddress2(readWriteModel.NewApplicationAddress2(0xFF), nil, 1)
if !c.sendCalDataWrite(ch, readWriteModel.Parameter_APPLICATION_ADDRESS_2, applicationAddress2, requestContext, cbusOptions) {
return
}
@@ -244,7 +244,7 @@ func (c *Connection) setupConnection(ch chan plc4go.PlcConnectionConnectResult)
}
{
log.Debug().Msg("Set interface options 3")
- interfaceOptions3 := readWriteModel.NewParameterValueInterfaceOptions3(readWriteModel.NewInterfaceOptions3(true, false, true, false), 1)
+ interfaceOptions3 := readWriteModel.NewParameterValueInterfaceOptions3(readWriteModel.NewInterfaceOptions3(true, false, true, false), nil, 1)
if !c.sendCalDataWrite(ch, readWriteModel.Parameter_INTERFACE_OPTIONS_3, interfaceOptions3, requestContext, cbusOptions) {
return
}
@@ -263,7 +263,7 @@ func (c *Connection) setupConnection(ch chan plc4go.PlcConnectionConnectResult)
}
{
log.Debug().Msg("Set interface options 1")
- interfaceOptions1 := readWriteModel.NewParameterValueInterfaceOptions1(readWriteModel.NewInterfaceOptions1(true, true, true, true, false, true), 1)
+ interfaceOptions1 := readWriteModel.NewParameterValueInterfaceOptions1(readWriteModel.NewInterfaceOptions1(true, true, true, true, false, true), nil, 1)
if !c.sendCalDataWrite(ch, readWriteModel.Parameter_INTERFACE_OPTIONS_1, interfaceOptions1, requestContext, cbusOptions) {
return
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress1.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress1.go
index c10c4136f..77aad7ccb 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress1.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress1.go
@@ -33,6 +33,8 @@ type ParameterValueApplicationAddress1 interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() ApplicationAddress1
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueApplicationAddress1Exactly can be used when we want exactly this type and not a type which fulfills ParameterValueApplicationAddress1.
@@ -46,6 +48,7 @@ type ParameterValueApplicationAddress1Exactly interface {
type _ParameterValueApplicationAddress1 struct {
*_ParameterValue
Value ApplicationAddress1
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueApplicationAddress1) GetValue() ApplicationAddress1 {
return m.Value
}
+func (m *_ParameterValueApplicationAddress1) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueApplicationAddress1 factory function for _ParameterValueApplicationAddress1
-func NewParameterValueApplicationAddress1(value ApplicationAddress1, numBytes uint8) *_ParameterValueApplicationAddress1 {
+func NewParameterValueApplicationAddress1(value ApplicationAddress1, data []byte, numBytes uint8) *_ParameterValueApplicationAddress1 {
_result := &_ParameterValueApplicationAddress1{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueApplicationAddress1) GetLengthInBitsConditional(lastItem
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueApplicationAddress1Parse(readBuffer utils.ReadBuffer, paramet
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"ApplicationAddress1 has exactly one byte"})
}
@@ -150,6 +163,12 @@ func ParameterValueApplicationAddress1Parse(readBuffer utils.ReadBuffer, paramet
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueApplicationAddress1")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueApplicationAddress1"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueApplicationAddress1")
@@ -158,6 +177,7 @@ func ParameterValueApplicationAddress1Parse(readBuffer utils.ReadBuffer, paramet
// Create a partially initialized instance
_child := &_ParameterValueApplicationAddress1{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueApplicationAddress1) Serialize(writeBuffer utils.WriteBu
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueApplicationAddress1"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueApplicationAddress1")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress2.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress2.go
index 2fc21e1cc..d0f3bdd3f 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress2.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueApplicationAddress2.go
@@ -32,7 +32,9 @@ type ParameterValueApplicationAddress2 interface {
utils.Serializable
ParameterValue
// GetValue returns Value (property field)
- GetValue() ApplicationAddress1
+ GetValue() ApplicationAddress2
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueApplicationAddress2Exactly can be used when we want exactly this type and not a type which fulfills ParameterValueApplicationAddress2.
@@ -45,7 +47,8 @@ type ParameterValueApplicationAddress2Exactly interface {
// _ParameterValueApplicationAddress2 is the data-structure of this message
type _ParameterValueApplicationAddress2 struct {
*_ParameterValue
- Value ApplicationAddress1
+ Value ApplicationAddress2
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -73,19 +76,24 @@ func (m *_ParameterValueApplicationAddress2) GetParent() ParameterValue {
/////////////////////// Accessors for property fields.
///////////////////////
-func (m *_ParameterValueApplicationAddress2) GetValue() ApplicationAddress1 {
+func (m *_ParameterValueApplicationAddress2) GetValue() ApplicationAddress2 {
return m.Value
}
+func (m *_ParameterValueApplicationAddress2) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueApplicationAddress2 factory function for _ParameterValueApplicationAddress2
-func NewParameterValueApplicationAddress2(value ApplicationAddress1, numBytes uint8) *_ParameterValueApplicationAddress2 {
+func NewParameterValueApplicationAddress2(value ApplicationAddress2, data []byte, numBytes uint8) *_ParameterValueApplicationAddress2 {
_result := &_ParameterValueApplicationAddress2{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueApplicationAddress2) GetLengthInBitsConditional(lastItem
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueApplicationAddress2Parse(readBuffer utils.ReadBuffer, paramet
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"ApplicationAddress2 has exactly one byte"})
}
@@ -142,14 +155,20 @@ func ParameterValueApplicationAddress2Parse(readBuffer utils.ReadBuffer, paramet
if pullErr := readBuffer.PullContext("value"); pullErr != nil {
return nil, errors.Wrap(pullErr, "Error pulling for value")
}
- _value, _valueErr := ApplicationAddress1Parse(readBuffer)
+ _value, _valueErr := ApplicationAddress2Parse(readBuffer)
if _valueErr != nil {
return nil, errors.Wrap(_valueErr, "Error parsing 'value' field of ParameterValueApplicationAddress2")
}
- value := _value.(ApplicationAddress1)
+ value := _value.(ApplicationAddress2)
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueApplicationAddress2")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueApplicationAddress2"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueApplicationAddress2")
@@ -158,6 +177,7 @@ func ParameterValueApplicationAddress2Parse(readBuffer utils.ReadBuffer, paramet
// Create a partially initialized instance
_child := &_ParameterValueApplicationAddress2{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueApplicationAddress2) Serialize(writeBuffer utils.WriteBu
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueApplicationAddress2"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueApplicationAddress2")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueBaudRateSelector.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueBaudRateSelector.go
index ea08078b5..af658ba3d 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueBaudRateSelector.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueBaudRateSelector.go
@@ -33,6 +33,8 @@ type ParameterValueBaudRateSelector interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() BaudRateSelector
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueBaudRateSelectorExactly can be used when we want exactly this type and not a type which fulfills ParameterValueBaudRateSelector.
@@ -46,6 +48,7 @@ type ParameterValueBaudRateSelectorExactly interface {
type _ParameterValueBaudRateSelector struct {
*_ParameterValue
Value BaudRateSelector
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueBaudRateSelector) GetValue() BaudRateSelector {
return m.Value
}
+func (m *_ParameterValueBaudRateSelector) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueBaudRateSelector factory function for _ParameterValueBaudRateSelector
-func NewParameterValueBaudRateSelector(value BaudRateSelector, numBytes uint8) *_ParameterValueBaudRateSelector {
+func NewParameterValueBaudRateSelector(value BaudRateSelector, data []byte, numBytes uint8) *_ParameterValueBaudRateSelector {
_result := &_ParameterValueBaudRateSelector{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueBaudRateSelector) GetLengthInBitsConditional(lastItem bo
// Simple field (value)
lengthInBits += 8
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueBaudRateSelectorParse(readBuffer utils.ReadBuffer, parameterT
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"BaudRateSelector has exactly one byte"})
}
@@ -150,6 +163,12 @@ func ParameterValueBaudRateSelectorParse(readBuffer utils.ReadBuffer, parameterT
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueBaudRateSelector")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueBaudRateSelector"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueBaudRateSelector")
@@ -158,6 +177,7 @@ func ParameterValueBaudRateSelectorParse(readBuffer utils.ReadBuffer, parameterT
// Create a partially initialized instance
_child := &_ParameterValueBaudRateSelector{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueBaudRateSelector) Serialize(writeBuffer utils.WriteBuffe
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueBaudRateSelector"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueBaudRateSelector")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1.go
index d387d11f6..b327bdca4 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1.go
@@ -33,6 +33,8 @@ type ParameterValueInterfaceOptions1 interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() InterfaceOptions1
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueInterfaceOptions1Exactly can be used when we want exactly this type and not a type which fulfills ParameterValueInterfaceOptions1.
@@ -46,6 +48,7 @@ type ParameterValueInterfaceOptions1Exactly interface {
type _ParameterValueInterfaceOptions1 struct {
*_ParameterValue
Value InterfaceOptions1
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueInterfaceOptions1) GetValue() InterfaceOptions1 {
return m.Value
}
+func (m *_ParameterValueInterfaceOptions1) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueInterfaceOptions1 factory function for _ParameterValueInterfaceOptions1
-func NewParameterValueInterfaceOptions1(value InterfaceOptions1, numBytes uint8) *_ParameterValueInterfaceOptions1 {
+func NewParameterValueInterfaceOptions1(value InterfaceOptions1, data []byte, numBytes uint8) *_ParameterValueInterfaceOptions1 {
_result := &_ParameterValueInterfaceOptions1{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueInterfaceOptions1) GetLengthInBitsConditional(lastItem b
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueInterfaceOptions1Parse(readBuffer utils.ReadBuffer, parameter
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"InterfaceOptions1 has exactly one byte"})
}
@@ -150,6 +163,12 @@ func ParameterValueInterfaceOptions1Parse(readBuffer utils.ReadBuffer, parameter
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueInterfaceOptions1")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueInterfaceOptions1"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueInterfaceOptions1")
@@ -158,6 +177,7 @@ func ParameterValueInterfaceOptions1Parse(readBuffer utils.ReadBuffer, parameter
// Create a partially initialized instance
_child := &_ParameterValueInterfaceOptions1{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueInterfaceOptions1) Serialize(writeBuffer utils.WriteBuff
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueInterfaceOptions1"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueInterfaceOptions1")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1PowerUpSettings.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1PowerUpSettings.go
index a5ef961e1..e867e4e45 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1PowerUpSettings.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions1PowerUpSettings.go
@@ -134,7 +134,7 @@ func ParameterValueInterfaceOptions1PowerUpSettingsParse(readBuffer utils.ReadBu
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"InterfaceOptions1PowerUpSettings has exactly one byte"})
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions2.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions2.go
index bd887e0f9..7311a953c 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions2.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions2.go
@@ -33,6 +33,8 @@ type ParameterValueInterfaceOptions2 interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() InterfaceOptions2
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueInterfaceOptions2Exactly can be used when we want exactly this type and not a type which fulfills ParameterValueInterfaceOptions2.
@@ -46,6 +48,7 @@ type ParameterValueInterfaceOptions2Exactly interface {
type _ParameterValueInterfaceOptions2 struct {
*_ParameterValue
Value InterfaceOptions2
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueInterfaceOptions2) GetValue() InterfaceOptions2 {
return m.Value
}
+func (m *_ParameterValueInterfaceOptions2) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueInterfaceOptions2 factory function for _ParameterValueInterfaceOptions2
-func NewParameterValueInterfaceOptions2(value InterfaceOptions2, numBytes uint8) *_ParameterValueInterfaceOptions2 {
+func NewParameterValueInterfaceOptions2(value InterfaceOptions2, data []byte, numBytes uint8) *_ParameterValueInterfaceOptions2 {
_result := &_ParameterValueInterfaceOptions2{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueInterfaceOptions2) GetLengthInBitsConditional(lastItem b
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueInterfaceOptions2Parse(readBuffer utils.ReadBuffer, parameter
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"InterfaceOptions2 has exactly one byte"})
}
@@ -150,6 +163,12 @@ func ParameterValueInterfaceOptions2Parse(readBuffer utils.ReadBuffer, parameter
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueInterfaceOptions2")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueInterfaceOptions2"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueInterfaceOptions2")
@@ -158,6 +177,7 @@ func ParameterValueInterfaceOptions2Parse(readBuffer utils.ReadBuffer, parameter
// Create a partially initialized instance
_child := &_ParameterValueInterfaceOptions2{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueInterfaceOptions2) Serialize(writeBuffer utils.WriteBuff
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueInterfaceOptions2"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueInterfaceOptions2")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions3.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions3.go
index bd76290ac..684c6c28f 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions3.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueInterfaceOptions3.go
@@ -33,6 +33,8 @@ type ParameterValueInterfaceOptions3 interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() InterfaceOptions3
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueInterfaceOptions3Exactly can be used when we want exactly this type and not a type which fulfills ParameterValueInterfaceOptions3.
@@ -46,6 +48,7 @@ type ParameterValueInterfaceOptions3Exactly interface {
type _ParameterValueInterfaceOptions3 struct {
*_ParameterValue
Value InterfaceOptions3
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueInterfaceOptions3) GetValue() InterfaceOptions3 {
return m.Value
}
+func (m *_ParameterValueInterfaceOptions3) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueInterfaceOptions3 factory function for _ParameterValueInterfaceOptions3
-func NewParameterValueInterfaceOptions3(value InterfaceOptions3, numBytes uint8) *_ParameterValueInterfaceOptions3 {
+func NewParameterValueInterfaceOptions3(value InterfaceOptions3, data []byte, numBytes uint8) *_ParameterValueInterfaceOptions3 {
_result := &_ParameterValueInterfaceOptions3{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueInterfaceOptions3) GetLengthInBitsConditional(lastItem b
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueInterfaceOptions3Parse(readBuffer utils.ReadBuffer, parameter
_ = currentPos
// Validation
- if !(bool((numBytes) == (1))) {
+ if !(bool((numBytes) >= (1))) {
return nil, errors.WithStack(utils.ParseValidationError{"InterfaceOptions3 has exactly one byte"})
}
@@ -150,6 +163,12 @@ func ParameterValueInterfaceOptions3Parse(readBuffer utils.ReadBuffer, parameter
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(1)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueInterfaceOptions3")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueInterfaceOptions3"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueInterfaceOptions3")
@@ -158,6 +177,7 @@ func ParameterValueInterfaceOptions3Parse(readBuffer utils.ReadBuffer, parameter
// Create a partially initialized instance
_child := &_ParameterValueInterfaceOptions3{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueInterfaceOptions3) Serialize(writeBuffer utils.WriteBuff
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueInterfaceOptions3"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueInterfaceOptions3")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterValueSerialNumber.go b/plc4go/protocols/cbus/readwrite/model/ParameterValueSerialNumber.go
index f01d7b502..efe23b8dc 100644
--- a/plc4go/protocols/cbus/readwrite/model/ParameterValueSerialNumber.go
+++ b/plc4go/protocols/cbus/readwrite/model/ParameterValueSerialNumber.go
@@ -33,6 +33,8 @@ type ParameterValueSerialNumber interface {
ParameterValue
// GetValue returns Value (property field)
GetValue() SerialNumber
+ // GetData returns Data (property field)
+ GetData() []byte
}
// ParameterValueSerialNumberExactly can be used when we want exactly this type and not a type which fulfills ParameterValueSerialNumber.
@@ -46,6 +48,7 @@ type ParameterValueSerialNumberExactly interface {
type _ParameterValueSerialNumber struct {
*_ParameterValue
Value SerialNumber
+ Data []byte
}
///////////////////////////////////////////////////////////
@@ -77,15 +80,20 @@ func (m *_ParameterValueSerialNumber) GetValue() SerialNumber {
return m.Value
}
+func (m *_ParameterValueSerialNumber) GetData() []byte {
+ return m.Data
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewParameterValueSerialNumber factory function for _ParameterValueSerialNumber
-func NewParameterValueSerialNumber(value SerialNumber, numBytes uint8) *_ParameterValueSerialNumber {
+func NewParameterValueSerialNumber(value SerialNumber, data []byte, numBytes uint8) *_ParameterValueSerialNumber {
_result := &_ParameterValueSerialNumber{
Value: value,
+ Data: data,
_ParameterValue: NewParameterValue(numBytes),
}
_result._ParameterValue._ParameterValueChildRequirements = _result
@@ -117,6 +125,11 @@ func (m *_ParameterValueSerialNumber) GetLengthInBitsConditional(lastItem bool)
// Simple field (value)
lengthInBits += m.Value.GetLengthInBits()
+ // Array field
+ if len(m.Data) > 0 {
+ lengthInBits += 8 * uint16(len(m.Data))
+ }
+
return lengthInBits
}
@@ -134,7 +147,7 @@ func ParameterValueSerialNumberParse(readBuffer utils.ReadBuffer, parameterType
_ = currentPos
// Validation
- if !(bool((numBytes) == (4))) {
+ if !(bool((numBytes) >= (4))) {
return nil, errors.WithStack(utils.ParseValidationError{"SerialNumber has exactly four bytes"})
}
@@ -150,6 +163,12 @@ func ParameterValueSerialNumberParse(readBuffer utils.ReadBuffer, parameterType
if closeErr := readBuffer.CloseContext("value"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for value")
}
+ // Byte Array field (data)
+ numberOfBytesdata := int(uint16(numBytes) - uint16(uint16(4)))
+ data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
+ if _readArrayErr != nil {
+ return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of ParameterValueSerialNumber")
+ }
if closeErr := readBuffer.CloseContext("ParameterValueSerialNumber"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for ParameterValueSerialNumber")
@@ -158,6 +177,7 @@ func ParameterValueSerialNumberParse(readBuffer utils.ReadBuffer, parameterType
// Create a partially initialized instance
_child := &_ParameterValueSerialNumber{
Value: value,
+ Data: data,
_ParameterValue: &_ParameterValue{
NumBytes: numBytes,
},
@@ -186,6 +206,12 @@ func (m *_ParameterValueSerialNumber) Serialize(writeBuffer utils.WriteBuffer) e
return errors.Wrap(_valueErr, "Error serializing 'value' field")
}
+ // Array Field (data)
+ // Byte Array field (data)
+ if err := writeBuffer.WriteByteArray("data", m.GetData()); err != nil {
+ return errors.Wrap(err, "Error serializing 'data' field")
+ }
+
if popErr := writeBuffer.PopContext("ParameterValueSerialNumber"); popErr != nil {
return errors.Wrap(popErr, "Error popping for ParameterValueSerialNumber")
}
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 5b0a6e2af..234bb8816 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
@@ -887,39 +887,53 @@
[type ParameterValue(ParameterType parameterType, uint 8 numBytes)
[typeSwitch parameterType
['APPLICATION_ADDRESS_1' *ApplicationAddress1
- [validation 'numBytes == 1' "ApplicationAddress1 has exactly one byte" ]
+ [validation 'numBytes >= 1' "ApplicationAddress1 has exactly one byte" ]
[simple ApplicationAddress1 value ]
+ // TODO: find out what additional bytes mean here... would that be application address 2 then?
+ [array byte data count 'numBytes-1' ]
]
['APPLICATION_ADDRESS_2' *ApplicationAddress2
- [validation 'numBytes == 1' "ApplicationAddress2 has exactly one byte" ]
- [simple ApplicationAddress1 value ]
+ [validation 'numBytes >= 1' "ApplicationAddress2 has exactly one byte" ]
+ [simple ApplicationAddress2 value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-1' ]
]
['INTERFACE_OPTIONS_1' *InterfaceOptions1
- [validation 'numBytes == 1' "InterfaceOptions1 has exactly one byte" ]
+ [validation 'numBytes >= 1' "InterfaceOptions1 has exactly one byte" ]
[simple InterfaceOptions1 value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-1' ]
]
['BAUD_RATE_SELECTOR' *BaudRateSelector
- [validation 'numBytes == 1' "BaudRateSelector has exactly one byte" ]
+ [validation 'numBytes >= 1' "BaudRateSelector has exactly one byte" ]
[simple BaudRateSelector value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-1' ]
]
['INTERFACE_OPTIONS_2' *InterfaceOptions2
- [validation 'numBytes == 1' "InterfaceOptions2 has exactly one byte" ]
+ [validation 'numBytes >= 1' "InterfaceOptions2 has exactly one byte" ]
[simple InterfaceOptions2 value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-1' ]
]
['INTERFACE_OPTIONS_1_POWER_UP_SETTINGS' *InterfaceOptions1PowerUpSettings
- [validation 'numBytes == 1' "InterfaceOptions1PowerUpSettings has exactly one byte" ]
+ [validation 'numBytes >= 1' "InterfaceOptions1PowerUpSettings has exactly one byte" ]
[simple InterfaceOptions1PowerUpSettings value ]
]
['INTERFACE_OPTIONS_3' *InterfaceOptions3
- [validation 'numBytes == 1' "InterfaceOptions3 has exactly one byte" ]
+ [validation 'numBytes >= 1' "InterfaceOptions3 has exactly one byte" ]
[simple InterfaceOptions3 value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-1' ]
]
['CUSTOM_MANUFACTURER' *CustomManufacturer
[simple CustomManufacturer('numBytes') value ]
]
['SERIAL_NUMBER' *SerialNumber
- [validation 'numBytes == 4' "SerialNumber has exactly four bytes" ]
+ [validation 'numBytes >= 4' "SerialNumber has exactly four bytes" ]
[simple SerialNumber value ]
+ // TODO: find out what additional bytes mean here...
+ [array byte data count 'numBytes-4' ]
]
['CUSTOM_TYPE' *CustomTypes
[simple CustomTypes('numBytes') value ]