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:
parent
2c3e1a8dc8
commit
734393831e
@ -86,8 +86,8 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||||
</option>
|
</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"/>
|
<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"/>
|
<inputType id="com.crt.advproject.compiler.input.765511076" superClass="com.crt.advproject.compiler.input"/>
|
||||||
@ -107,6 +107,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/master}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/peripherals}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1836378919" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
@ -257,6 +258,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/FreeRTOSCPP}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/common}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/user_interface}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/shoh/src/threads/logging}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1117166373" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<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"/>
|
<inputType id="com.crt.advproject.assembler.input.2071009798" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
|
|||||||
@ -17,11 +17,14 @@ int main(void)
|
|||||||
|
|
||||||
retarget_init();
|
retarget_init();
|
||||||
|
|
||||||
ThreadCommon::CommonManagers manager = {new ThreadCommon::ThreadManager,
|
ThreadCommon::ThreadManager *tm = new ThreadCommon::ThreadManager();
|
||||||
new ThreadCommon::QueueManager};
|
ThreadCommon::QueueManager *qm = new ThreadCommon::QueueManager();
|
||||||
manager.tm->createTask(thread_master, "master",
|
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,
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
static_cast<void*>(&manager));
|
static_cast<void*>(manager));
|
||||||
vTaskStartScheduler ();
|
vTaskStartScheduler ();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -11,7 +11,7 @@ static LpcDebugUart *dbgu;
|
|||||||
|
|
||||||
void retarget_init()
|
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.
|
//Sadly, it seems that only USART0 is redirected to USB.
|
||||||
//It means that those are pins PIO0_18 and PIO0_19
|
//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
|
LpcPinMap txpin = { 0, 19 }; // transmit pin that goes to debugger's UART->USB converter
|
||||||
|
|||||||
@ -77,15 +77,6 @@ namespace ThreadCommon
|
|||||||
ThreadManager * tm;
|
ThreadManager * tm;
|
||||||
QueueManager * qm;
|
QueueManager * qm;
|
||||||
} CommonManagers;
|
} 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_*/
|
#endif /*__THREAD_COMMON_H_*/
|
||||||
|
|||||||
@ -37,7 +37,7 @@ extern QueueHandle_t logging_queue;
|
|||||||
#define C_ERROR "ERROR"
|
#define C_ERROR "ERROR"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG_BUFFER_MAX_CAP 500
|
#define LOG_BUFFER_MAX_CAP 256
|
||||||
#define LOG_MESSAGE_MAX_CAP 150
|
#define LOG_MESSAGE_MAX_CAP 150
|
||||||
|
|
||||||
#define _LOG_STREAMOUT(message, message_length) \
|
#define _LOG_STREAMOUT(message, message_length) \
|
||||||
@ -58,7 +58,7 @@ static void create_log_line(const char * _status,
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
char buffer [LOG_BUFFER_MAX_CAP] = {0};
|
char buffer [LOG_BUFFER_MAX_CAP] = {0};
|
||||||
int buffer_len = snprintf(buffer, LOG_BUFFER_MAX_CAP,
|
int buffer_len = snprintf(buffer, LOG_BUFFER_MAX_CAP,
|
||||||
"[%s] [File: %s] [Line: %ld] %.*s",
|
"[%s] [File: %s] [Line: %d] %.*s",
|
||||||
_status,
|
_status,
|
||||||
_location,
|
_location,
|
||||||
_line,
|
_line,
|
||||||
|
|||||||
@ -19,6 +19,8 @@ Logging::~Logging() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Logging::taskFunction()
|
void Logging::taskFunction()
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
{
|
{
|
||||||
char data[LOG_BUFFER_MAX_CAP] = {0};
|
char data[LOG_BUFFER_MAX_CAP] = {0};
|
||||||
xQueueReceive(q, static_cast<char*>(data), portMAX_DELAY);
|
xQueueReceive(q, static_cast<char*>(data), portMAX_DELAY);
|
||||||
@ -26,6 +28,7 @@ void Logging::taskFunction()
|
|||||||
printf("%s\n", data);
|
printf("%s\n", data);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void thread_logging(void* pvParams)
|
void thread_logging(void* pvParams)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,7 +86,7 @@ void Master::taskFunction() {
|
|||||||
void thread_master(void* pvParams) {
|
void thread_master(void* pvParams) {
|
||||||
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
|
||||||
|
|
||||||
manager->qm->createQueue(50,
|
manager->qm->createQueue(5,
|
||||||
LOG_BUFFER_MAX_CAP,
|
LOG_BUFFER_MAX_CAP,
|
||||||
ThreadCommon::QueueManager::logging_message_all);
|
ThreadCommon::QueueManager::logging_message_all);
|
||||||
logging_queue = manager->qm->getQueue(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");
|
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",
|
manager->tm->createTask(thread_manager, "manager",
|
||||||
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
|
||||||
static_cast<void*>(manager));
|
static_cast<void*>(manager));
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str)
|
|||||||
{
|
{
|
||||||
lcd->setCursor(0, 0);
|
lcd->setCursor(0, 0);
|
||||||
lcd->print(str);
|
lcd->print(str);
|
||||||
LOG_INFO("Printing [%s] on LCD");
|
LOG_INFO("Printing [%s] on LCD", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user