- added IODevice support

- fixed some issues with the logger and stack sizes

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-09-26 11:11:33 +00:00
parent 7bcde7ff5d
commit 1bcb4809db
48 changed files with 1033 additions and 11740 deletions

View File

@@ -11,9 +11,9 @@
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision: 167 $
/// $Author: mmi $
/// $Date: 2017-09-12 13:09:10 +0200 (di, 12 sep 2017) $
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------------
#include <FreeRTOSFixes.h>
#include "FreeRTOS.h"
#include "Logger.h"
#include "semphr.h"
@@ -42,9 +43,9 @@
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define LOGQUEUE_SIZE (64)
#define LOGQUEUE_SIZE (16)
#define LOGGER_STACK_SIZE (512)
#define LOGGER_TASK_PRIORITY (1)
#define LOGGER_TASK_PRIORITY (2)
// Makefile compile options:
// ENABLE_SERIAL_LOGGING: Use the serial port for logging.
@@ -64,7 +65,7 @@
// File-scope variables
// -----------------------------------------------------------------------------
static struct Uart* loggerInterface;
static struct IODevice* loggerDevice;
static xQueueHandle logQueue;
@@ -90,34 +91,35 @@ static void loggerTask(void* parameters);
* ---------------------*
*/
void Logger_initialize(void* const interface)
ErrorStatus Logger_construct(struct IODevice* const device)
{
ErrorStatus returnValue = SUCCESS;
if(!initialized)
{
ErrorStatus errorStatus = SUCCESS;
///TODO This is currently hardcoded into the UART - there must be a way for more generic usage
loggerInterface = (struct Uart* const) interface;
loggerDevice = device;
if(errorStatus == SUCCESS)
if(returnValue == SUCCESS)
{
logQueue = xQueueCreate(LOGQUEUE_SIZE, sizeof(struct LogQueueItem));
if(logQueue == 0)
{
errorStatus = ERROR;
returnValue = ERROR;
}
}
if(errorStatus == SUCCESS)
if(returnValue == SUCCESS)
{
if(xTaskCreate(loggerTask, (const char*)"loggerTask", LOGGER_STACK_SIZE, NULL, LOGGER_TASK_PRIORITY, &loggerTaskHandle) != pdPASS)
{
errorStatus = ERROR;
returnValue = ERROR;
}
}
if(errorStatus == SUCCESS)
if(returnValue == SUCCESS)
{
initialized = true;
LOGGER_INFO("Logger started");
@@ -127,6 +129,11 @@ void Logger_initialize(void* const interface)
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
void Logger_terminate(void)
@@ -135,6 +142,15 @@ void Logger_terminate(void)
}
ErrorStatus Logger_logModuleInfo(void)
{
ErrorStatus errorStatus = SUCCESS;
OS_logTaskInfo(loggerTaskHandle);
return errorStatus;
}
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
{
if(initialized)
@@ -174,7 +190,7 @@ void Logger_log(const char* fileName, const char* functionName, int lineNumber,
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
va_end(ap);
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, logType, str);
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
(void)xQueueSend(logQueue, &logQueueItem, 0);
}
else
@@ -254,7 +270,7 @@ static void loggerTask(void* parameters)
{
// Raw print
#if defined(ENABLE_SERIAL_LOGGING)
Uart_Write(loggerInterface, (const uint8_t*)logQueueItem.context, strlen(logQueueItem.context));
IODevice_write(loggerDevice, logQueueItem.context, strlen(logQueueItem.context));
#endif
}
@@ -310,7 +326,7 @@ static void loggerTask(void* parameters)
#endif
#if defined(ENABLE_SERIAL_LOGGING)
Uart_Write(loggerInterface, (const uint8_t*)str, strlen(str));
IODevice_write(loggerDevice, str, strlen(str));
#endif
}