Fixed an missing include

This commit is contained in:
Steffen Gaisser 2022-02-23 22:36:29 +01:00
parent 32381a7872
commit 1ef3dae72e
2 changed files with 8 additions and 5 deletions

View File

@ -7,6 +7,7 @@
#include <fsfw/cfdp/tlv/Tlv.h>
#include <fsfw/cfdp/tlv/TlvIF.h>
#include <fsfw/serialize/SerializeIF.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <cstddef>
#include <cstdint>

View File

@ -1,6 +1,7 @@
#include "fsfw/globalfunctions/arrayprinter.h"
#include <bitset>
#include <cmath>
#include "fsfw/serviceinterface/ServiceInterface.h"
@ -68,7 +69,7 @@ void arrayprinter::printHex(const uint8_t *data, size_t size, size_t maxCharPerL
currentPos += snprintf(printBuffer + currentPos, 6, "%02x", data[i]);
if (i < size - 1) {
currentPos += sprintf(printBuffer + currentPos, ",");
if (i > 0 and (i + 1) % maxCharPerLine == 0) {
if ((i + 1) % maxCharPerLine == 0) {
currentPos += sprintf(printBuffer + currentPos, "\n");
}
}
@ -97,20 +98,21 @@ void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerL
}
std::cout << "]" << std::endl;
#else
// General format: 32, 243, -12 so it is number of chars times 5
// General format: 32,243,-12 so it is number of chars times 4
// plus line break plus small safety margin.
char printBuffer[(size + 1) * 5 + 1] = {};
uint16_t expectedLines = ceil((double)size / maxCharPerLine);
char printBuffer[size * 4 + 1 + expectedLines] = {};
size_t currentPos = 0;
for (size_t i = 0; i < size; i++) {
// To avoid buffer overflows.
if (sizeof(printBuffer) - currentPos <= 5) {
if (sizeof(printBuffer) - currentPos <= 4) {
break;
}
currentPos += snprintf(printBuffer + currentPos, 4, "%d", data[i]);
if (i < size - 1) {
currentPos += sprintf(printBuffer + currentPos, ",");
if (i > 0 and (i + 1) % maxCharPerLine == 0) {
if ((i + 1) % maxCharPerLine == 0) {
currentPos += sprintf(printBuffer + currentPos, "\n");
}
}