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 #55, add timeout to SB receive #144

Open
wants to merge 1 commit into
base: integration-candidate
Choose a base branch
from
Open
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: 10 additions & 3 deletions fsw/src/sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ void SAMPLE_APP_Main(void)
*/
CFE_ES_PerfLogExit(SAMPLE_APP_PERF_ID);

/* Pend on receipt of command packet */
status = CFE_SB_ReceiveBuffer(&SBBufPtr, SAMPLE_APP_Data.CommandPipe, CFE_SB_PEND_FOREVER);
/*
* Pend on receipt of command packet
*
* Note that apps should not wait forever here, to ensure
* that the status of CFE_ES_RunLoop() is also checked periodically,
* even if no software bus messages arrive.
*/
status = CFE_SB_ReceiveBuffer(&SBBufPtr, SAMPLE_APP_Data.CommandPipe, SAMPLE_APP_SB_WAIT_PERIOD);

/*
** Performance Log Entry Stamp
Expand All @@ -94,8 +100,9 @@ void SAMPLE_APP_Main(void)
{
SAMPLE_APP_ProcessCommandPacket(SBBufPtr);
}
else
else if (status != CFE_SB_TIME_OUT)
{
/* Timeout is normal if no activity, but anything else constitutes a real error */
CFE_EVS_SendEvent(SAMPLE_APP_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
"SAMPLE APP: SB Pipe Read Error, App Will Exit");

Expand Down
11 changes: 11 additions & 0 deletions fsw/src/sample_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
#define SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE -1

#define SAMPLE_APP_TBL_ELEMENT_1_MAX 10

/**
* \brief Amount of time to wait in CFE_SB_RecieveBuffer
*
* Applications need to wait for messages to arrive on the Software Bus,
* but this wait should be time limited to ensure that the app also
* periodically checks the status of CFE_ES_RunLoop(), in case an
* administrative command comes in.
*/
#define SAMPLE_APP_SB_WAIT_PERIOD 1000

/************************************************************************
** Type Definitions
*************************************************************************/
Expand Down