added option to add CR for printf support

This commit is contained in:
Robin Müller 2021-01-08 02:06:27 +01:00
parent 4255176b5c
commit 2ef3e0aa7b
5 changed files with 26 additions and 17 deletions

View File

@ -377,11 +377,11 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
auto poolIter = localPoolMap.find(localPoolId); auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) { if (poolIter == localPoolMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " sif::warning << "HousekeepingManager::fetchPoolEntry: Pool entry "
"not found." << std::endl; "not found." << std::endl;
#else #else
fsfw::printWarning("HousekeepingManager::fechPoolEntry: Pool entry " fsfw::printWarning("HousekeepingManager::fetchPoolEntry: Pool entry "
"not found."); "not found.\n");
#endif #endif
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND; return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
} }
@ -393,7 +393,7 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
" Pool entry type conflict." << std::endl; " Pool entry type conflict." << std::endl;
#else #else
fsfw::printWarning("HousekeepingManager::fetchPoolEntry:" fsfw::printWarning("HousekeepingManager::fetchPoolEntry:"
" Pool entry type conflict."); " Pool entry type conflict.\n");
#endif #endif
return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT; return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT;
} }

View File

@ -110,13 +110,12 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << variableType << ": " << type << " call | " << errMsg sif::warning << variableType << ": " << type << " call | " << errMsg
<< " | Owner: " << std::hex << std::setw(8) << " | Owner: 0x" << std::hex << std::setw(8)
<< std::setfill('0') << objectId << " LPID: 0x" << lpId << std::setfill('0') << objectId << std::dec << " LPID: " << lpId
<< std::dec << std::endl; << std::endl;
#else #else
fsfw::printWarning("LocalPoolVariable: %s of local pool variable of " fsfw::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n",
"object 0x%08x and lp ID 0x%08x failed.\n\r", variableType, type, errMsg, objectId, lpId);
type, objectId, lpId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_DISABLE_PRINTOUT == 0 */ #endif /* FSFW_DISABLE_PRINTOUT == 0 */
} }

View File

@ -98,11 +98,11 @@ inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
// If this happens, I have to set some value. I consider this // If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here. // a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVector: Invalid index. Setting or returning" sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl; " last value!" << std::endl;
#else #else
fsfw::printError("LocalPoolVector: Invalid index. Setting or returning" fsfw::printWarning("LocalPoolVector: Invalid index. Setting or returning"
" last value!\n\r"); " last value!\n");
#endif #endif
return value[vectorSize]; return value[vectorSize];
} }
@ -115,11 +115,11 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
// If this happens, I have to set some value. I consider this // If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here. // a configuration error, but I wont exit here.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVector: Invalid index. Setting or returning" sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl; " last value!" << std::endl;
#else #else
fsfw::printError("LocalPoolVector: Invalid index. Setting or returning" fsfw::printWarning("LocalPoolVector: Invalid index. Setting or returning"
" last value!\n\r"); " last value!\n");
#endif #endif
return value[vectorSize]; return value[vectorSize];
} }

View File

@ -10,7 +10,7 @@ fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG;
#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 #if defined(WIN32) && FSFW_COLORED_OUTPUT == 1
bool consoleInitialized = false; bool consoleInitialized = false;
#endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */ #endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */
bool addCrAtEnd = false;
#if FSFW_DISABLE_PRINTOUT == 0 #if FSFW_DISABLE_PRINTOUT == 0
uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE];
@ -80,6 +80,10 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
len += vsnprintf(bufferPosition + len, sizeof(printBuffer) - len, fmt, arg); len += vsnprintf(bufferPosition + len, sizeof(printBuffer) - len, fmt, arg);
if(addCrAtEnd) {
len += sprintf(bufferPosition + len, "\r");
}
printf("%s", printBuffer); printf("%s", printBuffer);
} }
@ -105,6 +109,10 @@ void fsfw::printDebug(const char *fmt, ...) {
va_end(args); va_end(args);
} }
void fsfw::setToAddCrAtEnd(bool addCrAtEnd_) {
addCrAtEnd = addCrAtEnd_;
}
void fsfw::printError(const char *fmt, ...) { void fsfw::printError(const char *fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);

View File

@ -16,6 +16,8 @@ enum class PrintLevel {
void setPrintLevel(PrintLevel printLevel); void setPrintLevel(PrintLevel printLevel);
PrintLevel getPrintLevel(); PrintLevel getPrintLevel();
void setToAddCrAtEnd(bool addCrAtEnd_);
/** /**
* These functions can be used like the C stdio printf and forward the * These functions can be used like the C stdio printf and forward the
* supplied formatted string arguments to a printf function. * supplied formatted string arguments to a printf function.