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 #219, #93, Add EVS port timestamp and simplify port selection #2295

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix #219, #93, Add EVS port timestamp and simplify port selection
  • Loading branch information
skliper committed Apr 17, 2023
commit 1dc455b9b236575253f8cebe2a9c79c9bab93f5c
11 changes: 11 additions & 0 deletions cmake/sample_defs/cpu1_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,17 @@
*/
#define CFE_PLATFORM_EVS_DEFAULT_MSG_FORMAT_MODE CFE_EVS_MsgFormat_LONG

/**
** \cfeevscfg Include time in port send
**
** \par Description:
** Includes the time when sending events out a port
**
** \par Limits
** Set as true or false
*/
#define CFE_PLATFORM_EVS_INCLUDE_TIME_IN_PORT_SEND false

/* Platform Configuration Parameters for Table Service (TBL) */

/**
Expand Down
37 changes: 4 additions & 33 deletions modules/evs/fsw/src/cfe_evs_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ int32 CFE_EVS_EarlyInit(void)
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort = CFE_PLATFORM_EVS_PORT_DEFAULT;
CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE;

CFE_EVS_Global.EVS_EventBurstMax = CFE_PLATFORM_EVS_MAX_APP_EVENT_BURST;
CFE_EVS_Global.EVS_EventBurstMax = CFE_PLATFORM_EVS_MAX_APP_EVENT_BURST;
CFE_EVS_Global.IncludeTimeInPortSend = CFE_PLATFORM_EVS_INCLUDE_TIME_IN_PORT_SEND;

/* Get a pointer to the CFE reset area from the BSP */
PspStatus = CFE_PSP_GetResetArea(&resetAreaAddr, &resetAreaSize);
Expand Down Expand Up @@ -491,22 +492,7 @@ int32 CFE_EVS_EnablePortsCmd(const CFE_EVS_EnablePortsCmd_t *data)
else
{
/* Process command data */
if (((CmdPtr->BitMask & CFE_EVS_PORT1_BIT) >> 0) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT1_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT2_BIT) >> 1) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT2_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT3_BIT) >> 2) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT3_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT4_BIT) >> 3) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CFE_EVS_PORT4_BIT;
}
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort |= CmdPtr->BitMask;

EVS_SendEvent(CFE_EVS_ENAPORT_EID, CFE_EVS_EventType_DEBUG,
"Enable Ports Command Received with Port Bit Mask = 0x%02x", (unsigned int)CmdPtr->BitMask);
Expand Down Expand Up @@ -538,22 +524,7 @@ int32 CFE_EVS_DisablePortsCmd(const CFE_EVS_DisablePortsCmd_t *data)
else
{
/* Process command data */
if (((CmdPtr->BitMask & CFE_EVS_PORT1_BIT) >> 0) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT1_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT2_BIT) >> 1) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT2_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT3_BIT) >> 2) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT3_BIT;
}
if (((CmdPtr->BitMask & CFE_EVS_PORT4_BIT) >> 3) == true)
{
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CFE_EVS_PORT4_BIT;
}
CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort &= ~CmdPtr->BitMask;

EVS_SendEvent(CFE_EVS_DISPORT_EID, CFE_EVS_EventType_DEBUG,
"Disable Ports Command Received with Port Bit Mask = 0x%02x", (unsigned int)CmdPtr->BitMask);
Expand Down
1 change: 1 addition & 0 deletions modules/evs/fsw/src/cfe_evs_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef struct
osal_id_t EVS_SharedDataMutexID;
CFE_ES_AppId_t EVS_AppID;
uint32 EVS_EventBurstMax;
bool IncludeTimeInPortSend; /* Includes time in message sent out ports */
} CFE_EVS_Global_t;

/*
Expand Down
92 changes: 27 additions & 65 deletions modules/evs/fsw/src/cfe_evs_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@

/* Local Function Prototypes */
void EVS_SendViaPorts(CFE_EVS_LongEventTlm_t *EVS_PktPtr);
void EVS_OutputPort1(char *Message);
void EVS_OutputPort2(char *Message);
void EVS_OutputPort3(char *Message);
void EVS_OutputPort4(char *Message);
void EVS_OutputPort(uint8 PortNum, char *Message);

/* Function Definitions */

Expand Down Expand Up @@ -541,50 +538,45 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1
*-----------------------------------------------------------------*/
void EVS_SendViaPorts(CFE_EVS_LongEventTlm_t *EVS_PktPtr)
{
char PortMessage[CFE_EVS_MAX_PORT_MSG_LENGTH];
char PortMessage[CFE_EVS_MAX_PORT_MSG_LENGTH];
char TimeBuffer[CFE_TIME_PRINTED_STRING_SIZE] = "";
char Separator[2] = "";
CFE_TIME_SysTime_t PktTime;

if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT1_BIT) >> 0) == true)
if (CFE_EVS_Global.IncludeTimeInPortSend)
{
CFE_MSG_GetMsgTime(CFE_MSG_PTR(EVS_PktPtr->TelemetryHeader), &PktTime);
CFE_TIME_Print(TimeBuffer, PktTime);
snprintf(Separator, sizeof(Separator), " ");
}

snprintf(PortMessage, sizeof(PortMessage), "%s%s%u/%u/%s %u: %s", TimeBuffer, Separator,
(unsigned int)EVS_PktPtr->Payload.PacketID.SpacecraftID,
(unsigned int)EVS_PktPtr->Payload.PacketID.ProcessorID, EVS_PktPtr->Payload.PacketID.AppName,
(unsigned int)EVS_PktPtr->Payload.PacketID.EventID, EVS_PktPtr->Payload.Message);

if (CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT1_BIT)
{
/* Copy event message to string format */
snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port1 %u/%u/%s %u: %s",
(unsigned int)EVS_PktPtr->Payload.PacketID.SpacecraftID,
(unsigned int)EVS_PktPtr->Payload.PacketID.ProcessorID, EVS_PktPtr->Payload.PacketID.AppName,
(unsigned int)EVS_PktPtr->Payload.PacketID.EventID, EVS_PktPtr->Payload.Message);
/* Send string event out port #1 */
EVS_OutputPort1(PortMessage);
EVS_OutputPort(1, PortMessage);
}

if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT2_BIT) >> 1) == true)
if (CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT2_BIT)
{
/* Copy event message to string format */
snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port2 %u/%u/%s %u: %s",
(unsigned int)EVS_PktPtr->Payload.PacketID.SpacecraftID,
(unsigned int)EVS_PktPtr->Payload.PacketID.ProcessorID, EVS_PktPtr->Payload.PacketID.AppName,
(unsigned int)EVS_PktPtr->Payload.PacketID.EventID, EVS_PktPtr->Payload.Message);
/* Send string event out port #2 */
EVS_OutputPort2(PortMessage);
EVS_OutputPort(2, PortMessage);
}

if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT3_BIT) >> 2) == true)
if (CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT3_BIT)
{
/* Copy event message to string format */
snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port3 %u/%u/%s %u: %s",
(unsigned int)EVS_PktPtr->Payload.PacketID.SpacecraftID,
(unsigned int)EVS_PktPtr->Payload.PacketID.ProcessorID, EVS_PktPtr->Payload.PacketID.AppName,
(unsigned int)EVS_PktPtr->Payload.PacketID.EventID, EVS_PktPtr->Payload.Message);
/* Send string event out port #3 */
EVS_OutputPort3(PortMessage);
EVS_OutputPort(3, PortMessage);
}

if (((CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT4_BIT) >> 3) == true)
if (CFE_EVS_Global.EVS_TlmPkt.Payload.OutputPort & CFE_EVS_PORT4_BIT)
{
/* Copy event message to string format */
snprintf(PortMessage, CFE_EVS_MAX_PORT_MSG_LENGTH, "EVS Port4 %u/%u/%s %u: %s",
(unsigned int)EVS_PktPtr->Payload.PacketID.SpacecraftID,
(unsigned int)EVS_PktPtr->Payload.PacketID.ProcessorID, EVS_PktPtr->Payload.PacketID.AppName,
(unsigned int)EVS_PktPtr->Payload.PacketID.EventID, EVS_PktPtr->Payload.Message);
/* Send string event out port #4 */
EVS_OutputPort4(PortMessage);
EVS_OutputPort(4, PortMessage);
}
}

Expand All @@ -593,39 +585,9 @@ void EVS_SendViaPorts(CFE_EVS_LongEventTlm_t *EVS_PktPtr)
* Internal helper routine only, not part of API.
*
*-----------------------------------------------------------------*/
void EVS_OutputPort1(char *Message)
{
OS_printf("%s\n", Message);
}

/*----------------------------------------------------------------
*
* Internal helper routine only, not part of API.
*
*-----------------------------------------------------------------*/
void EVS_OutputPort2(char *Message)
{
OS_printf("%s\n", Message);
}

/*----------------------------------------------------------------
*
* Internal helper routine only, not part of API.
*
*-----------------------------------------------------------------*/
void EVS_OutputPort3(char *Message)
{
OS_printf("%s\n", Message);
}

/*----------------------------------------------------------------
*
* Internal helper routine only, not part of API.
*
*-----------------------------------------------------------------*/
void EVS_OutputPort4(char *Message)
void EVS_OutputPort(uint8 PortNum, char *Message)
{
OS_printf("%s\n", Message);
OS_printf("EVS Port%u %s\n", PortNum, Message);
}

/*----------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions modules/evs/fsw/src/cfe_evs_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#error CFE_PLATFORM_EVS_DEFAULT_LOG_MODE can only be 0 (Overwrite) or 1 (Discard)!
#endif

#if (CFE_PLATFORM_EVS_INCLUDE_TIME_IN_PORT_SEND != true) && (CFE_PLATFORM_EVS_INCLUDE_TIME_IN_PORT_SEND != false)
#error CFE_PLATFORM_EVS_INCLUDE_TIME_IN_PORT_SEND must be true or false
#endif

#if (CFE_PLATFORM_EVS_DEFAULT_MSG_FORMAT_MODE != CFE_EVS_MsgFormat_LONG) && \
(CFE_PLATFORM_EVS_DEFAULT_MSG_FORMAT_MODE != CFE_EVS_MsgFormat_SHORT)
#error CFE_EVS_DEFAULT_MSG_FORMAT can only be CFE_EVS_MsgFormat_LONG or CFE_EVS_MsgFormat_SHORT !
Expand Down
15 changes: 14 additions & 1 deletion modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void Test_Init(void)
UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS);
UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, CFE_PSP_RST_TYPE_POWERON);
CFE_EVS_EarlyInit();
CFE_EVS_Global.IncludeTimeInPortSend = false; /* Do generic testing without time in port message */
CFE_UtAssert_SYSLOG(EVS_SYSLOG_MSGS[4]);

/* Task main with init failure */
Expand Down Expand Up @@ -359,6 +360,7 @@ void Test_Init(void)
UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS);
UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, CFE_PSP_RST_TYPE_POWERON);
CFE_EVS_EarlyInit();
CFE_EVS_Global.IncludeTimeInPortSend = false; /* Do generic testing without time in port message */
CFE_UtAssert_SYSLOG(EVS_SYSLOG_MSGS[4]);

/* Test task initialization where event services fails */
Expand Down Expand Up @@ -812,7 +814,9 @@ void Test_Ports(void)
{
CFE_EVS_BitMaskCmd_t bitmaskcmd;
UT_SoftwareBusSnapshot_Entry_t LocalSnapshotData = {.MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_LONG_EVENT_MSG_MID)};
CFE_TIME_SysTime_t PacketTime;

memset(&PacketTime, 0, sizeof(PacketTime));
memset(&bitmaskcmd, 0, sizeof(bitmaskcmd));

UtPrintf("Begin Test Ports");
Expand All @@ -829,8 +833,17 @@ void Test_Ports(void)
/* Test that ports are enabled by sending a message */
UT_InitData();
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Test ports message");
UtAssert_UINT32_EQ(CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Test ports message"), CFE_SUCCESS);
UtAssert_UINT32_EQ(LocalSnapshotData.Count, 1);
UtAssert_STUB_COUNT(CFE_TIME_Print, 0);

/* Test with time included */
UT_InitData();
CFE_EVS_Global.IncludeTimeInPortSend = true;
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgTime), &PacketTime, sizeof(PacketTime), false);
UtAssert_UINT32_EQ(CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Test ports message"), CFE_SUCCESS);
UtAssert_STUB_COUNT(CFE_TIME_Print, 1);
CFE_EVS_Global.IncludeTimeInPortSend = false; /* Do generic testing without time in port message */

/* Disable all ports to cut down on unneeded output */
UT_InitData();
Expand Down