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 f66dd42324 feat(plc4go/cbus): add more tracing, increase receive
timeout
f66dd42324 is described below
commit f66dd42324682acf0eac7dae1d5670b2945d626d
Author: Sebastian Rühl <[email protected]>
AuthorDate: Tue Mar 28 12:31:17 2023 +0200
feat(plc4go/cbus): add more tracing, increase receive timeout
---
plc4go/internal/cbus/MessageCodec.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/plc4go/internal/cbus/MessageCodec.go
b/plc4go/internal/cbus/MessageCodec.go
index b58ecbd2cc..635fd23c4a 100644
--- a/plc4go/internal/cbus/MessageCodec.go
+++ b/plc4go/internal/cbus/MessageCodec.go
@@ -128,6 +128,7 @@ func (m *MessageCodec) Receive() (spi.Message, error) {
}
readableBytes = numBytesAvailableInBuffer
}
+ log.Trace().Msgf("%d bytes available in buffer", readableBytes)
// Check for an isolated error
if bytes, err := ti.PeekReadableBytes(1); err == nil && (bytes[0] ==
byte(readWriteModel.ConfirmationType_CHECKSUM_FAILURE)) {
@@ -179,6 +180,8 @@ lookingForTheEnd:
// This means a <cr> is directly followed by a <lf> which means
that we know for sure this is a response
pciResponse = true
}
+ const numberOfCyclesToWait = 15
+ const estimatedElapsedTime = numberOfCyclesToWait * 10
if !pciResponse && !requestToPci && indexOfLF < 0 {
// To be sure we might receive that package later we hash the
bytes and check if we might receive one
hash := crc32.NewIEEE()
@@ -189,11 +192,12 @@ lookingForTheEnd:
}
log.Trace().Msgf("new hash %x, last hash %x, seen %d times",
newPackageHash, m.lastPackageHash, m.hashEncountered)
m.lastPackageHash = newPackageHash
- if m.hashEncountered < 11 {
+ if m.hashEncountered < numberOfCyclesToWait {
log.Trace().Msg("Waiting for more data")
return nil, nil
} else {
- // after 110ms we give up finding a lf
+ log.Trace().Msgf("stopping after ~%dms",
estimatedElapsedTime)
+ // after numberOfCyclesToWait*10 ms we give up finding
a lf
m.lastPackageHash, m.hashEncountered = 0, 0
if indexOfCR >= 0 {
log.Trace().Msg("setting requestToPci")