Difference between revisions of "OCEOS/oceos logging"

From wiki
Jump to navigation Jump to search
Line 159: Line 159:


<span style="color:#1b7ac2">'''Description'''</span><br>
<span style="color:#1b7ac2">'''Description'''</span><br>
Add a log entry (32-bit time is included automatically).
Overwrites the oldest unread entry if the log is full.


<span style="color:#1b7ac2">'''Prototype'''</span><br>
<span style="color:#1b7ac2">'''Prototype'''</span><br>
<syntaxhighlight lang="C">
<syntaxhighlight lang="C">
 
enum DIRECTIVE_STATUS  oceos_log_add_entry(
    enum LOG_ENTRY_TYPE type,// 8 bits
    const unsigned int info // information (24 bits)
);
</syntaxhighlight>
</syntaxhighlight>
<span style="color:#1b7ac2">'''Parameters'''</span><br>
<span style="color:#1b7ac2">'''Parameters'''</span><br>
Line 169: Line 175:
! Parameter !! Description
! Parameter !! Description
|-
|-
| ||
| type  || Log type (8 bits)
|-
| info  || Extra information (24 bits)
|}
|}
<span style="color:#1b7ac2">'''Returns'''</span><br>
<span style="color:#1b7ac2">'''Returns'''</span><br>
Line 177: Line 185:
! enum DIRECTIVE_STATUS !! Description
! enum DIRECTIVE_STATUS !! Description
|-
|-
| INCORRECT_STATE || If system Meta pointer is NULL or
|NOT_CONFIGURED  || Log check state failed or
                    Init pointer is NULL or
                Logging manager is not initialized
                    Start up phase check fail or
                    Fixed data checksum failed (check log)
|-
|-
| INVALID_NAME    || If Start Sentinel for fixed area is corrupt or
|INVALID_NUMBER  || Parameter info is more than 24 bits
                    Start Sentinel for dynamic area is corrupt
|-
|-
| INVALID_NUMBER  || If Configuration and actual parameters do not match
|INCORRECT_STATE || Problem with read/write indexes
                    (In configuration file was defined 5 tasks, but created less)
|-
|-
| SUCCESSFUL     || If All OK
|SUCCESSFUL     || All OK
|}
|}
<span style="color:#1b7ac2">'''Example Usage'''</span><br>
<span style="color:#1b7ac2">'''Example Usage'''</span><br>
<syntaxhighlight lang="C">
<syntaxhighlight lang="C">
      
enum DIRECTIVE_STATUS status;
</syntaxhighlight>
status = oceos_log_add_entry(LOG_INVALID_SYSTEM_STATE, 0xcafe); 
if(SUCCESSFUL != status){
     // Handle ERROR
}
</syntaxhighlight>
</blockquote>
</blockquote>
===<span style="color:#0000ff">oceos_log_remove_entry()</span>===
===<span style="color:#0000ff">oceos_log_remove_entry()</span>===
<blockquote style="border-left-style: none;">
<blockquote style="border-left-style: none;">

Revision as of 17:32, 25 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.
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

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;

API Functions

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

Prototype

Parameters

Parameter Description

Returns
This function returns enum DIRECTIVE_STATUS.

enum DIRECTIVE_STATUS Description
INCORRECT_STATE If system Meta pointer is NULL or

Init pointer is NULL or Start up phase check fail or Fixed data checksum failed (check log)

INVALID_NAME If Start Sentinel for fixed area is corrupt or

Start Sentinel for dynamic area is corrupt

INVALID_NUMBER If Configuration and actual parameters do not match

(In configuration file was defined 5 tasks, but created less)

SUCCESSFUL If All OK

Example Usage

oceos_log_get_indexed_entry()

Header File
system_log.h

Description

Prototype

Parameters

Parameter Description

Returns
This function returns enum DIRECTIVE_STATUS.

enum DIRECTIVE_STATUS Description
INCORRECT_STATE If system Meta pointer is NULL or

Init pointer is NULL or Start up phase check fail or Fixed data checksum failed (check log)

INVALID_NAME If Start Sentinel for fixed area is corrupt or

Start Sentinel for dynamic area is corrupt

INVALID_NUMBER If Configuration and actual parameters do not match

(In configuration file was defined 5 tasks, but created less)

SUCCESSFUL If All OK

Example Usage

oceos_log_reset()

Header File
system_log.h

Description

Prototype

Parameters

Parameter Description

Returns
This function returns enum DIRECTIVE_STATUS.

enum DIRECTIVE_STATUS Description
INCORRECT_STATE If system Meta pointer is NULL or

Init pointer is NULL or Start up phase check fail or Fixed data checksum failed (check log)

INVALID_NAME If Start Sentinel for fixed area is corrupt or

Start Sentinel for dynamic area is corrupt

INVALID_NUMBER If Configuration and actual parameters do not match

(In configuration file was defined 5 tasks, but created less)

SUCCESSFUL If All OK

Example Usage

oceos_log_get_size()

Header File
system_log.h

Description

Prototype

Parameters

Parameter Description

Returns
This function returns enum DIRECTIVE_STATUS.

enum DIRECTIVE_STATUS Description
INCORRECT_STATE If system Meta pointer is NULL or

Init pointer is NULL or Start up phase check fail or Fixed data checksum failed (check log)

INVALID_NAME If Start Sentinel for fixed area is corrupt or

Start Sentinel for dynamic area is corrupt

INVALID_NUMBER If Configuration and actual parameters do not match

(In configuration file was defined 5 tasks, but created less)

SUCCESSFUL If All OK

Example Usage