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 19:33:46 UTC
[plc4x] branch develop updated: fix(cbus): fixed response byte calculations
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
The following commit(s) were added to refs/heads/develop by this push:
new 376f950e3 fix(cbus): fixed response byte calculations
376f950e3 is described below
commit 376f950e35eaf17d5fd8e96d0b161f1a7769a4c5
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Jul 12 21:33:39 2022 +0200
fix(cbus): fixed response byte calculations
+ renamed fields that were apparently typos
---
.../cbus/readwrite/model/CALDataGetStatus.go | 38 +++++++++++-----------
.../cbus/readwrite/model/CALDataRecall.go | 38 +++++++++++-----------
.../protocols/cbus/readwrite/model/CALDataReply.go | 2 +-
.../cbus/readwrite/model/CALDataStatus.go | 2 +-
.../cbus/readwrite/model/CALDataStatusExtended.go | 2 +-
.../src/main/resources/protocols/cbus/c-bus.mspec | 12 +++----
6 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go b/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
index b24729acd..2713422de 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataGetStatus.go
@@ -33,8 +33,8 @@ type CALDataGetStatus interface {
CALData
// GetParamNo returns ParamNo (property field)
GetParamNo() Parameter
- // GetCode returns Code (property field)
- GetCode() uint8
+ // GetCount returns Count (property field)
+ GetCount() uint8
}
// CALDataGetStatusExactly can be used when we want exactly this type and not a type which fulfills CALDataGetStatus.
@@ -48,7 +48,7 @@ type CALDataGetStatusExactly interface {
type _CALDataGetStatus struct {
*_CALData
ParamNo Parameter
- Code uint8
+ Count uint8
}
///////////////////////////////////////////////////////////
@@ -79,8 +79,8 @@ func (m *_CALDataGetStatus) GetParamNo() Parameter {
return m.ParamNo
}
-func (m *_CALDataGetStatus) GetCode() uint8 {
- return m.Code
+func (m *_CALDataGetStatus) GetCount() uint8 {
+ return m.Count
}
///////////////////////
@@ -89,10 +89,10 @@ func (m *_CALDataGetStatus) GetCode() uint8 {
///////////////////////////////////////////////////////////
// NewCALDataGetStatus factory function for _CALDataGetStatus
-func NewCALDataGetStatus(paramNo Parameter, code uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataGetStatus {
+func NewCALDataGetStatus(paramNo Parameter, count uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataGetStatus {
_result := &_CALDataGetStatus{
ParamNo: paramNo,
- Code: code,
+ Count: count,
_CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
@@ -124,7 +124,7 @@ func (m *_CALDataGetStatus) GetLengthInBitsConditional(lastItem bool) uint16 {
// Simple field (paramNo)
lengthInBits += 8
- // Simple field (code)
+ // Simple field (count)
lengthInBits += 8
return lengthInBits
@@ -156,12 +156,12 @@ func CALDataGetStatusParse(readBuffer utils.ReadBuffer, requestContext RequestCo
return nil, errors.Wrap(closeErr, "Error closing for paramNo")
}
- // Simple Field (code)
- _code, _codeErr := readBuffer.ReadUint8("code", 8)
- if _codeErr != nil {
- return nil, errors.Wrap(_codeErr, "Error parsing 'code' field of CALDataGetStatus")
+ // Simple Field (count)
+ _count, _countErr := readBuffer.ReadUint8("count", 8)
+ if _countErr != nil {
+ return nil, errors.Wrap(_countErr, "Error parsing 'count' field of CALDataGetStatus")
}
- code := _code
+ count := _count
if closeErr := readBuffer.CloseContext("CALDataGetStatus"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CALDataGetStatus")
@@ -170,7 +170,7 @@ func CALDataGetStatusParse(readBuffer utils.ReadBuffer, requestContext RequestCo
// Create a partially initialized instance
_child := &_CALDataGetStatus{
ParamNo: paramNo,
- Code: code,
+ Count: count,
_CALData: &_CALData{
RequestContext: requestContext,
},
@@ -199,11 +199,11 @@ func (m *_CALDataGetStatus) Serialize(writeBuffer utils.WriteBuffer) error {
return errors.Wrap(_paramNoErr, "Error serializing 'paramNo' field")
}
- // Simple Field (code)
- code := uint8(m.GetCode())
- _codeErr := writeBuffer.WriteUint8("code", 8, (code))
- if _codeErr != nil {
- return errors.Wrap(_codeErr, "Error serializing 'code' field")
+ // Simple Field (count)
+ count := uint8(m.GetCount())
+ _countErr := writeBuffer.WriteUint8("count", 8, (count))
+ if _countErr != nil {
+ return errors.Wrap(_countErr, "Error serializing 'count' field")
}
if popErr := writeBuffer.PopContext("CALDataGetStatus"); popErr != nil {
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go b/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
index fc17f7a17..6825b4612 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataRecall.go
@@ -33,8 +33,8 @@ type CALDataRecall interface {
CALData
// GetParamNo returns ParamNo (property field)
GetParamNo() Parameter
- // GetCode returns Code (property field)
- GetCode() uint8
+ // GetCount returns Count (property field)
+ GetCount() uint8
}
// CALDataRecallExactly can be used when we want exactly this type and not a type which fulfills CALDataRecall.
@@ -48,7 +48,7 @@ type CALDataRecallExactly interface {
type _CALDataRecall struct {
*_CALData
ParamNo Parameter
- Code uint8
+ Count uint8
}
///////////////////////////////////////////////////////////
@@ -79,8 +79,8 @@ func (m *_CALDataRecall) GetParamNo() Parameter {
return m.ParamNo
}
-func (m *_CALDataRecall) GetCode() uint8 {
- return m.Code
+func (m *_CALDataRecall) GetCount() uint8 {
+ return m.Count
}
///////////////////////
@@ -89,10 +89,10 @@ func (m *_CALDataRecall) GetCode() uint8 {
///////////////////////////////////////////////////////////
// NewCALDataRecall factory function for _CALDataRecall
-func NewCALDataRecall(paramNo Parameter, code uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataRecall {
+func NewCALDataRecall(paramNo Parameter, count uint8, commandTypeContainer CALCommandTypeContainer, additionalData CALData, requestContext RequestContext) *_CALDataRecall {
_result := &_CALDataRecall{
ParamNo: paramNo,
- Code: code,
+ Count: count,
_CALData: NewCALData(commandTypeContainer, additionalData, requestContext),
}
_result._CALData._CALDataChildRequirements = _result
@@ -124,7 +124,7 @@ func (m *_CALDataRecall) GetLengthInBitsConditional(lastItem bool) uint16 {
// Simple field (paramNo)
lengthInBits += 8
- // Simple field (code)
+ // Simple field (count)
lengthInBits += 8
return lengthInBits
@@ -156,12 +156,12 @@ func CALDataRecallParse(readBuffer utils.ReadBuffer, requestContext RequestConte
return nil, errors.Wrap(closeErr, "Error closing for paramNo")
}
- // Simple Field (code)
- _code, _codeErr := readBuffer.ReadUint8("code", 8)
- if _codeErr != nil {
- return nil, errors.Wrap(_codeErr, "Error parsing 'code' field of CALDataRecall")
+ // Simple Field (count)
+ _count, _countErr := readBuffer.ReadUint8("count", 8)
+ if _countErr != nil {
+ return nil, errors.Wrap(_countErr, "Error parsing 'count' field of CALDataRecall")
}
- code := _code
+ count := _count
if closeErr := readBuffer.CloseContext("CALDataRecall"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CALDataRecall")
@@ -170,7 +170,7 @@ func CALDataRecallParse(readBuffer utils.ReadBuffer, requestContext RequestConte
// Create a partially initialized instance
_child := &_CALDataRecall{
ParamNo: paramNo,
- Code: code,
+ Count: count,
_CALData: &_CALData{
RequestContext: requestContext,
},
@@ -199,11 +199,11 @@ func (m *_CALDataRecall) Serialize(writeBuffer utils.WriteBuffer) error {
return errors.Wrap(_paramNoErr, "Error serializing 'paramNo' field")
}
- // Simple Field (code)
- code := uint8(m.GetCode())
- _codeErr := writeBuffer.WriteUint8("code", 8, (code))
- if _codeErr != nil {
- return errors.Wrap(_codeErr, "Error serializing 'code' field")
+ // Simple Field (count)
+ count := uint8(m.GetCount())
+ _countErr := writeBuffer.WriteUint8("count", 8, (count))
+ if _countErr != nil {
+ return errors.Wrap(_countErr, "Error serializing 'count' field")
}
if popErr := writeBuffer.PopContext("CALDataRecall"); popErr != nil {
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataReply.go b/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
index dd8bcabf8..23fd95f3e 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataReply.go
@@ -152,7 +152,7 @@ func CALDataReplyParse(readBuffer utils.ReadBuffer, requestContext RequestContex
}
paramNumber := _paramNumber
// Byte Array field (data)
- numberOfBytesdata := int(commandTypeContainer.NumBytes())
+ numberOfBytesdata := int(uint16(commandTypeContainer.NumBytes()) - uint16(uint16(1)))
data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of CALDataReply")
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
index eb9f62b47..df2612ef2 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go
@@ -176,7 +176,7 @@ func CALDataStatusParse(readBuffer utils.ReadBuffer, requestContext RequestConte
}
blockStart := _blockStart
// Byte Array field (data)
- numberOfBytesdata := int(commandTypeContainer.NumBytes())
+ numberOfBytesdata := int(uint16(commandTypeContainer.NumBytes()) - uint16(uint16(2)))
data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of CALDataStatus")
diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
index b678fe2fd..f104d6ec9 100644
--- a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
+++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go
@@ -194,7 +194,7 @@ func CALDataStatusExtendedParse(readBuffer utils.ReadBuffer, requestContext Requ
}
blockStart := _blockStart
// Byte Array field (data)
- numberOfBytesdata := int(commandTypeContainer.NumBytes())
+ numberOfBytesdata := int(uint16(commandTypeContainer.NumBytes()) - uint16(uint16(3)))
data, _readArrayErr := readBuffer.ReadByteArray("data", numberOfBytesdata)
if _readArrayErr != nil {
return nil, errors.Wrap(_readArrayErr, "Error parsing 'data' field of CALDataStatusExtended")
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 fc0acc692..9bce1a3f9 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
@@ -582,23 +582,23 @@
]
['RECALL' *Recall // Request
[simple Parameter paramNo ]
- [simple uint 8 code ]
+ [simple uint 8 count ]
]
['IDENTIFY' *Identify // Request
[simple Attribute attribute ]
]
['GET_STATUS' *GetStatus // Request
[simple Parameter paramNo ]
- [simple uint 8 code ]
+ [simple uint 8 count ]
]
['REPLY', 'true' *IdentifyReply(CALCommandTypeContainer commandTypeContainer) // Reply
[simple Attribute attribute ]
- [simple IdentifyReplyCommand('attribute', 'commandTypeContainer.numBytes-1') // We substract 1 byte as it was used by the attribute
+ [simple IdentifyReplyCommand('attribute', 'commandTypeContainer.numBytes - 1')
identifyReplyCommand ]
]
['REPLY' *Reply(CALCommandTypeContainer commandTypeContainer) // Reply
[simple uint 8 paramNumber ]
- [array byte data count 'commandTypeContainer.numBytes' ]
+ [array byte data count 'commandTypeContainer.numBytes-1' ]
]
['ACKNOWLEDGE' *Acknowledge // Reply
[simple Parameter paramNo ]
@@ -607,13 +607,13 @@
['STATUS' *Status(CALCommandTypeContainer commandTypeContainer) // Reply
[simple ApplicationIdContainer application ]
[simple uint 8 blockStart ]
- [array byte data count 'commandTypeContainer.numBytes' ]
+ [array byte data count 'commandTypeContainer.numBytes - 2' ]
]
['STATUS_EXTENDED' *StatusExtended(CALCommandTypeContainer commandTypeContainer) // Reply
[simple uint 8 encoding ]
[simple ApplicationIdContainer application ]
[simple uint 8 blockStart ]
- [array byte data count 'commandTypeContainer.numBytes' ]
+ [array byte data count 'commandTypeContainer.numBytes - 3' ]
]
]
// TODO: we need to check that we don't read the crc by accident