buffer changes

This commit is contained in:
Robin Müller 2020-06-04 14:22:04 +02:00
parent f8fb370ae7
commit 966c9c3993

View File

@ -95,24 +95,40 @@ std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
preamble[0] = '\r'; preamble[0] = '\r';
currentSize += 1; currentSize += 1;
} }
logMessage.copy(preamble.data() + 1, logMessage.size()); int32_t charCount = sprintf(preamble.data() + currentSize,
currentSize += logMessage.size(); "%s: | %lu:%02lu:%02lu.%03lu | ",
preamble[++currentSize] = ':'; this->logMessage.c_str(), (unsigned long) loggerTime.hour,
preamble[++currentSize] = ' '; (unsigned long) loggerTime.minute,
preamble[++currentSize] = '|'; (unsigned long) loggerTime.second,
zero_padded(loggerTime.hour, 2).copy(preamble.data() + ) (unsigned long) loggerTime.usecond /1000);
//preamble.c_str() + 1 = logMessage; if(charCount < 0) {
// printf("ServiceInterfaceBuffer: Failure parsing preamble");
// + ": | " + zero_padded(loggerTime.hour, 2) return "";
// + ":" + zero_padded(loggerTime.minute, 2) + ":" }
// + zero_padded(loggerTime.second, 2) + "." currentSize += charCount;
// + zero_padded(loggerTime.usecond/1000, 3) + " | "; // size_t currentSize = 0;
currentSize += logMessage.size(); //+ 4 +2 +1 +2 +1 +2 +1 + 3 + 3; // if(addCrToPreamble) {
preamble[currentSize] = '\0'; // preamble[0] = '\r';
printf("%s", preamble.c_str()); // currentSize += 1;
uint8_t debugArray[96]; // }
memcpy(debugArray, preamble.data(), currentSize); // logMessage.copy(preamble.data() + 1, logMessage.size());
*preambleSize = currentSize; // currentSize += logMessage.size();
// preamble[++currentSize] = ':';
// preamble[++currentSize] = ' ';
// preamble[++currentSize] = '|';
// zero_padded(loggerTime.hour, 2).copy(preamble.data() + )
// //preamble.c_str() + 1 = logMessage;
////
//// + ": | " + zero_padded(loggerTime.hour, 2)
//// + ":" + zero_padded(loggerTime.minute, 2) + ":"
//// + zero_padded(loggerTime.second, 2) + "."
//// + zero_padded(loggerTime.usecond/1000, 3) + " | ";
// currentSize += logMessage.size(); //+ 4 +2 +1 +2 +1 +2 +1 + 3 + 3;
// preamble[currentSize] = '\0';
// printf("%s", preamble.c_str());
// uint8_t debugArray[96];
// memcpy(debugArray, preamble.data(), currentSize);
// *preambleSize = currentSize;
return preamble; return preamble;
} }