diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml index a364b0b..9e71f60 100644 --- a/.github/workflows/codeql-build.yml +++ b/.github/workflows/codeql-build.yml @@ -3,11 +3,11 @@ name: "CodeQL Analysis" on: push: pull_request: - + jobs: codeql: name: CodeQL Analysis uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main - with: + with: component-path: apps/ci_lab make: 'make -C build/native/default_cpu1/apps/ci_lab' diff --git a/config/default_ci_lab_fcncodes.h b/config/default_ci_lab_fcncodes.h index ad1e543..8d1c456 100644 --- a/config/default_ci_lab_fcncodes.h +++ b/config/default_ci_lab_fcncodes.h @@ -35,7 +35,12 @@ /* ** CI_LAB command codes */ -#define CI_LAB_NOOP_CC 0 -#define CI_LAB_RESET_COUNTERS_CC 1 +#define CI_LAB_NOOP_CC 0 +#define CI_LAB_RESET_COUNTERS_CC 1 +#define CI_LAB_MODIFY_PDU_FILESIZE_CC 2 +#define CI_LAB_CORRUPT_PDU_CHECKSUM_CC 3 +#define CI_LAB_DROP_PDUS_CC 4 +#define CI_LAB_CAPTURE_PDUS_CC 5 +#define CI_LAB_STOP_PDU_CAPTURE_CC 6 #endif diff --git a/config/default_ci_lab_msgdefs.h b/config/default_ci_lab_msgdefs.h index c3005e6..04e876a 100644 --- a/config/default_ci_lab_msgdefs.h +++ b/config/default_ci_lab_msgdefs.h @@ -42,7 +42,6 @@ typedef struct uint32 IngestPackets; uint32 IngestErrors; uint32 Spare2; - } CI_LAB_HkTlm_Payload_t; #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 8cb550c..522b917 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -31,7 +31,7 @@ #include "ci_lab_version.h" /* -** CI global data... +** CI Global Data */ CI_LAB_GlobalData_t CI_LAB_Global; @@ -46,9 +46,9 @@ CI_LAB_GlobalData_t CI_LAB_Global; /* and acts accordingly to process them. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void CI_Lab_AppMain(void) +void CI_LAB_AppMain(void) { - int32 status; + CFE_Status_t status; uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; CFE_SB_Buffer_t *SBBufPtr; @@ -171,7 +171,7 @@ void CI_LAB_TaskInit(void) CFE_MSG_Init(CFE_MSG_PTR(CI_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(CI_LAB_HK_TLM_MID), sizeof(CI_LAB_Global.HkTlm)); - CFE_EVS_SendEvent(CI_LAB_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s", + CFE_EVS_SendEvent(CI_LAB_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s", CI_LAB_VERSION_STRING); } @@ -200,9 +200,9 @@ void CI_LAB_ResetCounters_Internal(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void CI_LAB_ReadUpLink(void) { - int i; - int32 status; - uint8 *bytes; + int i; + CFE_Status_t status; + uint8 * bytes; for (i = 0; i <= 10; i++) { diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index d196a70..0b2500f 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -36,11 +36,15 @@ #include "ci_lab_dispatch.h" #include "ci_lab_cmds.h" +#include "ci_lab_msg.h" + #include #include #include -/****************************************************************************/ +/************************************************************************ + * Macro Definitions + ************************************************************************/ /************************************************************************ ** Type Definitions @@ -66,7 +70,7 @@ typedef struct ** Note: Except for the entry point (CI_LAB_AppMain), these ** functions are not called from any other source module. */ -void CI_Lab_AppMain(void); +void CI_LAB_AppMain(void); void CI_LAB_TaskInit(void); void CI_LAB_ResetCounters_Internal(void); void CI_LAB_ReadUpLink(void); @@ -74,4 +78,17 @@ void CI_LAB_ReadUpLink(void); /* Global State Object */ extern CI_LAB_GlobalData_t CI_LAB_Global; +/* + * Individual message handler function prototypes + * + * Per the recommended code pattern, these should accept a const pointer + * to a structure type which matches the message, and return an int32 + * where CFE_SUCCESS (0) indicates successful handling of the message. + */ +int32 CI_LAB_Noop(const CI_LAB_NoopCmd_t *data); +int32 CI_LAB_ResetCounters(const CI_LAB_ResetCountersCmd_t *data); + +/* Housekeeping message handler */ +int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data); + #endif diff --git a/fsw/src/ci_lab_cmds.c b/fsw/src/ci_lab_cmds.c index 8910108..bda0665 100644 --- a/fsw/src/ci_lab_cmds.c +++ b/fsw/src/ci_lab_cmds.c @@ -39,7 +39,7 @@ CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) /* Does everything the name implies */ CI_LAB_Global.HkTlm.Payload.CommandCounter++; - CFE_EVS_SendEvent(CI_LAB_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); + CFE_EVS_SendEvent(CI_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: NOOP command"); return CFE_SUCCESS; } @@ -52,7 +52,7 @@ CFE_Status_t CI_LAB_NoopCmd(const CI_LAB_NoopCmd_t *cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CI_LAB_ResetCountersCmd(const CI_LAB_ResetCountersCmd_t *cmd) { - CFE_EVS_SendEvent(CI_LAB_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); + CFE_EVS_SendEvent(CI_LAB_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "CI: RESET command"); CI_LAB_ResetCounters_Internal(); return CFE_SUCCESS; } diff --git a/fsw/src/ci_lab_dispatch.c b/fsw/src/ci_lab_dispatch.c index d242db9..038002d 100644 --- a/fsw/src/ci_lab_dispatch.c +++ b/fsw/src/ci_lab_dispatch.c @@ -49,7 +49,7 @@ bool CI_LAB_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLeng CFE_MSG_GetMsgId(MsgPtr, &MsgId); CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_EVS_SendEvent(CI_LAB_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); @@ -68,12 +68,12 @@ bool CI_LAB_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLeng void CI_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) { - CFE_MSG_FcnCode_t CommandCode = 0; + CFE_MSG_FcnCode_t FcnCode = 0; - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &FcnCode); /* Process "known" CI task ground commands */ - switch (CommandCode) + switch (FcnCode) { case CI_LAB_NOOP_CC: if (CI_LAB_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CI_LAB_NoopCmd_t))) @@ -124,7 +124,7 @@ void CI_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) default: CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; - CFE_EVS_SendEvent(CI_LAB_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", + CFE_EVS_SendEvent(CI_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; }