From 2633a91ee60902afc75a3575e91c496b1a1824ad Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 21 May 2020 11:00:18 -0400 Subject: [PATCH] Fix #30, Apply standard style --- fsw/mission_inc/sch_lab_perfids.h | 5 +- fsw/platform_inc/sch_lab_sched_tab.h | 17 ++-- fsw/src/sch_lab_app.c | 142 ++++++++++++--------------- fsw/src/sch_lab_table.c | 34 +++---- fsw/src/sch_lab_version.h | 10 +- 5 files changed, 91 insertions(+), 117 deletions(-) diff --git a/fsw/mission_inc/sch_lab_perfids.h b/fsw/mission_inc/sch_lab_perfids.h index 797324d..4157931 100644 --- a/fsw/mission_inc/sch_lab_perfids.h +++ b/fsw/mission_inc/sch_lab_perfids.h @@ -20,7 +20,7 @@ ** ** File: sch_lab_perfids.h ** -** Purpose: +** Purpose: ** Define SCH Lab Performance IDs ** ** Notes: @@ -29,8 +29,7 @@ #ifndef _sch_lab_perfids_h_ #define _sch_lab_perfids_h_ - -#define SCH_MAIN_TASK_PERF_ID 36 +#define SCH_MAIN_TASK_PERF_ID 36 #endif /* _sch_lab_perfids_h_ */ diff --git a/fsw/platform_inc/sch_lab_sched_tab.h b/fsw/platform_inc/sch_lab_sched_tab.h index f641d55..37630c7 100644 --- a/fsw/platform_inc/sch_lab_sched_tab.h +++ b/fsw/platform_inc/sch_lab_sched_tab.h @@ -20,7 +20,7 @@ ** ** File: sch_lab_sched_tab.h ** -** Purpose: +** Purpose: ** This file contains the schedule tables for the SCH Lab app. ** It is intended to go in the platform include directory so the SCH_LAB ** app source code does not have to be modified. @@ -29,8 +29,7 @@ ** *************************************************************************/ - -#include "cfe_sb_extern_typedefs.h" /* for CFE_SB_MsgId_t */ +#include "cfe_sb_extern_typedefs.h" /* for CFE_SB_MsgId_t */ #include "cfe_msgids.h" /* @@ -52,22 +51,20 @@ /* ** Defines */ -#define SCH_LAB_END_OF_TABLE 0 -#define SCH_LAB_MAX_SCHEDULE_ENTRIES 32 -#define SCH_TBL_DEFAULT_FILE "/cf/sch_lab_table.tbl" +#define SCH_LAB_END_OF_TABLE 0 +#define SCH_LAB_MAX_SCHEDULE_ENTRIES 32 +#define SCH_TBL_DEFAULT_FILE "/cf/sch_lab_table.tbl" /* ** Typedefs */ typedef struct { - CFE_SB_MsgId_t MessageID; /* Message ID for the table entry */ - uint32 PacketRate; /* Rate: Send packet every N seconds */ + CFE_SB_MsgId_t MessageID; /* Message ID for the table entry */ + uint32 PacketRate; /* Rate: Send packet every N seconds */ } SCH_LAB_ScheduleTableEntry_t; - typedef struct { SCH_LAB_ScheduleTableEntry_t Config[SCH_LAB_MAX_SCHEDULE_ENTRIES]; } SCH_LAB_ScheduleTable_t; - diff --git a/fsw/src/sch_lab_app.c b/fsw/src/sch_lab_app.c index 03b24a7..455cc88 100644 --- a/fsw/src/sch_lab_app.c +++ b/fsw/src/sch_lab_app.c @@ -20,7 +20,7 @@ ** ** File: sch_lab_app.c ** -** Purpose: +** Purpose: ** This file contains the source code for the SCH lab application ** ** Notes: @@ -51,8 +51,8 @@ */ typedef union { - CFE_SB_Msg_t MsgHdr; - CFE_SB_CmdHdr_t CommandHeader; + CFE_SB_Msg_t MsgHdr; + CFE_SB_CmdHdr_t CommandHeader; } SCH_LAB_MessageBuffer_t; typedef struct @@ -64,19 +64,18 @@ typedef struct typedef struct { - SCH_LAB_StateEntry_t State[SCH_LAB_MAX_SCHEDULE_ENTRIES]; - CFE_TBL_Handle_t TblHandle; + SCH_LAB_StateEntry_t State[SCH_LAB_MAX_SCHEDULE_ENTRIES]; + CFE_TBL_Handle_t TblHandle; - CFE_SB_Msg_t *CmdPipePktPtr; - CFE_SB_PipeId_t CmdPipe; + CFE_SB_Msg_t * CmdPipePktPtr; + CFE_SB_PipeId_t CmdPipe; } SCH_LAB_GlobalData_t; /* ** Global Variables */ -SCH_LAB_GlobalData_t SCH_LAB_Global; - +SCH_LAB_GlobalData_t SCH_LAB_Global; /* ** Local Function Prototypes @@ -88,10 +87,10 @@ int32 SCH_LAB_AppInit(void); */ void SCH_Lab_AppMain(void) { - int i; - uint32 SCH_OneHzPktsRcvd = 0; - uint32 Status = CFE_SUCCESS; - uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; + int i; + uint32 SCH_OneHzPktsRcvd = 0; + uint32 Status = CFE_SUCCESS; + uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; SCH_LAB_StateEntry_t *LocalStateEntry; CFE_ES_PerfLogEntry(SCH_MAIN_TASK_PERF_ID); @@ -99,36 +98,34 @@ void SCH_Lab_AppMain(void) CFE_ES_RegisterApp(); Status = SCH_LAB_AppInit(); - if ( Status != CFE_SUCCESS ) + if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("SCH_LAB: Error Initializing RC = 0x%08lX\n", - (unsigned long)Status); + CFE_ES_WriteToSysLog("SCH_LAB: Error Initializing RC = 0x%08lX\n", (unsigned long)Status); + } - } - /* Loop Forever */ while (CFE_ES_RunLoop(&RunStatus) == true) { CFE_ES_PerfLogExit(SCH_MAIN_TASK_PERF_ID); /* Pend on receipt of 1Hz packet */ - Status = CFE_SB_RcvMsg(&SCH_LAB_Global.CmdPipePktPtr,SCH_LAB_Global.CmdPipe,CFE_SB_PEND_FOREVER); + Status = CFE_SB_RcvMsg(&SCH_LAB_Global.CmdPipePktPtr, SCH_LAB_Global.CmdPipe, CFE_SB_PEND_FOREVER); CFE_ES_PerfLogEntry(SCH_MAIN_TASK_PERF_ID); - if(Status == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { SCH_OneHzPktsRcvd++; /* - ** Process table every second, sending packets that are ready + ** Process table every second, sending packets that are ready */ LocalStateEntry = SCH_LAB_Global.State; - for (i = 0; i < SCH_LAB_MAX_SCHEDULE_ENTRIES; i++) + for (i = 0; i < SCH_LAB_MAX_SCHEDULE_ENTRIES; i++) { if (LocalStateEntry->PacketRate != 0) { ++LocalStateEntry->Counter; - if ( LocalStateEntry->Counter >= LocalStateEntry->PacketRate ) + if (LocalStateEntry->Counter >= LocalStateEntry->PacketRate) { LocalStateEntry->Counter = 0; CFE_SB_SendMsg(&LocalStateEntry->MsgBuf.MsgHdr); @@ -138,42 +135,38 @@ void SCH_Lab_AppMain(void) } } - }/* end while */ - - CFE_ES_ExitApp( Status ); - -}/* end SCH_Lab_AppMain */ + } /* end while */ + + CFE_ES_ExitApp(Status); -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ +} /* end SCH_Lab_AppMain */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ /* SCH_LAB_AppInit() -- initialization */ -/* */ +/* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 SCH_LAB_AppInit(void) -{ - int i; - int32 Status; - SCH_LAB_ScheduleTable_t *ConfigTable; +{ + int i; + int32 Status; + SCH_LAB_ScheduleTable_t * ConfigTable; SCH_LAB_ScheduleTableEntry_t *ConfigEntry; - SCH_LAB_StateEntry_t *LocalStateEntry; + SCH_LAB_StateEntry_t * LocalStateEntry; memset(&SCH_LAB_Global, 0, sizeof(SCH_LAB_Global)); /* ** Register tables with cFE and load default data */ - Status = CFE_TBL_Register(&SCH_LAB_Global.TblHandle, - "SCH_LAB_SchTbl", - sizeof(SCH_LAB_ScheduleTable_t), - CFE_TBL_OPT_DEFAULT, - NULL); + Status = CFE_TBL_Register(&SCH_LAB_Global.TblHandle, "SCH_LAB_SchTbl", sizeof(SCH_LAB_ScheduleTable_t), + CFE_TBL_OPT_DEFAULT, NULL); - if ( Status != CFE_SUCCESS ) + if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("SCH_LAB: Error Registering SCH_LAB_SchTbl, RC = 0x%08lX\n", - (unsigned long)Status); + CFE_ES_WriteToSysLog("SCH_LAB: Error Registering SCH_LAB_SchTbl, RC = 0x%08lX\n", (unsigned long)Status); - return ( Status ); + return (Status); } else { @@ -181,41 +174,38 @@ int32 SCH_LAB_AppInit(void) ** Loading Table */ Status = CFE_TBL_Load(SCH_LAB_Global.TblHandle, CFE_TBL_SRC_FILE, SCH_TBL_DEFAULT_FILE); - if ( Status != CFE_SUCCESS ) + if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("SCH_LAB: Error Loading Table SCH_LAB_SchTbl, RC = 0x%08lX\n", - (unsigned long)Status); + CFE_ES_WriteToSysLog("SCH_LAB: Error Loading Table SCH_LAB_SchTbl, RC = 0x%08lX\n", (unsigned long)Status); CFE_TBL_ReleaseAddress(SCH_LAB_Global.TblHandle); - return ( Status ); + return (Status); } } /* ** Get Table Address - */ + */ Status = CFE_TBL_GetAddress((void **)&ConfigTable, SCH_LAB_Global.TblHandle); - if ( Status != CFE_SUCCESS && - Status != CFE_TBL_INFO_UPDATED ) + if (Status != CFE_SUCCESS && Status != CFE_TBL_INFO_UPDATED) { CFE_ES_WriteToSysLog("SCH_LAB: Error Getting Table's Address SCH_LAB_SchTbl, RC = 0x%08lX\n", - (unsigned long)Status); + (unsigned long)Status); - return ( Status ); + return (Status); } - + /* ** Initialize the command headers */ - ConfigEntry = ConfigTable->Config; + ConfigEntry = ConfigTable->Config; LocalStateEntry = SCH_LAB_Global.State; - for (i = 0; i < SCH_LAB_MAX_SCHEDULE_ENTRIES; i++) + for (i = 0; i < SCH_LAB_MAX_SCHEDULE_ENTRIES; i++) { if (ConfigEntry->PacketRate != 0) { - CFE_SB_InitMsg(&LocalStateEntry->MsgBuf.MsgHdr, - ConfigEntry->MessageID, - sizeof(LocalStateEntry->MsgBuf), true); + CFE_SB_InitMsg(&LocalStateEntry->MsgBuf.MsgHdr, ConfigEntry->MessageID, sizeof(LocalStateEntry->MsgBuf), + true); LocalStateEntry->PacketRate = ConfigEntry->PacketRate; } ++ConfigEntry; @@ -226,33 +216,27 @@ int32 SCH_LAB_AppInit(void) ** Release the table */ Status = CFE_TBL_ReleaseAddress(SCH_LAB_Global.TblHandle); - if ( Status != CFE_SUCCESS ) + if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("SCH_LAB: Error Releasing Table SCH_LAB_SchTbl, RC = 0x%08lX\n", - (unsigned long)Status); - + CFE_ES_WriteToSysLog("SCH_LAB: Error Releasing Table SCH_LAB_SchTbl, RC = 0x%08lX\n", (unsigned long)Status); } /* Create pipe and subscribe to the 1Hz pkt */ - Status = CFE_SB_CreatePipe(&SCH_LAB_Global.CmdPipe,8,"SCH_LAB_CMD_PIPE"); - if ( Status != CFE_SUCCESS ) + Status = CFE_SB_CreatePipe(&SCH_LAB_Global.CmdPipe, 8, "SCH_LAB_CMD_PIPE"); + if (Status != CFE_SUCCESS) { - OS_printf("SCH Error creating pipe!\n"); + OS_printf("SCH Error creating pipe!\n"); } - - Status = CFE_SB_Subscribe(CFE_TIME_1HZ_CMD_MID,SCH_LAB_Global.CmdPipe); - if ( Status != CFE_SUCCESS ) + + Status = CFE_SB_Subscribe(CFE_TIME_1HZ_CMD_MID, SCH_LAB_Global.CmdPipe); + if (Status != CFE_SUCCESS) { - OS_printf("SCH Error subscribing to 1hz!\n"); + OS_printf("SCH Error subscribing to 1hz!\n"); } - - OS_printf ("SCH Lab Initialized. Version %d.%d.%d.%d\n", - SCH_LAB_MAJOR_VERSION, - SCH_LAB_MINOR_VERSION, - SCH_LAB_REVISION, - SCH_LAB_MISSION_REV); - return( CFE_SUCCESS ); + OS_printf("SCH Lab Initialized. Version %d.%d.%d.%d\n", SCH_LAB_MAJOR_VERSION, SCH_LAB_MINOR_VERSION, + SCH_LAB_REVISION, SCH_LAB_MISSION_REV); -}/*End of AppInit*/ + return (CFE_SUCCESS); +} /*End of AppInit*/ diff --git a/fsw/src/sch_lab_table.c b/fsw/src/sch_lab_table.c index 4bd43fb..05602ba 100644 --- a/fsw/src/sch_lab_table.c +++ b/fsw/src/sch_lab_table.c @@ -20,31 +20,28 @@ ** */ -#include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ -#include "sch_lab_sched_tab.h" -#include "cfe_sb.h" /* Required to use the CFE_SB_MSGID_WRAP_VALUE macro */ +#include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ +#include "sch_lab_sched_tab.h" +#include "cfe_sb.h" /* Required to use the CFE_SB_MSGID_WRAP_VALUE macro */ /* ** SCH Lab schedule table ** When populating this table: ** 1. Make sure the table is terminated by the SCH_LAB_END_OF_TABLE entry -** 2. You can have commented out entries, but a zero MID will terminate the table processing, +** 2. You can have commented out entries, but a zero MID will terminate the table processing, ** skipping the remaining entries. ** 3. If the table grows too big, increase SCH_LAB_MAX_SCHEDULE_ENTRIES */ -SCH_LAB_ScheduleTable_t SCH_TBL_Structure = -{ - .Config = - { - { CFE_SB_MSGID_WRAP_VALUE(CFE_ES_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(CFE_SB_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(CFE_TBL_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(CI_LAB_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(TO_LAB_SEND_HK_MID), 4 }, - { CFE_SB_MSGID_WRAP_VALUE(SAMPLE_APP_SEND_HK_MID), 4 }, +SCH_LAB_ScheduleTable_t SCH_TBL_Structure = {.Config = { + {CFE_SB_MSGID_WRAP_VALUE(CFE_ES_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(CFE_SB_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(CFE_TBL_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(CI_LAB_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(TO_LAB_SEND_HK_MID), 4}, + {CFE_SB_MSGID_WRAP_VALUE(SAMPLE_APP_SEND_HK_MID), 4}, #if 0 { SC_SEND_HK_MID, 4, 0 }, { SC_1HZ_WAKEUP_MID, 1, 0 }, /* Example of a 1hz packet */ @@ -53,8 +50,7 @@ SCH_LAB_ScheduleTable_t SCH_TBL_Structure = { DS_SEND_HK_MID, 4, 0 }, { LC_SEND_HK_MID, 4, 0 }, #endif - } -}; + }}; /* ** The macro below identifies: @@ -63,4 +59,4 @@ SCH_LAB_ScheduleTable_t SCH_TBL_Structure = ** 3) a brief description of the contents of the file image ** 4) the desired name of the table image binary file that is cFE compatible */ -CFE_TBL_FILEDEF(SCH_TBL_Structure, SCH_LAB_APP.SCH_LAB_SchTbl, Schedule Lab MsgID Table, sch_lab_table.tbl ) +CFE_TBL_FILEDEF(SCH_TBL_Structure, SCH_LAB_APP.SCH_LAB_SchTbl, Schedule Lab MsgID Table, sch_lab_table.tbl) diff --git a/fsw/src/sch_lab_version.h b/fsw/src/sch_lab_version.h index ebb7251..e407098 100644 --- a/fsw/src/sch_lab_version.h +++ b/fsw/src/sch_lab_version.h @@ -29,12 +29,10 @@ #ifndef _sch_lab_version_h_ #define _sch_lab_version_h_ - -#define SCH_LAB_MAJOR_VERSION 2 -#define SCH_LAB_MINOR_VERSION 3 -#define SCH_LAB_REVISION 6 -#define SCH_LAB_MISSION_REV 0 - +#define SCH_LAB_MAJOR_VERSION 2 +#define SCH_LAB_MINOR_VERSION 3 +#define SCH_LAB_REVISION 6 +#define SCH_LAB_MISSION_REV 0 #endif /* _sch_lab_version_h_ */