Skip to content

Commit

Permalink
try getset
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jul 11, 2024
1 parent b401717 commit b2670c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ CF_ChanAction_Status_t CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num)
* See description in cf_cmd.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num)
void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num)
{
CF_ConfigTable_t *config;
CFE_Status_t status = CF_ERROR;
Expand Down Expand Up @@ -1140,7 +1140,7 @@ 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);
CF_GetSetParamCmd(true, cmd->key, cmd->value, cmd->chan_num);

return CFE_SUCCESS;
}
Expand All @@ -1155,7 +1155,7 @@ 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);
CF_GetSetParamCmd(false, cmd->key, 0, cmd->chan_num);

return CFE_SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,13 @@ CF_ChanAction_Status_t CF_CmdValidateMaxOutgoing(uint32 val, uint8 chan_num);
* @par Assumptions, External Events, and Notes:
* None
*
* @param is_set Whether to get (0) or set (1)
* @param is_set Whether to get (false) or set (true)
* @param param_id Parameter ID
* @param value Value to get/set
* @param chan_num Channel number to operate on
*
*/
void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num);
void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num);

/************************************************************************/
/** @brief Ground command to set a configuration parameter.
Expand Down
12 changes: 6 additions & 6 deletions unit-test/cf_cmd_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ void Test_CF_CmdValidateMaxOutgoing_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Retu
void Test_CF_CmdGetSetParam(void)
{
/* Test cases for:
* void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num);
* void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num);
*/

/* Arrange */
Expand All @@ -3438,7 +3438,7 @@ void Test_CF_CmdGetSetParam(void)
for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id)
{
UT_CF_ResetEventCapture();
UtAssert_VOIDCALL(CF_GetSetParamCmd(1, param_id, 1 + param_id, UT_CFDP_CHANNEL));
UtAssert_VOIDCALL(CF_GetSetParamCmd(true, param_id, 1 + param_id, UT_CFDP_CHANNEL));
UT_CF_AssertEventID(CF_EID_INF_CMD_GETSET1);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, ++expected_count);
}
Expand All @@ -3459,26 +3459,26 @@ void Test_CF_CmdGetSetParam(void)
for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id)
{
UT_CF_ResetEventCapture();
UtAssert_VOIDCALL(CF_GetSetParamCmd(0, param_id, 1, UT_CFDP_CHANNEL));
UtAssert_VOIDCALL(CF_GetSetParamCmd(false, param_id, 1, UT_CFDP_CHANNEL));
UT_CF_AssertEventID(CF_EID_INF_CMD_GETSET2);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, ++expected_count);
}

/* Bad param ID */
UT_CF_ResetEventCapture();
UtAssert_VOIDCALL(CF_GetSetParamCmd(0, CF_GetSet_ValueID_MAX, 0, UT_CFDP_CHANNEL));
UtAssert_VOIDCALL(CF_GetSetParamCmd(false, CF_GetSet_ValueID_MAX, 0, UT_CFDP_CHANNEL));
UT_CF_AssertEventID(CF_EID_ERR_CMD_GETSET_PARAM);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1);

/* Bad channel ID */
UT_CF_ResetEventCapture();
UtAssert_VOIDCALL(CF_GetSetParamCmd(0, 0, 0, CF_NUM_CHANNELS + 1));
UtAssert_VOIDCALL(CF_GetSetParamCmd(false, 0, 0, CF_NUM_CHANNELS + 1));
UT_CF_AssertEventID(CF_EID_ERR_CMD_GETSET_CHAN);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 2);

/* Validation fail */
UT_CF_ResetEventCapture();
UtAssert_VOIDCALL(CF_GetSetParamCmd(1, CF_GetSet_ValueID_outgoing_file_chunk_size,
UtAssert_VOIDCALL(CF_GetSetParamCmd(true, CF_GetSet_ValueID_outgoing_file_chunk_size,
100 + sizeof(CF_CFDP_PduFileDataContent_t), UT_CFDP_CHANNEL));
UT_CF_AssertEventID(CF_EID_ERR_CMD_GETSET_VALIDATE);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 3);
Expand Down
4 changes: 2 additions & 2 deletions unit-test/stubs/cf_cmd_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg)
* Generated stub function for CF_GetSetParamCmd()
* ----------------------------------------------------
*/
void CF_GetSetParamCmd(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num)
void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num)
{
UT_GenStub_AddParam(CF_GetSetParamCmd, uint8, is_set);
UT_GenStub_AddParam(CF_GetSetParamCmd, bool, is_set);
UT_GenStub_AddParam(CF_GetSetParamCmd, CF_GetSet_ValueID_t, param_id);
UT_GenStub_AddParam(CF_GetSetParamCmd, uint32, value);
UT_GenStub_AddParam(CF_GetSetParamCmd, uint8, chan_num);
Expand Down

0 comments on commit b2670c4

Please sign in to comment.