diff --git a/source/shoh/src/threads/common/QueueManager.cpp b/source/shoh/src/threads/common/QueueManager.cpp index 8f4c42a..61a750a 100644 --- a/source/shoh/src/threads/common/QueueManager.cpp +++ b/source/shoh/src/threads/common/QueueManager.cpp @@ -6,17 +6,21 @@ */ #include "ThreadCommon.h" +#include "Log.h" ThreadCommon::QueueManager::QueueManager() {} bool ThreadCommon::QueueManager::createQueue(size_t queue_length, size_t item_size, Queue_id qid) { QueueHandle_t queue_to_create; + LOG_DEBUG("Creating queue with id %d", qid); if ((queue_to_create = xQueueCreate(queue_length, item_size))) { + LOG_DEBUG("Queue with id %d has been created", qid); queues.insert({qid, queue_to_create}); return true; } + LOG_ERROR("Failed to cerate queue with id %d", qid); return false; } diff --git a/source/shoh/src/threads/common/ThreadManager.cpp b/source/shoh/src/threads/common/ThreadManager.cpp index 2ac2803..877c5eb 100644 --- a/source/shoh/src/threads/common/ThreadManager.cpp +++ b/source/shoh/src/threads/common/ThreadManager.cpp @@ -1,4 +1,5 @@ #include "ThreadCommon.h" +#include "Log.h" ThreadCommon::ThreadManager::ThreadManager(){} @@ -10,12 +11,18 @@ bool ThreadCommon::ThreadManager::createTask(void (*task_func)(void*), void* parameters) { const char * t_name = name.c_str(); + LOG_DEBUG("Creating task [name: %s, priority: %ld, stack: %ld]", + t_name, priority, stack_size); BaseType_t taskCreated = xTaskCreate(task_func, t_name, stack_size, parameters, priority, NULL); - assert(taskCreated == pdPASS); + if (!(taskCreated == pdPASS)) + { + LOG_ERROR("Failed to create a task [name: %s, priority: %ld, stack: %ld]", + t_name, priority, stack_size) + } return (taskCreated == pdPASS); } diff --git a/source/shoh/src/threads/manager/Manager.cpp b/source/shoh/src/threads/manager/Manager.cpp index 2f4e9ca..668c551 100644 --- a/source/shoh/src/threads/manager/Manager.cpp +++ b/source/shoh/src/threads/manager/Manager.cpp @@ -7,15 +7,17 @@ #include "Manager.h" #include "ThreadCommon.h" +#include "Log.h" Manager::Manager(ThreadCommon::QueueManager* qm) : _qm(qm), _menu{qm} { + LOG_DEBUG("Creating Manager"); } Manager::~Manager() { - // TODO Auto-generated destructor stub + LOG_ERROR("Deleting Manager"); } Event::EventPair Manager::parseEvent(Event* e) @@ -32,6 +34,7 @@ Event::EventPair Manager::parseEvent(Event* e) return p; } } + LOG_WARNING("Event is empty"); return {ERROR_RETURN, Event::Null}; } diff --git a/source/shoh/src/threads/master/Master.cpp b/source/shoh/src/threads/master/Master.cpp index 775771b..18072e9 100644 --- a/source/shoh/src/threads/master/Master.cpp +++ b/source/shoh/src/threads/master/Master.cpp @@ -6,6 +6,7 @@ */ #include "Master.h" +#include "Log.h" static const char* rotary_direction[] = { @@ -17,7 +18,7 @@ static const char* rotary_direction[] = Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm) { - + LOG_DEBUG("Creating Master"); } void Master::HandleEventType(Event* e, Event::EventType type) @@ -29,6 +30,7 @@ void Master::HandleEventType(Event* e, Event::EventType type) case Event::Rotary: //Comes from rotary, goes to manager _qm->send(ThreadCommon::QueueManager::manager_event_master, e, 0); + LOG_DEBUG("Rotary: %s has been forwarded to manager", rotary_direction[e->getDataOf(type)]); break; case Event::InternalTemp: // TODO remove (deprecated) @@ -37,10 +39,12 @@ void Master::HandleEventType(Event* e, Event::EventType type) //Comes from sensors, goes to relay & manager _qm->send(ThreadCommon::QueueManager::relay_event_master, e, 0); _qm->send(ThreadCommon::QueueManager::manager_event_master, e, 0); + LOG_DEBUG("ExtTemp: %d has been forwarded to manager and relay", e->getDataOf(type)); break; case Event::SetPoint: //Comes from manager, goes to relay _qm->send(ThreadCommon::QueueManager::relay_event_master, e, 0); + LOG_DEBUG("SetPoint: %d has been forwarded to relay", e->getDataOf(type)); break; default: assert(0); diff --git a/source/shoh/src/threads/rotary/Rotary.cpp b/source/shoh/src/threads/rotary/Rotary.cpp index eb9f19d..71c36ce 100644 --- a/source/shoh/src/threads/rotary/Rotary.cpp +++ b/source/shoh/src/threads/rotary/Rotary.cpp @@ -8,6 +8,7 @@ #include "Rotary.h" #include "board.h" #include "queue.h" +#include "Log.h" static QueueHandle_t * p_rotary_isr_q; @@ -20,6 +21,10 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Right; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); + if(!xHigherPriorityWoken) + { + LOG_WARNING("[PIN_INT0_IRQn] portEND_SWITCHING_ISR called with False value"); + } portEND_SWITCHING_ISR(xHigherPriorityWoken); } @@ -30,6 +35,10 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Left; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); + if(!xHigherPriorityWoken) + { + LOG_WARNING("[PIN_INT1_IRQn] portEND_SWITCHING_ISR called with False value"); + } portEND_SWITCHING_ISR(xHigherPriorityWoken); } @@ -40,16 +49,23 @@ extern "C" portBASE_TYPE xHigherPriorityWoken = pdFALSE; uint8_t data = ThreadCommon::RotaryAction::Press; xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken); + if(!xHigherPriorityWoken) + { + LOG_WARNING("[PIN_INT2_IRQn] portEND_SWITCHING_ISR called with False value"); + } portEND_SWITCHING_ISR(xHigherPriorityWoken); } } Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm) { - + LOG_DEBUG("Creating Rotary"); } -Rotary::~Rotary() {} +Rotary::~Rotary() +{ + LOG_ERROR("Deleting Rotary"); +} void Rotary::taskFunction() { diff --git a/source/shoh/src/threads/user_interface/UserInterface.cpp b/source/shoh/src/threads/user_interface/UserInterface.cpp index bafd5d4..a720cc0 100644 --- a/source/shoh/src/threads/user_interface/UserInterface.cpp +++ b/source/shoh/src/threads/user_interface/UserInterface.cpp @@ -5,16 +5,19 @@ */ #include "UserInterface.h" +#include "Log.h" #include UserInterface::UserInterface(ThreadCommon::QueueManager* qm) : _qm(qm), lcd1(nullptr) { + LOG_DEBUG("Creating UserInterface"); this->initLCD1(); } UserInterface::~UserInterface() { + LOG_ERROR("Deleting UserInterface"); delete this->lcd1; delete this->lcd1_rs; delete this->lcd1_en; @@ -45,7 +48,7 @@ void UserInterface::handleEvent(InterfaceWithData* ui_data) break; default: //Should never happen. - printf("WARNING: [UserInterface::handleEvent] executed default case.\n"); + LOG_ERROR("[UserInterface::handleEvent] executed default case"); break; } } @@ -59,11 +62,13 @@ void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str) //Interpret empty string as clear. if(!strlen(str)) lcd->clear(); + LOG_INFO("Clear up LCD"); //Print the text otherwise. else { lcd->setCursor(0, 0); lcd->print(str); + LOG_INFO("Printing [%s] on LCD"); } }