Skip to content

Commit

Permalink
Fix #172, Add timeout and packet limit on sending telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Nov 15, 2023
1 parent 2d7e01c commit e8421f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions config/default_to_lab_internal_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,21 @@

/*****************************************************************************/

/**
* @brief Main loop task delay
*/
#define TO_LAB_TASK_MSEC 500 /* run at 2 Hz */

/**
* @brief Telemetry pipe timeout
*/
#define TO_LAB_TLM_PIPE_TIMEOUT CFE_SB_POLL

/**
* @brief Maximum number of telemetry packets to send each wakeup
*/
#define TO_LAB_MAX_TLM_PKTS OS_QUEUE_MAX_DEPTH

/**
* Depth of pipe for commands to the TO_LAB application itself
*/
Expand Down
9 changes: 6 additions & 3 deletions fsw/src/to_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void TO_LAB_AppMain(void)
{
CFE_ES_PerfLogExit(TO_LAB_MAIN_TASK_PERF_ID);

OS_TaskDelay(TO_LAB_TASK_MSEC); /*2 Hz*/
OS_TaskDelay(TO_LAB_TASK_MSEC);

CFE_ES_PerfLogEntry(TO_LAB_MAIN_TASK_PERF_ID);

Expand Down Expand Up @@ -263,6 +263,7 @@ void TO_LAB_forward_telemetry(void)
CFE_SB_Buffer_t *SBBufPtr;
const void * NetBufPtr;
size_t NetBufSize;
uint32 PktCount = 0;

OS_SocketAddrInit(&d_addr, OS_SocketDomain_INET);
OS_SocketAddrSetPort(&d_addr, TO_LAB_TLM_PORT);
Expand All @@ -271,7 +272,7 @@ void TO_LAB_forward_telemetry(void)

do
{
CfeStatus = CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Tlm_pipe, CFE_SB_POLL);
CfeStatus = CFE_SB_ReceiveBuffer(&SBBufPtr, TO_LAB_Global.Tlm_pipe, TO_LAB_TLM_PIPE_TIMEOUT);

if ((CfeStatus == CFE_SUCCESS) && (TO_LAB_Global.suppress_sendto == false))
{
Expand Down Expand Up @@ -304,7 +305,9 @@ void TO_LAB_forward_telemetry(void)
}
}
/* If CFE_SB_status != CFE_SUCCESS, then no packet was received from CFE_SB_ReceiveBuffer() */
} while (CfeStatus == CFE_SUCCESS);

PktCount++;
} while (CfeStatus == CFE_SUCCESS && PktCount < TO_LAB_MAX_TLM_PKTS);
}

/************************/
Expand Down

0 comments on commit e8421f6

Please sign in to comment.