Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #172, Add timeout and packet limit on sending telemetry #173

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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