1
0
forked from fsfw/fsfw

all cstdout uses wrapped in preprocessor defines

This commit is contained in:
2021-01-03 13:58:18 +01:00
parent 61fc6cac97
commit c19e628d79
96 changed files with 715 additions and 14 deletions

View File

@ -14,7 +14,9 @@ MutexIF* Clock::timeMutex = NULL;
using SystemClock = std::chrono::system_clock;
uint32_t Clock::getTicksPerSecond(void){
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl;
#endif
return 0;
//return CLOCKS_PER_SEC;
//uint32_t ticks = sysconf(_SC_CLK_TCK);
@ -23,7 +25,9 @@ uint32_t Clock::getTicksPerSecond(void){
ReturnValue_t Clock::setClock(const TimeOfDay_t* time) {
// do some magic with chrono
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::setClock: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -36,7 +40,9 @@ ReturnValue_t Clock::setClock(const timeval* time) {
#else
#endif
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -60,7 +66,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
time->tv_usec = timeUnix.tv_nsec / 1000.0;
return HasReturnvaluesIF::RETURN_OK;
#else
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
#endif
@ -68,7 +76,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
// do some magic with chrono
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -90,7 +100,9 @@ timeval Clock::getUptime() {
timeval.tv_usec = uptimeSeconds *(double) 1e6 - (timeval.tv_sec *1e6);
}
#else
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
#endif
return timeval;
}
@ -126,7 +138,9 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
auto usecond = std::chrono::duration_cast<std::chrono::microseconds>(fraction);
time->usecond = usecond.count();
#if CPP_OSTREAM_ENABLED == 1
//sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -148,7 +162,9 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from,
to->tv_usec = from->usecond;
//Fails in 2038..
return HasReturnvaluesIF::RETURN_OK;
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -35,15 +35,19 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority,
reinterpret_cast<HANDLE>(mainThread.native_handle()),
ABOVE_NORMAL_PRIORITY_CLASS);
if(result != 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl;
#endif
}
result = SetThreadPriority(
reinterpret_cast<HANDLE>(mainThread.native_handle()),
THREAD_PRIORITY_NORMAL);
if(result != 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl;
#endif
}
#elif defined(LINUX)
// TODO: we can just copy and paste the code from the linux OSAL here.
@ -70,8 +74,10 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) {
}
this->taskFunctionality();
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "FixedTimeslotTask::taskEntryPoint: "
"Returned from taskFunctionality." << std::endl;
#endif
}
ReturnValue_t FixedTimeslotTask::startTask() {
@ -134,8 +140,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK;
}
#if CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -10,8 +10,10 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
queueLock = MutexFactory::instance()->createMutex();
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);
if(result != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue:"
<< " Could not be created" << std::endl;
#endif
}
}
@ -137,8 +139,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
targetQueue->messageQueue.push(*mqmMessage);
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message"
"is not MessageQueueMessage!" << std::endl;
#endif
}
}

View File

@ -33,15 +33,19 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
reinterpret_cast<HANDLE>(mainThread.native_handle()),
ABOVE_NORMAL_PRIORITY_CLASS);
if(result != 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl;
#endif
}
result = SetThreadPriority(
reinterpret_cast<HANDLE>(mainThread.native_handle()),
THREAD_PRIORITY_NORMAL);
if(result != 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl;
#endif
}
#elif defined(LINUX)
// we can just copy and paste the code from linux here.
@ -69,8 +73,10 @@ void PeriodicTask::taskEntryPoint(void* argument) {
}
this->taskFunctionality();
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "PeriodicTask::taskEntryPoint: "
"Returned from taskFunctionality." << std::endl;
#endif
}
ReturnValue_t PeriodicTask::startTask() {

View File

@ -26,8 +26,10 @@ ReturnValue_t QueueMapManager::addMessageQueue(
auto returnPair = queueMap.emplace(currentId, queueToInsert);
if(not returnPair.second) {
// this should never happen for the atomic variable.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "QueueMapManager: This ID is already inside the map!"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
if (id != nullptr) {
@ -44,8 +46,10 @@ MessageQueueIF* QueueMapManager::getMessageQueue(
return queueIter->second;
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "QueueMapManager::getQueueHandle: The ID " <<
messageQueueId << " does not exists in the map" << std::endl;
#endif
return nullptr;
}
}

View File

@ -21,16 +21,20 @@ SemaphoreFactory* SemaphoreFactory::instance() {
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) {
// Just gonna wait for full C++20 for now.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet."
" Returning nullptr!\n" << std::flush;
#endif
return nullptr;
}
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount,
uint8_t initCount, uint32_t arguments) {
// Just gonna wait for full C++20 for now.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet."
" Returning nullptr!\n" << std::flush;
#endif
return nullptr;
}