ErrorLib 1.0.8-master SHA: 810228da25
LogMessage.h File Reference

Logmessage Plugin for Hermes PC-Tool. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define LOGMESSAGE_OPTION_NONE   0x00000000
 No option is added to the logmessage. More...
 
#define LOGMESSAGE_OPTION_TIMESTAMP   0x00000100
 A timestamp is added to this message. This flag is added to all ordinary messages. A timestamp data field is added. More...
 
#define LOGMESSAGE_OPTION_CONTAINS_DATA   0x00000200
 This message contains additional data, wghich is added to the buffer. More...
 
#define LOGMESSAGE_OPTION_ALERT   0x00000400
 This message results into an alert message-box on PC. More...
 
#define LOGMESSAGE_OPTION_DEBUG   0x00000800
 This message is only for debug purposes. The user can fadeout this messages if not required. More...
 
#define LOGMESSAGE_OPTION_UNDEFINED1   0x00001000
 Not defined in this version. More...
 
#define LOGMESSAGE_OPTION_UNDEFINED2   0x00002000
 Not defined in this version. More...
 
#define LOGMESSAGE_OPTION_UNDEFINED3   0x00004000
 Not defined in this version. More...
 
#define LOGMESSAGE_OPTION_UNDEFINED4   0x00008000
 Not defined in this version. More...
 
#define USER_LOGMESSAGE_OPTIONS   (LOGMESSAGE_OPTION_ALERT | LOGMESSAGE_OPTION_DEBUG)
 These Flags can be used by user, the other flags are used by the error-system himself. More...
 
#define CONCATENATE_DETAIL(x, y)   x##y
 Helper-macro to concat two strings. More...
 
#define CONCATENATE(x, y)   CONCATENATE_DETAIL(x, y)
 Helper-macro to concat two strings. More...
 
#define MAKE_UNIQUE(x)   CONCATENATE(x, __LINE__)
 Helper-macro to make the string unique. Add the linenumber of source-code to the name. More...
 
#define MSG(message)
 Print a simple message without any options. More...
 
#define LogMessage(message, Options)
 Print a message with defined options. More...
 
#define LogMessageAlert(message)
 Print a message and show this message immediately in a messagebox on all connected PCs. More...
 
#define LogMessageAppendLine(message)
 Add a message to the last printed message. More...
 
#define LogMessageDyn(message, Options)   DynamicString(message, ((Options) & USER_LOGMESSAGE_OPTIONS) | LOGMESSAGE_OPTION_TIMESTAMP)
 Print a string located in RAM. More...
 
#define LogMessageDyn_appendLine(message)   DynamicString(message, LOGMESSAGE_OPTION_NONE)
 Add a message located in RAM to the last printed message. More...
 
#define LogMessageData1(message, dat1, Options)
 Print a message with defined options and one data-field. More...
 
#define LogMessageData2(message, dat1, dat2, Options)
 Print a message with defined options and two data-fields. More...
 
#define LogMessageData3(message, dat1, dat2, dat3, Options)
 Print a message with defined options and three data-fields. More...
 
#define LogMessageData4(message, dat1, dat2, dat3, dat4, Options)
 Print a message with defined options and four data-fields. More...
 

Functions

void _LogMessage (const char str[], uint32_t ui32Options)
 Add a static String to the Message Buffer. More...
 
void _LogmessageData (const char *Message, uint32_t ui32Options, uint32_t ui32DataCount,...)
 Add a const String to the Message Buffer and adds additional Data. More...
 
void LogMessage_Init (void)
 Init the Logmessage System. More...
 
void DynamicString (char *str, uint32_t ui32Options)
 Add a dynamic String to the Message Buffer. More...
 

Variables

uint32_t g_ui32LogmessageBufferPosition
 Actual position in the logmessage buffer. More...
 
uint32_t g_ui32LogmessageBufferOverflowCounter
 Number of overflows of the logmessage buffer. More...
 
uint32_t g_pui32LogmessageBuffer []
 Buffer for storing the logmessages. More...
 
uint32_t g_ui32LogmessageAlertAddress
 Address of an alert message. More...
 
const uint32_t cui32_LogmessageBufferSize
 Size of the Logmessage buffer. More...
 

Detailed Description

Logmessage Plugin for Hermes PC-Tool.


© Copyright 2017-2022 Copyright: Retostronik GmbH Stütingstraße 30 58285 Gevelsberg

Macro Definition Documentation

◆ CONCATENATE

#define CONCATENATE (   x,
 
)    CONCATENATE_DETAIL(x, y)

Helper-macro to concat two strings.

◆ CONCATENATE_DETAIL

#define CONCATENATE_DETAIL (   x,
 
)    x##y

Helper-macro to concat two strings.

◆ LogMessage

#define LogMessage (   message,
  Options 
)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
_LogMessage((char*)MAKE_UNIQUE(Message), ((Options) & USER_LOGMESSAGE_OPTIONS) | LOGMESSAGE_OPTION_TIMESTAMP); \
} while(0)
#define LOGMESSAGE_OPTION_TIMESTAMP
A timestamp is added to this message. This flag is added to all ordinary messages....
Definition: LogMessage.h:30
#define MAKE_UNIQUE(x)
Helper-macro to make the string unique. Add the linenumber of source-code to the name.
Definition: LogMessage.h:54
#define USER_LOGMESSAGE_OPTIONS
These Flags can be used by user, the other flags are used by the error-system himself.
Definition: LogMessage.h:47

Print a message with defined options.

Parameters
messageText to print. Must be a constant string.
OptionsAdditional options

◆ LOGMESSAGE_OPTION_ALERT

#define LOGMESSAGE_OPTION_ALERT   0x00000400

This message results into an alert message-box on PC.

◆ LOGMESSAGE_OPTION_CONTAINS_DATA

#define LOGMESSAGE_OPTION_CONTAINS_DATA   0x00000200

This message contains additional data, wghich is added to the buffer.

◆ LOGMESSAGE_OPTION_DEBUG

#define LOGMESSAGE_OPTION_DEBUG   0x00000800

This message is only for debug purposes. The user can fadeout this messages if not required.

◆ LOGMESSAGE_OPTION_NONE

#define LOGMESSAGE_OPTION_NONE   0x00000000

No option is added to the logmessage.

◆ LOGMESSAGE_OPTION_TIMESTAMP

#define LOGMESSAGE_OPTION_TIMESTAMP   0x00000100

A timestamp is added to this message. This flag is added to all ordinary messages. A timestamp data field is added.

◆ LOGMESSAGE_OPTION_UNDEFINED1

#define LOGMESSAGE_OPTION_UNDEFINED1   0x00001000

Not defined in this version.

◆ LOGMESSAGE_OPTION_UNDEFINED2

#define LOGMESSAGE_OPTION_UNDEFINED2   0x00002000

Not defined in this version.

◆ LOGMESSAGE_OPTION_UNDEFINED3

#define LOGMESSAGE_OPTION_UNDEFINED3   0x00004000

Not defined in this version.

◆ LOGMESSAGE_OPTION_UNDEFINED4

#define LOGMESSAGE_OPTION_UNDEFINED4   0x00008000

Not defined in this version.

◆ LogMessageAlert

#define LogMessageAlert (   message)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
} while(0)
#define LOGMESSAGE_OPTION_ALERT
This message results into an alert message-box on PC.
Definition: LogMessage.h:34

Print a message and show this message immediately in a messagebox on all connected PCs.

Parameters
messageText to print. Must be a constant string.

◆ LogMessageAppendLine

#define LogMessageAppendLine (   message)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
_LogMessage((char*)MAKE_UNIQUE(Message), 0); \
} while(0)

Add a message to the last printed message.

It is used to print multiline messages.

Parameters
messageText to add to the last message. Must be a constant string.

◆ LogMessageData1

#define LogMessageData1 (   message,
  dat1,
  Options 
)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
if(sizeof(dat1) < 4) \
{ \
int32_t MAKE_UNIQUE(DataTemp) = dat1; \
_LogmessageData((char*)MAKE_UNIQUE(Message), (Options) & USER_LOGMESSAGE_OPTIONS, 1, MAKE_UNIQUE(DataTemp)); \
} \
else \
{ \
_LogmessageData((char*)MAKE_UNIQUE(Message), (Options) & USER_LOGMESSAGE_OPTIONS, 1, *(int32_t*)&(dat1)); \
} \
} while(0)

Print a message with defined options and one data-field.

Parameters
messageText to print. Must be a constant string.
dat1Data to append
OptionsAdditional options

◆ LogMessageData2

#define LogMessageData2 (   message,
  dat1,
  dat2,
  Options 
)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
int32_t* MAKE_UNIQUE(pDataTemp1); int32_t* MAKE_UNIQUE(pDataTemp2); \
int32_t MAKE_UNIQUE(DataTemp1), MAKE_UNIQUE(DataTemp2); \
if(sizeof(dat1) < 4) \
{ \
MAKE_UNIQUE(DataTemp1) = dat1; \
MAKE_UNIQUE(pDataTemp1) = &MAKE_UNIQUE(DataTemp1); \
} \
else \
{ \
MAKE_UNIQUE(pDataTemp1) = (int32_t*)&dat1; \
} \
if(sizeof(dat2) < 4) \
{ \
MAKE_UNIQUE(DataTemp2) = dat2; \
MAKE_UNIQUE(pDataTemp2) = &MAKE_UNIQUE(DataTemp2); \
} \
else \
{ \
MAKE_UNIQUE(pDataTemp2) = (int32_t*)&dat2; \
} \
_LogmessageData((char*)MAKE_UNIQUE(Message), (Options) & USER_LOGMESSAGE_OPTIONS, 2, *MAKE_UNIQUE(pDataTemp1), *MAKE_UNIQUE(pDataTemp2)); \
} while(0)

Print a message with defined options and two data-fields.

Parameters
messageText to print. Must be a constant string.
dat1Data to append
dat2Data to append
OptionsAdditional options

◆ LogMessageData3

#define LogMessageData3 (   message,
  dat1,
  dat2,
  dat3,
  Options 
)

Print a message with defined options and three data-fields.

Parameters
messageText to print. Must be a constant string.
dat1Data to append
dat2Data to append
dat3Data to append
OptionsAdditional options

◆ LogMessageData4

#define LogMessageData4 (   message,
  dat1,
  dat2,
  dat3,
  dat4,
  Options 
)

Print a message with defined options and four data-fields.

Parameters
messageText to print. Must be a constant string.
dat1Data to append
dat2Data to append
dat3Data to append
dat4Data to append
OptionsAdditional options

◆ LogMessageDyn

#define LogMessageDyn (   message,
  Options 
)    DynamicString(message, ((Options) & USER_LOGMESSAGE_OPTIONS) | LOGMESSAGE_OPTION_TIMESTAMP)

Print a string located in RAM.

Parameters
messageText to print. Must be a string located in RAM.
OptionsAdditional options

◆ LogMessageDyn_appendLine

#define LogMessageDyn_appendLine (   message)    DynamicString(message, LOGMESSAGE_OPTION_NONE)

Add a message located in RAM to the last printed message.

It is used to print multiline messages.

Parameters
messageText to add to the last message. Must be a string located in RAM.

◆ MAKE_UNIQUE

#define MAKE_UNIQUE (   x)    CONCATENATE(x, __LINE__)

Helper-macro to make the string unique. Add the linenumber of source-code to the name.

◆ MSG

#define MSG (   message)
Value:
do { \
static const char MAKE_UNIQUE(Message)[] __attribute__((section("message"))) = message; \
_LogMessage((char*)MAKE_UNIQUE(Message), LOGMESSAGE_OPTION_TIMESTAMP); \
} while(0)

Print a simple message without any options.

Parameters
messageText to print. Must be a constant string.

◆ USER_LOGMESSAGE_OPTIONS

#define USER_LOGMESSAGE_OPTIONS   (LOGMESSAGE_OPTION_ALERT | LOGMESSAGE_OPTION_DEBUG)

These Flags can be used by user, the other flags are used by the error-system himself.

Function Documentation

◆ _LogMessage()

void _LogMessage ( const char  str[],
uint32_t  ui32Options 
)

Add a static String to the Message Buffer.

Parameters
strString to Add. The String must be a const String located in flash
ui32OptionsOptions flags LOGMESSAGE_OPTION_ALERT, LOGMESSAGE_OPTION_DEBUG, LOGMESSAGE_OPTION_TIMESTAMP

◆ _LogmessageData()

void _LogmessageData ( const char *  Message,
uint32_t  ui32Options,
uint32_t  ui32DataCount,
  ... 
)

Add a const String to the Message Buffer and adds additional Data.

A Timestamp is added to this message. Repeated Messages counter is not used.

Parameters
MessageString to Add. The String must be a const String located in flash.
ui32OptionsOptions flags if required.
ui32DataCountCount of added Data pointers
...additional Pointers to Data. Each Pointer can be any datatype up to 32 Bit length.

◆ DynamicString()

void DynamicString ( char *  str,
uint32_t  ui32Options 
)

Add a dynamic String to the Message Buffer.

The dynamic string must be located in memory.

Parameters
strString to Add. This can be a local Variable. The String is copied to the Message Buffer
ui32OptionsOptions flags LOGMESSAGE_OPTION_TIMESTAMP if required.

◆ LogMessage_Init()

void LogMessage_Init ( void  )

Init the Logmessage System.

Must be called before usage of all other functions in this library.

Variable Documentation

◆ cui32_LogmessageBufferSize

const uint32_t cui32_LogmessageBufferSize
extern

Size of the Logmessage buffer.

◆ g_pui32LogmessageBuffer

uint32_t g_pui32LogmessageBuffer[]
extern

Buffer for storing the logmessages.

◆ g_ui32LogmessageAlertAddress

uint32_t g_ui32LogmessageAlertAddress
extern

Address of an alert message.

◆ g_ui32LogmessageBufferOverflowCounter

uint32_t g_ui32LogmessageBufferOverflowCounter
extern

Number of overflows of the logmessage buffer.

◆ g_ui32LogmessageBufferPosition

uint32_t g_ui32LogmessageBufferPosition
extern

Actual position in the logmessage buffer.