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/04 15:45:10 UTC
[plc4x] branch develop updated (62240fbb2 -> 3e2cd3ccd)
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
from 62240fbb2 fix(c-bus): smaller refinements decoding the messages
new a243df0a9 feat(spi): changed the way a byte is rendered
new 3e2cd3ccd fix(c-bus): fixed that alpha char handling on commands
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
plc4go/internal/spi/utils/WriteBufferBoxBased.go | 6 ++-
.../CBusCommandPointToPointToMultiPointNormal.go | 54 +------------------
.../CBusCommandPointToPointToMultiPointStatus.go | 54 +------------------
.../model/CBusPointToMultiPointCommandNormal.go | 54 +------------------
.../model/CBusPointToMultiPointCommandStatus.go | 54 +------------------
.../readwrite/model/CBusPointToPointCommand.go | 62 ++--------------------
.../model/CBusPointToPointCommandDirect.go | 7 ++-
.../model/CBusPointToPointCommandIndirect.go | 7 ++-
.../cbus/readwrite/model/RequestCommand.go | 56 ++++++++++++++++++-
.../protocols/cbus/readwrite/model/StaticHelper.go | 18 +++++++
.../java/cbus/readwrite/utils/StaticHelper.java | 19 +++++++
.../apache/plc4x/java/cbus/RandomPackagesTest.java | 10 ++++
.../java/spi/generation/WriteBufferBoxBased.java | 2 +-
.../src/main/resources/protocols/cbus/c-bus.mspec | 10 ++--
14 files changed, 126 insertions(+), 287 deletions(-)
[plc4x] 02/02: fix(c-bus): fixed that alpha char handling on commands
Posted by sr...@apache.org.
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 3e2cd3ccdab0aea6309ba67fe6140f5dc4e9bb98
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jul 4 17:45:02 2022 +0200
fix(c-bus): fixed that alpha char handling on commands
---
.../CBusCommandPointToPointToMultiPointNormal.go | 54 +------------------
.../CBusCommandPointToPointToMultiPointStatus.go | 54 +------------------
.../model/CBusPointToMultiPointCommandNormal.go | 54 +------------------
.../model/CBusPointToMultiPointCommandStatus.go | 54 +------------------
.../readwrite/model/CBusPointToPointCommand.go | 62 ++--------------------
.../model/CBusPointToPointCommandDirect.go | 7 ++-
.../model/CBusPointToPointCommandIndirect.go | 7 ++-
.../cbus/readwrite/model/RequestCommand.go | 56 ++++++++++++++++++-
.../protocols/cbus/readwrite/model/StaticHelper.go | 18 +++++++
.../java/cbus/readwrite/utils/StaticHelper.java | 19 +++++++
.../apache/plc4x/java/cbus/RandomPackagesTest.java | 10 ++++
.../src/main/resources/protocols/cbus/c-bus.mspec | 10 ++--
12 files changed, 120 insertions(+), 285 deletions(-)
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go
index 6875bcc3d..ead1fc767 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go
@@ -39,8 +39,6 @@ type CBusCommandPointToPointToMultiPointNormal interface {
GetSalData() SALData
// GetCrc returns Crc (property field)
GetCrc() Checksum
- // GetAlpha returns Alpha (property field)
- GetAlpha() Alpha
}
// CBusCommandPointToPointToMultiPointNormalExactly can be used when we want exactly this type and not a type which fulfills CBusCommandPointToPointToMultiPointNormal.
@@ -56,7 +54,6 @@ type _CBusCommandPointToPointToMultiPointNormal struct {
Application ApplicationIdContainer
SalData SALData
Crc Checksum
- Alpha Alpha
}
///////////////////////////////////////////////////////////
@@ -96,22 +93,17 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) GetCrc() Checksum {
return m.Crc
}
-func (m *_CBusCommandPointToPointToMultiPointNormal) GetAlpha() Alpha {
- return m.Alpha
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusCommandPointToPointToMultiPointNormal factory function for _CBusCommandPointToPointToMultiPointNormal
-func NewCBusCommandPointToPointToMultiPointNormal(application ApplicationIdContainer, salData SALData, crc Checksum, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointNormal {
+func NewCBusCommandPointToPointToMultiPointNormal(application ApplicationIdContainer, salData SALData, crc Checksum, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointNormal {
_result := &_CBusCommandPointToPointToMultiPointNormal{
Application: application,
SalData: salData,
Crc: crc,
- Alpha: alpha,
_CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, srchk),
}
_result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result
@@ -151,11 +143,6 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) GetLengthInBitsConditional(
lengthInBits += m.Crc.GetLengthInBits()
}
- // Optional Field (alpha)
- if m.Alpha != nil {
- lengthInBits += m.Alpha.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -220,28 +207,6 @@ func CBusCommandPointToPointToMultiPointNormalParse(readBuffer utils.ReadBuffer,
}
}
- // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
- var alpha Alpha = nil
- {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for alpha")
- }
- _val, _err := AlphaParse(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 'alpha' field of CBusCommandPointToPointToMultiPointNormal")
- default:
- alpha = _val.(Alpha)
- if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for alpha")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusCommandPointToPointToMultiPointNormal"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusCommandPointToPointToMultiPointNormal")
}
@@ -251,7 +216,6 @@ func CBusCommandPointToPointToMultiPointNormalParse(readBuffer utils.ReadBuffer,
Application: application,
SalData: salData,
Crc: crc,
- Alpha: alpha,
_CBusPointToPointToMultipointCommand: &_CBusPointToPointToMultipointCommand{
Srchk: srchk,
},
@@ -308,22 +272,6 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) Serialize(writeBuffer utils
}
}
- // Optional Field (alpha) (Can be skipped, if the value is null)
- var alpha Alpha = nil
- if m.GetAlpha() != nil {
- if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for alpha")
- }
- alpha = m.GetAlpha()
- _alphaErr := writeBuffer.WriteSerializable(alpha)
- if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for alpha")
- }
- if _alphaErr != nil {
- return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusCommandPointToPointToMultiPointNormal"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusCommandPointToPointToMultiPointNormal")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go
index ac8f7d067..fbfc84a5c 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go
@@ -37,8 +37,6 @@ type CBusCommandPointToPointToMultiPointStatus interface {
GetStatusRequest() StatusRequest
// GetCrc returns Crc (property field)
GetCrc() Checksum
- // GetAlpha returns Alpha (property field)
- GetAlpha() Alpha
}
// CBusCommandPointToPointToMultiPointStatusExactly can be used when we want exactly this type and not a type which fulfills CBusCommandPointToPointToMultiPointStatus.
@@ -53,7 +51,6 @@ type _CBusCommandPointToPointToMultiPointStatus struct {
*_CBusPointToPointToMultipointCommand
StatusRequest StatusRequest
Crc Checksum
- Alpha Alpha
}
///////////////////////////////////////////////////////////
@@ -89,21 +86,16 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) GetCrc() Checksum {
return m.Crc
}
-func (m *_CBusCommandPointToPointToMultiPointStatus) GetAlpha() Alpha {
- return m.Alpha
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusCommandPointToPointToMultiPointStatus factory function for _CBusCommandPointToPointToMultiPointStatus
-func NewCBusCommandPointToPointToMultiPointStatus(statusRequest StatusRequest, crc Checksum, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointStatus {
+func NewCBusCommandPointToPointToMultiPointStatus(statusRequest StatusRequest, crc Checksum, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointStatus {
_result := &_CBusCommandPointToPointToMultiPointStatus{
StatusRequest: statusRequest,
Crc: crc,
- Alpha: alpha,
_CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, srchk),
}
_result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result
@@ -143,11 +135,6 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) GetLengthInBitsConditional(
lengthInBits += m.Crc.GetLengthInBits()
}
- // Optional Field (alpha)
- if m.Alpha != nil {
- lengthInBits += m.Alpha.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -213,28 +200,6 @@ func CBusCommandPointToPointToMultiPointStatusParse(readBuffer utils.ReadBuffer,
}
}
- // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
- var alpha Alpha = nil
- {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for alpha")
- }
- _val, _err := AlphaParse(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 'alpha' field of CBusCommandPointToPointToMultiPointStatus")
- default:
- alpha = _val.(Alpha)
- if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for alpha")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusCommandPointToPointToMultiPointStatus"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusCommandPointToPointToMultiPointStatus")
}
@@ -243,7 +208,6 @@ func CBusCommandPointToPointToMultiPointStatusParse(readBuffer utils.ReadBuffer,
_child := &_CBusCommandPointToPointToMultiPointStatus{
StatusRequest: statusRequest,
Crc: crc,
- Alpha: alpha,
_CBusPointToPointToMultipointCommand: &_CBusPointToPointToMultipointCommand{
Srchk: srchk,
},
@@ -296,22 +260,6 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) Serialize(writeBuffer utils
}
}
- // Optional Field (alpha) (Can be skipped, if the value is null)
- var alpha Alpha = nil
- if m.GetAlpha() != nil {
- if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for alpha")
- }
- alpha = m.GetAlpha()
- _alphaErr := writeBuffer.WriteSerializable(alpha)
- if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for alpha")
- }
- if _alphaErr != nil {
- return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusCommandPointToPointToMultiPointStatus"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusCommandPointToPointToMultiPointStatus")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go
index 25c3eadf1..7f20c6179 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go
@@ -39,8 +39,6 @@ type CBusPointToMultiPointCommandNormal interface {
GetSalData() SALData
// GetCrc returns Crc (property field)
GetCrc() Checksum
- // GetAlpha returns Alpha (property field)
- GetAlpha() Alpha
}
// CBusPointToMultiPointCommandNormalExactly can be used when we want exactly this type and not a type which fulfills CBusPointToMultiPointCommandNormal.
@@ -56,7 +54,6 @@ type _CBusPointToMultiPointCommandNormal struct {
Application ApplicationIdContainer
SalData SALData
Crc Checksum
- Alpha Alpha
}
///////////////////////////////////////////////////////////
@@ -94,22 +91,17 @@ func (m *_CBusPointToMultiPointCommandNormal) GetCrc() Checksum {
return m.Crc
}
-func (m *_CBusPointToMultiPointCommandNormal) GetAlpha() Alpha {
- return m.Alpha
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToMultiPointCommandNormal factory function for _CBusPointToMultiPointCommandNormal
-func NewCBusPointToMultiPointCommandNormal(application ApplicationIdContainer, salData SALData, crc Checksum, alpha Alpha, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandNormal {
+func NewCBusPointToMultiPointCommandNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandNormal {
_result := &_CBusPointToMultiPointCommandNormal{
Application: application,
SalData: salData,
Crc: crc,
- Alpha: alpha,
_CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, srchk),
}
_result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result
@@ -152,11 +144,6 @@ func (m *_CBusPointToMultiPointCommandNormal) GetLengthInBitsConditional(lastIte
lengthInBits += m.Crc.GetLengthInBits()
}
- // Optional Field (alpha)
- if m.Alpha != nil {
- lengthInBits += m.Alpha.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -235,28 +222,6 @@ func CBusPointToMultiPointCommandNormalParse(readBuffer utils.ReadBuffer, srchk
}
}
- // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
- var alpha Alpha = nil
- {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for alpha")
- }
- _val, _err := AlphaParse(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 'alpha' field of CBusPointToMultiPointCommandNormal")
- default:
- alpha = _val.(Alpha)
- if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for alpha")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommandNormal"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommandNormal")
}
@@ -266,7 +231,6 @@ func CBusPointToMultiPointCommandNormalParse(readBuffer utils.ReadBuffer, srchk
Application: application,
SalData: salData,
Crc: crc,
- Alpha: alpha,
_CBusPointToMultiPointCommand: &_CBusPointToMultiPointCommand{
Srchk: srchk,
},
@@ -331,22 +295,6 @@ func (m *_CBusPointToMultiPointCommandNormal) Serialize(writeBuffer utils.WriteB
}
}
- // Optional Field (alpha) (Can be skipped, if the value is null)
- var alpha Alpha = nil
- if m.GetAlpha() != nil {
- if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for alpha")
- }
- alpha = m.GetAlpha()
- _alphaErr := writeBuffer.WriteSerializable(alpha)
- if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for alpha")
- }
- if _alphaErr != nil {
- return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommandNormal"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommandNormal")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
index 1a54fd230..9ce9c1fa7 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go
@@ -37,8 +37,6 @@ type CBusPointToMultiPointCommandStatus interface {
GetStatusRequest() StatusRequest
// GetCrc returns Crc (property field)
GetCrc() Checksum
- // GetAlpha returns Alpha (property field)
- GetAlpha() Alpha
}
// CBusPointToMultiPointCommandStatusExactly can be used when we want exactly this type and not a type which fulfills CBusPointToMultiPointCommandStatus.
@@ -53,7 +51,6 @@ type _CBusPointToMultiPointCommandStatus struct {
*_CBusPointToMultiPointCommand
StatusRequest StatusRequest
Crc Checksum
- Alpha Alpha
}
///////////////////////////////////////////////////////////
@@ -87,21 +84,16 @@ func (m *_CBusPointToMultiPointCommandStatus) GetCrc() Checksum {
return m.Crc
}
-func (m *_CBusPointToMultiPointCommandStatus) GetAlpha() Alpha {
- return m.Alpha
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// NewCBusPointToMultiPointCommandStatus factory function for _CBusPointToMultiPointCommandStatus
-func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, crc Checksum, alpha Alpha, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandStatus {
+func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, crc Checksum, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandStatus {
_result := &_CBusPointToMultiPointCommandStatus{
StatusRequest: statusRequest,
Crc: crc,
- Alpha: alpha,
_CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, srchk),
}
_result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result
@@ -144,11 +136,6 @@ func (m *_CBusPointToMultiPointCommandStatus) GetLengthInBitsConditional(lastIte
lengthInBits += m.Crc.GetLengthInBits()
}
- // Optional Field (alpha)
- if m.Alpha != nil {
- lengthInBits += m.Alpha.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -228,28 +215,6 @@ func CBusPointToMultiPointCommandStatusParse(readBuffer utils.ReadBuffer, srchk
}
}
- // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
- var alpha Alpha = nil
- {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for alpha")
- }
- _val, _err := AlphaParse(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 'alpha' field of CBusPointToMultiPointCommandStatus")
- default:
- alpha = _val.(Alpha)
- if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for alpha")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommandStatus"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommandStatus")
}
@@ -258,7 +223,6 @@ func CBusPointToMultiPointCommandStatusParse(readBuffer utils.ReadBuffer, srchk
_child := &_CBusPointToMultiPointCommandStatus{
StatusRequest: statusRequest,
Crc: crc,
- Alpha: alpha,
_CBusPointToMultiPointCommand: &_CBusPointToMultiPointCommand{
Srchk: srchk,
},
@@ -319,22 +283,6 @@ func (m *_CBusPointToMultiPointCommandStatus) Serialize(writeBuffer utils.WriteB
}
}
- // Optional Field (alpha) (Can be skipped, if the value is null)
- var alpha Alpha = nil
- if m.GetAlpha() != nil {
- if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for alpha")
- }
- alpha = m.GetAlpha()
- _alphaErr := writeBuffer.WriteSerializable(alpha)
- if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for alpha")
- }
- if _alphaErr != nil {
- return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommandStatus"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommandStatus")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go
index a9fe72bba..fc8981163 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go
@@ -38,8 +38,6 @@ type CBusPointToPointCommand interface {
GetCalData() CALData
// GetCrc returns Crc (property field)
GetCrc() Checksum
- // GetAlpha returns Alpha (property field)
- GetAlpha() Alpha
// GetIsDirect returns IsDirect (virtual field)
GetIsDirect() bool
}
@@ -57,7 +55,6 @@ type _CBusPointToPointCommand struct {
BridgeAddressCountPeek uint16
CalData CALData
Crc Checksum
- Alpha Alpha
// Arguments.
Srchk bool
@@ -76,7 +73,7 @@ type CBusPointToPointCommandParent interface {
type CBusPointToPointCommandChild interface {
utils.Serializable
- InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha)
+ InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum)
GetParent() *CBusPointToPointCommand
GetTypeName() string
@@ -100,10 +97,6 @@ func (m *_CBusPointToPointCommand) GetCrc() Checksum {
return m.Crc
}
-func (m *_CBusPointToPointCommand) GetAlpha() Alpha {
- return m.Alpha
-}
-
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
@@ -116,8 +109,6 @@ func (m *_CBusPointToPointCommand) GetAlpha() Alpha {
func (m *_CBusPointToPointCommand) GetIsDirect() bool {
crc := m.Crc
_ = crc
- alpha := m.Alpha
- _ = alpha
return bool(bool(((m.GetBridgeAddressCountPeek()) & (0x00FF)) == (0x0000)))
}
@@ -127,8 +118,8 @@ func (m *_CBusPointToPointCommand) GetIsDirect() bool {
///////////////////////////////////////////////////////////
// NewCBusPointToPointCommand factory function for _CBusPointToPointCommand
-func NewCBusPointToPointCommand(bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha, srchk bool) *_CBusPointToPointCommand {
- return &_CBusPointToPointCommand{BridgeAddressCountPeek: bridgeAddressCountPeek, CalData: calData, Crc: crc, Alpha: alpha, Srchk: srchk}
+func NewCBusPointToPointCommand(bridgeAddressCountPeek uint16, calData CALData, crc Checksum, srchk bool) *_CBusPointToPointCommand {
+ return &_CBusPointToPointCommand{BridgeAddressCountPeek: bridgeAddressCountPeek, CalData: calData, Crc: crc, Srchk: srchk}
}
// Deprecated: use the interface for direct cast
@@ -159,11 +150,6 @@ func (m *_CBusPointToPointCommand) GetParentLengthInBits() uint16 {
lengthInBits += m.Crc.GetLengthInBits()
}
- // Optional Field (alpha)
- if m.Alpha != nil {
- lengthInBits += m.Alpha.GetLengthInBits()
- }
-
return lengthInBits
}
@@ -197,7 +183,7 @@ func CBusPointToPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBus
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
type CBusPointToPointCommandChildSerializeRequirement interface {
CBusPointToPointCommand
- InitializeParent(CBusPointToPointCommand, uint16, CALData, Checksum, Alpha)
+ InitializeParent(CBusPointToPointCommand, uint16, CALData, Checksum)
GetParent() CBusPointToPointCommand
}
var _childTemp interface{}
@@ -251,34 +237,12 @@ func CBusPointToPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBus
}
}
- // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
- var alpha Alpha = nil
- {
- currentPos = positionAware.GetPos()
- if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
- return nil, errors.Wrap(pullErr, "Error pulling for alpha")
- }
- _val, _err := AlphaParse(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 'alpha' field of CBusPointToPointCommand")
- default:
- alpha = _val.(Alpha)
- if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
- return nil, errors.Wrap(closeErr, "Error closing for alpha")
- }
- }
- }
-
if closeErr := readBuffer.CloseContext("CBusPointToPointCommand"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for CBusPointToPointCommand")
}
// Finish initializing
- _child.InitializeParent(_child, bridgeAddressCountPeek, calData, crc, alpha)
+ _child.InitializeParent(_child, bridgeAddressCountPeek, calData, crc)
return _child, nil
}
@@ -329,22 +293,6 @@ func (pm *_CBusPointToPointCommand) SerializeParent(writeBuffer utils.WriteBuffe
}
}
- // Optional Field (alpha) (Can be skipped, if the value is null)
- var alpha Alpha = nil
- if m.GetAlpha() != nil {
- if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
- return errors.Wrap(pushErr, "Error pushing for alpha")
- }
- alpha = m.GetAlpha()
- _alphaErr := writeBuffer.WriteSerializable(alpha)
- if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
- return errors.Wrap(popErr, "Error popping for alpha")
- }
- if _alphaErr != nil {
- return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
- }
- }
-
if popErr := writeBuffer.PopContext("CBusPointToPointCommand"); popErr != nil {
return errors.Wrap(popErr, "Error popping for CBusPointToPointCommand")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go
index a03449092..40bcf5bdc 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go
@@ -59,11 +59,10 @@ type _CBusPointToPointCommandDirect struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CBusPointToPointCommandDirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha) {
+func (m *_CBusPointToPointCommandDirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum) {
m.BridgeAddressCountPeek = bridgeAddressCountPeek
m.CalData = calData
m.Crc = crc
- m.Alpha = alpha
}
func (m *_CBusPointToPointCommandDirect) GetParent() CBusPointToPointCommand {
@@ -85,10 +84,10 @@ func (m *_CBusPointToPointCommandDirect) GetUnitAddress() UnitAddress {
///////////////////////////////////////////////////////////
// NewCBusPointToPointCommandDirect factory function for _CBusPointToPointCommandDirect
-func NewCBusPointToPointCommandDirect(unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha, srchk bool) *_CBusPointToPointCommandDirect {
+func NewCBusPointToPointCommandDirect(unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, srchk bool) *_CBusPointToPointCommandDirect {
_result := &_CBusPointToPointCommandDirect{
UnitAddress: unitAddress,
- _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, alpha, srchk),
+ _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, srchk),
}
_result._CBusPointToPointCommand._CBusPointToPointCommandChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go
index c75adcf30..28ffcce31 100644
--- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go
+++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go
@@ -64,11 +64,10 @@ type _CBusPointToPointCommandIndirect struct {
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
-func (m *_CBusPointToPointCommandIndirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha) {
+func (m *_CBusPointToPointCommandIndirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum) {
m.BridgeAddressCountPeek = bridgeAddressCountPeek
m.CalData = calData
m.Crc = crc
- m.Alpha = alpha
}
func (m *_CBusPointToPointCommandIndirect) GetParent() CBusPointToPointCommand {
@@ -98,12 +97,12 @@ func (m *_CBusPointToPointCommandIndirect) GetUnitAddress() UnitAddress {
///////////////////////////////////////////////////////////
// NewCBusPointToPointCommandIndirect factory function for _CBusPointToPointCommandIndirect
-func NewCBusPointToPointCommandIndirect(bridgeAddress BridgeAddress, networkRoute NetworkRoute, unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, alpha Alpha, srchk bool) *_CBusPointToPointCommandIndirect {
+func NewCBusPointToPointCommandIndirect(bridgeAddress BridgeAddress, networkRoute NetworkRoute, unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, srchk bool) *_CBusPointToPointCommandIndirect {
_result := &_CBusPointToPointCommandIndirect{
BridgeAddress: bridgeAddress,
NetworkRoute: networkRoute,
UnitAddress: unitAddress,
- _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, alpha, srchk),
+ _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, srchk),
}
_result._CBusPointToPointCommand._CBusPointToPointCommandChildRequirements = _result
return _result
diff --git a/plc4go/protocols/cbus/readwrite/model/RequestCommand.go b/plc4go/protocols/cbus/readwrite/model/RequestCommand.go
index 008c67c5b..0b7ad0561 100644
--- a/plc4go/protocols/cbus/readwrite/model/RequestCommand.go
+++ b/plc4go/protocols/cbus/readwrite/model/RequestCommand.go
@@ -23,6 +23,8 @@ import (
"fmt"
"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,6 +39,8 @@ type RequestCommand interface {
Request
// GetCbusCommand returns CbusCommand (property field)
GetCbusCommand() CBusCommand
+ // GetAlpha returns Alpha (property field)
+ GetAlpha() Alpha
}
// RequestCommandExactly can be used when we want exactly this type and not a type which fulfills RequestCommand.
@@ -50,6 +54,7 @@ type RequestCommandExactly interface {
type _RequestCommand struct {
*_Request
CbusCommand CBusCommand
+ Alpha Alpha
// Arguments.
PayloadLength uint16
@@ -83,6 +88,10 @@ func (m *_RequestCommand) GetCbusCommand() CBusCommand {
return m.CbusCommand
}
+func (m *_RequestCommand) GetAlpha() Alpha {
+ return m.Alpha
+}
+
///////////////////////
///////////////////////
///////////////////////////////////////////////////////////
@@ -102,9 +111,10 @@ func (m *_RequestCommand) GetInitiator() byte {
///////////////////////////////////////////////////////////
// NewRequestCommand factory function for _RequestCommand
-func NewRequestCommand(cbusCommand CBusCommand, peekedByte RequestType, termination RequestTermination, srchk bool, messageLength uint16, payloadLength uint16) *_RequestCommand {
+func NewRequestCommand(cbusCommand CBusCommand, alpha Alpha, peekedByte RequestType, termination RequestTermination, srchk bool, messageLength uint16, payloadLength uint16) *_RequestCommand {
_result := &_RequestCommand{
CbusCommand: cbusCommand,
+ Alpha: alpha,
_Request: NewRequest(peekedByte, termination, srchk, messageLength),
}
_result._Request._RequestChildRequirements = _result
@@ -139,6 +149,11 @@ func (m *_RequestCommand) GetLengthInBitsConditional(lastItem bool) uint16 {
// Manual Field (cbusCommand)
lengthInBits += uint16(int32(m.GetLengthInBytes()) * int32(int32(2)))
+ // Optional Field (alpha)
+ if m.Alpha != nil {
+ lengthInBits += m.Alpha.GetLengthInBits()
+ }
+
return lengthInBits
}
@@ -171,6 +186,28 @@ func RequestCommandParse(readBuffer utils.ReadBuffer, srchk bool, messageLength
}
cbusCommand := _cbusCommand.(CBusCommand)
+ // Optional Field (alpha) (Can be skipped, if a given expression evaluates to false)
+ var alpha Alpha = nil
+ {
+ currentPos = positionAware.GetPos()
+ if pullErr := readBuffer.PullContext("alpha"); pullErr != nil {
+ return nil, errors.Wrap(pullErr, "Error pulling for alpha")
+ }
+ _val, _err := AlphaParse(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 'alpha' field of RequestCommand")
+ default:
+ alpha = _val.(Alpha)
+ if closeErr := readBuffer.CloseContext("alpha"); closeErr != nil {
+ return nil, errors.Wrap(closeErr, "Error closing for alpha")
+ }
+ }
+ }
+
if closeErr := readBuffer.CloseContext("RequestCommand"); closeErr != nil {
return nil, errors.Wrap(closeErr, "Error closing for RequestCommand")
}
@@ -178,6 +215,7 @@ func RequestCommandParse(readBuffer utils.ReadBuffer, srchk bool, messageLength
// Create a partially initialized instance
_child := &_RequestCommand{
CbusCommand: cbusCommand,
+ Alpha: alpha,
_Request: &_Request{
Srchk: srchk,
MessageLength: messageLength,
@@ -207,6 +245,22 @@ func (m *_RequestCommand) Serialize(writeBuffer utils.WriteBuffer) error {
return errors.Wrap(_cbusCommandErr, "Error serializing 'cbusCommand' field")
}
+ // Optional Field (alpha) (Can be skipped, if the value is null)
+ var alpha Alpha = nil
+ if m.GetAlpha() != nil {
+ if pushErr := writeBuffer.PushContext("alpha"); pushErr != nil {
+ return errors.Wrap(pushErr, "Error pushing for alpha")
+ }
+ alpha = m.GetAlpha()
+ _alphaErr := writeBuffer.WriteSerializable(alpha)
+ if popErr := writeBuffer.PopContext("alpha"); popErr != nil {
+ return errors.Wrap(popErr, "Error popping for alpha")
+ }
+ if _alphaErr != nil {
+ return errors.Wrap(_alphaErr, "Error serializing 'alpha' field")
+ }
+ }
+
if popErr := writeBuffer.PopContext("RequestCommand"); popErr != nil {
return errors.Wrap(popErr, "Error popping for RequestCommand")
}
diff --git a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
index 6aeb26c4b..51f7d7088 100644
--- a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
+++ b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go
@@ -44,6 +44,12 @@ func ReadCBusCommand(readBuffer utils.ReadBuffer, payloadLength uint16, srcchk b
if err != nil {
return nil, errors.Wrap(err, "Error parsing")
}
+ lastByte := hexBytes[len(hexBytes)-1]
+ if (lastByte >= 0x67) && (lastByte <= 0x7A) {
+ // We need to reset the alpha
+ readBuffer.Reset(readBuffer.GetPos() - 1)
+ hexBytes = hexBytes[:len(hexBytes)-1]
+ }
rawBytes := make([]byte, hex.DecodedLen(len(hexBytes)))
n, err := hex.Decode(rawBytes, hexBytes)
if err != nil {
@@ -71,6 +77,12 @@ func ReadCALReply(readBuffer utils.ReadBuffer, payloadLength uint16) (CALReply,
if err != nil {
return nil, errors.Wrap(err, "Error parsing")
}
+ lastByte := hexBytes[len(hexBytes)-1]
+ if (lastByte >= 0x67) && (lastByte <= 0x7A) {
+ // We need to reset the alpha
+ readBuffer.Reset(readBuffer.GetPos() - 1)
+ hexBytes = hexBytes[:len(hexBytes)-1]
+ }
rawBytes := make([]byte, hex.DecodedLen(len(hexBytes)))
n, err := hex.Decode(rawBytes, hexBytes)
if err != nil {
@@ -98,6 +110,12 @@ func ReadCALData(readBuffer utils.ReadBuffer, payloadLength uint16) (CALData, er
if err != nil {
return nil, errors.Wrap(err, "Error parsing")
}
+ lastByte := hexBytes[len(hexBytes)-1]
+ if (lastByte >= 0x67) && (lastByte <= 0x7A) {
+ // We need to reset the alpha
+ readBuffer.Reset(readBuffer.GetPos() - 1)
+ hexBytes = hexBytes[:len(hexBytes)-1]
+ }
rawBytes := make([]byte, hex.DecodedLen(len(hexBytes)))
n, err := hex.Decode(rawBytes, hexBytes)
if err != nil {
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 53cca9396..06117c959 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
@@ -26,6 +26,7 @@ import org.apache.plc4x.java.cbus.readwrite.CBusCommand;
import org.apache.plc4x.java.spi.generation.*;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
public class StaticHelper {
public static void writeCBusCommand(WriteBuffer writeBuffer, CBusCommand cbusCommand) throws SerializationException {
@@ -38,6 +39,12 @@ public class StaticHelper {
public static CBusCommand readCBusCommand(ReadBuffer readBuffer, Integer payloadLength, boolean srcchk) throws ParseException {
byte[] hexBytes = readBuffer.readByteArray("cbusCommand", payloadLength);
+ byte lastByte = hexBytes[hexBytes.length - 1];
+ if ((lastByte >= 0x67) && (lastByte <= 0x7A)) {
+ // We need to reset the alpha
+ readBuffer.reset(readBuffer.getPos() - 1);
+ hexBytes = Arrays.copyOf(hexBytes,hexBytes.length-1);
+ }
byte[] rawBytes;
try {
rawBytes = Hex.decodeHex(new String(hexBytes));
@@ -57,6 +64,12 @@ public class StaticHelper {
public static CALReply readCALReply(ReadBuffer readBuffer, Integer payloadLength) throws ParseException {
byte[] hexBytes = readBuffer.readByteArray("calReply", payloadLength);
+ byte lastByte = hexBytes[hexBytes.length - 1];
+ if ((lastByte >= 0x67) && (lastByte <= 0x7A)) {
+ // We need to reset the alpha
+ readBuffer.reset(readBuffer.getPos() - 1);
+ hexBytes = Arrays.copyOf(hexBytes,hexBytes.length-1);
+ }
byte[] rawBytes;
try {
rawBytes = Hex.decodeHex(new String(hexBytes));
@@ -76,6 +89,12 @@ public class StaticHelper {
public static CALData readCALData(ReadBuffer readBuffer, Integer payloadLength) throws ParseException {
byte[] hexBytes = readBuffer.readByteArray("calReply", payloadLength);
+ byte lastByte = hexBytes[hexBytes.length - 1];
+ if ((lastByte >= 0x67) && (lastByte <= 0x7A)) {
+ // We need to reset the alpha
+ readBuffer.reset(readBuffer.getPos() - 1);
+ hexBytes = Arrays.copyOf(hexBytes,hexBytes.length-1);
+ }
byte[] rawBytes;
try {
rawBytes = Hex.decodeHex(new String(hexBytes));
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 f83036b6a..6aca19792 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
@@ -524,5 +524,15 @@ public class RandomPackagesTest {
.isNotNull();
System.out.println(msg);
}
+
+ @Test
+ void setLight() throws Exception {
+ byte[] bytes = "\\0538000100g\r".getBytes(StandardCharsets.UTF_8);
+ ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+ CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, false, true, bytes.length);
+ assertThat(msg)
+ .isNotNull();
+ System.out.println(msg);
+ }
}
}
diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
index 1afb93f20..3a00232bf 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
@@ -62,7 +62,7 @@
calData
'STATIC_CALL("readCALData", readBuffer, payloadLength)'
'STATIC_CALL("writeCALData", writeBuffer, calData)'
- '_value.lengthInBytes*2' ]
+ '_value.lengthInBytes*2' ]
]
['REQUEST_COMMAND' *Command(uint 16 payloadLength)
[const byte initiator 0x5C ] // 0x5C == "/"
@@ -72,7 +72,8 @@
cbusCommand
'STATIC_CALL("readCBusCommand", readBuffer, payloadLength, srchk)'
'STATIC_CALL("writeCBusCommand", writeBuffer, cbusCommand)'
- '_value.lengthInBytes*2' ]
+ '_value.lengthInBytes*2' ]
+ [optional Alpha alpha ]
]
['NULL' *Null
[const uint 32 nullIndicator 0x6E756C6C ] // "null"
@@ -195,7 +196,6 @@
]
[simple CALData calData ]
[optional Checksum crc 'srchk' ] // checksum is optional but mspec checksum isn't
- [optional Alpha alpha ]
]
[discriminatedType CBusPointToMultiPointCommand(bit srchk)
@@ -206,14 +206,12 @@
[reserved byte '0x00' ]
[simple StatusRequest statusRequest ]
[optional Checksum crc 'srchk' ] // checksum is optional but mspec checksum isn't
- [optional Alpha alpha ]
]
[ CBusPointToMultiPointCommandNormal
[simple ApplicationIdContainer application ]
[reserved byte '0x00' ]
[simple SALData salData ]
[optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't
- [optional Alpha alpha ]
]
]
]
@@ -227,13 +225,11 @@
[reserved byte '0xFF' ]
[simple StatusRequest statusRequest ]
[optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't
- [optional Alpha alpha ]
]
[ CBusCommandPointToPointToMultiPointNormal
[simple ApplicationIdContainer application ]
[simple SALData salData ]
[optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't
- [optional Alpha alpha ]
]
]
]
[plc4x] 01/02: feat(spi): changed the way a byte is rendered
Posted by sr...@apache.org.
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 a243df0a92bc2753ddd8bd9d64a6ee7ee2703ba4
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jul 4 17:44:31 2022 +0200
feat(spi): changed the way a byte is rendered
- Now a ascii representation is displayed if applicable
---
plc4go/internal/spi/utils/WriteBufferBoxBased.go | 6 +++++-
.../org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/plc4go/internal/spi/utils/WriteBufferBoxBased.go b/plc4go/internal/spi/utils/WriteBufferBoxBased.go
index 9e6cb8b6a..80e1a2d36 100644
--- a/plc4go/internal/spi/utils/WriteBufferBoxBased.go
+++ b/plc4go/internal/spi/utils/WriteBufferBoxBased.go
@@ -98,7 +98,11 @@ func (b *boxedWriteBuffer) WriteBit(logicalName string, value bool, writerArgs .
func (b *boxedWriteBuffer) WriteByte(logicalName string, value byte, writerArgs ...WithWriterArgs) error {
additionalStringRepresentation := b.extractAdditionalStringRepresentation(upcastWriterArgs(writerArgs...)...)
- b.PushBack(b.asciiBoxWriter.BoxString(logicalName, fmt.Sprintf("%#02x%s", value, additionalStringRepresentation), 0))
+ printSafeChar := value
+ if value < 32 || value > 126 {
+ printSafeChar = '.'
+ }
+ b.PushBack(b.asciiBoxWriter.BoxString(logicalName, fmt.Sprintf("%#02x '%c'%s", value, printSafeChar, additionalStringRepresentation), 0))
b.move(8)
return nil
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
index 6175eef21..397a93406 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
@@ -92,7 +92,7 @@ public class WriteBufferBoxBased implements WriteBuffer, BufferCommons {
@Override
public void writeByte(String logicalName, byte value, WithWriterArgs... writerArgs) throws SerializationException {
String additionalStringRepresentation = extractAdditionalStringRepresentation(writerArgs).map(s -> " " + s).orElse("");
- boxes.offerLast(Either.left(asciiBoxWriter.boxString(logicalName, String.format("%02x%s", value, additionalStringRepresentation), 0)));
+ boxes.offerLast(Either.left(asciiBoxWriter.boxString(logicalName, String.format("0x%02x '%c'%s", value, value < 32 || value > 126 ? '.' : value, additionalStringRepresentation), 0)));
move(8);
}