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 16:10:52 UTC
[plc4x] branch develop updated: fix(plc4go/cbus): added a workaround from a nasty bug in using PeekReadableBytes
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 548e3b43f fix(plc4go/cbus): added a workaround from a nasty bug in using PeekReadableBytes
548e3b43f is described below
commit 548e3b43f2d8f06dcbbcffa3d874d0b005d1f3e7
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Aug 4 18:10:44 2022 +0200
fix(plc4go/cbus): added a workaround from a nasty bug in using PeekReadableBytes
---
plc4go/internal/cbus/MessageCodec.go | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/plc4go/internal/cbus/MessageCodec.go b/plc4go/internal/cbus/MessageCodec.go
index 33685dd8d..d19a414ee 100644
--- a/plc4go/internal/cbus/MessageCodec.go
+++ b/plc4go/internal/cbus/MessageCodec.go
@@ -98,6 +98,18 @@ func (m *MessageCodec) Receive() (spi.Message, error) {
log.Trace().Msg("receiving")
ti := m.GetTransportInstance()
+ // TODO: workaround as getNumReadableBytes seem to lie
+ {
+ nBytes := uint32(1)
+ hitCR := false
+ for ; !hitCR; nBytes++ {
+ bytes, err := ti.PeekReadableBytes(nBytes)
+ if err != nil {
+ return nil, err
+ }
+ hitCR = bytes[len(bytes)-1] == '\r'
+ }
+ }
readableBytes, err := ti.GetNumReadableBytes()
if err != nil {
log.Warn().Err(err).Msg("Got error reading")