logging: Fixing hard faults. Small cleanup.

*Lesser queue size.
*Removed recursive master task creation.
*Logging task now has a loop.
*Little fixes and cleanup here and there.
This commit is contained in:
RedHawk
2023-05-12 16:44:11 +03:00
parent 2c3e1a8dc8
commit 734393831e
8 changed files with 23 additions and 27 deletions

View File

@@ -77,15 +77,6 @@ namespace ThreadCommon
ThreadManager * tm;
QueueManager * qm;
} CommonManagers;
/* global variables */
/* 'receiver'_'what'_'sender'_q */
/*
extern QueueHandle_t master_event_all_q;
extern QueueHandle_t relay_event_master_q;
extern QueueHandle_t manager_event_master_q;
extern QueueHandle_t ui_event_manager_q;
*/
}
#endif /*__THREAD_COMMON_H_*/

View File

@@ -37,7 +37,7 @@ extern QueueHandle_t logging_queue;
#define C_ERROR "ERROR"
#endif
#define LOG_BUFFER_MAX_CAP 500
#define LOG_BUFFER_MAX_CAP 256
#define LOG_MESSAGE_MAX_CAP 150
#define _LOG_STREAMOUT(message, message_length) \
@@ -58,7 +58,7 @@ static void create_log_line(const char * _status,
va_end(args);
char buffer [LOG_BUFFER_MAX_CAP] = {0};
int buffer_len = snprintf(buffer, LOG_BUFFER_MAX_CAP,
"[%s] [File: %s] [Line: %ld] %.*s",
"[%s] [File: %s] [Line: %d] %.*s",
_status,
_location,
_line,

View File

@@ -20,11 +20,14 @@ Logging::~Logging() {
void Logging::taskFunction()
{
char data[LOG_BUFFER_MAX_CAP] = {0};
xQueueReceive(q, static_cast<char*>(data), portMAX_DELAY);
mutex.lock();
printf("%s\n", data);
mutex.unlock();
for(;;)
{
char data[LOG_BUFFER_MAX_CAP] = {0};
xQueueReceive(q, static_cast<char*>(data), portMAX_DELAY);
mutex.lock();
printf("%s\n", data);
mutex.unlock();
}
}
void thread_logging(void* pvParams)

View File

@@ -86,7 +86,7 @@ void Master::taskFunction() {
void thread_master(void* pvParams) {
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
manager->qm->createQueue(50,
manager->qm->createQueue(5,
LOG_BUFFER_MAX_CAP,
ThreadCommon::QueueManager::logging_message_all);
logging_queue = manager->qm->getQueue(ThreadCommon::QueueManager::logging_message_all);
@@ -111,9 +111,6 @@ void thread_master(void* pvParams) {
LOG_INFO("Master is creating tasks");
manager->tm->createTask(thread_master, "master",
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager));
manager->tm->createTask(thread_manager, "manager",
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager));

View File

@@ -68,7 +68,7 @@ void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str)
{
lcd->setCursor(0, 0);
lcd->print(str);
LOG_INFO("Printing [%s] on LCD");
LOG_INFO("Printing [%s] on LCD", str);
}
}