Skip to content

Commit

Permalink
Fix nasa#67, Standardize naming of TO_LAB functions/macros etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Sep 30, 2022
1 parent a6ab386 commit c5be117
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 75 deletions.
4 changes: 2 additions & 2 deletions fsw/mission_inc/to_lab_perfids.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef TO_LAB_PERFIDS_H
#define TO_LAB_PERFIDS_H

#define TO_MAIN_TASK_PERF_ID 34
#define TO_SOCKET_SEND_PERF_ID 35
#define TO_LAB_MAIN_TASK_PERF_ID 34
#define TO_LAB_SOCKET_SEND_PERF_ID 35

#endif
84 changes: 42 additions & 42 deletions fsw/src/to_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ int32 TO_LAB_SendHousekeeping(const CFE_MSG_CommandHeader_t *data);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_Lab_AppMain() -- Application entry point and main process loop */
/* TO_LAB_AppMain() -- Application entry point and main process loop */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_Lab_AppMain(void)
void TO_LAB_AppMain(void)
{
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
int32 status;

CFE_ES_PerfLogEntry(TO_MAIN_TASK_PERF_ID);
CFE_ES_PerfLogEntry(TO_LAB_MAIN_TASK_PERF_ID);

status = TO_LAB_init();

Expand All @@ -95,11 +95,11 @@ void TO_Lab_AppMain(void)
*/
while (CFE_ES_RunLoop(&RunStatus) == true)
{
CFE_ES_PerfLogExit(TO_MAIN_TASK_PERF_ID);
CFE_ES_PerfLogExit(TO_LAB_MAIN_TASK_PERF_ID);

OS_TaskDelay(TO_TASK_MSEC); /*2 Hz*/
OS_TaskDelay(TO_LAB_TASK_MSEC); /*2 Hz*/

CFE_ES_PerfLogEntry(TO_MAIN_TASK_PERF_ID);
CFE_ES_PerfLogEntry(TO_LAB_MAIN_TASK_PERF_ID);

TO_LAB_forward_telemetry();

Expand All @@ -114,7 +114,7 @@ void TO_Lab_AppMain(void)
** This function will be called in the event that the TO app is killed.
** It will close the network socket for TO
*/
void TO_delete_callback(void)
void TO_LAB_delete_callback(void)
{
OS_printf("TO delete callback -- Closing TO Network socket.\n");
if (TO_LAB_Global.downlink_on)
Expand All @@ -125,7 +125,7 @@ void TO_delete_callback(void)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_init() -- TO initialization */
/* TO_LAB_init() -- TO initialization */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 TO_LAB_init(void)
Expand Down Expand Up @@ -157,7 +157,7 @@ int32 TO_LAB_init(void)

if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't register table status %i", __LINE__,
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;
}
Expand All @@ -166,7 +166,7 @@ int32 TO_LAB_init(void)

if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(TO_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't load table status %i", __LINE__,
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;
}
Expand All @@ -175,7 +175,7 @@ int32 TO_LAB_init(void)

if (status != CFE_SUCCESS && status != CFE_TBL_INFO_UPDATED)
{
CFE_EVS_SendEvent(TO_TBL_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't get table addr status %i", __LINE__,
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;
}
Expand All @@ -188,14 +188,14 @@ int32 TO_LAB_init(void)
CFE_SB_Subscribe(CFE_SB_ValueToMsgId(TO_LAB_SEND_HK_MID), TO_LAB_Global.Cmd_pipe);
}
else
CFE_EVS_SendEvent(TO_CRCMDPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create cmd pipe status %i",
CFE_EVS_SendEvent(TO_LAB_CRCMDPIPE_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_TLMPIPE_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't create Tlm pipe status %i",
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);
}

Expand All @@ -204,7 +204,7 @@ int32 TO_LAB_init(void)
{
if (!CFE_SB_IsValidMsgId(TO_LAB_Subs->Subs[i].Stream))
{
/* Only process until invalid MsgId (aka TO_UNUSED) is found*/
/* Only process until invalid MsgId (aka TO_LAB_UNUSED) is found*/
break;
}
else if (CFE_SB_IsValidMsgId(TO_LAB_Subs->Subs[i].Stream))
Expand All @@ -214,17 +214,17 @@ int32 TO_LAB_init(void)
}

if (status != CFE_SUCCESS)
CFE_EVS_SendEvent(TO_SUBSCRIBE_ERR_EID, CFE_EVS_EventType_ERROR,
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(TO_LAB_Subs->Subs[i].Stream), (int)status);
}

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

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

return CFE_SUCCESS;
Expand All @@ -242,7 +242,7 @@ int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutputCmd_t *data)
(void)CFE_SB_MessageStringGet(TO_LAB_Global.tlm_dest_IP, pCmd->dest_IP, "", sizeof(TO_LAB_Global.tlm_dest_IP),
sizeof(pCmd->dest_IP));
TO_LAB_Global.suppress_sendto = false;
CFE_EVS_SendEvent(TO_TLMOUTENA_INF_EID, CFE_EVS_EventType_INFORMATION, "TO telemetry output enabled for IP %s",
CFE_EVS_SendEvent(TO_LAB_TLMOUTENA_INF_EID, CFE_EVS_EventType_INFORMATION, "TO telemetry output enabled for IP %s",
TO_LAB_Global.tlm_dest_IP);

if (!TO_LAB_Global.downlink_on) /* Then turn it on, otherwise we will just switch destination addresses*/
Expand All @@ -257,7 +257,7 @@ int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutputCmd_t *data)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_process_commands() -- Process command pipe message */
/* TO_LAB_process_commands() -- Process command pipe message */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_LAB_process_commands(void)
Expand Down Expand Up @@ -285,7 +285,7 @@ void TO_LAB_process_commands(void)
break;

default:
CFE_EVS_SendEvent(TO_MSGID_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO: Invalid Msg ID Rcvd 0x%x",
CFE_EVS_SendEvent(TO_LAB_MSGID_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO: Invalid Msg ID Rcvd 0x%x",
__LINE__, (unsigned int)CFE_SB_MsgIdToValue(MsgId));
break;
}
Expand All @@ -299,7 +299,7 @@ void TO_LAB_process_commands(void)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_exec_local_command() -- Process local message */
/* TO_LAB_exec_local_command() -- Process local message */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_LAB_exec_local_command(CFE_SB_Buffer_t *SBBufPtr)
Expand All @@ -310,36 +310,36 @@ void TO_LAB_exec_local_command(CFE_SB_Buffer_t *SBBufPtr)

switch (CommandCode)
{
case TO_NOP_CC:
case TO_LAB_NOOP_CC:
TO_LAB_Noop((const TO_LAB_NoopCmd_t *)SBBufPtr);
break;

case TO_RESET_STATUS_CC:
case TO_LAB_RESET_STATUS_CC:
TO_LAB_ResetCounters((const TO_LAB_ResetCountersCmd_t *)SBBufPtr);
break;

case TO_SEND_DATA_TYPES_CC:
case TO_LAB_SEND_DATA_TYPES_CC:
TO_LAB_SendDataTypes((const TO_LAB_SendDataTypesCmd_t *)SBBufPtr);
break;

case TO_ADD_PKT_CC:
case TO_LAB_ADD_PKT_CC:
TO_LAB_AddPacket((const TO_LAB_AddPacketCmd_t *)SBBufPtr);
break;

case TO_REMOVE_PKT_CC:
case TO_LAB_REMOVE_PKT_CC:
TO_LAB_RemovePacket((const TO_LAB_RemovePacketCmd_t *)SBBufPtr);
break;

case TO_REMOVE_ALL_PKT_CC:
case TO_LAB_REMOVE_ALL_PKT_CC:
TO_LAB_RemoveAll((const TO_LAB_RemoveAllCmd_t *)SBBufPtr);
break;

case TO_OUTPUT_ENABLE_CC:
case TO_LAB_OUTPUT_ENABLE_CC:
TO_LAB_EnableOutput((const TO_LAB_EnableOutputCmd_t *)SBBufPtr);
break;

default:
CFE_EVS_SendEvent(TO_FNCODE_ERR_EID, CFE_EVS_EventType_ERROR,
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);
++TO_LAB_Global.HkTlm.Payload.CommandErrorCounter;
Expand All @@ -353,7 +353,7 @@ void TO_LAB_exec_local_command(CFE_SB_Buffer_t *SBBufPtr)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 TO_LAB_Noop(const TO_LAB_NoopCmd_t *data)
{
CFE_EVS_SendEvent(TO_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command");
CFE_EVS_SendEvent(TO_LAB_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command");
++TO_LAB_Global.HkTlm.Payload.CommandCounter;
return CFE_SUCCESS;
}
Expand Down Expand Up @@ -435,7 +435,7 @@ int32 TO_LAB_SendHousekeeping(const CFE_MSG_CommandHeader_t *data)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_openTLM() -- Open TLM */
/* TO_LAB_openTLM() -- Open TLM */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_LAB_openTLM(void)
Expand All @@ -445,7 +445,7 @@ void TO_LAB_openTLM(void)
status = OS_SocketOpen(&TO_LAB_Global.TLMsockid, OS_SocketDomain_INET, OS_SocketType_DATAGRAM);
if (status != OS_SUCCESS)
{
CFE_EVS_SendEvent(TO_TLMOUTSOCKET_ERR_EID, CFE_EVS_EventType_ERROR, "L%d, TO TLM socket error: %d", __LINE__,
CFE_EVS_SendEvent(TO_LAB_TLMOUTSOCKET_ERR_EID, CFE_EVS_EventType_ERROR, "L%d, TO TLM socket error: %d", __LINE__,
(int)status);
}

Expand All @@ -465,10 +465,10 @@ int32 TO_LAB_AddPacket(const TO_LAB_AddPacketCmd_t *data)
status = CFE_SB_SubscribeEx(pCmd->Stream, TO_LAB_Global.Tlm_pipe, pCmd->Flags, pCmd->BufLimit);

if (status != CFE_SUCCESS)
CFE_EVS_SendEvent(TO_ADDPKT_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe 0x%x status %i", __LINE__,
CFE_EVS_SendEvent(TO_LAB_ADDPKT_ERR_EID, CFE_EVS_EventType_ERROR, "L%d TO Can't subscribe 0x%x status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status);
else
CFE_EVS_SendEvent(TO_ADDPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO AddPkt 0x%x, QoS %d.%d, limit %d",
CFE_EVS_SendEvent(TO_LAB_ADDPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO AddPkt 0x%x, QoS %d.%d, limit %d",
__LINE__, (unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), pCmd->Flags.Priority,
pCmd->Flags.Reliability, pCmd->BufLimit);

Expand All @@ -488,11 +488,11 @@ int32 TO_LAB_RemovePacket(const TO_LAB_RemovePacketCmd_t *data)

status = CFE_SB_Unsubscribe(pCmd->Stream, TO_LAB_Global.Tlm_pipe);
if (status != CFE_SUCCESS)
CFE_EVS_SendEvent(TO_REMOVEPKT_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO Can't Unsubscribe to Stream 0x%x, status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream), (int)status);
else
CFE_EVS_SendEvent(TO_REMOVEPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO RemovePkt 0x%x", __LINE__,
CFE_EVS_SendEvent(TO_LAB_REMOVEPKT_INF_EID, CFE_EVS_EventType_INFORMATION, "L%d TO RemovePkt 0x%x", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(pCmd->Stream));
++TO_LAB_Global.HkTlm.Payload.CommandCounter;
return CFE_SUCCESS;
Expand All @@ -515,13 +515,13 @@ int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAllCmd_t *data)
status = CFE_SB_Unsubscribe(TO_LAB_Subs->Subs[i].Stream, TO_LAB_Global.Tlm_pipe);

if (status != CFE_SUCCESS)
CFE_EVS_SendEvent(TO_REMOVEALLPTKS_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(TO_LAB_REMOVEALLPTKS_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO Can't Unsubscribe to stream 0x%x status %i", __LINE__,
(unsigned int)CFE_SB_MsgIdToValue(TO_LAB_Subs->Subs[i].Stream), (int)status);
}
}

CFE_EVS_SendEvent(TO_REMOVEALLPKTS_INF_EID, CFE_EVS_EventType_INFORMATION,
CFE_EVS_SendEvent(TO_LAB_REMOVEALLPKTS_INF_EID, CFE_EVS_EventType_INFORMATION,
"L%d TO Unsubscribed to all Commands and Telemetry", __LINE__);

++TO_LAB_Global.HkTlm.Payload.CommandCounter;
Expand All @@ -530,7 +530,7 @@ int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAllCmd_t *data)

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* TO_forward_telemetry() -- Forward telemetry */
/* TO_LAB_forward_telemetry() -- Forward telemetry */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TO_LAB_forward_telemetry(void)
Expand All @@ -556,19 +556,19 @@ void TO_LAB_forward_telemetry(void)

if (TO_LAB_Global.downlink_on == true)
{
CFE_ES_PerfLogEntry(TO_SOCKET_SEND_PERF_ID);
CFE_ES_PerfLogEntry(TO_LAB_SOCKET_SEND_PERF_ID);

status = OS_SocketSendTo(TO_LAB_Global.TLMsockid, SBBufPtr, size, &d_addr);

CFE_ES_PerfLogExit(TO_SOCKET_SEND_PERF_ID);
CFE_ES_PerfLogExit(TO_LAB_SOCKET_SEND_PERF_ID);
}
else
{
status = 0;
}
if (status < 0)
{
CFE_EVS_SendEvent(TO_TLMOUTSTOP_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(TO_LAB_TLMOUTSTOP_ERR_EID, CFE_EVS_EventType_ERROR,
"L%d TO sendto error %d. Tlm output suppressed\n", __LINE__, (int)status);
TO_LAB_Global.suppress_sendto = true;
}
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/to_lab_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

/*****************************************************************************/

#define TO_TASK_MSEC 500 /* run at 2 Hz */
#define TO_UNUSED CFE_SB_MSGID_RESERVED
#define TO_LAB_TASK_MSEC 500 /* run at 2 Hz */
#define TO_LAB_UNUSED CFE_SB_MSGID_RESERVED

/**
* Depth of pipe for commands to the TO_LAB application itself
Expand All @@ -57,7 +57,7 @@
/*
** Prototypes Section
*/
void TO_Lab_AppMain(void);
void TO_LAB_AppMain(void);

/******************************************************************************/

Expand Down
36 changes: 18 additions & 18 deletions fsw/src/to_lab_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
/*****************************************************************************/

/* Event message ID's */
#define TO_EVM_RESERVED 0
#define TO_LAB_EVM_RESERVED 0

#define TO_INIT_INF_EID 1
#define TO_CRCMDPIPE_ERR_EID 2
#define TO_TLMOUTENA_INF_EID 3
#define TO_SUBSCRIBE_ERR_EID 4
#define TO_TLMPIPE_ERR_EID 5
#define TO_TLMOUTSOCKET_ERR_EID 6
#define TO_TLMOUTSTOP_ERR_EID 7
#define TO_MSGID_ERR_EID 8
#define TO_FNCODE_ERR_EID 9
#define TO_ADDPKT_ERR_EID 10
#define TO_REMOVEPKT_ERR_EID 11
#define TO_REMOVEALLPTKS_ERR_EID 12
#define TO_ADDPKT_INF_EID 15
#define TO_REMOVEPKT_INF_EID 16
#define TO_REMOVEALLPKTS_INF_EID 17
#define TO_NOOP_INF_EID 18
#define TO_TBL_ERR_EID 19
#define TO_LAB_INIT_INF_EID 1
#define TO_LAB_CRCMDPIPE_ERR_EID 2
#define TO_LAB_TLMOUTENA_INF_EID 3
#define TO_LAB_SUBSCRIBE_ERR_EID 4
#define TO_LAB_TLMPIPE_ERR_EID 5
#define TO_LAB_TLMOUTSOCKET_ERR_EID 6
#define TO_LAB_TLMOUTSTOP_ERR_EID 7
#define TO_LAB_MSGID_ERR_EID 8
#define TO_LAB_FNCODE_ERR_EID 9
#define TO_LAB_ADDPKT_ERR_EID 10
#define TO_LAB_REMOVEPKT_ERR_EID 11
#define TO_LAB_REMOVEALLPTKS_ERR_EID 12
#define TO_LAB_ADDPKT_INF_EID 15
#define TO_LAB_REMOVEPKT_INF_EID 16
#define TO_LAB_REMOVEALLPKTS_INF_EID 17
#define TO_LAB_NOOP_INF_EID 18
#define TO_LAB_TBL_ERR_EID 19

/******************************************************************************/

Expand Down
Loading

0 comments on commit c5be117

Please sign in to comment.