Skip to content

Commit

Permalink
Merge branch 'main' into fix-96-check-returns-from-init-cfe-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen authored Nov 8, 2023
2 parents 9f37dde + 68a7336 commit daca072
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
9 changes: 7 additions & 2 deletions config/default_ci_lab_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion config/default_ci_lab_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ typedef struct
uint32 IngestPackets;
uint32 IngestErrors;
uint32 Spare2;

} CI_LAB_HkTlm_Payload_t;

#endif
14 changes: 7 additions & 7 deletions fsw/src/ci_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "ci_lab_version.h"

/*
** CI global data...
** CI Global Data
*/
CI_LAB_GlobalData_t CI_LAB_Global;

Expand All @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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++)
{
Expand Down
21 changes: 19 additions & 2 deletions fsw/src/ci_lab_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
#include "ci_lab_dispatch.h"
#include "ci_lab_cmds.h"

#include "ci_lab_msg.h"

#include <string.h>
#include <errno.h>
#include <unistd.h>

/****************************************************************************/
/************************************************************************
* Macro Definitions
************************************************************************/

/************************************************************************
** Type Definitions
Expand All @@ -66,12 +70,25 @@ 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);

/* 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
4 changes: 2 additions & 2 deletions fsw/src/ci_lab_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions fsw/src/ci_lab_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)))
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit daca072

Please sign in to comment.