From 3cec9f5f8054e2003c66affc39f45ed73cba2398 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 Aug 2021 13:18:42 +0200 Subject: [PATCH] Made two functions private, small tweak --- src/fsfw/globalfunctions/DleEncoder.cpp | 19 +++++++------------ src/fsfw/globalfunctions/DleEncoder.h | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index 6ad5e5fa..e30eee22 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -122,18 +122,13 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ destStream[decodedIndex] = nextByte; } else { - if(this->escapeStxEtx) { - /* The next byte is a STX, DTX or 0x0D character which - * was escaped by a DLE character. The actual byte was - * also encoded by adding + 0x40 to prevent having control chars, - * in the stream at all, so we convert it back. */ - if ((nextByte == STX_CHAR + 0x40 or nextByte == ETX_CHAR + 0x40) or - (this->escapeCr and nextByte == CARRIAGE_RETURN + 0x40)) { - destStream[decodedIndex] = nextByte - 0x40; - } - else { - return DECODING_ERROR; - } + /* The next byte is a STX, DTX or 0x0D character which + * was escaped by a DLE character. The actual byte was + * also encoded by adding + 0x40 to prevent having control chars, + * in the stream at all, so we convert it back. */ + if ((nextByte == STX_CHAR + 0x40 or nextByte == ETX_CHAR + 0x40) or + (this->escapeCr and nextByte == CARRIAGE_RETURN + 0x40)) { + destStream[decodedIndex] = nextByte - 0x40; } else { return DECODING_ERROR; diff --git a/src/fsfw/globalfunctions/DleEncoder.h b/src/fsfw/globalfunctions/DleEncoder.h index cd2164f8..292e00f8 100644 --- a/src/fsfw/globalfunctions/DleEncoder.h +++ b/src/fsfw/globalfunctions/DleEncoder.h @@ -87,14 +87,14 @@ public: size_t sourceStreamLen, size_t *readLen, uint8_t *destStream, size_t maxDestStreamlen, size_t *decodedLen); +private: + ReturnValue_t decodeStreamEscaped(const uint8_t *sourceStream, size_t sourceStreamLen, size_t *readLen, uint8_t *destStream, size_t maxDestStreamlen, size_t *decodedLen); ReturnValue_t decodeStreamNonEscaped(const uint8_t *sourceStream, size_t sourceStreamLen, size_t *readLen, uint8_t *destStream, size_t maxDestStreamlen, size_t *decodedLen); -private: - bool escapeStxEtx; bool escapeCr; };