Skip to content

Commit

Permalink
Merge pull request #2505 from jphickey:fix-2502-2504
Browse files Browse the repository at this point in the history
Fix #2502, #2504, CFE updates needed for generated header compatibility (EDS)
  • Loading branch information
dzbaker committed Jan 31, 2024
2 parents 37f1d28 + ec04415 commit fb2f6e8
Show file tree
Hide file tree
Showing 32 changed files with 569 additions and 375 deletions.
4 changes: 2 additions & 2 deletions docs/src/cfe_es.dox
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,13 @@
The System Log is an array of bytes that contains back-to-back printf type
messages from applications. The cFE internal applications use this log when
errors are encountered during initialization before the Event Manager is fully
initialized. To view the information the #CFE_ES_WRITE_SYSLOG_CC command must
initialized. To view the information the #CFE_ES_WRITE_SYS_LOG_CC command must
be sent. This command will write the log to a binary file. The path and
filename may be specified in the command. If the filename command field
contains an empty string, the configuration parameter
#CFE_PLATFORM_ES_DEFAULT_SYSLOG_FILE is used to specify the path and filename. Use the
ground system to get the file and display the contents. The
#CFE_ES_CLEAR_SYSLOG_CC is used to clear the System log.
#CFE_ES_CLEAR_SYS_LOG_CC is used to clear the System log.

The size of the System log is defined by the platform configuration parameter
#CFE_PLATFORM_ES_SYSTEM_LOG_SIZE. This log is preserved after a processor reset and
Expand Down
4 changes: 2 additions & 2 deletions docs/src/cfe_time.dox
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
TIME provides the ability to command a one time adjustment
(#CFE_TIME_ADD_ADJUST_CC and #CFE_TIME_SUB_ADJUST_CC)
to the current STCF. In addition there is a 1Hz adjustment
(#CFE_TIME_ADD_ONEHZ_ADJUSTMENT_CC and #CFE_TIME_SUB_ONEHZ_ADJUSTMENT_CC)
(#CFE_TIME_ADD_ONE_HZ_ADJUSTMENT_CC and #CFE_TIME_SUB_ONE_HZ_ADJUSTMENT_CC)
that can be made to the STCF to compensate for oscillator drift.
Mission specific ground correlation should be used to assist in
determining the proper values to use. The Leap Seconds should be
Expand All @@ -671,7 +671,7 @@
to by the other systems.

\sa #CFE_TIME_ADD_ADJUST_CC, #CFE_TIME_SUB_ADJUST_CC, #CFE_TIME_SET_STCF_CC,
#CFE_TIME_ADD_ONEHZ_ADJUSTMENT_CC, #CFE_TIME_SUB_ONEHZ_ADJUSTMENT_CC, #CFE_TIME_SET_LEAP_SECONDS_CC
#CFE_TIME_ADD_ONE_HZ_ADJUSTMENT_CC, #CFE_TIME_SUB_ONE_HZ_ADJUSTMENT_CC, #CFE_TIME_SET_LEAP_SECONDS_CC
**/


Expand Down
3 changes: 2 additions & 1 deletion modules/core_api/fsw/inc/cfe_fs_api_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
#include "common_types.h"
#include "osconfig.h"
#include "cfe_mission_cfg.h"
#include "cfe_fs_extern_typedefs.h"

/**
Expand Down Expand Up @@ -124,7 +125,7 @@ typedef struct CFE_FS_FileWriteMetaData
{
volatile bool IsPending; /**< Whether request is pending (volatile as it may be checked outside lock) */

char FileName[OS_MAX_PATH_LEN]; /**< Name of file to write */
char FileName[CFE_MISSION_MAX_PATH_LEN]; /**< Name of file to write */

/* Data for FS header */
uint32 FileSubType; /**< Type of file to write (for FS header) */
Expand Down
61 changes: 61 additions & 0 deletions modules/core_private/ut-stubs/inc/ut_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@ typedef struct
void * SnapshotBuffer;
} UT_SoftwareBusSnapshot_Entry_t;

/**
* Style of message dispatch to perform
*/
typedef enum
{
/**
* If method is set to NONE, then no dispatch will be set up.
* This can be used to e.g. check error paths but not actual message handling.
*/
UT_TaskPipeDispatchMethod_NONE,

/**
* If method is set to MSG_ID_CC, then no dispatch will be set up based on the
* MsgID value and command code. This is the traditional method and works with
* task pipe implementations that utilize a local switch() statement.
*/
UT_TaskPipeDispatchMethod_MSG_ID_CC,

/**
* If method is set to TABLE_OFFSET, then no dispatch will be set up based on the
* offset into a dispatch table. This is the EDS method and works with
* task pipe implementations that perform message dispatch via a table lookup.
*/
UT_TaskPipeDispatchMethod_TABLE_OFFSET

} UT_TaskPipeDispatchMethod_t;

/*
* Information to identify a message in the "Task Pipe"
* or message dispatch routines, to indicate which of
Expand All @@ -122,19 +149,53 @@ typedef struct
*/
typedef struct
{
/**
* Method of dispatch to use.
* This should match how the source was compiled,
* and it controls how the stubs are configured.
*/
UT_TaskPipeDispatchMethod_t Method;

/**
* Invoke the handler for this MsgID
* This is only used/relevant when Method is set to MSG_ID_CC
*/
CFE_SB_MsgId_t MsgId;

/**
* Offset of handler function to invoke
* This is only used/relevant when Method is set to TABLE_OFFSET
*/
int32 TableOffset;

/**
* Specifies the sub-command to invoke
* (ignored if the handler does not use command codes,
* set to zero in this case).
*/
CFE_MSG_FcnCode_t CommandCode;

/**
* Set nonzero to indicate a code to be returned from dispatcher.
* This may be relevant for any dispatch method
*/
CFE_Status_t DispatchError;

/**
* Expected size of the message being handled
*/
size_t NominalMsgSize;

} UT_TaskPipeDispatchId_t;

/*
* The following macros set certain fields inside the UT_TaskPipeDispatchId_t
* They can be combined as needed for various situations
*/
#define UT_TPD_SETSIZE(cmd) .NominalMsgSize = sizeof(cmd##_t)
#define UT_TPD_SETCC(cc) .CommandCode = cc
#define UT_TPD_SETERR(err) .DispatchError = err

/*
** Functions
*/
Expand Down
93 changes: 84 additions & 9 deletions modules/core_private/ut-stubs/src/ut_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ static uint16 UT_SendEventAppIDHistory[UT_EVENT_HISTORY_SIZE * 10];

int32 dummy_function(void);

static const UT_EntryKey_t UT_TABLE_DISPATCHER = 0;

/*
** Functions
*/
Expand Down Expand Up @@ -195,6 +197,38 @@ void UT_ResetPoolBufferIndex(void)
UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_CFE_ES_MemoryPool, sizeof(UT_CFE_ES_MemoryPool), false);
}

void UT_DispatchTableHandler(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
UT_TaskPipeDispatchId_t *DispatchId = UserObj;
const CFE_SB_Buffer_t * Buffer = UT_Hook_GetArgValueByName(Context, "Buffer", const CFE_SB_Buffer_t *);
const void * DispatchTable = UT_Hook_GetArgValueByName(Context, "DispatchTable", const void *);
const uint8 * Addr;
CFE_Status_t (*MsgHandler)(const CFE_SB_Buffer_t *);
CFE_Status_t Status;

MsgHandler = NULL;
UT_Stub_GetInt32StatusCode(Context, &Status);

if (Status == 0 && DispatchId != NULL)
{
Status = DispatchId->DispatchError;

if (DispatchId->Method == UT_TaskPipeDispatchMethod_TABLE_OFFSET && DispatchTable != NULL)
{
Addr = DispatchTable;
Addr += DispatchId->TableOffset;
memcpy(&MsgHandler, Addr, sizeof(void *));
}
}

if (MsgHandler != NULL)
{
Status = MsgHandler(Buffer);
}

UT_Stub_SetReturnValue(FuncKey, Status);
}

/*
** Sets up the MSG stubs in preparation to invoke a "TaskPipe" dispatch function
**
Expand All @@ -204,21 +238,58 @@ void UT_ResetPoolBufferIndex(void)
void UT_SetupBasicMsgDispatch(const UT_TaskPipeDispatchId_t *DispatchReq, CFE_MSG_Size_t MsgSize,
bool ExpectFailureEvent)
{
CFE_Status_t ErrorCode;

if (DispatchReq != NULL)
{
/* Set up for the typical task pipe related calls */
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), (void *)&DispatchReq->MsgId, sizeof(DispatchReq->MsgId), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), (void *)&DispatchReq->CommandCode,
sizeof(DispatchReq->CommandCode), true);

/* If a failure event is being set up, also set for MsgId/FcnCode retrieval as part of failure event reporting
*/
if (ExpectFailureEvent)
if (DispatchReq->Method == UT_TaskPipeDispatchMethod_MSG_ID_CC)
{
/* Set up for the typical task pipe related calls */
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), (void *)&DispatchReq->MsgId, sizeof(DispatchReq->MsgId), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), (void *)&DispatchReq->CommandCode,
sizeof(DispatchReq->CommandCode), true);
}

if (DispatchReq->Method == UT_TaskPipeDispatchMethod_TABLE_OFFSET)
{
/* If the code uses EDS dispatch, this will invoke the right member function from the table (based on
* offset). This requires setting up the function used for table dispatching first. */
if (UT_TABLE_DISPATCHER == 0)
{
UtAssert_Failed(
"Setup error: Method set to TABLE_OFFSET but table dispatcher function is not configured");
}
else
{
UT_SetHandlerFunction(UT_TABLE_DISPATCHER, UT_DispatchTableHandler, (void *)DispatchReq);
}
}

/* If a failure event is being set up, set for MsgId/FcnCode retrieval as part of failure event reporting */
if (ExpectFailureEvent || DispatchReq->DispatchError != CFE_SUCCESS)
{
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), (void *)&DispatchReq->MsgId, sizeof(DispatchReq->MsgId), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), true);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), (void *)&DispatchReq->CommandCode,
sizeof(DispatchReq->CommandCode), true);

if (UT_TABLE_DISPATCHER != 0)
{
/* If the code uses EDS dispatch, this will cause it to return the specified error */
if (DispatchReq->DispatchError != CFE_SUCCESS)
{
ErrorCode = DispatchReq->DispatchError;
}
else
{
/* If not specified, default to WRONG_MSG_LENGTH as this feature was historically used for testing
* bad length */
ErrorCode = CFE_STATUS_WRONG_MSG_LENGTH;
}

UT_SetDefaultReturnValue(UT_TABLE_DISPATCHER, ErrorCode);
}
}
}
else
Expand All @@ -227,6 +298,10 @@ void UT_SetupBasicMsgDispatch(const UT_TaskPipeDispatchId_t *DispatchReq, CFE_MS
UT_ResetState(UT_KEY(CFE_MSG_GetMsgId));
UT_ResetState(UT_KEY(CFE_MSG_GetSize));
UT_ResetState(UT_KEY(CFE_MSG_GetFcnCode));
if (UT_TABLE_DISPATCHER != 0)
{
UT_ResetState(UT_TABLE_DISPATCHER);
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions modules/es/config/default_cfe_es_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@
** This command is not dangerous. However, any previously logged data
** will be lost.
**
** \sa #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ER_LOG_CC, #CFE_ES_WRITE_ER_LOG_CC,
** #CFE_ES_OVER_WRITE_SYSLOG_CC
** \sa #CFE_ES_WRITE_SYS_LOG_CC, #CFE_ES_CLEAR_ER_LOG_CC, #CFE_ES_WRITE_ER_LOG_CC,
** #CFE_ES_OVER_WRITE_SYS_LOG_CC
*/
#define CFE_ES_CLEAR_SYSLOG_CC 10
#define CFE_ES_CLEAR_SYS_LOG_CC 10

/** \cfeescmd Writes contents of Executive Services System Log to a File
**
Expand Down Expand Up @@ -500,10 +500,10 @@
** if performed repeatedly without sufficient file management by the
** operator, fill the file system.
**
** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_CLEAR_ER_LOG_CC, #CFE_ES_WRITE_ER_LOG_CC,
** #CFE_ES_OVER_WRITE_SYSLOG_CC
** \sa #CFE_ES_CLEAR_SYS_LOG_CC, #CFE_ES_CLEAR_ER_LOG_CC, #CFE_ES_WRITE_ER_LOG_CC,
** #CFE_ES_OVER_WRITE_SYS_LOG_CC
*/
#define CFE_ES_WRITE_SYSLOG_CC 11
#define CFE_ES_WRITE_SYS_LOG_CC 11

/** \cfeescmd Clears the contents of the Exception and Reset Log
**
Expand Down Expand Up @@ -535,7 +535,7 @@
** This command is not dangerous. However, any previously logged data
** will be lost.
**
** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_WRITE_ER_LOG_CC
** \sa #CFE_ES_CLEAR_SYS_LOG_CC, #CFE_ES_WRITE_SYS_LOG_CC, #CFE_ES_WRITE_ER_LOG_CC
*/
#define CFE_ES_CLEAR_ER_LOG_CC 12

Expand Down Expand Up @@ -578,7 +578,7 @@
** if performed repeatedly without sufficient file management by the
** operator, fill the file system.
**
** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC, #CFE_ES_CLEAR_ER_LOG_CC
** \sa #CFE_ES_CLEAR_SYS_LOG_CC, #CFE_ES_WRITE_SYS_LOG_CC, #CFE_ES_CLEAR_ER_LOG_CC
*/
#define CFE_ES_WRITE_ER_LOG_CC 13

Expand Down Expand Up @@ -787,9 +787,9 @@
** identifying the cause of a problem to be lost by a subsequent flood of
** additional messages).
**
** \sa #CFE_ES_CLEAR_SYSLOG_CC, #CFE_ES_WRITE_SYSLOG_CC
** \sa #CFE_ES_CLEAR_SYS_LOG_CC, #CFE_ES_WRITE_SYS_LOG_CC
*/
#define CFE_ES_OVER_WRITE_SYSLOG_CC 18
#define CFE_ES_OVER_WRITE_SYS_LOG_CC 18

/** \cfeescmd Resets the Processor Reset Counter to Zero
**
Expand Down
1 change: 1 addition & 0 deletions modules/es/config/default_cfe_es_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define CFE_ES_MSG_H

#include "cfe_mission_cfg.h"
#include "cfe_es_fcncodes.h"
#include "cfe_es_msgdefs.h"
#include "cfe_es_msgstruct.h"

Expand Down
16 changes: 8 additions & 8 deletions modules/es/config/default_cfe_es_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct CFE_ES_RestartCmd_Payload
**
** This format is shared by several executive services commands.
** For command details, see #CFE_ES_QUERY_ALL_CC, #CFE_ES_QUERY_ALL_TASKS_CC,
** #CFE_ES_WRITE_SYSLOG_CC, and #CFE_ES_WRITE_ER_LOG_CC
** #CFE_ES_WRITE_SYS_LOG_CC, and #CFE_ES_WRITE_ER_LOG_CC
**
**/
typedef struct CFE_ES_FileNameCmd_Payload
Expand All @@ -64,7 +64,7 @@ typedef struct CFE_ES_FileNameCmd_Payload
/**
** \brief Overwrite/Discard System Log Configuration Command Payload
**
** For command details, see #CFE_ES_OVER_WRITE_SYSLOG_CC
** For command details, see #CFE_ES_OVER_WRITE_SYS_LOG_CC
**
**/
typedef struct CFE_ES_OverWriteSysLogCmd_Payload
Expand Down Expand Up @@ -146,13 +146,12 @@ typedef struct CFE_ES_DeleteCDSCmd_Payload
/**
* @brief Labels for values to use in #CFE_ES_StartPerfCmd_Payload.TriggerMode
* @sa CFE_ES_StartPerfCmd_Payload
*/
*/
enum CFE_ES_PerfMode
{
CFE_ES_PERF_TRIGGER_START = 0,
CFE_ES_PERF_TRIGGER_CENTER,
CFE_ES_PERF_TRIGGER_END,
CFE_ES_PERF_MAX_MODES
CFE_ES_PerfTrigger_START = 0,
CFE_ES_PerfTrigger_CENTER,
CFE_ES_PerfTrigger_END
};

typedef uint32 CFE_ES_PerfMode_Enum_t;
Expand All @@ -165,7 +164,8 @@ typedef uint32 CFE_ES_PerfMode_Enum_t;
**/
typedef struct CFE_ES_StartPerfCmd_Payload
{
CFE_ES_PerfMode_Enum_t TriggerMode; /**< \brief Desired trigger position (Start, Center, End). Values defined by #CFE_ES_PerfMode. */
CFE_ES_PerfMode_Enum_t
TriggerMode; /**< \brief Desired trigger position (Start, Center, End). Values defined by #CFE_ES_PerfMode. */
} CFE_ES_StartPerfCmd_Payload_t;

/**
Expand Down
Loading

0 comments on commit fb2f6e8

Please sign in to comment.