Skip to content
Closed
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: 12 additions & 1 deletion modules/evs/fsw/src/cfe_evs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
* NASA Docket No. GSC-19,200-1, and identified as "cFS Draco"
*
* Copyright (c) 2023 United States Government as represented by the
Expand Down Expand Up @@ -183,6 +183,17 @@ CFE_Status_t CFE_EVS_SendEventWithAppID(uint16 EventID,
}

AppDataPtr = EVS_GetAppDataByID(AppID);
if (AppDataPtr == NULL)
{
CFE_ES_AppId_t callerAppId;
EVS_AppData_t *callerAppData;
if (EVS_GetCurrentContext(&callerAppData, &callerAppId) == CFE_SUCCESS && callerAppData != NULL
&& CFE_RESOURCEID_TEST_EQUAL(callerAppId, AppID))
{
AppDataPtr = callerAppData;
}
}

if (AppDataPtr == NULL)
{
Status = CFE_EVS_APP_ILLEGAL_APP_ID;
Expand Down
8 changes: 8 additions & 0 deletions modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ void Test_IllegalAppID(void)
{
CFE_TIME_SysTime_t time = { 0, 0 };
CFE_ES_AppId_t AppID;
EVS_AppData_t *CallerDataPtr;

UtPrintf("Begin Test Illegal App ID");

Expand Down Expand Up @@ -328,6 +329,13 @@ void Test_IllegalAppID(void)
UT_InitData_EVS();
AppID = CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_PLATFORM_ES_MAX_APPLICATIONS));
UtAssert_INT32_EQ(CFE_EVS_SendEventWithAppID(0, 0, AppID, "NULL"), CFE_EVS_APP_ILLEGAL_APP_ID);

/* Test caller-fallback: EVS_GetAppDataByID fails (first call) but caller IS the app.
* EVS_GetCurrentContext inside the fallback succeeds and IDs match → event is sent. */
UT_InitData_EVS();
EVS_GetCurrentContext(&CallerDataPtr, &AppID);
UT_SetDeferredRetcode(UT_KEY(CFE_ES_AppID_ToIndex), 1, CFE_ES_ERR_RESOURCEID_NOT_VALID);
CFE_UtAssert_SUCCESS(CFE_EVS_SendEventWithAppID(0, CFE_EVS_EventType_INFORMATION, AppID, "NULL"));
}

/*
Expand Down