Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #82, use separate dispatcher for messages #88

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

jphickey
Copy link
Contributor

Checklist (Please check before submitting)

Describe the contribution
Isolate the message verification and dispatch from the general message processing. Functions in the "cmds" file now strictly handle the command content, and do not get involved in general validation.

Fixes #82

Testing performed
Build and run CFE with LC, sanity check operation

Expected behavior changes
No impact, just improves source unit organization

System(s) tested on
Debian

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

/* Process a command pipe message */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr)

Check notice

Code scanning / CodeQL

Function too long

LC_AppPipe has too many lines (84, while 60 are allowed).
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Housekeeping request */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr)
int32 LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)

Check notice

Code scanning / CodeQL

Long function without assertion

All functions of more than 10 lines should have at least one assertion.
/* Process a command pipe message */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr)

Check notice

Code scanning / CodeQL

Long function without assertion

All functions of more than 10 lines should have at least one assertion.
/* Verify message packet length */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength)

Check notice

Code scanning / CodeQL

Long function without assertion

All functions of more than 10 lines should have at least one assertion.
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Housekeeping request */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr)
int32 LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)

Check notice

Code scanning / CodeQL

Function too long

LC_SendHkCmd has too many lines (273, while 60 are allowed).
Comment on lines +252 to +324
switch (CFE_SB_MsgIdToValue(MessageID))
{
/*
** Sample actionpoints request
*/
case LC_SAMPLE_AP_MID:
LC_SampleAPVerifyDispatch(BufPtr);
break;

/*
** Housekeeping telemetry request
** (only routine that can return a critical error indicator)
*/
case LC_SEND_HK_MID:
LC_SendHkVerifyDispatch(BufPtr);
break;

/*
** LC application commands...
*/
case LC_CMD_MID:

CFE_MSG_GetFcnCode(&BufPtr->Msg, &CommandCode);
switch (CommandCode)
{
case LC_NOOP_CC:
LC_NoopVerifyDispatch(BufPtr);
break;

case LC_RESET_CC:
LC_ResetCountersVerifyDispatch(BufPtr);
break;

case LC_SET_LC_STATE_CC:
LC_SetLCStateVerifyDispatch(BufPtr);
break;

case LC_SET_AP_STATE_CC:
LC_SetAPStateVerifyDispatch(BufPtr);
break;

case LC_SET_AP_PERM_OFF_CC:
LC_SetAPPermOffVerifyDispatch(BufPtr);
break;

case LC_RESET_AP_STATS_CC:
LC_ResetAPStatsVerifyDispatch(BufPtr);
break;

case LC_RESET_WP_STATS_CC:
LC_ResetWPStatsVerifyDispatch(BufPtr);
break;

default:
CFE_EVS_SendEvent(LC_CC_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid command code: ID = 0x%08lX, CC = %d",
(unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode);

LC_AppData.CmdErrCount++;
break;

} /* end CommandCode switch */
break;

/*
** All other message ID's should be monitor
** packets
*/
default:
LC_CheckMsgForWPs(MessageID, BufPtr);
break;

} /* end MessageID switch */

Check notice

Code scanning / CodeQL

Long switch case

Switch has at least one case that is too long: [6308 (47 lines)](1).
Isolate the message verification and dispatch from the general message
processing.  Functions in the "cmds" file now strictly handle the
command content, and do not get involved in general validation.
@jphickey
Copy link
Contributor Author

Format checks fixed, all passing now.

@dzbaker dzbaker merged commit 0dba171 into nasa:main Apr 17, 2023
@jphickey jphickey deleted the fix-82-dispatch branch April 21, 2023 13:39
@dmknutsen dmknutsen added this to the Equuleus milestone May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apps should check/verify msg BEFORE calling handler
4 participants