Skip to content

Commit

Permalink
Fix nasa#120 nasa#256, Move timers into channel config and remove cfg…
Browse files Browse the repository at this point in the history
… telemetry
  • Loading branch information
skliper committed Jun 7, 2022
1 parent bfeaa9a commit 76d5429
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 234 deletions.
1 change: 0 additions & 1 deletion docs/cf_FunctionalRequirements.csv
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ CF5002.3,CF5002.3,"When CF receives a ""Set CFDP Channel Protocol Configuration"
CF5002.4,CF5002.4,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, if the command-specified parameter *value* is invalid, CF shall reject the command.",Command validity check for robust operation
CF5003,CF5003,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, CF shall issue an event message containing the current value of the command-specified configuration-table parameter.",Operational interface
CF5003.1,CF5003.1,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, if the command-specified parameter is invalid, CF shall reject the command. ",Operational robustness
CF5004,CF5004,"When CF receives a ""Get Full CFDP Channel-Protocol Configuration"" command, CF shall publish all CFDP Channel Protocol Configuration parameters to a cFS-SB message. ",Compatibility with cFE App behavior. Message can be downlinked as Housekeeping Data or sent to another app for consumption
CF5005,CF5005,"When CF receives a ""Cancel Transaction"" command, CF shall cancel the transaction indicated by the command-specified Entity ID and transaction-sequence number.",Support an operational interface to control transactions. Transaction-Id provides a mechanism to scale to large systems and avoid performance issues with string searches
CF5005.1,CF5005.1,"When CF receives a ""Cancel Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command.",Support an operational interface to provide operator feedback.
CF5006,CF5006,"When CF receives an ""Abandon Transaction"" command, CF shall abandon the command-specified transaction.",Support an operational interface to provide operator feedback.
Expand Down
1 change: 0 additions & 1 deletion fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ int32 CF_Init(void)
CF_AppData.run_status = CFE_ES_RunStatus_APP_RUN;

CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk));
CFE_MSG_Init(&CF_AppData.cfg.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_CONFIG_TLM_MID), sizeof(CF_AppData.cfg));

status = CFE_EVS_Register(cf_event_filters, sizeof(cf_event_filters) / sizeof(*cf_event_filters),
CFE_EVS_EventFilter_BINARY);
Expand Down
3 changes: 1 addition & 2 deletions fsw/src/cf_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
*/
typedef struct
{
CF_HkPacket_t hk;
CF_ConfigPacket_t cfg;
CF_HkPacket_t hk;

uint32 run_status;

Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical
*-----------------------------------------------------------------*/
void CF_CFDP_ArmAckTimer(CF_Transaction_t *t)
{
CF_Timer_InitRelSec(&t->ack_timer, CF_AppData.config_table->ack_timer_s);
CF_Timer_InitRelSec(&t->ack_timer, CF_AppData.config_table->chan[t->chan_num].ack_timer_s);
t->flags.com.ack_timer_armed = 1;
}

Expand Down Expand Up @@ -169,7 +169,7 @@ static inline int CF_CFDP_IsSender(CF_Transaction_t *ti)
*-----------------------------------------------------------------*/
static inline void CF_CFDP_ArmInactTimer(CF_Transaction_t *t)
{
CF_Timer_InitRelSec(&t->inactivity_timer, CF_AppData.config_table->inactivity_timer_s);
CF_Timer_InitRelSec(&t->inactivity_timer, CF_AppData.config_table->chan[t->chan_num].inactivity_timer_s);
}

/*----------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *t, int ok_to_send_nak)
++t->state_data.r.r2.acknak_count;

/* Check limit and handle if needed */
if (t->state_data.r.r2.acknak_count >= CF_AppData.config_table->nak_limit)
if (t->state_data.r.r2.acknak_count >= CF_AppData.config_table->chan[t->chan_num].nak_limit)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_NAK_LIMIT, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): nak limited reach", (t->state == CF_TxnState_R2),
Expand Down Expand Up @@ -1057,7 +1057,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont /* unused */)
++t->state_data.r.r2.acknak_count;

/* Check limit and handle if needed */
if (t->state_data.r.r2.acknak_count >= CF_AppData.config_table->ack_limit)
if (t->state_data.r.r2.acknak_count >= CF_AppData.config_table->chan[t->chan_num].ack_limit)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_ACK_LIMIT, CFE_EVS_EventType_ERROR,
"CF R2(%lu:%lu): ack limit reached, no fin-ack",
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ void CF_CFDP_S_Tick(CF_Transaction_t *t, int *cont /* unused */)
++t->state_data.s.s2.acknak_count;

/* Check limit and handle if needed */
if (t->state_data.s.s2.acknak_count >= CF_AppData.config_table->ack_limit)
if (t->state_data.s.s2.acknak_count >= CF_AppData.config_table->chan[t->chan_num].ack_limit)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_ACK_LIMIT, CFE_EVS_EventType_ERROR,
"CF S2(%lu:%lu), ack limit reached, no eof-ack",
Expand Down
48 changes: 11 additions & 37 deletions fsw/src/cf_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,32 +833,6 @@ void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg)
CF_CmdRej();
}

/*----------------------------------------------------------------
*
* Function: CF_CmdSendCfgParams
*
* Application-scope internal function
* See description in cf_cmd.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CmdSendCfgParams(CFE_SB_Buffer_t *msg)
{
CF_AppData.cfg.ticks_per_second = CF_AppData.config_table->ticks_per_second;
CF_AppData.cfg.rx_crc_calc_bytes_per_wakeup = CF_AppData.config_table->rx_crc_calc_bytes_per_wakeup;
CF_AppData.cfg.ack_timer_s = CF_AppData.config_table->ack_timer_s;
CF_AppData.cfg.nak_timer_s = CF_AppData.config_table->nak_timer_s;
CF_AppData.cfg.inactivity_timer_s = CF_AppData.config_table->inactivity_timer_s;
CF_AppData.cfg.outgoing_file_chunk_size = CF_AppData.config_table->outgoing_file_chunk_size;
CF_AppData.cfg.ack_limit = CF_AppData.config_table->ack_limit;
CF_AppData.cfg.nak_limit = CF_AppData.config_table->nak_limit;
CF_AppData.cfg.local_eid = CF_AppData.config_table->local_eid;

CFE_MSG_SetMsgTime(&CF_AppData.cfg.tlm_header.Msg, CFE_TIME_GetTime());
/* return value ignored */ CFE_SB_TransmitMsg(&CF_AppData.cfg.tlm_header.Msg, true);

CF_CmdAcc();
}

/*----------------------------------------------------------------
*
* Function: CF_CmdValidateChunkSize
Expand Down Expand Up @@ -934,29 +908,29 @@ void CF_CmdGetSetParam(uint8 is_set, CF_GetSet_ValueID_t param_id, uint32 value,
item.size = sizeof(config->rx_crc_calc_bytes_per_wakeup);
break;
case CF_GetSet_ValueID_ack_timer_s:
item.ptr = &config->ack_timer_s;
item.size = sizeof(config->ack_timer_s);
item.ptr = &config->chan[chan_num].ack_timer_s;
item.size = sizeof(config->chan[chan_num].ack_timer_s);
break;
case CF_GetSet_ValueID_nak_timer_s:
item.ptr = &config->nak_timer_s;
item.size = sizeof(config->nak_timer_s);
item.ptr = &config->chan[chan_num].nak_timer_s;
item.size = sizeof(config->chan[chan_num].nak_timer_s);
break;
case CF_GetSet_ValueID_inactivity_timer_s:
item.ptr = &config->inactivity_timer_s;
item.size = sizeof(config->inactivity_timer_s);
item.ptr = &config->chan[chan_num].inactivity_timer_s;
item.size = sizeof(config->chan[chan_num].inactivity_timer_s);
break;
case CF_GetSet_ValueID_outgoing_file_chunk_size:
item.ptr = &config->outgoing_file_chunk_size;
item.size = sizeof(config->outgoing_file_chunk_size);
item.fn = CF_CmdValidateChunkSize;
break;
case CF_GetSet_ValueID_ack_limit:
item.ptr = &config->ack_limit;
item.size = sizeof(config->ack_limit);
item.ptr = &config->chan[chan_num].ack_limit;
item.size = sizeof(config->chan[chan_num].ack_limit);
break;
case CF_GetSet_ValueID_nak_limit:
item.ptr = &config->nak_limit;
item.size = sizeof(config->nak_limit);
item.ptr = &config->chan[chan_num].nak_limit;
item.size = sizeof(config->chan[chan_num].nak_limit);
break;
case CF_GetSet_ValueID_local_eid:
item.ptr = &config->local_eid;
Expand Down Expand Up @@ -1161,7 +1135,7 @@ void CF_ProcessGroundCommand(CFE_SB_Buffer_t *msg)
CF_CmdGetParam, /* CF_GET_MIB_PARAM_CC */
NULL,
NULL,
CF_CmdSendCfgParams, /* CF_SendRet_CFG_PARAMS_CC */
NULL,
CF_CmdWriteQueue, /* CF_WRITE_QUEUE_CC */
CF_CmdEnableDequeue, /* CF_ENABLE_DEQUEUE_CC */
CF_CmdDisableDequeue, /* CF_DISABLE_DEQUEUE_CC */
Expand Down
10 changes: 0 additions & 10 deletions fsw/src/cf_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,6 @@ void CF_CmdPurgeQueue(CFE_SB_Buffer_t *msg);
*/
void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg);

/************************************************************************/
/** @brief Ground command to send configuration parameters.
*
* @par Assumptions, External Events, and Notes:
* msg must not be NULL.
*
* @param msg Pointer to command message
*/
void CF_CmdSendCfgParams(CFE_SB_Buffer_t *msg);

/************************************************************************/
/** @brief Checks if the value is less than or equal to the max pdu size.
*
Expand Down
48 changes: 13 additions & 35 deletions fsw/src/cf_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,6 @@ typedef struct CF_HkPacket
CF_HkChannel_Data_t channel_hk[CF_NUM_CHANNELS];
} CF_HkPacket_t;

/* used with CF_SendRet_CFG_PARAMS_CC */
typedef struct CF_ConfigPacket
{
CFE_MSG_TelemetryHeader_t tlm_header;

uint32 ticks_per_second; /* expected ticks per second to cfdp app */
uint32 rx_crc_calc_bytes_per_wakeup; /* max number of bytes per wakeup to calculate r2 crc for recvd file (must by
1024-byte aligned */

uint32 ack_timer_s; /* in seconds */
uint32 nak_timer_s; /* in seconds */
uint32 inactivity_timer_s; /* in seconds */

uint16 outgoing_file_chunk_size;
uint8 ack_limit; /* number of times to retry ACK (for ex, send fin and wait for fin-ack) */
uint8 nak_limit; /* number of times to retry NAK before giving up (resets on a single response */

CF_EntityId_t local_eid;

} CF_ConfigPacket_t;

/**\}*/

/**
Expand All @@ -139,20 +118,19 @@ typedef struct CF_ConfigPacket
*/
typedef enum
{
CF_NOOP_CC = 0,
CF_RESET_CC = 1,
CF_TX_FILE_CC = 2,
CF_PLAYBACK_DIR_CC = 3,
CF_FREEZE_CC = 4,
CF_THAW_CC = 5,
CF_SUSPEND_CC = 6,
CF_RESUME_CC = 7,
CF_CANCEL_CC = 8,
CF_ABANDON_CC = 9,
CF_SET_MIB_PARAM_CC = 10,
CF_GET_MIB_PARAM_CC = 11,
CF_SendRet_CFG_PARAMS_CC = 14,
CF_WRITE_QUEUE_CC = 15,
CF_NOOP_CC = 0,
CF_RESET_CC = 1,
CF_TX_FILE_CC = 2,
CF_PLAYBACK_DIR_CC = 3,
CF_FREEZE_CC = 4,
CF_THAW_CC = 5,
CF_SUSPEND_CC = 6,
CF_RESUME_CC = 7,
CF_CANCEL_CC = 8,
CF_ABANDON_CC = 9,
CF_SET_MIB_PARAM_CC = 10,
CF_GET_MIB_PARAM_CC = 11,
CF_WRITE_QUEUE_CC = 15,

/* NOTE: ENABLE/DISABLE commands should be a single command code, but legacy has them separate (ugh) */
CF_ENABLE_DEQUEUE_CC = 16,
Expand Down
14 changes: 7 additions & 7 deletions fsw/src/cf_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ typedef struct CF_ChannelConfig
uint32 max_outgoing_messages_per_wakeup; /**< \brief max number of messages to send per wakeup (0 - unlimited) */
uint32 rx_max_messages_per_wakeup; /**< \brief max number of rx messages to process per wakeup */

uint32 ack_timer_s; /**< \brief Acknowledge timer in seconds */
uint32 nak_timer_s; /**< \brief Non-acknowledge timer in seconds */
uint32 inactivity_timer_s; /**< \brief Inactivity timer in seconds */

uint8 ack_limit; /**< number of times to retry ACK (for ex, send fin and wait for fin-ack) */
uint8 nak_limit; /**< number of times to retry NAK before giving up (resets on a single response */

CFE_SB_MsgId_Atom_t mid_input; /**< \brief msgid integer value for incoming messages */
CFE_SB_MsgId_Atom_t mid_output; /**< \brief msgid integer value for outgoing messages */

Expand All @@ -82,13 +89,6 @@ typedef struct CF_ConfigTable

CF_ChannelConfig_t chan[CF_NUM_CHANNELS]; /**< \brief Channel configuration */

uint32 ack_timer_s; /**< \brief Acknowledge timer in seconds */
uint32 nak_timer_s; /**< \brief Non-acknowledge timer in seconds */
uint32 inactivity_timer_s; /**< \brief Inactivity timer in seconds */

uint8 ack_limit; /**< number of times to retry ACK (for ex, send fin and wait for fin-ack) */
uint8 nak_limit; /**< number of times to retry NAK before giving up (resets on a single response */

uint16 outgoing_file_chunk_size; /**< maximum size of outgoing file data PDUs */
char tmp_dir[CF_FILENAME_MAX_PATH]; /**< directory to put temp files */
} CF_ConfigTable_t;
Expand Down
23 changes: 14 additions & 9 deletions fsw/tables/cf_def_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,33 @@ CF_ConfigTable_t CF_config_table = {
16384, /* max number of bytes per wakeup to calculate r2 recv file crc */
25, /* temp local id */
{{
5, /* max number of outgoing messages per wakeup */
5, /* max number of rx messages per wakeup */
5, /* max number of outgoing messages per wakeup */
5, /* max number of rx messages per wakeup */
3, /* ack timer */
3, /* nak timer */
30, /* inactivity timer */
4, /* ack limit */
4, /* nak limit */
0x18c8,
0x08c2,
16,
{{5, 25, CF_CFDP_CLASS_2, 23, "/cf/poll_dir", "./poll_dir", 1}, {0}, {0}, {0}, {0}},
"", /* throttle sem for channel 1, empty string means no throttle */
1,
},
{5, /* max number of outgoing messages per wakeup */
5, /* max number of rx messages per wakeup */
{5, /* max number of outgoing messages per wakeup */
5, /* max number of rx messages per wakeup */
3, /* ack timer */
3, /* nak timer */
30, /* inactivity timer */
4, /* ack limit */
4, /* nak limit */
0x18c9,
0x08c3,
16,
{{0}, {0}, {0}, {0}, {0}},
"", /* throttle sem for channel 2, empty string means no throttle */
1}},
3, /* ack timer */
3, /* nak timer */
30, /* inactivity timer */
4, /* ack limit */
4, /* nak limit */
480, /* outgoing_file_chunk_size */
"/cf/tmp",
};
Expand Down
14 changes: 7 additions & 7 deletions unit-test/cf_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ void Test_CF_Init_CallTo_CFE_EVS_Register_ReturnsNot_CFE_SUCCESS_Call_CFE_ES_Wri
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1);
UtAssert_INT32_EQ(result, forced_return_CFE_MSG_Init);
Expand All @@ -475,7 +475,7 @@ void Test_CF_Init_CallTo_CFE_SB_CreatePipe_ReturnsNot_CFE_SUCCESS_Call_CFE_ES_Wr
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1);
UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1);
Expand All @@ -494,7 +494,7 @@ void Test_CF_Init_FirstCallTo_CFE_SB_Subscribe_ReturnsNot_CFE_SUCCESS_Call_CFE_E
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1);
UtAssert_STUB_COUNT(CFE_SB_Subscribe, 1);
Expand All @@ -517,7 +517,7 @@ void Test_CF_Init_CallTo_CF_TableInit_ReturnsNot_CFE_SUCCESS_ReturnErrorStatus(v
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1);
UtAssert_STUB_COUNT(CFE_SB_Subscribe, 3);
Expand All @@ -538,7 +538,7 @@ void Test_CF_Init_CallTo_CF_CFDP_InitEngine_ReturnsNot_CFE_SUCCESS_ReturnErrorSt
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1);
UtAssert_STUB_COUNT(CFE_SB_Subscribe, 3);
Expand All @@ -559,7 +559,7 @@ void Test_CF_Init_CallTo_CFE_EVS_SendEvent_ReturnsNot_CFE_SUCCESS_Call_CFE_ES_Wr
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_STUB_COUNT(CFE_EVS_Register, 1);
UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1);
UtAssert_STUB_COUNT(CFE_SB_Subscribe, 3);
Expand All @@ -578,7 +578,7 @@ void Test_CF_Init_Success(void)
result = CF_Init();

/* Assert */
UtAssert_STUB_COUNT(CFE_MSG_Init, 2);
UtAssert_STUB_COUNT(CFE_MSG_Init, 1);
UtAssert_INT32_EQ(result, CFE_SUCCESS);
} /* end Test_CF_Init_Success */

Expand Down
Loading

0 comments on commit 76d5429

Please sign in to comment.