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

@ -86,8 +86,8 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/user_interface}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/logging}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.82852045" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c17" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.765511076" superClass="com.crt.advproject.compiler.input"/>
@ -107,6 +107,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/master}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/user_interface}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/logging}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/peripherals}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
@ -257,6 +258,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/FreeRTOSCPP}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/user_interface}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/shoh/src/threads/logging}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>

View File

@ -17,11 +17,14 @@ int main(void)
retarget_init();
ThreadCommon::CommonManagers manager = {new ThreadCommon::ThreadManager,
new ThreadCommon::QueueManager};
manager.tm->createTask(thread_master, "master",
ThreadCommon::ThreadManager *tm = new ThreadCommon::ThreadManager();
ThreadCommon::QueueManager *qm = new ThreadCommon::QueueManager();
ThreadCommon::CommonManagers *manager = new ThreadCommon::CommonManagers;
manager->tm = tm;
manager->qm = qm;
manager->tm->createTask(thread_master, "master",
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(&manager));
static_cast<void*>(manager));
vTaskStartScheduler ();
return 1;

View File

@ -11,7 +11,7 @@ static LpcDebugUart *dbgu;
void retarget_init()
{
LpcPinMap none = {-1, -1}; // unused pin has negative values in it
//LpcPinMap none = {-1, -1}; // unused pin has negative values in it
//Sadly, it seems that only USART0 is redirected to USB.
//It means that those are pins PIO0_18 and PIO0_19
LpcPinMap txpin = { 0, 19 }; // transmit pin that goes to debugger's UART->USB converter

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()
{
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);
}
}