all cstdout uses wrapped in preprocessor defines
This commit is contained in:
@ -8,8 +8,10 @@
|
||||
BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() {
|
||||
handle = TaskManagement::getCurrentTaskHandle();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Could not retrieve task handle. Please ensure the"
|
||||
"constructor was called inside a task." << std::endl;
|
||||
#endif
|
||||
}
|
||||
xTaskNotifyGive(handle);
|
||||
}
|
||||
|
@ -5,7 +5,9 @@
|
||||
BinarySemaphore::BinarySemaphore() {
|
||||
handle = xSemaphoreCreateBinary();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Semaphore: Binary semaph creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
// Initiated semaphore must be given before it can be taken.
|
||||
xSemaphoreGive(handle);
|
||||
@ -18,7 +20,9 @@ BinarySemaphore::~BinarySemaphore() {
|
||||
BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) {
|
||||
handle = xSemaphoreCreateBinary();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Binary semaphore creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
xSemaphoreGive(handle);
|
||||
}
|
||||
@ -28,7 +32,9 @@ BinarySemaphore& BinarySemaphore::operator =(
|
||||
if(&s != this) {
|
||||
handle = xSemaphoreCreateBinary();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Binary semaphore creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
xSemaphoreGive(handle);
|
||||
}
|
||||
|
@ -9,25 +9,31 @@
|
||||
CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount,
|
||||
uint8_t initCount): maxCount(maxCount) {
|
||||
if(initCount > maxCount) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
|
||||
"intial cout. Setting initial count to max count." << std::endl;
|
||||
#endif
|
||||
initCount = maxCount;
|
||||
}
|
||||
|
||||
handle = TaskManagement::getCurrentTaskHandle();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphoreUsingTask: Could not retrieve task "
|
||||
"handle. Please ensure the constructor was called inside a "
|
||||
"task." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t oldNotificationValue;
|
||||
xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite,
|
||||
&oldNotificationValue);
|
||||
if(oldNotificationValue != 0) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "CountinSemaphoreUsingTask: Semaphore initiated but "
|
||||
"current notification value is not 0. Please ensure the "
|
||||
"notification value is not used for other purposes!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
for(int i = 0; i < initCount; i++) {
|
||||
xTaskNotifyGive(handle);
|
||||
|
@ -10,14 +10,18 @@
|
||||
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
|
||||
maxCount(maxCount), initCount(initCount) {
|
||||
if(initCount > maxCount) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
|
||||
"intial cout. Setting initial count to max count." << std::endl;
|
||||
#endif
|
||||
initCount = maxCount;
|
||||
}
|
||||
|
||||
handle = xSemaphoreCreateCounting(maxCount, initCount);
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +29,9 @@ CountingSemaphore::CountingSemaphore(CountingSemaphore&& other):
|
||||
maxCount(other.maxCount), initCount(other.initCount) {
|
||||
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +39,9 @@ CountingSemaphore& CountingSemaphore::operator =(
|
||||
CountingSemaphore&& other) {
|
||||
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
return * this;
|
||||
}
|
||||
|
@ -37,15 +37,19 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) {
|
||||
}
|
||||
|
||||
originalTask->taskFunctionality();
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Polling task " << originalTask->handle
|
||||
<< " returned from taskFunctionality." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void FixedTimeslotTask::missedDeadlineCounter() {
|
||||
FixedTimeslotTask::deadlineMissedCount++;
|
||||
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount
|
||||
<< " deadlines." << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +73,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;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||
maxMessageSize(maxMessageSize) {
|
||||
handle = xQueueCreate(messageDepth, maxMessageSize);
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
if (handle == nullptr) {
|
||||
sif::error << "MessageQueue::MessageQueue:"
|
||||
<< " Creation failed." << std::endl;
|
||||
@ -17,7 +18,9 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||
<< std::endl;
|
||||
sif::error << "Specified Maximum Message Size: "
|
||||
<< maxMessageSize << std::endl;
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MessageQueue::~MessageQueue() {
|
||||
|
@ -5,7 +5,9 @@
|
||||
Mutex::Mutex() {
|
||||
handle = xSemaphoreCreateMutex();
|
||||
if(handle == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,10 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
||||
BaseType_t status = xTaskCreate(taskEntryPoint, name,
|
||||
stackSize, this, setPriority, &handle);
|
||||
if(status != pdPASS){
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "PeriodicTask Insufficient heap memory remaining. "
|
||||
"Status: " << status << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,8 +43,10 @@ void PeriodicTask::taskEntryPoint(void* argument) {
|
||||
}
|
||||
|
||||
originalTask->taskFunctionality();
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Polling task " << originalTask->handle
|
||||
<< " returned from taskFunctionality." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicTask::startTask() {
|
||||
@ -99,8 +103,10 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||
object);
|
||||
if (newObject == nullptr) {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||
"it implement ExecutableObjectIF" << std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
objectList.push_back(newObject);
|
||||
|
@ -32,8 +32,10 @@ SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) {
|
||||
return new BinarySemaphoreUsingTask();
|
||||
}
|
||||
else {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SemaphoreFactory: Invalid argument, return regular"
|
||||
"binary semaphore" << std::endl;
|
||||
#endif
|
||||
return new BinarySemaphore();
|
||||
}
|
||||
}
|
||||
@ -47,8 +49,10 @@ SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount,
|
||||
return new CountingSemaphoreUsingTask(maxCount, initCount);
|
||||
}
|
||||
else {
|
||||
#if CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SemaphoreFactory: Invalid argument, return regular"
|
||||
"binary semaphore" << std::endl;
|
||||
#endif
|
||||
return new CountingSemaphore(maxCount, initCount);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user