Skip to content

Commit

Permalink
CF_CFDP_R_CheckCrc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jul 11, 2024
1 parent b2670c4 commit e192dfc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
void CF_CFDP_R2_SetFinTxnStatus(CF_Transaction_t *txn, CF_TxnStatus_t txn_stat)
{
CF_CFDP_SetTxnStatus(txn, txn_stat);
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}

/*----------------------------------------------------------------
Expand Down Expand Up @@ -78,7 +78,7 @@ void CF_CFDP_R2_Reset(CF_Transaction_t *txn)
else
{
/* not waiting for FIN ACK, so trigger send FIN */
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
}

Expand All @@ -100,7 +100,7 @@ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn, uint32 expected_crc)
(unsigned long)txn->history->seq_num, (unsigned long)txn->crc.result,
(unsigned long)expected_crc);
++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch;
ret = 1;
ret = CF_ERROR;
}

return ret;
Expand Down Expand Up @@ -689,7 +689,7 @@ CFE_Status_t CF_CFDP_R2_CalcCrcChunk(CF_Transaction_t *txn)
if (success && txn->state_data.receive.r2.rx_crc_calc_bytes == txn->fsize)
{
/* all bytes calculated, so now check */
if (!CF_CFDP_R_CheckCrc(txn, txn->state_data.receive.r2.eof_crc))
if (CF_CFDP_R_CheckCrc(txn, txn->state_data.receive.r2.eof_crc) == CFE_SUCCESS)
{
/* CRC matched! We are happy */
txn->keep = 1; /* save the file */
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp_r.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void CF_CFDP_R2_Reset(CF_Transaction_t *txn);
* txn must not be NULL.
*
*
* @retval CFE_SUCCESS on CRC match, otherwise error.
* @retval CFE_SUCCESS on CRC match, otherwise CF_ERROR.
*
*
* @param txn Pointer to the transaction object
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value,
{
if (CF_ChanAction_Status_IS_SUCCESS(item.fn(value, chan_num)))
{
valid_set = 1;
valid_set = true;
}
else
{
Expand All @@ -1071,7 +1071,7 @@ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value,
}
else
{
valid_set = 1;
valid_set = true;
}

if (valid_set)
Expand Down
6 changes: 3 additions & 3 deletions unit-test/cf_cfdp_r_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,22 +462,22 @@ void Test_CF_CFDP_R_CheckCrc(void)
UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL);
txn->state = CF_TxnState_R1;
txn->crc.result = 0xdeadbeef;
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0x1badc0de), 1);
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0x1badc0de), CF_ERROR);
UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_CRC);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch, 1);

/* CRC mismatch, class 2 */
UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL);
txn->state = CF_TxnState_R2;
txn->crc.result = 0xdeadbeef;
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0x2badc0de), 1);
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0x2badc0de), CF_ERROR);
UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_CRC);
UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch, 2);

/* CRC match */
UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL);
txn->crc.result = 0xc0ffee;
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0xc0ffee), 0);
UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn, 0xc0ffee), CFE_SUCCESS);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0);
}

Expand Down

0 comments on commit e192dfc

Please sign in to comment.