Difference between revisions of "OCEOS/oceos logging"
Okhoruzhyy (talk | contribs) |
Okhoruzhyy (talk | contribs) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
The application developer can specify a function to be called when 3/4 of log entries are in use. This function is called again only after 3/4 of log entries have been read and the log has again become 3/4 full.<br> | The application developer can specify a function to be called when 3/4 of log entries are in use. This function is called again only after 3/4 of log entries have been read and the log has again become 3/4 full.<br> | ||
Log entry types are defined in ''system_log.h'' header file. A log entry type is an 8-bit number. Values from 0 to 127 can be defined by the application developer. Values from 128 to 255 are used by OCEOS as below. | Log entry types are defined in ''system_log.h'' header file. A log entry type is an 8-bit number. Values from 0 to 127 can be defined by the application developer. Values from 128 to 255 are used by OCEOS as below. | ||
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> | ||
Line 134: | Line 126: | ||
struct application_configuration app_config = {0}; | struct application_configuration app_config = {0}; | ||
app_config.log_number_of_entries = NUMBER_OF_LOG_ENTRIES; | app_config.log_number_of_entries = NUMBER_OF_LOG_ENTRIES; | ||
</syntaxhighlight> | |||
</blockquote> | |||
<blockquote> | |||
OCEOS will call a user defined function '''void oceos_on_full_log(void*)'''. | |||
<syntaxhighlight lang="C"> | |||
void oceos_on_full_log(void*); | |||
/* | |||
* Create the application configuration structure | |||
*/ | |||
struct application_configuration app_config = {0}; | |||
app_config.log_full_function = &oceos_on_full_log; // NULL => ignore | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote> | </blockquote> | ||
Line 313: | Line 316: | ||
<span style="color:#1b7ac2">'''Description'''</span><br> | <span style="color:#1b7ac2">'''Description'''</span><br> | ||
Clear all log entries and reset to empty. Set all log entries to | Clear all log entries and reset to empty. Set all log entries to LOG_NOT_VALID_ENTRY and the log to empty, with the read and write indices set to 0 and function called flag 0.<br> | ||
Does not affect the system status variable. Does not affect the context switch log.<br> | Does not affect the system status variable. Does not affect the context switch log.<br> | ||
<span style="color:#1b7ac2">'''Prototype'''</span><br> | <span style="color:#1b7ac2">'''Prototype'''</span><br> | ||
Line 357: | Line 360: | ||
<span style="color:#1b7ac2">'''Description'''</span><br> | <span style="color:#1b7ac2">'''Description'''</span><br> | ||
Get the number of log entries. Return the number of entries in the log according to the current values of the read and write indices.<br> | |||
The value will be zero if the current values of the read and write indices are the same.<br> | |||
<span style="color:#1b7ac2">'''Prototype'''</span><br> | <span style="color:#1b7ac2">'''Prototype'''</span><br> | ||
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> | ||
unsigned int oceos_log_get_size(void); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<span style="color:#1b7ac2">'''Parameters'''</span><br> | <span style="color:#1b7ac2">'''Parameters'''</span><br> | ||
Line 370: | Line 374: | ||
|} | |} | ||
<span style="color:#1b7ac2">'''Returns'''</span><br> | <span style="color:#1b7ac2">'''Returns'''</span><br> | ||
This function returns | This function returns unsigned int.<br> | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! unsigned int!! Description | ||
|- | |- | ||
| | | LOG_INVALID_SIZE || Log state is invalid or | ||
Logging manager is not initialised or | |||
Problem with read/write indexes | |||
|- | |- | ||
| | | >= 0 || Log size | ||
|} | |} | ||
<span style="color:#1b7ac2">'''Example Usage'''</span><br> | <span style="color:#1b7ac2">'''Example Usage'''</span><br> | ||
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> | ||
U32_t size; | |||
size = oceos_log_get_size(); | |||
if (LOG_INVALID_SIZE == size) { | |||
// Handle ERROR | |||
} | |||
</syntaxhighlight> | |||
</blockquote> | </blockquote> | ||
[[Category:backup]] | [[Category:backup]] |
Latest revision as of 08:54, 28 March 2022
OCEOS Logging
OCEOS logs time stamped records of anomalies detected during execution.
Logging Introduction
OCEOS logging is structured as a circular buffer, older entries are overwritten by new entries once all entries are in use. System calls are provided to add entries the log, set its maximum size, and return the number of entries, and reset.
It is set up initially as an array of 32-bit words that starts at a 32-bit aligned address provided by the application developer.
OCEOS does not change the log entries after reset, so if log area is located in non-volatile memory, after reset, the application can read to recover possible reasons of failure. Only call to oceos_log_reset() can be used to reset all log entries if desired.
Log directives can be called from main() after oceos_init().
The read and write indices are stored in the log area and if equal indicate that the log is empty.
The application developer can specify a function to be called when 3/4 of log entries are in use. This function is called again only after 3/4 of log entries have been read and the log has again become 3/4 full.
Log entry types are defined in system_log.h header file. A log entry type is an 8-bit number. Values from 0 to 127 can be defined by the application developer. Values from 128 to 255 are used by OCEOS as below.
enum LOG_ENTRY_TYPE{
LOG_SYS_OK = 0x80U,
LOG_NULL_FATAL,
LOG_OCEOS_ABORT,
LOG_INVALID_SYSTEM_STATE,
LOG_LOG_NOT_VALID_ENTRY,
LOG_STATUS_INVALID,
LOG_NULL_POINTER,
LOG_INIT_FAIL,
LOG_TIME_INIT_FAIL,
LOG_TIME_CONFIG_FREEZE_FAIL,
LOG_TIME_CONFIG_UNFREEZE_FAIL,
LOG_TIME_RESET_FAIL,
LOG_TIME_SCALER_FAIL,
LOG_TIME_RELOAD_FAIL,
LOG_TIME_COUNTER_FAIL,
LOG_TIME_CONTROL_FAIL,
LOG_TIME_POINTER_NULL,
LOG_TIME_POINTER_LOW_NULL,
LOG_TIME_START_FAIL,
LOG_FIXED_INIT_FAIL,
LOG_DYNAMIC_INIT_FAIL,
LOG_INIT_TASK_START_FAIL,
LOG_DEADLINE_MISSED,
LOG_TASK_DISABLED,
LOG_TASK_ENABLED,
LOG_JOB_INVALID,
LOG_JOB_NONE_FREE,
LOG_JOB_NOT_EXECUTING,
LOG_JOB_NOT_ACTIVE,
LOG_READYQ_TOO_BIG,
LOG_READYQ_SENTINEL_BAD,
LOG_READYQ_FULL,
LOG_READYQ_EMPTY,
LOG_READYQ_PUT_DISABLED_TASK,
LOG_READYQ_PUT_FAIL,
LOG_READYQ_REMOVE_DONE,
LOG_READYQ_REMOVE_FAIL,
LOG_PARAM_BAD_ID,
LOG_PARAM_BAD_TIME,
LOG_PARAM_ACTION_MISSING,
LOG_PARAM_JOB_MISSING,
LOG_MUTEX_BAD_CEILING,
LOG_MUTEX_ALREADY_HELD,
LOG_MUTEX_ALREADY_FREE,
LOG_MUTEX_WRONG_JOB,
LOG_MUTEX_NESTING_BAD,
LOG_MUTEX_EXIT_HOLDING,
LOG_SEMAPHORE_COUNT_EXCEEDED,
LOG_SEMAPHORE_MAX_ALREADY_REACHED,
LOG_SEMAPHORE_INVALID_PENDING_JOB,
LOG_SEMAPHORE_PENDING_REMOVE_FAIL,
LOG_SEMAPHORE_PENDING_TIMED_REMOVE_FAIL,
LOG_SEMAPHORE_TRANSFER_READYQ_FAIL,
LOG_DATAQ_FULL,
LOG_DATAQ_EMPTY,
LOG_DATAQ_COUNT_EXCEEDED,
LOG_DATAQ_PENDING_QUEUE_FULL,
LOG_DATAQ_INVALID_PENDING_JOB,
LOG_DATAQ_PENDING_REMOVE_FAIL,
LOG_DATAQ_TIMED_JOB_REMOVE_FAIL,
LOG_TIMED_ACTION_TIMER_NULL,
LOG_TIMED_ACTION_TIMER_STOP_FAIL,
LOG_TIMED_ACTION_NOT_INIT,
LOG_TIMED_ACTION_INT_REG_FAILED, // Failed to register timed action interrupt handler
LOG_TIMED_ACTION_INVALID,
LOG_TIMED_ACTION_BAD_INDEX,
LOG_TIMED_ACTION_MISSED,
LOG_TIMED_ACTION_Q_FULL,
LOG_TIMED_ACTION_Q_EMPTY,
LOG_TIMED_ACTION_PUT_FAIL,
LOG_TIMED_ACTION_REMOVE_FAIL,
LOG_TIMED_ACTION_BAD_JOB_ID,
LOG_TIMED_ACTION_DO_FAIL,
LOG_SYSTEM_ERROR,
LOG_TIME_BSP_SYSFREQ_NULL,
LOG_SEMAPHORE_TIMEOUT_NOT_INIT, // If user wants to use semaphore with timeout without previous initialization of timed actions
LOG_DATAQ_TIMEOUT_NOT_INIT, // If user wants to use dataq with timeout without previous initialization of timed actions
LOG_TIMED_ACTION_START_WHILE_RUNNING,
LOG_INT_HANDLER_IS_NULL,
LOG_SET_OCEOS_TRAP_HANDLER_FAILED,
LOG_INT_CALLED_NO_INIT,
LOG_FAILED_SET_INT_PRIO, // Failed to set PendSV priority
LOG_FAILED_PENDSV_INIT,
LOG_SYS_TIME_NOT_INIT // System time is not initialized
};
Logging Configuration
Application defines arrays to hold OCEOS internal data. User must specified array to accommodate all logging information. Please read OCEOS data area layouts
#define LOG_DATA_ARRAY_SIZE_U32S 0x100// Calculated value. Read manual U32_t log_data[LOG_DATA_ARRAY_SIZE_U32S]; ... /* * Create the application configuration structure */ struct application_configuration app_config = {0}; app_config.log_address = (adrs_t)log_data;
User must define number of log entries.
#define NUMBER_OF_LOG_ENTRIES 16 // 16 to 1024 /* * Create the application configuration structure */ struct application_configuration app_config = {0}; app_config.log_number_of_entries = NUMBER_OF_LOG_ENTRIES;
OCEOS will call a user defined function void oceos_on_full_log(void*).
void oceos_on_full_log(void*); /* * Create the application configuration structure */ struct application_configuration app_config = {0}; app_config.log_full_function = &oceos_on_full_log; // NULL => ignore
API Functions
Directive | Description | main | task | IRQ handler |
---|---|---|---|---|
oceos_log_add_entry() | Add a log entry | * | * | * |
oceos_log_remove_entry() | Read and remove the oldest unread log entry | * | * | * |
oceos_log_get_indexed_entry() | Read the log entry at the given index | * | * | * |
oceos_log_reset() | Clear all log entries and reset to empty | * | * | * |
oceos_log_get_size() | Get the number of log entries | * | * | * |
oceos_log_add_entry()
Header File
system_log.h
Description
Add a log entry (32-bit time is included automatically).Overwrites the oldest unread entry if the log is full.
Prototype
enum DIRECTIVE_STATUS oceos_log_add_entry( enum LOG_ENTRY_TYPE type,// 8 bits const unsigned int info // information (24 bits) );Parameters
Parameter Description type Log type (8 bits) info Extra information (24 bits) Returns
This function returns enum DIRECTIVE_STATUS.
enum DIRECTIVE_STATUS Description NOT_CONFIGURED Log check state failed or Logging manager is not initialized
INVALID_NUMBER Parameter info is more than 24 bits INCORRECT_STATE Problem with read/write indexes SUCCESSFUL All OK Example Usage
enum DIRECTIVE_STATUS status; status = oceos_log_add_entry(LOG_INVALID_SYSTEM_STATE, 0xcafe); if(SUCCESSFUL != status){ // Handle ERROR }
oceos_log_remove_entry()
Header File
system_log.h
Description
Read and remove the oldest unread log entry.If the log is not empty use the entry at the read index to update the value at the output pointer, returning SUCCESSFUL.
If the log is empty, set the value at the output pointer to LOG_LOG_NOT_VALID_ENTRY and return UNSATISFIED.
The read index is incremented in a circular fashion.
Prototype
enum DIRECTIVE_STATUS oceos_log_remove_entry( struct log_entry * const outputPtr );Parameters
Parameter Description outputPtr Pointer to Log entry to return log information Returns
This function returns enum DIRECTIVE_STATUS.
enum DIRECTIVE_STATUS Description NOT_CONFIGURED Log check state failed or Logging is not setup
INCORRECT_STATE Problem with read/write indexes UNSATISFIED Log is empty SUCCESSFUL All OK Example Usage
enum DIRECTIVE_STATUS status; struct log_entry outputPtr; status = oceos_log_remove_entry(&outputPtr); if(SUCCESSFUL != status){ // Handle ERROR }
oceos_log_get_indexed_entry()
Header File
system_log.h
Description
Read the log entry at the given index.
Returns the entry at the specified position in the log. The entry is not removed and the log and log indices are not changed.
(intended to allow the log be examined for example after reset)Prototype
enum DIRECTIVE_STATUS oceos_log_get_indexed_entry( const unsigned int index, struct log_entry * const outputPtr );Parameters
Parameter Description index Log entry index outputPtr log entry pointer Returns
This function returns enum DIRECTIVE_STATUS.
enum DIRECTIVE_STATUS Description NOT_CONFIGURED Logging is not set up INVALID_NUMBER Index is out of range INVALID_ADDRESS OutputPtr is NULL SUCCESSFUL All OK Example Usage
enum DIRECTIVE_STATUS status; struct log_entry outputPtr; status = oceos_log_get_indexed_entry(3, &outputPtr); if(SUCCESSFUL != status){ // Handle ERROR }
oceos_log_reset()
Header File
system_log.h
Description
Clear all log entries and reset to empty. Set all log entries to LOG_NOT_VALID_ENTRY and the log to empty, with the read and write indices set to 0 and function called flag 0.
Does not affect the system status variable. Does not affect the context switch log.
Prototype
enum DIRECTIVE_STATUS oceos_log_reset(void);Parameters
Parameter Description Returns
This function returns enum DIRECTIVE_STATUS.
enum DIRECTIVE_STATUS Description NOT_CONFIGURED System Meta pointer is NULL or Fixed data start sentinel is corrupt System Log pointer is NULL or Logging manager is not initialised
UNSATISFIED Log area end sentinel is corrupt SUCCESSFUL All OK Example Usage
enum DIRECTIVE_STATUS status; status = oceos_log_reset(); if(SUCCESSFUL != status){ // Handle ERROR }
oceos_log_get_size()
Header File
system_log.h
Description
Get the number of log entries. Return the number of entries in the log according to the current values of the read and write indices.
The value will be zero if the current values of the read and write indices are the same.
Prototype
unsigned int oceos_log_get_size(void);Parameters
Parameter Description Returns
This function returns unsigned int.
unsigned int Description LOG_INVALID_SIZE Log state is invalid or Logging manager is not initialised or Problem with read/write indexes
>= 0 Log size Example Usage
U32_t size; size = oceos_log_get_size(); if (LOG_INVALID_SIZE == size) { // Handle ERROR }