From 7d13f76f33e5b55845be7940d8c30b9b7d921ef1 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Wed, 22 Jan 2020 06:43:00 -0800 Subject: [PATCH] fix for #308 - improved create pipe error reporting with eid and unit test changes --- fsw/cfe-core/src/inc/cfe_sb_events.h | 26 +++++++++++++++++++++++++- fsw/cfe-core/src/sb/cfe_sb_api.c | 24 +++++++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/fsw/cfe-core/src/inc/cfe_sb_events.h b/fsw/cfe-core/src/inc/cfe_sb_events.h index e2b4e014f..02d358aa8 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_events.h +++ b/fsw/cfe-core/src/inc/cfe_sb_events.h @@ -40,7 +40,7 @@ ** and when you're done adding, set this to the highest EID you used. It may ** be worthwhile to, on occasion, re-number the EID's to put them back in order. */ -#define CFE_SB_MAX_EID 61 +#define CFE_SB_MAX_EID 63 /* ** SB task event message ID's. @@ -858,6 +858,30 @@ **/ #define CFE_SB_LEN_ERR_EID 61 +/** \brief 'CreatePipeErr:Name Taken:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** \event 'CreatePipeErr:Name Taken:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_CreatePipe API tries to create +** a pipe with a name that is in use. +**/ +#define CFE_SB_CR_PIPE_NAME_TAKEN_EID 62 + +/** \brief 'CreatePipeErr:No Free:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** \event 'CreatePipeErr:No Free:app=\%s,ptr=0x\%x,depth=\%d,maxdepth=\%d' +** +** \par Type: ERROR +** +** \par Cause: +** +** This error event message is issued when the #CFE_SB_CreatePipe API is unable to +** create a queue because there are no queues free. +**/ +#define CFE_SB_CR_PIPE_NO_FREE_EID 63 + #endif /* _cfe_sb_events_ */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/fsw/cfe-core/src/sb/cfe_sb_api.c index ee7f2d6ad..29e78583b 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/fsw/cfe-core/src/sb/cfe_sb_api.c @@ -160,13 +160,27 @@ int32 CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char * /* if OS_QueueCreate() failed because the pipe name passed in was already in use... */ /* let's make sure we don't alter the user's pipe ID data */ - if (Status == CFE_OS_ERR_NAME_TAKEN){ - *PipeIdPtr = OriginalPipeIdParamValue; - } - - CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + switch(Status) { + case OS_ERR_NAME_TAKEN: + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NAME_TAKEN_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + "CreatePipeErr:OS_QueueCreate failed, name taken (app=%s, name=%s)", + CFE_SB_GetAppTskName(TskId,FullName), PipeName); + + *PipeIdPtr = OriginalPipeIdParamValue; + + break; + case OS_ERR_NO_FREE_IDS: + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_NO_FREE_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, + "CreatePipeErr:OS_QueueCreate failed, no free id's (app=%s)", + CFE_SB_GetAppTskName(TskId,FullName)); + + break; + default: + CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID,CFE_EVS_EventType_ERROR,CFE_SB.AppId, "CreatePipeErr:OS_QueueCreate returned %d,app %s", (int)Status,CFE_SB_GetAppTskName(TskId,FullName)); + }/* end switch(Status) */ + return CFE_SB_PIPE_CR_ERR; }/* end if */