Skip to content

Commit

Permalink
Merge pull request #41 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
Integration Candidate: 2020-05-20
  • Loading branch information
astrogeco authored May 29, 2020
2 parents 27a2bd7 + e5600d1 commit 2e8c267
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 117 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ To change the list of packets that sch_lab sends out, edit the schedule table lo

## Version History

### Development Build: 2.3.7

- Apply the CFE_SB_MsgIdToValue() and CFE_SB_ValueToMsgId() routines where compatibility with an integer MsgId is necessary - syslog prints, events, compile-time MID #define values.
- See <https://github.com/nasa/sch_lab/pull/41>

### Development Build: 2.3.6

- Apply the CFE_SB_MsgIdToValue() and CFE_SB_ValueToMsgId() routines where compatibility with an integer MsgId is necessary - syslog prints, events, compile-time MID #define values.
Expand Down
5 changes: 2 additions & 3 deletions fsw/mission_inc/sch_lab_perfids.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
**
** File: sch_lab_perfids.h
**
** Purpose:
** Purpose:
** Define SCH Lab Performance IDs
**
** Notes:
Expand All @@ -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_ */

Expand Down
17 changes: 7 additions & 10 deletions fsw/platform_inc/sch_lab_sched_tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"

/*
Expand All @@ -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;

142 changes: 63 additions & 79 deletions fsw/src/sch_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
**
** File: sch_lab_app.c
**
** Purpose:
** Purpose:
** This file contains the source code for the SCH lab application
**
** Notes:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -88,47 +87,45 @@ 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);

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);
Expand All @@ -138,84 +135,77 @@ 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
{
/*
** 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;
Expand All @@ -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*/
Loading

0 comments on commit 2e8c267

Please sign in to comment.