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

to_lab Integration candidate: Equuleus-rc1+dev19 #203

Merged
merged 5 commits into from
Oct 3, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Development Build: equuleus-rc1+dev62
- Rename CommandCode variable to Fcncode
- Light initialization logic refactor + remove multiple returns
- See <https://github.com/nasa/to_lab/pull/171> and <https://github.com/nasa/to_lab/pull/180>

## Development Build: equuleus-rc1+dev56
- Add CFE_EVS_SHORT_EVENT_MSG_MID to to_lab_sub.c
- See <https://github.com/nasa/to_lab/pull/198>
Expand Down
141 changes: 78 additions & 63 deletions fsw/src/to_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ CFE_Status_t TO_LAB_init(void)
uint16 i;
char ToTlmPipeName[16];
uint16 ToTlmPipeDepth;
void * TblPtr;
void *TblPtr;
TO_LAB_Sub_t *SubEntry;
char VersionString[TO_LAB_CFG_MAX_VERSION_STR_LEN];

Expand All @@ -126,97 +126,112 @@ CFE_Status_t TO_LAB_init(void)
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("TO_LAB: Error registering for Event Services, RC = 0x%08X\n", (unsigned int)status);
return status;
}

/*
** Initialize housekeeping packet (clear user data area)...
*/
CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_HK_TLM_MID),
sizeof(TO_LAB_Global.HkTlm));
if (status == CFE_SUCCESS)
{
/*
** Initialize housekeeping packet (clear user data area)...
*/
CFE_MSG_Init(CFE_MSG_PTR(TO_LAB_Global.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(TO_LAB_HK_TLM_MID),
sizeof(TO_LAB_Global.HkTlm));

status =
CFE_TBL_Register(&TO_LAB_Global.SubsTblHandle, "TO_LAB_Subs", sizeof(TO_LAB_Subs_t), CFE_TBL_OPT_DEFAULT, NULL);
status = CFE_TBL_Register(&TO_LAB_Global.SubsTblHandle, "TO_LAB_Subs", sizeof(TO_LAB_Subs_t),
CFE_TBL_OPT_DEFAULT, NULL);

if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't register table status %i",
__LINE__, (int)status);
return status;
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't register table status %i",
__LINE__, (int)status);
}
}

status = CFE_TBL_Load(TO_LAB_Global.SubsTblHandle, CFE_TBL_SRC_FILE, "/cf/to_lab_sub.tbl");

if (status != CFE_SUCCESS)
if (status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't load table status %i", __LINE__,
(int)status);
return status;
}
status = CFE_TBL_Load(TO_LAB_Global.SubsTblHandle, CFE_TBL_SRC_FILE, "/cf/to_lab_sub.tbl");

status = CFE_TBL_GetAddress((void **)&TblPtr, TO_LAB_Global.SubsTblHandle);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't load table status %i",
__LINE__, (int)status);
}
}

if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED)
if (status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't get table addr status %i",
__LINE__, (int)status);
return status;
status = CFE_TBL_GetAddress((void **)&TblPtr, TO_LAB_Global.SubsTblHandle);

if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED)
{
CFE_EVS_SendEvent(TO_LAB_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't get table addr status %i",
__LINE__, (int)status);
}
}

TO_LAB_Global.SubsTblPtr = TblPtr; /* Save returned address */
if (status == CFE_SUCCESS || status == CFE_TBL_INFO_UPDATED)
{
TO_LAB_Global.SubsTblPtr = TblPtr; /* Save returned address */

/* Subscribe to my commands */
status = CFE_SB_CreatePipe(&TO_LAB_Global.Cmd_pipe, PipeDepth, PipeName);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create cmd pipe status %i",
__LINE__, (int)status);
}
}

/* Subscribe to my commands */
status = CFE_SB_CreatePipe(&TO_LAB_Global.Cmd_pipe, PipeDepth, PipeName);
if (status == CFE_SUCCESS)
{

CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_CMD_MID), TO_LAB_Global.Cmd_pipe);
CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe);
}
else
CFE_EVS_SendEvent(TO_LAB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create cmd pipe status %i",
__LINE__, (int)status);

/* Create TO TLM pipe */
status = CFE_SB_CreatePipe(&TO_LAB_Global.Tlm_pipe, ToTlmPipeDepth, ToTlmPipeName);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create Tlm pipe status %i",
__LINE__, (int)status);
/* Create TO TLM pipe */
status = CFE_SB_CreatePipe(&TO_LAB_Global.Tlm_pipe, ToTlmPipeDepth, ToTlmPipeName);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create Tlm pipe status %i",
__LINE__, (int)status);
}
}

/* Subscriptions for TLM pipe*/
SubEntry = TO_LAB_Global.SubsTblPtr->Subs;
for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++)
if (status == CFE_SUCCESS)
{
if (!CFE_SB_IsValidMsgId(SubEntry->Stream))
/* Subscriptions for TLM pipe*/
SubEntry = TO_LAB_Global.SubsTblPtr->Subs;
for (i = 0; i < TO_LAB_MAX_SUBSCRIPTIONS; i++)
{
/* Only process until invalid MsgId is found*/
break;
}
if (!CFE_SB_IsValidMsgId(SubEntry->Stream))
{
/* Only process until invalid MsgId is found*/
break;
}

status = CFE_SB_SubscribeEx(SubEntry->Stream, TO_LAB_Global.Tlm_pipe, SubEntry->Flags, SubEntry->BufLimit);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO Can't subscribe to stream 0x%x status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status);
status = CFE_SB_SubscribeEx(SubEntry->Stream, TO_LAB_Global.Tlm_pipe, SubEntry->Flags, SubEntry->BufLimit);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_LAB_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO Can't subscribe to stream 0x%x status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(SubEntry->Stream), (int)status);
}

++SubEntry;
}

++SubEntry;
CFE_Config_GetVersionString(VersionString, TO_LAB_CFG_MAX_VERSION_STR_LEN, "TO Lab", TO_LAB_VERSION,
TO_LAB_BUILD_CODENAME, TO_LAB_LAST_OFFICIAL);

CFE_EVS_SendEvent(TO_LAB_INIT_INF_EID, CFE_EVS_EventType_INFORMATION,
"TO Lab Initialized.%s, Awaiting enable command.", VersionString);
}

/*
** Install the delete handler
*/
** Install the delete handler
*/
OS_TaskInstallDeleteHandler(&TO_LAB_delete_callback);

CFE_Config_GetVersionString(VersionString, TO_LAB_CFG_MAX_VERSION_STR_LEN, "TO Lab",
TO_LAB_VERSION, TO_LAB_BUILD_CODENAME, TO_LAB_LAST_OFFICIAL);

CFE_EVS_SendEvent(TO_LAB_INIT_INF_EID, CFE_EVS_EventType_INFORMATION,
"TO Lab Initialized.%s, Awaiting enable command.", VersionString);

return CFE_SUCCESS;
return status;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand Down Expand Up @@ -272,7 +287,7 @@ void TO_LAB_forward_telemetry(void)
int32 OsStatus;
CFE_Status_t CfeStatus;
CFE_SB_Buffer_t *SBBufPtr;
const void * NetBufPtr;
const void *NetBufPtr;
size_t NetBufSize;
uint32 PktCount = 0;

Expand Down
9 changes: 5 additions & 4 deletions fsw/src/to_lab_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr)
{
CFE_MSG_FcnCode_t CommandCode = 0;
CFE_MSG_FcnCode_t FcnCode = 0;

CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode);
CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &FcnCode);

switch (CommandCode)
switch (FcnCode)
{
case TO_LAB_NOOP_CC:
TO_LAB_NoopCmd((const TO_LAB_NoopCmd_t *)SBBufPtr);
Expand Down Expand Up @@ -74,8 +74,9 @@ void TO_LAB_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr)
default:
CFE_EVS_SendEvent(TO_LAB_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x", __LINE__,
(unsigned int)CommandCode);
(unsigned int)FcnCode);
++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter;
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion fsw/src/to_lab_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define TO_LAB_VERSION_H

/* Development Build Macro Definitions */
#define TO_LAB_BUILD_NUMBER 56 /*!< Development Build: Number of commits since baseline */
#define TO_LAB_BUILD_NUMBER 62 /*!< Development Build: Number of commits since baseline */
#define TO_LAB_BUILD_BASELINE "equuleus-rc1" /*!< Development Build: git tag that is the base for the current development */
#define TO_LAB_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define TO_LAB_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
Loading