DLE Encoder Improvements #467

Merged
muellerr merged 22 commits from KSat/fsfw:mueller/dle-improvements into development 2021-09-13 15:25:02 +02:00
Showing only changes of commit dae27a8e10 - Show all commits

View File

@ -1,13 +1,13 @@
#include "fsfw/globalfunctions/DleEncoder.h"
DleEncoder::DleEncoder(bool escapeStxEtx, bool escapeCr): escapeStxEtx(escapeStxEtx),
escapeCr(escapeCr) {}
DleEncoder::DleEncoder(bool escapeStxEtx, bool escapeCr):
escapeStxEtx(escapeStxEtx), escapeCr(escapeCr) {}
DleEncoder::~DleEncoder() {}
ReturnValue_t DleEncoder::encode(const uint8_t* sourceStream,
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
size_t* encodedLen, bool addStxEtx) {
size_t sourceLen, uint8_t* destStream, size_t maxDestLen,
size_t* encodedLen, bool addStxEtx) {
if(escapeStxEtx) {
mohr marked this conversation as resolved Outdated
Outdated
Review

addStxEtx comes into play here, too. If it is false, 1 or even 0 might be valid. I think STREAM_TOO_SHORT should be caught directely when writing to the dest stream

addStxEtx comes into play here, too. If it is false, 1 or even 0 might be valid. I think STREAM_TOO_SHORT should be caught directely when writing to the dest stream
return encodeStreamEscaped(sourceStream, sourceLen,
destStream, maxDestLen, encodedLen, addStxEtx);
@ -136,16 +136,16 @@ ReturnValue_t DleEncoder::encodeStreamNonEscaped(const uint8_t *sourceStream, si
}
ReturnValue_t DleEncoder::decode(const uint8_t *sourceStream,
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen) {
if(escapeStxEtx) {
return decodeStreamEscaped(sourceStream, sourceStreamLen,
readLen, destStream, maxDestStreamlen, decodedLen);
}
else {
size_t sourceStreamLen, size_t *readLen, uint8_t *destStream,
size_t maxDestStreamlen, size_t *decodedLen) {
if(escapeStxEtx) {
return decodeStreamEscaped(sourceStream, sourceStreamLen,
readLen, destStream, maxDestStreamlen, decodedLen);
mohr marked this conversation as resolved Outdated
Outdated
Review

as with encode, I think it is cleaner if all the handling, including the start marker, is in the individual decode functions

as with encode, I think it is cleaner if all the handling, including the start marker, is in the individual decode functions
}
else {
return decodeStreamNonEscaped(sourceStream, sourceStreamLen,
readLen, destStream, maxDestStreamlen, decodedLen);
}
}
}
ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_t sourceStreamLen,