Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/triceDoubleBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,16 @@ static void TriceOut(uint32_t* tb, size_t tLen) {
size_t len8 = (triceNettoLen + 7) & ~7; // Only multiple of 8 encryptable, so we adjust len.
memset((crypt) + triceNettoLen, 0, len8 - triceNettoLen); // Clear padding space.
XTEAEncrypt((uint32_t*)crypt, len8 >> 2);
encLen += (size_t)TCOBSEncode(dst, crypt, len8); // encLen is re-used here
size_t len = (size_t)TCOBSEncode(dst, crypt, len8); // encLen is re-used here
encLen += len;
dst[encLen++] = 0; // Add zero as package delimiter.
#elif (TRICE_DEFERRED_XTEA_ENCRYPT == 1) && (TRICE_DEFERRED_OUT_FRAMING == TRICE_FRAMING_COBS)
memmove(crypt, triceNettoStart, triceNettoLen);
size_t len8 = (triceNettoLen + 7) & ~7; // Only multiple of 8 encryptable, so we adjust len.
memset((crypt) + triceNettoLen, 0, len8 - triceNettoLen); // Clear padding space.
XTEAEncrypt((uint32_t*)crypt, len8 >> 2);
encLen += (size_t)COBSEncode(dst, crypt, len8); // encLen is re-used here
size_t len = (size_t)COBSEncode(dst, crypt, len8); // encLen is re-used here
encLen += len;
dst[encLen++] = 0; // Add zero as package delimiter.
#elif (TRICE_DEFERRED_XTEA_ENCRYPT == 1) && (TRICE_DEFERRED_OUT_FRAMING == TRICE_FRAMING_NONE)
#if TRICE_CONFIG_WARNINGS == 1
Expand All @@ -252,6 +254,7 @@ static void TriceOut(uint32_t* tb, size_t tLen) {
encLen += len;
#elif (TRICE_DEFERRED_XTEA_ENCRYPT == 0) && (TRICE_DEFERRED_OUT_FRAMING == TRICE_FRAMING_NONE)
memmove(dst, triceNettoStart, triceNettoLen);
size_t len = triceNettoLen;
encLen += triceNettoLen;
#else
#error configuration: unexpected
Expand All @@ -262,6 +265,11 @@ static void TriceOut(uint32_t* tb, size_t tLen) {
memmove(packed, triceNettoStart, triceNettoLen); // This action removes all padding bytes of the trices, compacting their sequence this way
encLen += triceNettoLen;
#endif // #elif TRICE_DEFERRED_TRANSFER_MODE == TRICE_MULTI_PACK_MODE
#if TRICE_DEFERRED_TRANSFER_MODE == TRICE_SINGLE_PACK_MODE
TRICE_ENTER_CRITICAL_SECTION
TriceNonBlockingDeferredWrite8(triceID, dst, len);
TRICE_LEAVE_CRITICAL_SECTION
#endif // TRICE_DEFERRED_TRANSFER_MODE == TRICE_SINGLE_PACK_MODE
#if (TRICE_PROTECT == 1) || (TRICE_DIAGNOSTICS == 1)
dst = enc + encLen; // When several Trices in the double buffer, with each encoding the new dst could drift a bit closer towards triceNettoStart.
int triceDataOffsetSpaceRemained = nxt - dst; // THe begin of unprocessed data MINUS next dst must not be negative.
Expand Down Expand Up @@ -319,7 +327,6 @@ static void TriceOut(uint32_t* tb, size_t tLen) {
TriceDataOffsetDepthMax = triceDataOffsetDepth < TriceDataOffsetDepthMax ? TriceDataOffsetDepthMax : triceDataOffsetDepth;
#endif
encLen = eLen;
#endif

// Reaching here means all trice data in the current half buffer are encoded
// into a single continuous buffer having 0-delimiters between them or not but at the ent is a 0-delimiter.
Expand All @@ -328,6 +335,7 @@ static void TriceOut(uint32_t* tb, size_t tLen) {
TRICE_ENTER_CRITICAL_SECTION
TriceNonBlockingDeferredWrite8(triceID, enc, encLen); // lint !e771 Info 771: Symbol 'triceID' conceivably not initialized. Comment: tLen is always > 0.
TRICE_LEAVE_CRITICAL_SECTION
#endif // TRICE_DEFERRED_TRANSFER_MODE == TRICE_MULTI_PACK_MODE
}

#endif // #if TRICE_BUFFER == TRICE_DOUBLE_BUFFER && TRICE_OFF == 0