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

Inconsistent use of SC_LAST_RTS_WITH_EVENTS #138

Closed
2 tasks done
skliper opened this issue Jan 30, 2024 · 0 comments · Fixed by #139
Closed
2 tasks done

Inconsistent use of SC_LAST_RTS_WITH_EVENTS #138

skliper opened this issue Jan 30, 2024 · 0 comments · Fixed by #139
Assignees
Labels

Comments

@skliper
Copy link
Contributor

skliper commented Jan 30, 2024

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
SC_LAST_RTS_WITH_EVENTS is documented like an index (1 based), but converted from 0 based in tests.

Documented as 1 based:

* \par Limits:
* This parameter needs to be less than or equal to SC_NUMBER_OF_RTS
*/
#define SC_LAST_RTS_WITH_EVENTS 20

Verified as 1 based:

SC/fsw/src/sc_verify.h

Lines 108 to 114 in 29f7bad

#ifndef SC_LAST_RTS_WITH_EVENTS
#error SC_LAST_RTS_WITH_EVENTS must be defined!
#elif (SC_LAST_RTS_WITH_EVENTS > SC_NUMBER_OF_RTS)
#error SC_LAST_RTS_WITH_EVENTS cannot be greater than SC_NUMBER_OF_RTS!
#elif (SC_LAST_RTS_WITH_EVENTS < 1)
#error SC_LAST_RTS_WITH_EVENTS cannot be less than 1!
#endif

Compared against 1 based number here:

if (Cmd->Payload.RtsNum <= SC_LAST_RTS_WITH_EVENTS)

Correctly converted to an index here:

SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS - 1);

Questionable use here since CFE_MSG_Init expects a size:

CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), SC_LAST_RTS_WITH_EVENTS - 1);

BROKEN references here, used as 0 based:

SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS);

SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS);

These tests will probably fail if SC_LAST_RTS_WITH_EVENTS set to SC_NUMBER_OF_RTS - 1, should work correctly if 1 based.

if (SC_LAST_RTS_WITH_EVENTS < SC_NUMBER_OF_RTS)
{
UtTest_Add(SC_GetNextRtsCommand_Test_ZeroCommandLengthLastRts, SC_Test_Setup, SC_Test_TearDown,
"SC_GetNextRtsCommand_Test_ZeroCommandLengthLastRts");
UtTest_Add(SC_GetNextRtsCommand_Test_EndOfBufferLastRts, SC_Test_Setup, SC_Test_TearDown,
"SC_GetNextRtsCommand_Test_EndOfBufferLastRts");
}

To Reproduce
Set SC_LAST_RTS_WITH_EVENTS to SC_NUMBER_OF_RTS as documented in the config header, fails at compile time
Note if set to SC_NUMBER_OF_RTS - 1, it doesn't look like it will report the last RTS events

Expected behavior
Setting SC_LAST_RTS_WITH_EVENTS to SC_NUMBER_OF_RTS should send event for all RTS's

Code snips
See above

System observed on:
all

Additional context
None

Reporter Info
Jacob Hageman/NASA GSFC

Ping @jphickey

@skliper skliper added the bug label Jan 30, 2024
@skliper skliper self-assigned this Jan 30, 2024
dzbaker added a commit that referenced this issue Feb 1, 2024
Fix #138, Unit test update for 1 based SC_LAST_RTS_WITH_EVENTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant