Skip to content

Commit

Permalink
Merge pull request nasa#152 from jphickey/fix-110-149-more-renames
Browse files Browse the repository at this point in the history
Fix #110, nasa#149, update identifier names
  • Loading branch information
astrogeco authored Jan 12, 2022
2 parents 67259cc + bc7ee2b commit 1c54b31
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 392 deletions.
47 changes: 24 additions & 23 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
#include <string.h>
#include "cf_assert.h"

const int CF_max_chunks[CF_Direction_NUM][CF_NUM_CHANNELS] = {CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION,
CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION};

/**
* @brief Initiate the process of encoding a new PDU to send
*
Expand Down Expand Up @@ -1101,6 +1098,9 @@ int32 CF_CFDP_InitEngine(void)
CF_ChunkWrapper_t *c = CF_AppData.engine.chunks;
int32 ret = CFE_SUCCESS;

static const int CF_DIR_MAX_CHUNKS[CF_Direction_NUM][CF_NUM_CHANNELS] = {CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION,
CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION};

memset(&CF_AppData.engine, 0, sizeof(CF_AppData.engine));

for (i = 0; i < CF_NUM_CHANNELS; ++i)
Expand Down Expand Up @@ -1147,9 +1147,9 @@ int32 CF_CFDP_InitEngine(void)

for (k = 0; k < CF_Direction_NUM; ++k, ++c)
{
CF_Assert((chunk_mem_offset + CF_max_chunks[k][i]) <= CF_NUM_CHUNKS_ALL_CHANNELS);
CF_ChunkListInit(&c->chunks, CF_max_chunks[k][i], &CF_AppData.engine.chunk_mem[chunk_mem_offset]);
chunk_mem_offset += CF_max_chunks[k][i];
CF_Assert((chunk_mem_offset + CF_DIR_MAX_CHUNKS[k][i]) <= CF_NUM_CHUNKS_ALL_CHANNELS);
CF_ChunkListInit(&c->chunks, CF_DIR_MAX_CHUNKS[k][i], &CF_AppData.engine.chunk_mem[chunk_mem_offset]);
chunk_mem_offset += CF_DIR_MAX_CHUNKS[k][i];
CF_CList_InitNode(&c->cl_node);
CF_CList_InsertBack(&CF_AppData.engine.channels[i].cs[k], &c->cl_node);
}
Expand Down Expand Up @@ -1186,7 +1186,7 @@ int32 CF_CFDP_InitEngine(void)
** \endreturns
**
*************************************************************************/
int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context)
int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
{
CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
Expand Down Expand Up @@ -1254,7 +1254,7 @@ void CF_CFDP_CycleTx(CF_Channel_t *c)
CF_MoveTransaction(t, CF_QueueIdx_TXA);
/* args is ok, still { c, 0 } */
entry_jump:
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTx_, &args);
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTxFirstActive, &args);
}
}

Expand All @@ -1277,9 +1277,9 @@ void CF_CFDP_CycleTx(CF_Channel_t *c)
*************************************************************************/
int CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
{
int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
tick_args_t *args = (tick_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
CF_CFDP_Tick_args_t *args = (CF_CFDP_Tick_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
if (!args->c->cur || (args->c->cur == t))
{
/* found where we left off, so clear that and move on */
Expand Down Expand Up @@ -1329,7 +1329,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *c)

for (; c->tick_type < CF_TickType_NUM_TYPES; ++c->tick_type)
{
tick_args_t args = {c, fns[c->tick_type], 0, 0};
CF_CFDP_Tick_args_t args = {c, fns[c->tick_type], 0, 0};

do
{
Expand Down Expand Up @@ -1392,8 +1392,8 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint
** t must not be NULL.
**
*************************************************************************/
static void CF_CFDP_TxFile_(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan,
uint8 priority, CF_EntityId_t dest_id)
{
CFE_EVS_SendEvent(CF_EID_INF_CFDP_S_START_SEND, CFE_EVS_EventType_INFORMATION,
"CF: start class %d tx of file %d:%.*s -> %d:%.*s", cfdp_class + 1,
Expand Down Expand Up @@ -1456,7 +1456,7 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP
t->history->fnames.src_filename[sizeof(t->history->fnames.src_filename) - 1] = 0;
strncpy(t->history->fnames.dst_filename, dst_filename, sizeof(t->history->fnames.dst_filename) - 1);
t->history->fnames.dst_filename[sizeof(t->history->fnames.dst_filename) - 1] = 0;
CF_CFDP_TxFile_(t, cfdp_class, keep, chan, priority, dest_id);
CF_CFDP_TxFile_Initiate(t, cfdp_class, keep, chan, priority, dest_id);

++c->num_cmd_tx;
t->flags.tx.cmd_tx = 1;
Expand All @@ -1480,9 +1480,9 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP
** \endreturns
**
*************************************************************************/
static int32 CF_CFDP_PlaybackDir_(CF_Playback_t *p, const char *src_filename, const char *dst_filename,
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_filename, const char *dst_filename,
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
{
int32 ret = CFE_SUCCESS;

Expand Down Expand Up @@ -1552,7 +1552,7 @@ int32 CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF
return -1;
}

return CF_CFDP_PlaybackDir_(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id);
return CF_CFDP_PlaybackDir_Initiate(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id);
}

/************************************************************************/
Expand Down Expand Up @@ -1606,7 +1606,8 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p)
pt->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0;
pt->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0;

CF_CFDP_TxFile_(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority, p->dest_id);
CF_CFDP_TxFile_Initiate(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority,
p->dest_id);

pt->p = p;
++p->num_ts;
Expand Down Expand Up @@ -1715,16 +1716,16 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
else if (CF_Timer_Expired(&p->interval_timer))
{
/* the timer has expired */
int ret = CF_CFDP_PlaybackDir_(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index,
pd->priority, pd->dest_eid);
int ret = CF_CFDP_PlaybackDir_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0,
chan_index, pd->priority, pd->dest_eid);
if (!ret)
{
p->timer_set = 0;
}
else
{
/* error occured in playback directory, so reset the timer */
/* an event is sent in CF_CFDP_PlaybackDir_ so there is no reason to
/* an event is sent in CF_CFDP_PlaybackDir_Initiate so there is no reason to
* to have another here */
CF_Timer_InitRelSec(&p->interval_timer, pd->interval_sec);
}
Expand Down
10 changes: 4 additions & 6 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@

#include "cf_cfdp_types.h"

typedef struct CF_CFDP_CycleTx_args_t
typedef struct CF_CFDP_CycleTx_args
{
CF_Channel_t *c;
int ran_one;
} CF_CFDP_CycleTx_args_t;

typedef struct
typedef struct CF_CFDP_Tick_args
{
CF_Channel_t *c; /* IN param */
void (*fn)(CF_Transaction_t *, int *); /* IN param */
int early_exit; /* OUT param */
int cont; /* if 1, then re-traverse the list */
} tick_args_t;
} CF_CFDP_Tick_args_t;

void CF_CFDP_EncodeStart(CF_EncoderState_t *penc, void *msgbuf, CF_Logical_PduBuffer_t *ph, size_t encap_hdr_size,
size_t total_size);
Expand Down Expand Up @@ -100,8 +100,6 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint
/* returns number of bytes copied, or -1 on error */
extern int CF_CFDP_CopyStringFromLV(char *buf, size_t buf_maxsz, const CF_Logical_Lv_t *src_lv);

extern const int CF_max_chunks[CF_Direction_NUM][CF_NUM_CHANNELS];

extern void CF_CFDP_ArmAckTimer(CF_Transaction_t *t);

void CF_CFDP_RecvDrop(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph);
Expand All @@ -110,7 +108,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph);
int CF_CFDP_CloseFiles(CF_CListNode_t *n, void *context);

void CF_CFDP_CycleTx(CF_Channel_t *c);
int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context);
int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context);
void CF_CFDP_TickTransactions(CF_Channel_t *c);
void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p);
void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c);
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t)

nak->scope_start = 0;
cret = CF_ChunkList_ComputeGaps(&t->chunks->chunks,
(t->chunks->chunks.count < t->chunks->chunks.CF_max_chunks)
? t->chunks->chunks.CF_max_chunks
: (t->chunks->chunks.CF_max_chunks - 1),
(t->chunks->chunks.count < t->chunks->chunks.max_chunks)
? t->chunks->chunks.max_chunks
: (t->chunks->chunks.max_chunks - 1),
t->fsize, 0, CF_CFDP_R2_GapCompute, &args);

if (!cret)
Expand Down
16 changes: 8 additions & 8 deletions fsw/src/cf_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CF_Chunks_EraseChunk(CF_ChunkList_t *chunks, CF_ChunkIdx_t erase_index)
*************************************************************************/
void CF_Chunks_InsertChunk(CF_ChunkList_t *chunks, CF_ChunkIdx_t index_before, const CF_Chunk_t *chunk)
{
CF_Assert(chunks->count < chunks->CF_max_chunks);
CF_Assert(chunks->count < chunks->max_chunks);
CF_Assert(index_before <= chunks->count);

if (chunks->count && (index_before != chunks->count))
Expand Down Expand Up @@ -155,7 +155,7 @@ CF_ChunkIdx_t CF_Chunks_FindInsertPosition(CF_ChunkList_t *chunks, const CF_Chun
int CF_Chunks_CombinePrevious(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t *chunk)
{
int ret = 0;
CF_Assert(i <= chunks->CF_max_chunks);
CF_Assert(i <= chunks->max_chunks);

CF_ChunkOffset_t chunk_end = chunk->offset + chunk->size;

Expand Down Expand Up @@ -292,7 +292,7 @@ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t
int combined = CF_Chunks_CombinePrevious(chunks, i, chunk);
if (!combined)
{
if (chunks->count < chunks->CF_max_chunks)
if (chunks->count < chunks->max_chunks)
{
CF_Chunks_InsertChunk(chunks, i, chunk);
}
Expand Down Expand Up @@ -395,11 +395,11 @@ const CF_Chunk_t *CF_ChunkList_GetFirstChunk(const CF_ChunkList_t *chunks)
** chunks must not be NULL. chunks_mem must not be NULL.
**
*************************************************************************/
void CF_ChunkListInit(CF_ChunkList_t *chunks, CF_ChunkIdx_t CF_max_chunks, CF_Chunk_t *chunks_mem)
void CF_ChunkListInit(CF_ChunkList_t *chunks, CF_ChunkIdx_t max_chunks, CF_Chunk_t *chunks_mem)
{
CF_Assert(CF_max_chunks > 0);
chunks->CF_max_chunks = CF_max_chunks;
chunks->chunks = chunks_mem;
CF_Assert(max_chunks > 0);
chunks->max_chunks = max_chunks;
chunks->chunks = chunks_mem;
CF_ChunkListReset(chunks);
}

Expand All @@ -413,7 +413,7 @@ void CF_ChunkListInit(CF_ChunkList_t *chunks, CF_ChunkIdx_t CF_max_chunks, CF_Ch
void CF_ChunkListReset(CF_ChunkList_t *chunks)
{
chunks->count = 0;
memset(chunks->chunks, 0, sizeof(*chunks->chunks) * chunks->CF_max_chunks);
memset(chunks->chunks, 0, sizeof(*chunks->chunks) * chunks->max_chunks);
}

/************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct CF_Chunk
typedef struct CF_ChunkList
{
CF_ChunkIdx_t count;
CF_ChunkIdx_t CF_max_chunks;
CF_ChunkIdx_t max_chunks;
CF_Chunk_t *chunks;
} CF_ChunkList_t;

Expand All @@ -61,7 +61,7 @@ static inline CF_ChunkOffset_t CF_Chunk_MAX(CF_ChunkOffset_t a, CF_ChunkOffset_t
}
}

void CF_ChunkListInit(CF_ChunkList_t *chunks, CF_ChunkIdx_t CF_max_chunks, CF_Chunk_t *chunks_mem);
void CF_ChunkListInit(CF_ChunkList_t *chunks, CF_ChunkIdx_t max_chunks, CF_Chunk_t *chunks_mem);
void CF_ChunkListAdd(CF_ChunkList_t *chunks, CF_ChunkOffset_t offset, CF_ChunkSize_t size);
void CF_ChunkListReset(CF_ChunkList_t *chunks);
/* CF_ChunkList_RemoveFromFirst -
Expand Down
Loading

0 comments on commit 1c54b31

Please sign in to comment.