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/10 09:44:53 UTC

[plc4x] branch develop updated: fix(plc4xpcapanalyzer): remove ! in the middle of responses and return it as a "single" response

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 9a1fb1cef fix(plc4xpcapanalyzer): remove ! in the middle of responses and return it as a "single" response
9a1fb1cef is described below

commit 9a1fb1cef604c56ba48c89cab3a59d8ed8de029b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Aug 10 11:44:47 2022 +0200

    fix(plc4xpcapanalyzer): remove ! in the middle of responses and return it as a "single" response
---
 .../internal/cbusanalyzer/analyzer.go                  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go b/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
index d5b55afdf..2a48ac09d 100644
--- a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
+++ b/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go
@@ -134,6 +134,14 @@ func (a *Analyzer) getCurrentPayload(packetInformation common.PacketInformation,
 		// This is an errormessage from the server
 		return currentPayload, nil
 	}
+	containsError := false
+	// We ensure that there are no random ! in the string
+	currentPayload, containsError = filterOneServerError(currentPayload)
+	if containsError {
+		// Save the current inbound payload for the next try
+		currentInboundPayloads[srcUip] = currentPayload
+		return []byte{'!'}, nil
+	}
 	// Check if we have a termination in the middle
 	isMergedMessage, shouldClearInboundPayload := mergeCheck(&currentPayload, srcUip, mergeCallback, currentInboundPayloads, lastPayload)
 	if !isMergedMessage {
@@ -219,6 +227,16 @@ func filterXOnXOff(payload []byte) []byte {
 	return payload[:n]
 }
 
+func filterOneServerError(unfilteredPayload []byte) (filteredPayload []byte, containsError bool) {
+	for i, b := range unfilteredPayload {
+		if b == '!' {
+			return append(unfilteredPayload[:i], unfilteredPayload[i+1:]...), true
+
+		}
+	}
+	return unfilteredPayload, false
+}
+
 func (a *Analyzer) SerializePackage(message spi.Message) ([]byte, error) {
 	if message, ok := message.(model.CBusMessage); !ok {
 		log.Fatal().Msgf("Unsupported type %T supplied", message)