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

Add prototype Event Management calls and Event Proxy impl files #1

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

keegan-moore
Copy link
Owner

@keegan-moore keegan-moore commented Mar 19, 2024

Describe the contribution

This PR add prototype implementations for the cFS Event Proxy design.
This design intends to abstract the cFS EVS API calls through the Event Management core in BPLib.
A related PR exists for BPLib, here: keegan-moore/bplib#1 .

This design change causes the following in the BP app:

  • During app initialization BP now calls BPL_EVM_Initialize instead of CFE_EVS_Register
    • BPL_EVM_Initialize takes a struct of function pointers to the cFS Event Proxy implementation
  • When the BP app wants to generate an event, the app should now use BPL_EVM_SendEvent

Testing performed

Steps taken to test the contribution:

  1. Build steps
    1. make native.distclean
      2.make ENABLE_TESTS=false native.install
  2. Execution steps '...'
    1. cd build-native-9.4.0/exe/cpu1
    2. ./core-cpu1

Expected behavior changes

EVS's CFE_EVS_Register should no longer generate the following warning in the ES System Log, since the event filter array is now appropriately sized:

1980-012-14:03:20.55879 CFE_EVS_Register: Filter limit truncated to 8

A clear and concise description of how this contribution will change behavior and level of impact.

  • API Changes:
    • During app initialization BP now calls BPL_EVM_Initialize instead of CFE_EVS_Register
    • When the BP app wants to generate an event, the app should now use BPL_EVM_SendEvent
  • Behavior Change:
    • EVS's CFE_EVS_Register should no longer generate a warning in the ES System Log during BP app init
    • No other changes to behavior

System(s) tested on

  • Hardware: PC / x86_64
  • OS: Ubuntu 22.04
  • Versions: cFE 6.7 (equuleus) release candidate

Additional context
N/A

Third party code
N/A

Contributor Info - All information REQUIRED for consideration of pull request
Keegan Moore, NASA/GSFC Code 582 (Flight Software Systems)

@keegan-moore keegan-moore self-assigned this Mar 19, 2024
Comment on lines +129 to +131
/* TODO: We'll probably want to remove this, or wrap it behind an "if debug" compiler flag. */
OS_printf("BPNODE_EVP_SendEvent_Impl(%u, %s, %s)\n",
EventID, BPL_EVM_EventTypeToString(EventType), ExpandedEventText);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I simply remove this, or are there debug print flags in BP that we should use?

Comment on lines +109 to +127
/*
** Due to how we truncate the message if its too long (as seen in code, below),
** we need to ensure that this buffer is at least 2 characters long.
*/
assert(BPNODE_EVP_MAX_MESSAGE_LENGTH >= 2);
assert(BPNODE_EVP_MAX_MESSAGE_LENGTH <= CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

memset(&ExpandedEventText, 0, sizeof(ExpandedEventText));
ExpandedLength = vsnprintf((char *)ExpandedEventText, sizeof(ExpandedEventText),
EventText, EventTextArgPtr);
if (ExpandedLength >= (int)sizeof(ExpandedEventText))
{
/* Mark character before zero terminator to indicate truncation */
ExpandedEventText[sizeof(ExpandedEventText) - 2u] = BPNODE_EVP_MSG_TRUNCATED;
/*
** TODO: should we return an error here?
** Note: In the cFE implementation, they don't treat message truncation as an error.
*/
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error handling response should be reviewed by the group.

Comment on lines +137 to +138
OS_printf("BPNODE_EVP_SendEvent_Impl CFE_EVS_SendEvent returned error status: 0x%08X!\n",
ProxyStatus);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and other places, I've put OS_printf debug print calls in to help catch errors. Is there a better strategy for this?

Comment on lines 167 to 169
/* Application startup event message */
CFE_EVS_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "BP App Version %d.%d.%d.%d: Initialized",
(void) BPL_EVM_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "BP App Version %d.%d.%d.%d: Initialized",
BP_MAJOR_VERSION, BP_MINOR_VERSION, BP_REVISION, BP_MISSION_REV);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous call to CFE_EVS_SendEvent ignored its CFE_Status_t return status, so I kept that going here.

However, if we wanted to check the return status, it would look something like this:

    /* Application startup event message */
    BPL_Status_t BPL_EVM_SendEventStatus;
    (void) BPL_EVM_SendEvent(BP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION,
                      "BP App Version %d.%d.%d.%d: Initialized",
                      BP_MAJOR_VERSION, BP_MINOR_VERSION, BP_REVISION, BP_MISSION_REV);
    if (BPL_EVM_SendEventStatus.ReturnValue != BPL_STATUS_SUCCESS)
    {
        fprintf(stderr, "%s(): First BPL_EVM_SendEvent call failed\n", __func__);
        return BPL_EVM_SendEventStatus.ReturnValue;
    }

I find this to be a little too distracting for such a benign activity, but I'm happy to go with the group's decision on whether to continue ignoring the status return from Send Event calls.

@keegan-moore keegan-moore changed the title WIP: Add prototype Event Management calls and Event Proxy impl files Add prototype Event Management calls and Event Proxy impl files Mar 20, 2024
@keegan-moore keegan-moore marked this pull request as draft March 20, 2024 18:19
@keegan-moore
Copy link
Owner Author

Before this change set is complete, we'd need to scrape through BP and look for all calls to CFE_EVS_SendEvent, replacing them with calls to BPL_EVM_SendEvent .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant