nasa / cFE

The Core Flight System (cFS) Core Flight Executive (cFE)
Apache License 2.0
402 stars 198 forks source link

Improve CFE_SB_AllocateMessageBuffer error reporting #2559

Closed skliper closed 1 week ago

skliper commented 2 months ago

Is your feature request related to a problem? Please describe. Current log message isn't very informative: https://github.com/nasa/cFE/blob/28a58203a56ed7c1512c79c961fadeddb5bbb7bb/modules/sb/fsw/src/cfe_sb_api.c#L2016

Describe the solution you'd like Consider adding appname, requested size, and current limit

Describe alternatives you've considered None

Additional context None

Requester Info Jacob Hageman - NASA/GSFC

skliper commented 2 months ago

Suggested update:

    char              AppName[OS_MAX_API_NAME] = {""};
    CFE_SB_BufferD_t *BufDscPtr;
    CFE_SB_Buffer_t * BufPtr;
    CFE_Status_t      Status;

    AppId     = CFE_ES_APPID_UNDEFINED;
    BufDscPtr = NULL;
    BufPtr    = NULL;

    Status = CFE_ES_GetAppID(&AppId);

    if (MsgSize > CFE_MISSION_SB_MAX_SB_MSG_SIZE)
    {
        CFE_ES_GetAppName(AppName, AppId, sizeof(AppName));
        CFE_ES_WriteToSysLog("%s %s: Failed, requested size %ld larger than allowed %d\n",
                             AppName, __func__, MsgSize, CFE_MISSION_SB_MAX_SB_MSG_SIZE);
        return NULL;
    }