From 607bc17691a8c3d6103b6ebf98ba1abc068db704 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 13 Dec 2023 08:50:42 -0500 Subject: [PATCH] Fix #422, implement dispatcher pattern for CF Move message identification, validation, and routing to a separate source file per the recommended CFS app patterns. --- CMakeLists.txt | 1 + config/default_cf_extern_typedefs.h | 45 +++- config/default_cf_fcncodes.h | 8 +- config/default_cf_interface_cfg.h | 80 -------- config/default_cf_mission_cfg.h | 8 + config/default_cf_msgstruct.h | 20 ++ config/default_cf_platform_cfg.h | 30 +++ fsw/inc/cf_events.h | 4 +- fsw/src/cf_app.c | 71 +------ fsw/src/cf_app.h | 38 +--- fsw/src/cf_cfdp_types.h | 1 + fsw/src/cf_cmd.c | 195 ++++++++---------- fsw/src/cf_cmd.h | 76 ++++--- fsw/src/cf_dispatch.c | 158 ++++++++++++++ fsw/src/cf_dispatch.h | 61 ++++++ fsw/src/cf_logical_pdu.h | 2 +- unit-test/CMakeLists.txt | 1 + unit-test/cf_app_tests.c | 159 +-------------- unit-test/cf_cmd_tests.c | 167 +++------------ unit-test/cf_dispatch_tests.c | 305 ++++++++++++++++++++++++++++ unit-test/stubs/cf_app_stubs.c | 34 ---- unit-test/stubs/cf_cmd_stubs.c | 192 ++++++++++++----- unit-test/stubs/cf_dispatch_stubs.c | 51 +++++ 23 files changed, 1009 insertions(+), 698 deletions(-) create mode 100644 fsw/src/cf_dispatch.c create mode 100644 fsw/src/cf_dispatch.h create mode 100644 unit-test/cf_dispatch_tests.c create mode 100644 unit-test/stubs/cf_dispatch_stubs.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f0d128ef..fd53722c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set(APP_SRC_FILES fsw/src/cf_codec.c fsw/src/cf_cmd.c fsw/src/cf_crc.c + fsw/src/cf_dispatch.c fsw/src/cf_timer.c fsw/src/cf_utils.c ) diff --git a/config/default_cf_extern_typedefs.h b/config/default_cf_extern_typedefs.h index a5c5e3db..75db27be 100644 --- a/config/default_cf_extern_typedefs.h +++ b/config/default_cf_extern_typedefs.h @@ -26,7 +26,8 @@ #ifndef CF_EXTERN_TYPEDEFS_H #define CF_EXTERN_TYPEDEFS_H -#include "cf_platform_cfg.h" +/* constants such as CF_FILENAME_MAX_LEN are in mission_cfg.h */ +#include "cf_mission_cfg.h" /** * @brief Values for CFDP file transfer class @@ -70,4 +71,46 @@ typedef struct CF_TxnFilenames char dst_filename[CF_FILENAME_MAX_LEN]; } CF_TxnFilenames_t; +/** + * @brief Entity id size + * + * @par Description: + * The maximum size of the entity id as expected for all CFDP packets. + * CF supports the spec's variable size of EID, where the actual size is + * selected at runtime, and therefore the size in CFDP PDUs may be smaller + * than the size specified here. This type only establishes the maximum + * size (and therefore maximum value) that an EID may be. + * + * @note This type is used in several CF commands, and so changing the size + * of this type will affect the following structs: + * CF_ConfigTable_t, configuration table - will change size of file + * CF_ConfigPacket_t, set config params command + * CF_TxFileCmd_t, transmit file command + * CF_PlaybackDirCmd_t, equivalent to above + * CF_Transaction_Payload_t, any command that selects a transaction based on EID + * + * @par Limits + * Must be one of uint8, uint16, uint32, uint64. + */ +typedef uint32 CF_EntityId_t; + +/** + * @brief transaction sequence number size + * + * @par Description: + * The max size of the transaction sequence number as expected for all CFDP packets. + * CF supports the spec's variable size of TSN, where the actual size is + * selected at runtime, and therefore the size in CFDP PDUs may be smaller + * than the size specified here. This type only establishes the maximum + * size (and therefore maximum value) that a TSN may be. + * + * @note This type is used in several CF commands, and so changing the size + * of this type will affect the following structure: + * CF_Transaction_Payload_t, any command that selects a transaction based on TSN + * + * @par Limits + * Must be one of uint8, uint16, uint32, uint64. + */ +typedef uint32 CF_TransactionSeq_t; + #endif /* CF_EXTERN_TYPEDEFS_H */ diff --git a/config/default_cf_fcncodes.h b/config/default_cf_fcncodes.h index f7da5030..7e946e8c 100644 --- a/config/default_cf_fcncodes.h +++ b/config/default_cf_fcncodes.h @@ -400,9 +400,9 @@ typedef enum * \par Criticality * None * - * \sa #CF_GET_MIB_PARAM_CC + * \sa #CF_GET_PARAM_CC */ - CF_SET_MIB_PARAM_CC = 10, + CF_SET_PARAM_CC = 10, /** * \brief Get parameter @@ -431,9 +431,9 @@ typedef enum * \par Criticality * None * - * \sa #CF_SET_MIB_PARAM_CC + * \sa #CF_SET_PARAM_CC */ - CF_GET_MIB_PARAM_CC = 11, + CF_GET_PARAM_CC = 11, /** * \brief Write queue diff --git a/config/default_cf_interface_cfg.h b/config/default_cf_interface_cfg.h index bb250711..4fab3120 100644 --- a/config/default_cf_interface_cfg.h +++ b/config/default_cf_interface_cfg.h @@ -41,48 +41,6 @@ * \{ */ -/** - * @brief Entity id size - * - * @par Description: - * The maximum size of the entity id as expected for all CFDP packets. - * CF supports the spec's variable size of EID, where the actual size is - * selected at runtime, and therefore the size in CFDP PDUs may be smaller - * than the size specified here. This type only establishes the maximum - * size (and therefore maximum value) that an EID may be. - * - * @note This type is used in several CF commands, and so changing the size - * of this type will affect the following structs: - * CF_ConfigTable_t, configuration table - will change size of file - * CF_ConfigPacket_t, set config params command - * CF_TxFileCmd_t, transmit file command - * CF_PlaybackDirCmd_t, equivalent to above - * CF_Transaction_Payload_t, any command that selects a transaction based on EID - * - * @par Limits - * Must be one of uint8, uint16, uint32, uint64. - */ -typedef uint32 CF_EntityId_t; - -/** - * @brief transaction sequence number size - * - * @par Description: - * The max size of the transaction sequence number as expected for all CFDP packets. - * CF supports the spec's variable size of TSN, where the actual size is - * selected at runtime, and therefore the size in CFDP PDUs may be smaller - * than the size specified here. This type only establishes the maximum - * size (and therefore maximum value) that a TSN may be. - * - * @note This type is used in several CF commands, and so changing the size - * of this type will affect the following structure: - * CF_Transaction_Payload_t, any command that selects a transaction based on TSN - * - * @par Limits - * Must be one of uint8, uint16, uint32, uint64. - */ -typedef uint32 CF_TransactionSeq_t; - /** * @brief Number of channels * @@ -108,20 +66,6 @@ typedef uint32 CF_TransactionSeq_t; */ #define CF_NAK_MAX_SEGMENTS (58) -/** - * @brief Total number of chunks (tx, rx, all channels) - * - * @par Description: - * Must be equal to the sum of all values input in CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION - * and CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION. - * - * @par Limits: - * - */ -/* CF_TOTAL_CHUNKS must be equal to the total number of chunks per rx/tx transactions per channel */ -/* (in other words, the summation of all elements in CF_CHANNEL_NUM_R/TX_CHUNKS_PER_TRANSACTION */ -#define CF_TOTAL_CHUNKS (CF_NAK_MAX_SEGMENTS * 4) - /** * @brief Max number of polling directories per channel. * @@ -158,14 +102,6 @@ typedef uint32 CF_TransactionSeq_t; */ #define CF_FILENAME_MAX_NAME CFE_MISSION_MAX_FILE_LEN -/** - * @brief Maximum file path (not including file name) - * - * @par Limits: - * - */ -#define CF_FILENAME_MAX_PATH (CFE_MISSION_MAX_PATH_LEN - CFE_MISSION_MAX_FILE_LEN) - /** * @brief Max filename and path length. * @@ -196,22 +132,6 @@ typedef uint32 CF_TransactionSeq_t; */ #define CF_PDU_ENCAPSULATION_EXTRA_TRAILING_BYTES 0 -/** - * \brief Mission specific version number - * - * \par Description: - * An application version number consists of four parts: - * major version number, minor version number, revision - * number and mission specific revision number. The mission - * specific revision number is defined here such - * that missions can manage as a configuration definition - * - * \par Limits: - * Must be defined as a numeric value that is greater than - * or equal to zero. - */ -#define CF_MISSION_REV 0 - /**\}*/ #endif diff --git a/config/default_cf_mission_cfg.h b/config/default_cf_mission_cfg.h index 12e35876..6c0efa5a 100644 --- a/config/default_cf_mission_cfg.h +++ b/config/default_cf_mission_cfg.h @@ -34,4 +34,12 @@ #include "cf_interface_cfg.h" +/** + * @brief Maximum file path (not including file name) + * + * @par Limits: + * + */ +#define CF_FILENAME_MAX_PATH (CFE_MISSION_MAX_PATH_LEN - CFE_MISSION_MAX_FILE_LEN) + #endif diff --git a/config/default_cf_msgstruct.h b/config/default_cf_msgstruct.h index b789d9f6..2a659993 100644 --- a/config/default_cf_msgstruct.h +++ b/config/default_cf_msgstruct.h @@ -283,6 +283,26 @@ typedef struct CF_AbandonCmd CF_Transaction_Payload_t Payload; } CF_AbandonCmd_t; +/** + * \brief Send Housekeeping Command + * + * Internal notification from SCH with no payload + */ +typedef struct CF_SendHkCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} CF_SendHkCmd_t; + +/** + * \brief Wake Up Command + * + * Internal notification from SCH with no payload + */ +typedef struct CF_WakeupCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} CF_WakeupCmd_t; + /**\}*/ #endif diff --git a/config/default_cf_platform_cfg.h b/config/default_cf_platform_cfg.h index 53641d00..1580a393 100644 --- a/config/default_cf_platform_cfg.h +++ b/config/default_cf_platform_cfg.h @@ -39,4 +39,34 @@ #include "cf_mission_cfg.h" #include "cf_internal_cfg.h" +/** + * @brief Total number of chunks (tx, rx, all channels) + * + * @par Description: + * Must be equal to the sum of all values input in CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION + * and CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION. + * + * @par Limits: + * + */ +/* CF_TOTAL_CHUNKS must be equal to the total number of chunks per rx/tx transactions per channel */ +/* (in other words, the summation of all elements in CF_CHANNEL_NUM_R/TX_CHUNKS_PER_TRANSACTION */ +#define CF_TOTAL_CHUNKS (CF_NAK_MAX_SEGMENTS * 4) + +/** + * \brief Mission specific version number + * + * \par Description: + * An application version number consists of four parts: + * major version number, minor version number, revision + * number and mission specific revision number. The mission + * specific revision number is defined here such + * that missions can manage as a configuration definition + * + * \par Limits: + * Must be defined as a numeric value that is greater than + * or equal to zero. + */ +#define CF_MISSION_REV 0 + #endif diff --git a/fsw/inc/cf_events.h b/fsw/inc/cf_events.h index 8d0d51d0..bd12f644 100644 --- a/fsw/inc/cf_events.h +++ b/fsw/inc/cf_events.h @@ -132,7 +132,7 @@ * * Invalid message ID received on the software bus pipe */ -#define CF_EID_ERR_INIT_CMD_LENGTH (28) +#define CF_EID_ERR_INVALID_MID (28) /** * \brief CF SB Receive Buffer Failed Event ID @@ -372,7 +372,7 @@ * * Can be induced via various off-nominal conditions - such as sending a META-data PDU * with an invalid file destination. - * + * */ #define CF_EID_DBG_RESET_FREED_XACT (59) diff --git a/fsw/src/cf_app.c b/fsw/src/cf_app.c index 736dc5c9..d22b9ecf 100644 --- a/fsw/src/cf_app.c +++ b/fsw/src/cf_app.c @@ -32,24 +32,13 @@ #include "cf_perfids.h" #include "cf_cfdp.h" #include "cf_version.h" -#include "cf_cmd.h" +#include "cf_dispatch.h" +#include "cf_tbl.h" #include CF_AppData_t CF_AppData; -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in cf_app.h for argument/return detail - * - *-----------------------------------------------------------------*/ -void CF_HkCmd(void) -{ - CFE_MSG_SetMsgTime(&CF_AppData.hk.TelemetryHeader.Msg, CFE_TIME_GetTime()); - /* return value ignored */ CFE_SB_TransmitMsg(&CF_AppData.hk.TelemetryHeader.Msg, true); -} - /*---------------------------------------------------------------- * * Application-scope internal function @@ -199,9 +188,9 @@ CFE_Status_t CF_TableInit(void) *-----------------------------------------------------------------*/ CFE_Status_t CF_Init(void) { - CFE_Status_t status; - static const CFE_SB_MsgId_Atom_t MID_VALUES[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID}; - uint32 i; + CFE_Status_t status; + const CFE_SB_MsgId_Atom_t MID_VALUES[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID}; + uint32 i; CF_AppData.run_status = CFE_ES_RunStatus_APP_RUN; @@ -260,54 +249,6 @@ CFE_Status_t CF_Init(void) return status; } -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in cf_app.h for argument/return detail - * - *-----------------------------------------------------------------*/ -void CF_WakeUp(void) -{ - CFE_ES_PerfLogEntry(CF_PERF_ID_CYCLE_ENG); - CF_CFDP_CycleEngine(); - CFE_ES_PerfLogExit(CF_PERF_ID_CYCLE_ENG); -} - -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in cf_app.h for argument/return detail - * - *-----------------------------------------------------------------*/ -void CF_ProcessMsg(CFE_SB_Buffer_t *msg) -{ - CFE_SB_MsgId_t msg_id = CFE_SB_INVALID_MSG_ID; - - CFE_MSG_GetMsgId(&msg->Msg, &msg_id); - - switch (CFE_SB_MsgIdToValue(msg_id)) - { - case CF_CMD_MID: - CF_ProcessGroundCommand(msg); - break; - - case CF_WAKE_UP_MID: - CF_WakeUp(); - break; - - case CF_SEND_HK_MID: - CF_HkCmd(); - CF_CheckTables(); - break; - - default: - ++CF_AppData.hk.Payload.counters.err; - CFE_EVS_SendEvent(CF_EID_ERR_INIT_CMD_LENGTH, CFE_EVS_EventType_ERROR, - "CF: invalid command packet id=0x%lx", (unsigned long)CFE_SB_MsgIdToValue(msg_id)); - break; - } -} - /*---------------------------------------------------------------- * * Entry point function @@ -342,7 +283,7 @@ void CF_AppMain(void) */ if (status == CFE_SUCCESS && msg != NULL) { - CF_ProcessMsg(msg); + CF_AppPipe(msg); } else if (status != CFE_SB_TIME_OUT && status != CFE_SB_NO_MESSAGE) { diff --git a/fsw/src/cf_app.h b/fsw/src/cf_app.h index c79170d7..ba18a9ae 100644 --- a/fsw/src/cf_app.h +++ b/fsw/src/cf_app.h @@ -32,6 +32,7 @@ #include "cf_tbl.h" #include "cf_msgids.h" #include "cf_tbldefs.h" +#include "cf_mission_cfg.h" #include "cf_platform_cfg.h" #include "cf_cfdp.h" #include "cf_clist.h" @@ -107,17 +108,6 @@ extern CF_AppData_t CF_AppData; ** **************************************************************************/ -/************************************************************************/ -/** @brief Send CF housekeeping packet - * - * @par Description - * The command to send the CF housekeeping packet - * - * @par Assumptions, External Events, and Notes: - * None - */ -void CF_HkCmd(void); - /************************************************************************/ /** @brief Checks to see if a table update is pending, and perform it. * @@ -175,32 +165,6 @@ CFE_Status_t CF_TableInit(void); */ CFE_Status_t CF_Init(void); -/************************************************************************/ -/** @brief CF wakeup function - * - * @par Description - * Performs a single engine cycle for each wakeup - * - * @par Assumptions, External Events, and Notes: - * None - * - */ -void CF_WakeUp(void); - -/************************************************************************/ -/** @brief CF message processing function - * - * @par Description - * Process message packets received via the Software Bus command pipe - * - * @par Assumptions, External Events, and Notes: - * msg must not be NULL. - * - * @param[in] msg Software Bus message pointer - * - */ -void CF_ProcessMsg(CFE_SB_Buffer_t *msg); - /************************************************************************/ /** @brief CF app entry point * diff --git a/fsw/src/cf_cfdp_types.h b/fsw/src/cf_cfdp_types.h index 188fd76f..3b3f2b30 100644 --- a/fsw/src/cf_cfdp_types.h +++ b/fsw/src/cf_cfdp_types.h @@ -33,6 +33,7 @@ #include "common_types.h" #include "cf_cfdp_pdu.h" +#include "cf_extern_typedefs.h" #include "cf_platform_cfg.h" #include "cf_msg.h" #include "cf_clist.h" diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index d44f23e9..457656dd 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -32,6 +32,7 @@ #include "cf_perfids.h" #include "cf_utils.h" #include "cf_version.h" +#include "cf_platform_cfg.h" #include "cf_cfdp.h" #include "cf_cmd.h" @@ -44,11 +45,14 @@ * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_NoopCmd(const CF_NoopCmd_t *msg) +CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg) { CFE_EVS_SendEvent(CF_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: No-Op received, Version %d.%d.%d.%d", CF_MAJOR_VERSION, CF_MINOR_VERSION, CF_REVISION, CF_MISSION_REV); + ++CF_AppData.hk.Payload.counters.cmd; + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -57,7 +61,7 @@ void CF_NoopCmd(const CF_NoopCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_ResetCmd(const CF_ResetCmd_t *msg) +CFE_Status_t CF_ResetCmd(const CF_ResetCmd_t *msg) { const CF_UnionArgs_Payload_t *data = &msg->Payload; static const char * names[5] = {"all", "cmd", "fault", "up", "down"}; @@ -117,6 +121,8 @@ void CF_ResetCmd(const CF_ResetCmd_t *msg) ++CF_AppData.hk.Payload.counters.cmd; } } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -125,7 +131,7 @@ void CF_ResetCmd(const CF_ResetCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_TxFileCmd(const CF_TxFileCmd_t *msg) +CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) { const CF_TxFile_Payload_t *tx = &msg->Payload; @@ -141,7 +147,9 @@ void CF_TxFileCmd(const CF_TxFileCmd_t *msg) "CF: bad parameter in CF_TxFileCmd(): chan=%u, class=%u keep=%u", (unsigned int)tx->chan_num, (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); ++CF_AppData.hk.Payload.counters.err; - return; + + /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ + return CFE_SUCCESS; } #ifdef jphfix @@ -162,6 +170,8 @@ void CF_TxFileCmd(const CF_TxFileCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_TX_FILE, CFE_EVS_EventType_ERROR, "CF: file transfer initiation failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -170,7 +180,7 @@ void CF_TxFileCmd(const CF_TxFileCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) +CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) { const CF_TxFile_Payload_t *tx = &msg->Payload; @@ -186,7 +196,9 @@ void CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) "CF: bad parameter in CF_PlaybackDirCmd(): chan=%u, class=%u keep=%u", (unsigned int)tx->chan_num, (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); ++CF_AppData.hk.Payload.counters.err; - return; + + /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ + return CFE_SUCCESS; } #ifdef jphfix @@ -208,6 +220,8 @@ void CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) "CF: directory playback initiation failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -265,7 +279,7 @@ CFE_Status_t CF_DoFreezeThaw(uint8 chan_num, const CF_ChanAction_BoolArg_t *cont * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_FreezeCmd(const CF_FreezeCmd_t *msg) +CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) { CF_ChanAction_BoolArg_t barg = {1}; /* param is frozen, so 1 means freeze */ @@ -279,6 +293,8 @@ void CF_FreezeCmd(const CF_FreezeCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_FREEZE, CFE_EVS_EventType_ERROR, "CF: freeze cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -287,7 +303,7 @@ void CF_FreezeCmd(const CF_FreezeCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_ThawCmd(const CF_ThawCmd_t *msg) +CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) { CF_ChanAction_BoolArg_t barg = {0}; /* param is frozen, so 0 means thawed */ @@ -301,6 +317,8 @@ void CF_ThawCmd(const CF_ThawCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_THAW, CFE_EVS_EventType_ERROR, "CF: thaw cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -445,9 +463,10 @@ void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_SuspendCmd(const CF_SuspendCmd_t *msg) +CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg) { CF_DoSuspRes(&msg->Payload, 1); + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -456,9 +475,10 @@ void CF_SuspendCmd(const CF_SuspendCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_ResumeCmd(const CF_ResumeCmd_t *msg) +CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg) { CF_DoSuspRes(&msg->Payload, 0); + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -478,7 +498,7 @@ void CF_CmdCancel_Txn(CF_Transaction_t *txn, void *ignored) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_CancelCmd(const CF_CancelCmd_t *msg) +CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) { if (CF_TsnChanAction(&msg->Payload, "cancel", CF_CmdCancel_Txn, NULL) > 0) { @@ -492,6 +512,8 @@ void CF_CancelCmd(const CF_CancelCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_CANCEL_CHAN, CFE_EVS_EventType_ERROR, "CF: cancel cmd: no transaction found"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -511,7 +533,7 @@ void CF_CmdAbandon_Txn(CF_Transaction_t *txn, void *ignored) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_AbandonCmd(const CF_AbandonCmd_t *msg) +CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) { if (CF_TsnChanAction(&msg->Payload, "abandon", CF_CmdAbandon_Txn, NULL) > 0) { @@ -525,6 +547,8 @@ void CF_AbandonCmd(const CF_AbandonCmd_t *msg) "CF: abandon cmd: no transaction found"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -546,7 +570,7 @@ CFE_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, const CF_ChanAction_BoolA * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) +CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) { CF_ChanAction_BoolArg_t barg = {1}; @@ -561,6 +585,8 @@ void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_ENABLE_DEQUEUE, CFE_EVS_EventType_ERROR, "CF: enable dequeue cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -569,7 +595,7 @@ void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) +CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) { CF_ChanAction_BoolArg_t barg = {0}; @@ -584,6 +610,8 @@ void CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_DISABLE_DEQUEUE, CFE_EVS_EventType_ERROR, "CF: disable dequeue cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -624,7 +652,7 @@ CFE_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolM * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg) +CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg) { CF_ChanAction_BoolMsgArg_t barg = {&msg->Payload, 1}; @@ -641,6 +669,8 @@ void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg) "CF: enable polling directory cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -649,7 +679,7 @@ void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_DisablePolldirCmd(const CF_DisableDirPollingCmd_t *msg) +CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg) { CF_ChanAction_BoolMsgArg_t barg = {&msg->Payload, 0}; @@ -666,6 +696,8 @@ void CF_DisablePolldirCmd(const CF_DisableDirPollingCmd_t *msg) "CF: disable polling directory cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -751,9 +783,10 @@ CFE_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) +CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) { CF_ChanAction_MsgArg_t arg = {&msg->Payload}; + if (CF_DoChanAction(&msg->Payload, "purge_queue", (CF_ChanActionFn_t)CF_DoPurgeQueue, &arg) == CFE_SUCCESS) { CFE_EVS_SendEvent(CF_EID_INF_CMD_PURGE_QUEUE, CFE_EVS_EventType_INFORMATION, "CF: queue purged"); @@ -764,6 +797,8 @@ void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) CFE_EVS_SendEvent(CF_EID_ERR_CMD_PURGE_QUEUE, CFE_EVS_EventType_ERROR, "CF: purge queue cmd failed"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -772,7 +807,7 @@ void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) +CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) { const CF_WriteQueue_Payload_t *wq = &msg->Payload; @@ -898,6 +933,8 @@ void CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_SendEvent(CF_EID_INF_CMD_WQ, CFE_EVS_EventType_INFORMATION, "CF: write queue successful"); ++CF_AppData.hk.Payload.counters.cmd; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -1096,11 +1133,13 @@ void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_SetParamCmd(const CF_SetParamCmd_t *msg) +CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg) { const CF_SetParam_Payload_t *cmd = &msg->Payload; CF_GetSetParamCmd(1, cmd->key, cmd->value, cmd->chan_num); + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -1109,11 +1148,13 @@ void CF_SetParamCmd(const CF_SetParamCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_GetParamCmd(const CF_GetParamCmd_t *msg) +CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) { const CF_GetParam_Payload_t *cmd = &msg->Payload; CF_GetSetParamCmd(0, cmd->key, 0, cmd->chan_num); + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -1122,7 +1163,7 @@ void CF_GetParamCmd(const CF_GetParamCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) +CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) { if (!CF_AppData.engine.enabled) { @@ -1144,6 +1185,8 @@ void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) "CF: received enable engine command while engine already enabled"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -1152,7 +1195,7 @@ void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) +CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) { if (CF_AppData.engine.enabled) { @@ -1166,102 +1209,38 @@ void CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) "CF: received disable engine command while engine already disabled"); ++CF_AppData.hk.Payload.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- * * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * See description in cf_app.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_ProcessGroundCommand(CFE_SB_Buffer_t *msg) +CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) { - typedef void (*const handler_fn_t)(const void *); - - static handler_fn_t fns[CF_NUM_COMMANDS] = { - (handler_fn_t)CF_NoopCmd, /* CF_NOOP_CC */ - (handler_fn_t)CF_ResetCmd, /* CF_RESET_CC */ - (handler_fn_t)CF_TxFileCmd, /* CF_TX_FILE_CC */ - (handler_fn_t)CF_PlaybackDirCmd, /* CF_PLAYBACK_DIR_CC */ - (handler_fn_t)CF_FreezeCmd, /* CF_FREEZE_CC */ - (handler_fn_t)CF_ThawCmd, /* CF_THAW_CC */ - (handler_fn_t)CF_SuspendCmd, /* CF_SUSPEND_CC */ - (handler_fn_t)CF_ResumeCmd, /* CF_RESUME_CC */ - (handler_fn_t)CF_CancelCmd, /* CF_CANCEL_CC */ - (handler_fn_t)CF_AbandonCmd, /* CF_ABANDON_CC */ - (handler_fn_t)CF_SetParamCmd, /* CF_SET_MIB_PARAM_CC */ - (handler_fn_t)CF_GetParamCmd, /* CF_GET_MIB_PARAM_CC */ - NULL, - NULL, - NULL, - (handler_fn_t)CF_WriteQueueCmd, /* CF_WRITE_QUEUE_CC */ - (handler_fn_t)CF_EnableDequeueCmd, /* CF_ENABLE_DEQUEUE_CC */ - (handler_fn_t)CF_DisableDequeueCmd, /* CF_DISABLE_DEQUEUE_CC */ - (handler_fn_t)CF_EnablePolldirCmd, /* CF_ENABLE_DIR_POLLING_CC */ - (handler_fn_t)CF_DisablePolldirCmd, /* CF_DISABLE_DIR_POLLING_CC */ - NULL, - (handler_fn_t)CF_PurgeQueueCmd, /* CF_PURGE_QUEUE_CC */ - (handler_fn_t)CF_EnableEngineCmd, /* CF_ENABLE_ENGINE_CC */ - (handler_fn_t)CF_DisableEngineCmd, /* CF_DISABLE_ENGINE_CC */ - }; + CFE_MSG_SetMsgTime(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), CFE_TIME_GetTime()); + /* return value ignored */ CFE_SB_TransmitMsg(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), true); - static const uint16 expected_lengths[CF_NUM_COMMANDS] = { - sizeof(CF_NoopCmd_t), /* CF_NOOP_CC */ - sizeof(CF_ResetCmd_t), /* CF_RESET_CC */ - sizeof(CF_TxFileCmd_t), /* CF_TX_FILE_CC */ - sizeof(CF_PlaybackDirCmd_t), /* CF_PLAYBACK_DIR_CC */ - sizeof(CF_FreezeCmd_t), /* CF_FREEZE_CC */ - sizeof(CF_ThawCmd_t), /* CF_THAW_CC */ - sizeof(CF_SuspendCmd_t), /* CF_SUSPEND_CC */ - sizeof(CF_ResumeCmd_t), /* CF_RESUME_CC */ - sizeof(CF_CancelCmd_t), /* CF_CANCEL_CC */ - sizeof(CF_AbandonCmd_t), /* CF_ABANDON_CC */ - sizeof(CF_SetParamCmd_t), /* CF_SET_MIB_PARAM_CC */ - sizeof(CF_GetParamCmd_t), /* CF_GET_MIB_PARAM_CC */ - 0, - 0, - 0, - sizeof(CF_WriteQueueCmd_t), /* CF_WRITE_QUEUE_CC */ - sizeof(CF_EnableDequeueCmd_t), /* CF_ENABLE_DEQUEUE_CC */ - sizeof(CF_DisableDequeueCmd_t), /* CF_DISABLE_DEQUEUE_CC */ - sizeof(CF_EnableDirPollingCmd_t), /* CF_ENABLE_DIR_POLLING_CC */ - sizeof(CF_DisableDirPollingCmd_t), /* CF_DISABLE_DIR_POLLING_CC */ - 0, - sizeof(CF_UnionArgs_Payload_t), /* CF_PURGE_QUEUE_CC */ - sizeof(CF_EnableEngineCmd_t), /* CF_ENABLE_ENGINE_CC */ - sizeof(CF_DisableEngineCmd_t), /* CF_DISABLE_ENGINE_CC */ - }; - - CFE_MSG_FcnCode_t cmd = 0; - size_t len = 0; + /* This is also used to check tables */ + CF_CheckTables(); - CFE_MSG_GetFcnCode(&msg->Msg, &cmd); + return CFE_SUCCESS; +} - if (cmd < CF_NUM_COMMANDS) - { - CFE_MSG_GetSize(&msg->Msg, &len); +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_app.h for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_WakeupCmd(const CF_WakeupCmd_t *msg) +{ + CFE_ES_PerfLogEntry(CF_PERF_ID_CYCLE_ENG); + CF_CFDP_CycleEngine(); + CFE_ES_PerfLogExit(CF_PERF_ID_CYCLE_ENG); - /* first, verify command length */ - if (len == expected_lengths[cmd]) - { - /* if valid, process command */ - if (fns[cmd]) - { - fns[cmd](msg); - } - } - else - { - CFE_EVS_SendEvent(CF_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: invalid ground command length for command 0x%02x, expected %d got %zd", cmd, - expected_lengths[cmd], len); - ++CF_AppData.hk.Payload.counters.err; - } - } - else - { - CFE_EVS_SendEvent(CF_CC_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: invalid ground command packet cmd_code=0x%02x", cmd); - ++CF_AppData.hk.Payload.counters.err; - } + return CFE_SUCCESS; } diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index b1aad7ab..02acd0e0 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -86,6 +86,32 @@ typedef struct CF_ChanAction_MsgArg const CF_UnionArgs_Payload_t *data; } CF_ChanAction_MsgArg_t; +/************************************************************************/ +/** @brief Send CF housekeeping packet + * + * @par Description + * The command to send the CF housekeeping packet + * + * @par Assumptions, External Events, and Notes: + * None + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg); + +/************************************************************************/ +/** @brief CF wakeup function + * + * @par Description + * Performs a single engine cycle for each wakeup + * + * @par Assumptions, External Events, and Notes: + * None + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_WakeupCmd(const CF_WakeupCmd_t *msg); + /************************************************************************/ /** @brief The no-operation command. * @@ -100,7 +126,7 @@ typedef struct CF_ChanAction_MsgArg * * @param msg Pointer to command message */ -void CF_NoopCmd(const CF_NoopCmd_t *msg); +CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg); /************************************************************************/ /** @brief The reset counters command. @@ -116,7 +142,7 @@ void CF_NoopCmd(const CF_NoopCmd_t *msg); * * @param msg Pointer to command message */ -void CF_ResetCmd(const CF_ResetCmd_t *msg); +CFE_Status_t CF_ResetCmd(const CF_ResetCmd_t *msg); /************************************************************************/ /** @brief Ground command to start a file transfer. @@ -131,7 +157,7 @@ void CF_ResetCmd(const CF_ResetCmd_t *msg); * @param msg Pointer to command message * */ -void CF_TxFileCmd(const CF_TxFileCmd_t *msg); +CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg); /************************************************************************/ /** @brief Ground command to start directory playback. @@ -145,7 +171,7 @@ void CF_TxFileCmd(const CF_TxFileCmd_t *msg); * * @param msg Pointer to command message */ -void CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg); +CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg); /************************************************************************/ /** @brief Common logic for all channel-based commands. @@ -191,7 +217,7 @@ CFE_Status_t CF_DoFreezeThaw(uint8 chan_num, const CF_ChanAction_BoolArg_t *cont * * @param msg Pointer to command message */ -void CF_FreezeCmd(const CF_FreezeCmd_t *msg); +CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg); /************************************************************************/ /** @brief Thaw a channel. @@ -201,7 +227,7 @@ void CF_FreezeCmd(const CF_FreezeCmd_t *msg); * * @param msg Pointer to command message */ -void CF_ThawCmd(const CF_ThawCmd_t *msg); +CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg); /************************************************************************/ /** @brief Search for a transaction across all channels. @@ -274,7 +300,7 @@ void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action); * * @param msg Pointer to command message */ -void CF_SuspendCmd(const CF_SuspendCmd_t *msg); +CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg); /************************************************************************/ /** @brief Handle transaction resume command. @@ -284,7 +310,7 @@ void CF_SuspendCmd(const CF_SuspendCmd_t *msg); * * @param msg Pointer to command message */ -void CF_ResumeCmd(const CF_ResumeCmd_t *msg); +CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg); /************************************************************************/ /** @brief tsn chan action to cancel a transaction. @@ -307,7 +333,7 @@ void CF_CmdCancel_Txn(CF_Transaction_t *txn, void *ignored); * * @param msg Pointer to command message */ -void CF_CancelCmd(const CF_CancelCmd_t *msg); +CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg); /************************************************************************/ /** @brief tsn chan action to abandon a transaction. @@ -330,7 +356,7 @@ void CF_CmdAbandon_Txn(CF_Transaction_t *txn, void *ignored); * * @param msg Pointer to command message */ -void CF_AbandonCmd(const CF_AbandonCmd_t *msg); +CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg); /************************************************************************/ /** @brief Sets the dequeue enable/disable flag for a channel. @@ -354,7 +380,7 @@ CFE_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, const CF_ChanAction_BoolA * * @param msg Pointer to command message */ -void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg); +CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg); /************************************************************************/ /** @brief Handle a disable dequeue ground command. @@ -364,7 +390,7 @@ void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg); * * @param msg Pointer to command message */ -void CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg); +CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg); /************************************************************************/ /** @brief Sets the enable/disable flag for the specified polling directory. @@ -389,7 +415,7 @@ CFE_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolM * * @param msg Pointer to command message */ -void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg); +CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg); /************************************************************************/ /** @brief Disable a polling dir ground command. @@ -399,7 +425,7 @@ void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg); * * @param msg Pointer to command message */ -void CF_DisablePolldirCmd(const CF_DisableDirPollingCmd_t *msg); +CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg); /************************************************************************/ /** @brief Purge the history queue for the given channel. @@ -458,7 +484,7 @@ CFE_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg); * * @param msg Pointer to command message */ -void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg); +CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg); /************************************************************************/ /** @brief Ground command to write a file with queue information. @@ -468,7 +494,7 @@ void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg); * * @param msg Pointer to command message */ -void CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg); +CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg); /************************************************************************/ /** @brief Checks if the value is less than or equal to the max PDU size. @@ -530,7 +556,7 @@ void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, * * @param msg Pointer to command message */ -void CF_SetParamCmd(const CF_SetParamCmd_t *msg); +CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg); /************************************************************************/ /** @brief Ground command to set a configuration parameter. @@ -540,7 +566,7 @@ void CF_SetParamCmd(const CF_SetParamCmd_t *msg); * * @param msg Pointer to command message */ -void CF_GetParamCmd(const CF_GetParamCmd_t *msg); +CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg); /************************************************************************/ /** @brief Ground command enable engine. @@ -550,7 +576,7 @@ void CF_GetParamCmd(const CF_GetParamCmd_t *msg); * * @param msg Pointer to command message */ -void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg); +CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg); /************************************************************************/ /** @brief Ground command disable engine. @@ -560,16 +586,6 @@ void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg); * * @param msg Pointer to command message */ -void CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg); - -/************************************************************************/ -/** @brief Process any ground command contained in the given message. - * - * @par Assumptions, External Events, and Notes: - * msg must not be NULL. - * - * @param msg Pointer to command message - */ -void CF_ProcessGroundCommand(CFE_SB_Buffer_t *msg); +CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg); #endif diff --git a/fsw/src/cf_dispatch.c b/fsw/src/cf_dispatch.c new file mode 100644 index 00000000..7fb323b1 --- /dev/null +++ b/fsw/src/cf_dispatch.c @@ -0,0 +1,158 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * The CF Application main application source file + * + * This file contains the functions that initialize the application and link + * all logic and functionality to the CFS. + */ + +#include "cf_dispatch.h" +#include "cf_app.h" +#include "cf_events.h" +#include "cf_cmd.h" + +#include "cfe.h" +#include + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *msg) +{ + typedef void (*const handler_fn_t)(const void *); + + static handler_fn_t fns[] = { + [CF_NOOP_CC] = (handler_fn_t)CF_NoopCmd, + [CF_RESET_CC] = (handler_fn_t)CF_ResetCmd, + [CF_TX_FILE_CC] = (handler_fn_t)CF_TxFileCmd, + [CF_PLAYBACK_DIR_CC] = (handler_fn_t)CF_PlaybackDirCmd, + [CF_FREEZE_CC] = (handler_fn_t)CF_FreezeCmd, + [CF_THAW_CC] = (handler_fn_t)CF_ThawCmd, + [CF_SUSPEND_CC] = (handler_fn_t)CF_SuspendCmd, + [CF_RESUME_CC] = (handler_fn_t)CF_ResumeCmd, + [CF_CANCEL_CC] = (handler_fn_t)CF_CancelCmd, + [CF_ABANDON_CC] = (handler_fn_t)CF_AbandonCmd, + [CF_SET_PARAM_CC] = (handler_fn_t)CF_SetParamCmd, + [CF_GET_PARAM_CC] = (handler_fn_t)CF_GetParamCmd, + [CF_WRITE_QUEUE_CC] = (handler_fn_t)CF_WriteQueueCmd, + [CF_ENABLE_DEQUEUE_CC] = (handler_fn_t)CF_EnableDequeueCmd, + [CF_DISABLE_DEQUEUE_CC] = (handler_fn_t)CF_DisableDequeueCmd, + [CF_ENABLE_DIR_POLLING_CC] = (handler_fn_t)CF_EnableDirPollingCmd, + [CF_DISABLE_DIR_POLLING_CC] = (handler_fn_t)CF_DisableDirPollingCmd, + [CF_PURGE_QUEUE_CC] = (handler_fn_t)CF_PurgeQueueCmd, + [CF_ENABLE_ENGINE_CC] = (handler_fn_t)CF_EnableEngineCmd, + [CF_DISABLE_ENGINE_CC] = (handler_fn_t)CF_DisableEngineCmd, + }; + + static const uint16 expected_lengths[] = { + [CF_NOOP_CC] = sizeof(CF_NoopCmd_t), + [CF_RESET_CC] = sizeof(CF_ResetCmd_t), + [CF_TX_FILE_CC] = sizeof(CF_TxFileCmd_t), + [CF_PLAYBACK_DIR_CC] = sizeof(CF_PlaybackDirCmd_t), + [CF_FREEZE_CC] = sizeof(CF_FreezeCmd_t), + [CF_THAW_CC] = sizeof(CF_ThawCmd_t), + [CF_SUSPEND_CC] = sizeof(CF_SuspendCmd_t), + [CF_RESUME_CC] = sizeof(CF_ResumeCmd_t), + [CF_CANCEL_CC] = sizeof(CF_CancelCmd_t), + [CF_ABANDON_CC] = sizeof(CF_AbandonCmd_t), + [CF_SET_PARAM_CC] = sizeof(CF_SetParamCmd_t), + [CF_GET_PARAM_CC] = sizeof(CF_GetParamCmd_t), + [CF_WRITE_QUEUE_CC] = sizeof(CF_WriteQueueCmd_t), + [CF_ENABLE_DEQUEUE_CC] = sizeof(CF_EnableDequeueCmd_t), + [CF_DISABLE_DEQUEUE_CC] = sizeof(CF_DisableDequeueCmd_t), + [CF_ENABLE_DIR_POLLING_CC] = sizeof(CF_EnableDirPollingCmd_t), + [CF_DISABLE_DIR_POLLING_CC] = sizeof(CF_DisableDirPollingCmd_t), + [CF_PURGE_QUEUE_CC] = sizeof(CF_UnionArgs_Payload_t), + [CF_ENABLE_ENGINE_CC] = sizeof(CF_EnableEngineCmd_t), + [CF_DISABLE_ENGINE_CC] = sizeof(CF_DisableEngineCmd_t), + }; + + CFE_MSG_FcnCode_t cmd = 0; + size_t len = 0; + + CFE_MSG_GetFcnCode(&msg->Msg, &cmd); + + if (cmd < (sizeof(expected_lengths) / sizeof(expected_lengths[0]))) + { + CFE_MSG_GetSize(&msg->Msg, &len); + + /* first, verify command length */ + if (len == expected_lengths[cmd]) + { + /* if valid, process command */ + if (fns[cmd]) + { + fns[cmd](msg); + } + } + else + { + CFE_EVS_SendEvent(CF_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "CF: invalid ground command length for command 0x%02x, expected %d got %zd", cmd, + expected_lengths[cmd], len); + ++CF_AppData.hk.Payload.counters.err; + } + } + else + { + CFE_EVS_SendEvent(CF_CC_ERR_EID, CFE_EVS_EventType_ERROR, "CF: invalid ground command packet cmd_code=0x%02x", + cmd); + ++CF_AppData.hk.Payload.counters.err; + } +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_app.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_AppPipe(const CFE_SB_Buffer_t *msg) +{ + CFE_SB_MsgId_t msg_id = CFE_SB_INVALID_MSG_ID; + + CFE_MSG_GetMsgId(&msg->Msg, &msg_id); + + switch (CFE_SB_MsgIdToValue(msg_id)) + { + case CF_CMD_MID: + CF_ProcessGroundCommand(msg); + break; + + case CF_WAKE_UP_MID: + CF_WakeupCmd((const CF_WakeupCmd_t *)msg); + break; + + case CF_SEND_HK_MID: + CF_SendHkCmd((const CF_SendHkCmd_t *)msg); + break; + + default: + ++CF_AppData.hk.Payload.counters.err; + CFE_EVS_SendEvent(CF_EID_ERR_INVALID_MID, CFE_EVS_EventType_ERROR, "CF: invalid command packet id=0x%lx", + (unsigned long)CFE_SB_MsgIdToValue(msg_id)); + break; + } +} diff --git a/fsw/src/cf_dispatch.h b/fsw/src/cf_dispatch.h new file mode 100644 index 00000000..42c2ad6f --- /dev/null +++ b/fsw/src/cf_dispatch.h @@ -0,0 +1,61 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * The CF Application main application header file + */ + +#ifndef CF_DISPATCH_H +#define CF_DISPATCH_H + +#include "cfe.h" + +/************************************************************************** + ** + ** Function definitions + ** + **************************************************************************/ + +/************************************************************************/ +/** @brief Process any ground command contained in the given message. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *msg); + +/************************************************************************/ +/** @brief CF message processing function + * + * @par Description + * Process message packets received via the Software Bus command pipe + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param[in] msg Software Bus message pointer + * + */ +void CF_AppPipe(const CFE_SB_Buffer_t *msg); + +#endif /* !CF_DISPATCH_H */ diff --git a/fsw/src/cf_logical_pdu.h b/fsw/src/cf_logical_pdu.h index 48bbb59a..e3652f2a 100644 --- a/fsw/src/cf_logical_pdu.h +++ b/fsw/src/cf_logical_pdu.h @@ -39,7 +39,7 @@ #define CF_LOGICAL_PDU_H #include "common_types.h" -#include "cf_platform_cfg.h" +#include "cf_extern_typedefs.h" /* many enum values in this file are based on CFDP-defined values */ #include "cf_cfdp_pdu.h" diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index ba60e92a..a2b75c3e 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -56,6 +56,7 @@ add_cfe_coverage_stubs(cf_internal stubs/cf_codec_handlers.c stubs/cf_codec_stubs.c stubs/cf_crc_stubs.c + stubs/cf_dispatch_stubs.c stubs/cf_timer_stubs.c stubs/cf_utils_handlers.c stubs/cf_utils_stubs.c diff --git a/unit-test/cf_app_tests.c b/unit-test/cf_app_tests.c index 712b23a7..6dc07dba 100644 --- a/unit-test/cf_app_tests.c +++ b/unit-test/cf_app_tests.c @@ -20,6 +20,7 @@ /* cf testing includes */ #include "cf_test_utils.h" #include "cf_events.h" +#include "cf_dispatch.h" #include "cf_app.h" #include "cf_cmd.h" @@ -59,23 +60,6 @@ void UT_UpdatedDefaultHandler_CFE_SB_ReceiveBuffer(void *UserObj, UT_EntryKey_t UT_Stub_CopyToLocal(UT_KEY(CFE_SB_ReceiveBuffer), BufPtr, sizeof(*BufPtr)); } -/******************************************************************************* -** -** CF_HkCmd tests - full coverage -** -*******************************************************************************/ - -void Test_CF_HkCmd(void) -{ - /* Act */ - CF_HkCmd(); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_SetMsgTime, 1); - UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); - UtAssert_STUB_COUNT(CFE_TIME_GetTime, 1); -} - /******************************************************************************* ** ** CF_CheckTables tests - full coverage @@ -482,104 +466,6 @@ void Test_CF_Init_Success(void) UtAssert_STUB_COUNT(CFE_MSG_Init, 1); } -/******************************************************************************* -** -** CF_WakeUp tests -** -*******************************************************************************/ - -void Test_CF_WakeUp(void) -{ - /* Arrange */ - /* No Arrange Required */ - - /* Act */ - CF_WakeUp(); - - /* Assert */ - UtAssert_STUB_COUNT(CF_CFDP_CycleEngine, 1); -} - -/******************************************************************************* -** -** CF_ProcessMsg tests -** -*******************************************************************************/ - -void Test_CF_ProcessMsg_ProcessGroundCommand(void) -{ - /* Arrange */ - CFE_SB_Buffer_t sbbuf; - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_CMD_MID); - - memset(&sbbuf, 0, sizeof(sbbuf)); - - /* CFE_MSG_GetMsgId uses return by ref */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); - - /* Act */ - CF_ProcessMsg(&sbbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); - UtAssert_STUB_COUNT(CF_ProcessGroundCommand, 1); -} - -void Test_CF_ProcessMsg_WakeUp(void) -{ - /* Arrange */ - CFE_SB_Buffer_t sbbuf; - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_WAKE_UP_MID); - - memset(&sbbuf, 0, sizeof(sbbuf)); - - /* CFE_MSG_GetMsgId uses return by ref */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); - - /* Act */ - CF_ProcessMsg(&sbbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); - UtAssert_STUB_COUNT(CF_CFDP_CycleEngine, 1); -} - -void Test_CF_ProcessMsg_SendHk(void) -{ - CFE_SB_Buffer_t sbbuf; - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_SEND_HK_MID); - - memset(&sbbuf, 0, sizeof(sbbuf)); - - /* CFE_MSG_GetMsgId uses return by ref */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); - - /* Act */ - CF_ProcessMsg(&sbbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_STUB_COUNT(CFE_MSG_SetMsgTime, 1); /* Confirms CF_HkCmd path was taken */ -} - -void Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath(void) -{ - /* Arrange */ - CFE_SB_MsgId_t forced_MsgID = CFE_SB_INVALID_MSG_ID; - CFE_SB_Buffer_t *arg_msg = NULL; - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); - - /* Act */ - CF_ProcessMsg(arg_msg); - - /* Assert */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_EID_ERR_INIT_CMD_LENGTH); -} - /******************************************************************************* ** ** CF_AppMain tests @@ -663,7 +549,7 @@ void Test_CF_AppMain_CFE_SB_ReceiveBuffer_Cases(void) UtAssert_STUB_COUNT(CFE_ES_RunLoop, 3); } -void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_ProcessMsg(void) +void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_AppPipe(void) { /* Arrange */ CFE_SB_MsgId_t forced_MsgID = CFE_SB_INVALID_MSG_ID; @@ -676,7 +562,7 @@ void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndV /* Actual data not used, just address is needed */ UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msg, sizeof(msg), false); - /* Arrange unstubbable: CF_ProcessMsg, invalid ID */ + /* Arrange unstubbable: CF_AppPipe, invalid ID */ UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); /* Act */ @@ -686,10 +572,8 @@ void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndV UtAssert_STUB_COUNT(CFE_ES_PerfLogAdd, 4); UtAssert_STUB_COUNT(CFE_ES_RunLoop, 2); UtAssert_STUB_COUNT(CFE_ES_ExitApp, 1); - /* Assert for CF_Init call and CF_ProcessMsg */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); - /* Assert for CF_ProcessMsg */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + /* Assert for CF_Init call */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } /******************************************************************************* @@ -698,11 +582,6 @@ void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndV ** *******************************************************************************/ -void add_CF_HkCmd_tests(void) -{ - UtTest_Add(Test_CF_HkCmd, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_HkCmd"); -} - void add_CF_CheckTables_tests(void) { UtTest_Add(Test_CF_CheckTables_DoNotReleaseAddressBecauseEngineIsEnabled, Setup_cf_config_table_tests, @@ -782,21 +661,6 @@ void add_CF_Init_tests(void) UtTest_Add(Test_CF_Init_Success, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_Init_Success"); } -void add_CF_WakeUp_tests(void) -{ - UtTest_Add(Test_CF_WakeUp, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_WakeUp"); -} - -void add_CF_ProcessMsg_tests(void) -{ - UtTest_Add(Test_CF_ProcessMsg_ProcessGroundCommand, cf_app_tests_Setup, CF_App_Tests_Teardown, - "Test_CF_ProcessMsg_ProcessGroundCommand"); - UtTest_Add(Test_CF_ProcessMsg_WakeUp, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_ProcessMsg_WakeUp"); - UtTest_Add(Test_CF_ProcessMsg_SendHk, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_ProcessMsg_SendHk"); - UtTest_Add(Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath, cf_app_tests_Setup, CF_App_Tests_Teardown, - "Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath"); -} - void add_CF_AppMain_tests(void) { UtTest_Add( @@ -806,10 +670,9 @@ void add_CF_AppMain_tests(void) "ERROR"); UtTest_Add(Test_CF_AppMain_CFE_SB_ReceiveBuffer_Cases, cf_app_tests_Setup, CF_App_Tests_Teardown, "Test_CF_AppMain_CFE_SB_ReceiveBuffer_Cases"); - UtTest_Add( - Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_ProcessMsg, - cf_app_tests_Setup, CF_App_Tests_Teardown, - "Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_ProcessMsg"); + UtTest_Add(Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_AppPipe, + cf_app_tests_Setup, CF_App_Tests_Teardown, + "Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndValid_msg_Call_CF_AppPipe"); } /******************************************************************************* @@ -822,8 +685,6 @@ void UtTest_Setup(void) { TestUtil_InitializeRandomSeed(); - add_CF_HkCmd_tests(); - add_CF_CheckTables_tests(); add_CF_ValidateConfigTable_tests(); @@ -832,9 +693,5 @@ void UtTest_Setup(void) add_CF_Init_tests(); - add_CF_WakeUp_tests(); - - add_CF_ProcessMsg_tests(); - add_CF_AppMain_tests(); } \ No newline at end of file diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index 0e6858f2..e222ab6a 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -23,7 +23,6 @@ #include "cf_events.h" #include "cf_test_alt_handler.h" - /******************************************************************************* ** ** cf_cmd_tests Setup and Teardown @@ -242,7 +241,6 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_fault_ResetAllHkFaultCountSendEven CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit = Any_uint16_Except(0); CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit = Any_uint16_Except(0); CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.spare = Any_uint16_Except(0); } CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; @@ -267,7 +265,6 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_fault_ResetAllHkFaultCountSendEven UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit); UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit); UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.spare); UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.fault, 0, sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.fault), "fault channel %d was completely cleared to 0", i); @@ -391,7 +388,6 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_all_AndResetAllMemValuesSendEvent( CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit = Any_uint16_Except(0); CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit = Any_uint16_Except(0); CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.spare = Any_uint16_Except(0); } for (i = 0; i < CF_NUM_CHANNELS; ++i) @@ -1860,7 +1856,7 @@ void Test_CF_CmdEnablePolldir_SuccessWhenActionSuccess(void) CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; /* Act */ - CF_EnablePolldirCmd(&utbuf); + CF_EnableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ @@ -1894,7 +1890,7 @@ void Test_CF_CmdEnablePolldir_FailWhenActionFail(void) CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; /* Act */ - CF_EnablePolldirCmd(&utbuf); + CF_EnableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ @@ -1936,7 +1932,7 @@ void Test_CF_CmdDisablePolldir_SuccessWhenActionSuccess(void) CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; /* Act */ - CF_DisablePolldirCmd(&utbuf); + CF_DisableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ @@ -1971,7 +1967,7 @@ void Test_CF_CmdDisablePolldir_FailWhenActionFail(void) CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; /* Act */ - CF_DisablePolldirCmd(&utbuf); + CF_DisableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ @@ -3715,136 +3711,37 @@ void Test_CF_CmdDisableEngine_WhenEngineDisabledAndIncrementErrCounterThenFail(v /******************************************************************************* ** -** CF_ProcessGroundCommand tests +** CF_SendHkCmd tests - full coverage ** *******************************************************************************/ -void Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent(void) +void Test_CF_SendHkCmd(void) { - /* Arrange */ - CFE_SB_Buffer_t utbuf; - CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NUM_COMMANDS; - - memset(&utbuf, 0, sizeof(utbuf)); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, - sizeof(forced_return_CFE_MSG_GetFcnCode), false); - /* CFE_MSG_GetSize does not matter for Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent - */ - /* Act */ - CF_ProcessGroundCommand(&utbuf); + CF_SendHkCmd(NULL); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CC_ERR_EID); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_STUB_COUNT(CFE_MSG_SetMsgTime, 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); + UtAssert_STUB_COUNT(CFE_TIME_GetTime, 1); } -void Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent(void) -{ - /* Arrange */ - CFE_SB_Buffer_t utbuf; - CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NUM_COMMANDS + 1; - - memset(&utbuf, 0, sizeof(utbuf)); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, - sizeof(forced_return_CFE_MSG_GetFcnCode), false); - /* CFE_MSG_GetSize does not matter for Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent - */ - - /* Act */ - CF_ProcessGroundCommand(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CC_ERR_EID); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); -} - -void Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure(void) -{ - /* Arrange */ - CFE_SB_Buffer_t utbuf; - CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NOOP_CC; - CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = sizeof(CF_NoopCmd_t) + 1; /* Invalid size */ - - memset(&utbuf, 0, sizeof(utbuf)); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, - sizeof(forced_return_CFE_MSG_GetFcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), - false); - - /* Act */ - CF_ProcessGroundCommand(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_LEN_ERR_EID); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); -} - -void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg(void) -{ - /* Arrange */ - CFE_SB_Buffer_t utbuf; - CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NOOP_CC; - CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = sizeof(CF_NoopCmd_t); /* Valid size */ - - memset(&utbuf, 0, sizeof(utbuf)); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, - sizeof(forced_return_CFE_MSG_GetFcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), - false); - - /* Act */ - CF_ProcessGroundCommand(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); - /* Assert for CF_CmdNoop */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_NOOP_INF_EID); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); -} +/******************************************************************************* +** +** CF_WakeupCmd tests +** +*******************************************************************************/ -/* Hit a NULL entry to exercise that conditional and no action */ -void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL(void) +void Test_CF_WakeupCmd(void) { /* Arrange */ - CFE_SB_Buffer_t utbuf; - CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = 0x0C; /* 0x0C forces a null slot */ - CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = 0; - - memset(&utbuf, 0, sizeof(utbuf)); - - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, - sizeof(forced_return_CFE_MSG_GetFcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), - false); + /* No Arrange Required */ /* Act */ - CF_ProcessGroundCommand(&utbuf); + CF_WakeupCmd(NULL); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 0); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 0); + UtAssert_STUB_COUNT(CF_CFDP_CycleEngine, 1); } /******************************************************************************* @@ -4237,22 +4134,14 @@ void add_CF_CmdDisableEngine_tests(void) cf_cmd_tests_Teardown, "Test_CF_CmdDisableEngine_WhenEngineDisabledAndIncrementErrCounterThenFail"); } -void add_CF_ProcessGroundCommand_tests(void) +void add_CF_SendHkCmd_tests(void) { - UtTest_Add(Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, "Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent"); - UtTest_Add(Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent"); - UtTest_Add( - Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure, - cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure"); - UtTest_Add(Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, "Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg"); - UtTest_Add(Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL"); + UtTest_Add(Test_CF_SendHkCmd, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SendHkCmd"); +} + +void add_CF_WakeupCmd_tests(void) +{ + UtTest_Add(Test_CF_WakeupCmd, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_WakeupCmd"); } /******************************************************************************* @@ -4337,5 +4226,7 @@ void UtTest_Setup(void) add_CF_CmdDisableEngine_tests(); - add_CF_ProcessGroundCommand_tests(); + add_CF_SendHkCmd_tests(); + + add_CF_WakeupCmd_tests(); } diff --git a/unit-test/cf_dispatch_tests.c b/unit-test/cf_dispatch_tests.c new file mode 100644 index 00000000..37d89d83 --- /dev/null +++ b/unit-test/cf_dispatch_tests.c @@ -0,0 +1,305 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* cf testing includes */ +#include "cf_test_utils.h" +#include "cf_dispatch.h" +#include "cf_cmd.h" +#include "cf_msgids.h" +#include "cf_events.h" + +/* UT includes */ +#include "uttest.h" +#include "utassert.h" +#include "utstubs.h" + +/******************************************************************************* +** +** cf_dispatch_tests Setup and Teardown +** +*******************************************************************************/ + +void cf_dispatch_tests_Setup(void) +{ + cf_tests_Setup(); +} + +void cf_dispatch_tests_Teardown(void) +{ + cf_tests_Teardown(); +} + +/******************************************************************************* +** +** CF_ProcessGroundCommand tests +** +*******************************************************************************/ + +void Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent(void) +{ + /* Arrange */ + CFE_SB_Buffer_t utbuf; + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = 24; + + memset(&utbuf, 0, sizeof(utbuf)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + /* CFE_MSG_GetSize does not matter for Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent + */ + + /* Act */ + CF_ProcessGroundCommand(&utbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CC_ERR_EID); + /* Assert for incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); +} + +void Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent(void) +{ + /* Arrange */ + CFE_SB_Buffer_t utbuf; + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = 123; + + memset(&utbuf, 0, sizeof(utbuf)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + /* CFE_MSG_GetSize does not matter for Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent + */ + + /* Act */ + CF_ProcessGroundCommand(&utbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CC_ERR_EID); + /* Assert for incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); +} + +void Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure(void) +{ + /* Arrange */ + CFE_SB_Buffer_t utbuf; + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NOOP_CC; + CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = sizeof(CF_NoopCmd_t) + 1; /* Invalid size */ + + memset(&utbuf, 0, sizeof(utbuf)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), + false); + + /* Act */ + CF_ProcessGroundCommand(&utbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_LEN_ERR_EID); + /* Assert for incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); +} + +void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg(void) +{ + /* Arrange */ + CFE_SB_Buffer_t utbuf; + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = CF_NOOP_CC; + CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = sizeof(CF_NoopCmd_t); /* Valid size */ + + memset(&utbuf, 0, sizeof(utbuf)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), + false); + + /* Act */ + CF_ProcessGroundCommand(&utbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); +} + +/* Hit a NULL entry to exercise that conditional and no action */ +void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL(void) +{ + /* Arrange */ + CFE_SB_Buffer_t utbuf; + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = 0x0C; /* 0x0C forces a null slot */ + CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = 0; + + memset(&utbuf, 0, sizeof(utbuf)); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), + false); + + /* Act */ + CF_ProcessGroundCommand(&utbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + /* Assert for incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 0); +} + +/******************************************************************************* +** +** CF_AppPipe tests +** +*******************************************************************************/ + +void Test_CF_AppPipe_ProcessGroundCommand(void) +{ + /* Arrange */ + CFE_SB_Buffer_t sbbuf; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_CMD_MID); + CFE_MSG_FcnCode_t forced_return_CFE_MSG_GetFcnCode = 0; + CFE_MSG_Size_t forced_return_CFE_MSG_GetSize = 0; /* Invalid size */ + + memset(&sbbuf, 0, sizeof(sbbuf)); + + /* CFE_MSG_GetMsgId uses return by ref */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_return_CFE_MSG_GetFcnCode, + sizeof(forced_return_CFE_MSG_GetFcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_return_CFE_MSG_GetSize, sizeof(forced_return_CFE_MSG_GetSize), + false); + + /* Act */ + CF_AppPipe(&sbbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); + UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); + UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + + /* Assert for incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); +} + +void Test_CF_AppPipe_WakeUp(void) +{ + /* Arrange */ + CFE_SB_Buffer_t sbbuf; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_WAKE_UP_MID); + + memset(&sbbuf, 0, sizeof(sbbuf)); + + /* CFE_MSG_GetMsgId uses return by ref */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); + + /* Act */ + CF_AppPipe(&sbbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); + UtAssert_STUB_COUNT(CF_WakeupCmd, 1); +} + +void Test_CF_AppPipe_SendHk(void) +{ + CFE_SB_Buffer_t sbbuf; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_SEND_HK_MID); + + memset(&sbbuf, 0, sizeof(sbbuf)); + + /* CFE_MSG_GetMsgId uses return by ref */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); + + /* Act */ + CF_AppPipe(&sbbuf); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_GetMsgId, 1); + UtAssert_STUB_COUNT(CF_SendHkCmd, 1); +} + +void Test_CF_AppPipe_UnrecognizedCommandEnterDefaultPath(void) +{ + /* Arrange */ + CFE_SB_MsgId_t forced_MsgID = CFE_SB_INVALID_MSG_ID; + CFE_SB_Buffer_t *arg_msg = NULL; + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); + + /* Act */ + CF_AppPipe(arg_msg); + + /* Assert */ + UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_EID_ERR_INVALID_MID); +} + +void add_CF_ProcessGroundCommand_tests(void) +{ + UtTest_Add(Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent, cf_dispatch_tests_Setup, + cf_dispatch_tests_Teardown, + "Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent"); + UtTest_Add(Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent, + cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, + "Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent"); + UtTest_Add( + Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure, + cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, + "Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure"); + UtTest_Add(Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg, cf_dispatch_tests_Setup, + cf_dispatch_tests_Teardown, + "Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_CmdNoop_With_msg"); + UtTest_Add(Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL, + cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, + "Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_12_Is_NULL"); +} + +void add_CF_AppPipe_tests(void) +{ + UtTest_Add(Test_CF_AppPipe_ProcessGroundCommand, cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, + "Test_CF_AppPipe_ProcessGroundCommand"); + UtTest_Add(Test_CF_AppPipe_WakeUp, cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, "Test_CF_AppPipe_WakeUp"); + UtTest_Add(Test_CF_AppPipe_SendHk, cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, "Test_CF_AppPipe_SendHk"); + UtTest_Add(Test_CF_AppPipe_UnrecognizedCommandEnterDefaultPath, cf_dispatch_tests_Setup, cf_dispatch_tests_Teardown, + "Test_CF_AppPipe_UnrecognizedCommandEnterDefaultPath"); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + add_CF_ProcessGroundCommand_tests(); + add_CF_AppPipe_tests(); +} diff --git a/unit-test/stubs/cf_app_stubs.c b/unit-test/stubs/cf_app_stubs.c index bceb5843..f9a87b33 100644 --- a/unit-test/stubs/cf_app_stubs.c +++ b/unit-test/stubs/cf_app_stubs.c @@ -48,17 +48,6 @@ void CF_CheckTables(void) UT_GenStub_Execute(CF_CheckTables, Basic, NULL); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_HkCmd() - * ---------------------------------------------------- - */ -void CF_HkCmd(void) -{ - - UT_GenStub_Execute(CF_HkCmd, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_Init() @@ -73,18 +62,6 @@ CFE_Status_t CF_Init(void) return UT_GenStub_GetReturnValue(CF_Init, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_ProcessMsg() - * ---------------------------------------------------- - */ -void CF_ProcessMsg(CFE_SB_Buffer_t *msg) -{ - UT_GenStub_AddParam(CF_ProcessMsg, CFE_SB_Buffer_t *, msg); - - UT_GenStub_Execute(CF_ProcessMsg, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_TableInit() @@ -114,14 +91,3 @@ CFE_Status_t CF_ValidateConfigTable(void *tbl_ptr) return UT_GenStub_GetReturnValue(CF_ValidateConfigTable, CFE_Status_t); } - -/* - * ---------------------------------------------------- - * Generated stub function for CF_WakeUp() - * ---------------------------------------------------- - */ -void CF_WakeUp(void) -{ - - UT_GenStub_Execute(CF_WakeUp, Basic, NULL); -} diff --git a/unit-test/stubs/cf_cmd_stubs.c b/unit-test/stubs/cf_cmd_stubs.c index 48cbf833..0f4994a5 100644 --- a/unit-test/stubs/cf_cmd_stubs.c +++ b/unit-test/stubs/cf_cmd_stubs.c @@ -26,18 +26,20 @@ #include "cf_cmd.h" #include "utgenstub.h" -void UT_DefaultHandler_CF_ProcessGroundCommand(void *, UT_EntryKey_t, const UT_StubContext_t *); - /* * ---------------------------------------------------- * Generated stub function for CF_AbandonCmd() * ---------------------------------------------------- */ -void CF_AbandonCmd(const CF_AbandonCmd_t *msg) +CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_AbandonCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_AbandonCmd, const CF_AbandonCmd_t *, msg); UT_GenStub_Execute(CF_AbandonCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_AbandonCmd, CFE_Status_t); } /* @@ -45,11 +47,15 @@ void CF_AbandonCmd(const CF_AbandonCmd_t *msg) * Generated stub function for CF_CancelCmd() * ---------------------------------------------------- */ -void CF_CancelCmd(const CF_CancelCmd_t *msg) +CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_CancelCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_CancelCmd, const CF_CancelCmd_t *, msg); UT_GenStub_Execute(CF_CancelCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_CancelCmd, CFE_Status_t); } /* @@ -117,35 +123,47 @@ CFE_Status_t CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num) * Generated stub function for CF_DisableDequeueCmd() * ---------------------------------------------------- */ -void CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) +CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_DisableDequeueCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_DisableDequeueCmd, const CF_DisableDequeueCmd_t *, msg); UT_GenStub_Execute(CF_DisableDequeueCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_DisableDequeueCmd, CFE_Status_t); } /* * ---------------------------------------------------- - * Generated stub function for CF_DisableEngineCmd() + * Generated stub function for CF_DisableDirPollingCmd() * ---------------------------------------------------- */ -void CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) +CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg) { - UT_GenStub_AddParam(CF_DisableEngineCmd, const CF_DisableEngineCmd_t *, msg); + UT_GenStub_SetupReturnBuffer(CF_DisableDirPollingCmd, CFE_Status_t); - UT_GenStub_Execute(CF_DisableEngineCmd, Basic, NULL); + UT_GenStub_AddParam(CF_DisableDirPollingCmd, const CF_DisableDirPollingCmd_t *, msg); + + UT_GenStub_Execute(CF_DisableDirPollingCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_DisableDirPollingCmd, CFE_Status_t); } /* * ---------------------------------------------------- - * Generated stub function for CF_DisablePolldirCmd() + * Generated stub function for CF_DisableEngineCmd() * ---------------------------------------------------- */ -void CF_DisablePolldirCmd(const CF_DisableDirPollingCmd_t *msg) +CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) { - UT_GenStub_AddParam(CF_DisablePolldirCmd, const CF_DisableDirPollingCmd_t *, msg); + UT_GenStub_SetupReturnBuffer(CF_DisableEngineCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_DisableEngineCmd, const CF_DisableEngineCmd_t *, msg); - UT_GenStub_Execute(CF_DisablePolldirCmd, Basic, NULL); + UT_GenStub_Execute(CF_DisableEngineCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_DisableEngineCmd, CFE_Status_t); } /* @@ -267,35 +285,47 @@ void CF_DoSuspRes_Txn(CF_Transaction_t *txn, CF_ChanAction_SuspResArg_t *context * Generated stub function for CF_EnableDequeueCmd() * ---------------------------------------------------- */ -void CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) +CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_EnableDequeueCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_EnableDequeueCmd, const CF_EnableDequeueCmd_t *, msg); UT_GenStub_Execute(CF_EnableDequeueCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_EnableDequeueCmd, CFE_Status_t); } /* * ---------------------------------------------------- - * Generated stub function for CF_EnableEngineCmd() + * Generated stub function for CF_EnableDirPollingCmd() * ---------------------------------------------------- */ -void CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) +CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg) { - UT_GenStub_AddParam(CF_EnableEngineCmd, const CF_EnableEngineCmd_t *, msg); + UT_GenStub_SetupReturnBuffer(CF_EnableDirPollingCmd, CFE_Status_t); - UT_GenStub_Execute(CF_EnableEngineCmd, Basic, NULL); + UT_GenStub_AddParam(CF_EnableDirPollingCmd, const CF_EnableDirPollingCmd_t *, msg); + + UT_GenStub_Execute(CF_EnableDirPollingCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_EnableDirPollingCmd, CFE_Status_t); } /* * ---------------------------------------------------- - * Generated stub function for CF_EnablePolldirCmd() + * Generated stub function for CF_EnableEngineCmd() * ---------------------------------------------------- */ -void CF_EnablePolldirCmd(const CF_EnableDirPollingCmd_t *msg) +CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) { - UT_GenStub_AddParam(CF_EnablePolldirCmd, const CF_EnableDirPollingCmd_t *, msg); + UT_GenStub_SetupReturnBuffer(CF_EnableEngineCmd, CFE_Status_t); - UT_GenStub_Execute(CF_EnablePolldirCmd, Basic, NULL); + UT_GenStub_AddParam(CF_EnableEngineCmd, const CF_EnableEngineCmd_t *, msg); + + UT_GenStub_Execute(CF_EnableEngineCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_EnableEngineCmd, CFE_Status_t); } /* @@ -320,11 +350,15 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSe * Generated stub function for CF_FreezeCmd() * ---------------------------------------------------- */ -void CF_FreezeCmd(const CF_FreezeCmd_t *msg) +CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_FreezeCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_FreezeCmd, const CF_FreezeCmd_t *, msg); UT_GenStub_Execute(CF_FreezeCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_FreezeCmd, CFE_Status_t); } /* @@ -332,11 +366,15 @@ void CF_FreezeCmd(const CF_FreezeCmd_t *msg) * Generated stub function for CF_GetParamCmd() * ---------------------------------------------------- */ -void CF_GetParamCmd(const CF_GetParamCmd_t *msg) +CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_GetParamCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_GetParamCmd, const CF_GetParamCmd_t *, msg); UT_GenStub_Execute(CF_GetParamCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_GetParamCmd, CFE_Status_t); } /* @@ -359,11 +397,15 @@ void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, * Generated stub function for CF_NoopCmd() * ---------------------------------------------------- */ -void CF_NoopCmd(const CF_NoopCmd_t *msg) +CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_NoopCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_NoopCmd, const CF_NoopCmd_t *, msg); UT_GenStub_Execute(CF_NoopCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_NoopCmd, CFE_Status_t); } /* @@ -371,23 +413,15 @@ void CF_NoopCmd(const CF_NoopCmd_t *msg) * Generated stub function for CF_PlaybackDirCmd() * ---------------------------------------------------- */ -void CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) +CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_PlaybackDirCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_PlaybackDirCmd, const CF_PlaybackDirCmd_t *, msg); UT_GenStub_Execute(CF_PlaybackDirCmd, Basic, NULL); -} -/* - * ---------------------------------------------------- - * Generated stub function for CF_ProcessGroundCommand() - * ---------------------------------------------------- - */ -void CF_ProcessGroundCommand(CFE_SB_Buffer_t *msg) -{ - UT_GenStub_AddParam(CF_ProcessGroundCommand, CFE_SB_Buffer_t *, msg); - - UT_GenStub_Execute(CF_ProcessGroundCommand, Basic, UT_DefaultHandler_CF_ProcessGroundCommand); + return UT_GenStub_GetReturnValue(CF_PlaybackDirCmd, CFE_Status_t); } /* @@ -412,11 +446,15 @@ CFE_Status_t CF_PurgeHistory(CF_CListNode_t *node, CF_Channel_t *chan) * Generated stub function for CF_PurgeQueueCmd() * ---------------------------------------------------- */ -void CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) +CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_PurgeQueueCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_PurgeQueueCmd, const CF_PurgeQueueCmd_t *, msg); UT_GenStub_Execute(CF_PurgeQueueCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_PurgeQueueCmd, CFE_Status_t); } /* @@ -441,11 +479,15 @@ CFE_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignored) * Generated stub function for CF_ResetCmd() * ---------------------------------------------------- */ -void CF_ResetCmd(const CF_ResetCmd_t *msg) +CFE_Status_t CF_ResetCmd(const CF_ResetCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_ResetCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_ResetCmd, const CF_ResetCmd_t *, msg); UT_GenStub_Execute(CF_ResetCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ResetCmd, CFE_Status_t); } /* @@ -453,11 +495,31 @@ void CF_ResetCmd(const CF_ResetCmd_t *msg) * Generated stub function for CF_ResumeCmd() * ---------------------------------------------------- */ -void CF_ResumeCmd(const CF_ResumeCmd_t *msg) +CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_ResumeCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_ResumeCmd, const CF_ResumeCmd_t *, msg); UT_GenStub_Execute(CF_ResumeCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ResumeCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_SendHkCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_SendHkCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_SendHkCmd, const CF_SendHkCmd_t *, msg); + + UT_GenStub_Execute(CF_SendHkCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_SendHkCmd, CFE_Status_t); } /* @@ -465,11 +527,15 @@ void CF_ResumeCmd(const CF_ResumeCmd_t *msg) * Generated stub function for CF_SetParamCmd() * ---------------------------------------------------- */ -void CF_SetParamCmd(const CF_SetParamCmd_t *msg) +CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_SetParamCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_SetParamCmd, const CF_SetParamCmd_t *, msg); UT_GenStub_Execute(CF_SetParamCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_SetParamCmd, CFE_Status_t); } /* @@ -477,11 +543,15 @@ void CF_SetParamCmd(const CF_SetParamCmd_t *msg) * Generated stub function for CF_SuspendCmd() * ---------------------------------------------------- */ -void CF_SuspendCmd(const CF_SuspendCmd_t *msg) +CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_SuspendCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_SuspendCmd, const CF_SuspendCmd_t *, msg); UT_GenStub_Execute(CF_SuspendCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_SuspendCmd, CFE_Status_t); } /* @@ -489,11 +559,15 @@ void CF_SuspendCmd(const CF_SuspendCmd_t *msg) * Generated stub function for CF_ThawCmd() * ---------------------------------------------------- */ -void CF_ThawCmd(const CF_ThawCmd_t *msg) +CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_ThawCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_ThawCmd, const CF_ThawCmd_t *, msg); UT_GenStub_Execute(CF_ThawCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ThawCmd, CFE_Status_t); } /* @@ -501,12 +575,12 @@ void CF_ThawCmd(const CF_ThawCmd_t *msg) * Generated stub function for CF_TsnChanAction() * ---------------------------------------------------- */ -CFE_Status_t CF_TsnChanAction(const CF_Transaction_Payload_t *payload, const char *cmdstr, CF_TsnChanAction_fn_t fn, +CFE_Status_t CF_TsnChanAction(const CF_Transaction_Payload_t *data, const char *cmdstr, CF_TsnChanAction_fn_t fn, void *context) { UT_GenStub_SetupReturnBuffer(CF_TsnChanAction, CFE_Status_t); - UT_GenStub_AddParam(CF_TsnChanAction, const CF_Transaction_Payload_t *, payload); + UT_GenStub_AddParam(CF_TsnChanAction, const CF_Transaction_Payload_t *, data); UT_GenStub_AddParam(CF_TsnChanAction, const char *, cmdstr); UT_GenStub_AddParam(CF_TsnChanAction, CF_TsnChanAction_fn_t, fn); UT_GenStub_AddParam(CF_TsnChanAction, void *, context); @@ -521,11 +595,31 @@ CFE_Status_t CF_TsnChanAction(const CF_Transaction_Payload_t *payload, const cha * Generated stub function for CF_TxFileCmd() * ---------------------------------------------------- */ -void CF_TxFileCmd(const CF_TxFileCmd_t *msg) +CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_TxFileCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_TxFileCmd, const CF_TxFileCmd_t *, msg); UT_GenStub_Execute(CF_TxFileCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_TxFileCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_WakeupCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_WakeupCmd(const CF_WakeupCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_WakeupCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_WakeupCmd, const CF_WakeupCmd_t *, msg); + + UT_GenStub_Execute(CF_WakeupCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_WakeupCmd, CFE_Status_t); } /* @@ -533,9 +627,13 @@ void CF_TxFileCmd(const CF_TxFileCmd_t *msg) * Generated stub function for CF_WriteQueueCmd() * ---------------------------------------------------- */ -void CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) +CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) { + UT_GenStub_SetupReturnBuffer(CF_WriteQueueCmd, CFE_Status_t); + UT_GenStub_AddParam(CF_WriteQueueCmd, const CF_WriteQueueCmd_t *, msg); UT_GenStub_Execute(CF_WriteQueueCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_WriteQueueCmd, CFE_Status_t); } diff --git a/unit-test/stubs/cf_dispatch_stubs.c b/unit-test/stubs/cf_dispatch_stubs.c new file mode 100644 index 00000000..0b0a7740 --- /dev/null +++ b/unit-test/stubs/cf_dispatch_stubs.c @@ -0,0 +1,51 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cf_dispatch header + */ + +#include "cf_dispatch.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CF_AppPipe() + * ---------------------------------------------------- + */ +void CF_AppPipe(const CFE_SB_Buffer_t *msg) +{ + UT_GenStub_AddParam(CF_AppPipe, const CFE_SB_Buffer_t *, msg); + + UT_GenStub_Execute(CF_AppPipe, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_ProcessGroundCommand() + * ---------------------------------------------------- + */ +void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *msg) +{ + UT_GenStub_AddParam(CF_ProcessGroundCommand, const CFE_SB_Buffer_t *, msg); + + UT_GenStub_Execute(CF_ProcessGroundCommand, Basic, NULL); +}