From f972312ad83a0e84d16d8191ac4a93279b3e3cdd Mon Sep 17 00:00:00 2001 From: avan989 Date: Thu, 19 Sep 2019 14:11:18 -0400 Subject: [PATCH] Fix #1, update to match cfe --- fsw/src/sample_app.c | 439 ++++++++++++++++++++++++++++------- fsw/src/sample_app.h | 73 +++++- fsw/src/sample_app_events.h | 22 +- fsw/src/sample_app_msg.h | 31 ++- fsw/src/sample_app_version.h | 14 +- fsw/src/sample_table.c | 49 ++++ 6 files changed, 507 insertions(+), 121 deletions(-) create mode 100644 fsw/src/sample_table.c diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 17ba37c..5a4b027 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -26,108 +26,225 @@ *******************************************************************************/ /* -** Include Files: +** Include Files: */ - -#include "sample_app.h" -#include "sample_app_perfids.h" -#include "sample_app_msgids.h" -#include "sample_app_msg.h" #include "sample_app_events.h" #include "sample_app_version.h" +#include "sample_app.h" + +#include /* ** global data */ +Sample_AppData_t Sample_AppData; -sample_hk_tlm_t SAMPLE_HkTelemetryPkt; -CFE_SB_PipeId_t SAMPLE_CommandPipe; -CFE_SB_MsgPtr_t SAMPLEMsgPtr; - -static CFE_EVS_BinFilter_t SAMPLE_EventFilters[] = - { /* Event ID mask */ - {SAMPLE_STARTUP_INF_EID, 0x0000}, - {SAMPLE_COMMAND_ERR_EID, 0x0000}, - {SAMPLE_COMMANDNOP_INF_EID, 0x0000}, - {SAMPLE_COMMANDRST_INF_EID, 0x0000}, - }; - -/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* SAMPLE_AppMain() -- Application entry point and main process loop */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_AppMain( void ) { int32 status; - uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; + /* + ** Register the app with Executive services + */ + CFE_ES_RegisterApp(); + + /* + ** Create the first Performance Log entry + */ CFE_ES_PerfLogEntry(SAMPLE_APP_PERF_ID); - SAMPLE_AppInit(); + /* + ** Perform application specific initialization + ** If the Initialization fails, set the RunStatus to + ** CFE_ES_APP_ERROR and the App will not enter the RunLoop + */ + status = SAMPLE_AppInit(); + if (status != CFE_SUCCESS) + { + Sample_AppData.RunStatus = CFE_ES_APP_ERROR; + } /* ** SAMPLE Runloop */ - while (CFE_ES_RunLoop(&RunStatus) == true) + while (CFE_ES_RunLoop(&Sample_AppData.RunStatus) == TRUE) { + /* + ** Performance Log Exit Stamp + */ CFE_ES_PerfLogExit(SAMPLE_APP_PERF_ID); - /* Pend on receipt of command packet -- timeout set to 500 millisecs */ - status = CFE_SB_RcvMsg(&SAMPLEMsgPtr, SAMPLE_CommandPipe, 500); - + /* Pend on receipt of command packet */ + status = CFE_SB_RcvMsg(&Sample_AppData.SAMPLEMsgPtr, + Sample_AppData.SAMPLE_CommandPipe, + CFE_SB_PEND_FOREVER); + + /* + ** Performance Log Entry Stamp + */ CFE_ES_PerfLogEntry(SAMPLE_APP_PERF_ID); if (status == CFE_SUCCESS) { - SAMPLE_ProcessCommandPacket(); + SAMPLE_ProcessCommandPacket(Sample_AppData.SAMPLEMsgPtr); + } + else + { + CFE_EVS_SendEvent(SAMPLE_PIPE_ERR_EID, + CFE_EVS_ERROR, + "SAMPLE APP: SB Pipe Read Error, App Will Exit"); + + Sample_AppData.RunStatus = CFE_ES_APP_ERROR; } } - CFE_ES_ExitApp(RunStatus); + /* + ** Performance Log Exit Stamp + */ + CFE_ES_PerfLogExit(SAMPLE_APP_PERF_ID); + + CFE_ES_ExitApp(Sample_AppData.RunStatus); } /* End of SAMPLE_AppMain() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* SAMPLE_AppInit() -- initialization */ +/* SAMPLE_AppInit() -- initialization */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void SAMPLE_AppInit(void) +int32 SAMPLE_AppInit( void ) { + int32 status; + + Sample_AppData.RunStatus = CFE_ES_APP_RUN; + /* - ** Register the app with Executive services + ** Initialize app command execution counters */ - CFE_ES_RegisterApp() ; + Sample_AppData.CmdCounter = 0; + Sample_AppData.ErrCounter = 0; /* - ** Register the events - */ - CFE_EVS_Register(SAMPLE_EventFilters, - sizeof(SAMPLE_EventFilters)/sizeof(CFE_EVS_BinFilter_t), - CFE_EVS_EventFilter_BINARY); + ** Initialize app configuration data + */ + Sample_AppData.PipeDepth = SAMPLE_PIPE_DEPTH; + + strcpy(Sample_AppData.PipeName, "SAMPLE_CMD_PIPE"); /* - ** Create the Software Bus command pipe and subscribe to housekeeping - ** messages + ** Initialize event filter table... */ - CFE_SB_CreatePipe(&SAMPLE_CommandPipe, SAMPLE_PIPE_DEPTH,"SAMPLE_CMD_PIPE"); - CFE_SB_Subscribe(SAMPLE_APP_CMD_MID, SAMPLE_CommandPipe); - CFE_SB_Subscribe(SAMPLE_APP_SEND_HK_MID, SAMPLE_CommandPipe); + Sample_AppData.SAMPLE_EventFilters[0].EventID = SAMPLE_STARTUP_INF_EID; + Sample_AppData.SAMPLE_EventFilters[0].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[1].EventID = SAMPLE_COMMAND_ERR_EID; + Sample_AppData.SAMPLE_EventFilters[1].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[2].EventID = SAMPLE_COMMANDNOP_INF_EID; + Sample_AppData.SAMPLE_EventFilters[2].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[3].EventID = SAMPLE_COMMANDRST_INF_EID; + Sample_AppData.SAMPLE_EventFilters[3].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[4].EventID = SAMPLE_INVALID_MSGID_ERR_EID; + Sample_AppData.SAMPLE_EventFilters[4].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[5].EventID = SAMPLE_LEN_ERR_EID; + Sample_AppData.SAMPLE_EventFilters[5].Mask = 0x0000; + Sample_AppData.SAMPLE_EventFilters[6].EventID = SAMPLE_PIPE_ERR_EID; + Sample_AppData.SAMPLE_EventFilters[6].Mask = 0x0000; - SAMPLE_ResetCounters(); + /* + ** Register the events + */ + status = CFE_EVS_Register(Sample_AppData.SAMPLE_EventFilters, + SAMPLE_EVENT_COUNTS, + CFE_EVS_BINARY_FILTER); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Registering Events, RC = 0x%08X\n", + status); + return ( status ); + } - CFE_SB_InitMsg(&SAMPLE_HkTelemetryPkt, + /* + ** Initialize housekeeping packet (clear user data area). + */ + CFE_SB_InitMsg(&Sample_AppData.SAMPLE_HkTelemetryPkt, SAMPLE_APP_HK_TLM_MID, - SAMPLE_APP_HK_TLM_LNGTH, true); - - CFE_EVS_SendEvent (SAMPLE_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, - "SAMPLE App Initialized. Version %d.%d.%d.%d", - SAMPLE_APP_MAJOR_VERSION, - SAMPLE_APP_MINOR_VERSION, - SAMPLE_APP_REVISION, - SAMPLE_APP_MISSION_REV); - + sizeof(sample_hk_tlm_t), + true); + + /* + ** Create Software Bus message pipe. + */ + status = CFE_SB_CreatePipe(&Sample_AppData.SAMPLE_CommandPipe, + Sample_AppData.PipeDepth, + Sample_AppData.PipeName); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error creating pipe, RC = 0x%08X\n", + status); + return ( status ); + } + + /* + ** Subscribe to Housekeeping request commands + */ + status = CFE_SB_Subscribe(SAMPLE_APP_SEND_HK_MID, + Sample_AppData.SAMPLE_CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Subscribing to HK request, RC = 0x%08X\n", + status); + return ( status ); + } + + /* + ** Subscribe to ground command packets + */ + status = CFE_SB_Subscribe(SAMPLE_APP_CMD_MID, + Sample_AppData.SAMPLE_CommandPipe); + if (status != CFE_SUCCESS ) + { + CFE_ES_WriteToSysLog("Sample App: Error Subscribing to Command, RC = 0x%08X\n", + status); + + return ( status ); + } + + /* + ** Register Table(s) + */ + status = CFE_TBL_Register(&Sample_AppData.TblHandles[0], + "SampleTable", + sizeof(SampleTable_t), + CFE_TBL_OPT_DEFAULT, + SAMPLE_TblValidationFunc); + if ( status != CFE_SUCCESS ) + { + CFE_ES_WriteToSysLog("Sample App: Error Registering \ + Table, RC = 0x%08X\n", status); + + return ( status ); + } + else + { + status = CFE_TBL_Load(Sample_AppData.TblHandles[0], + CFE_TBL_SRC_FILE, + SAMPLE_TABLE_FILE); + } + + CFE_EVS_SendEvent (SAMPLE_STARTUP_INF_EID, + CFE_EVS_INFORMATION, + "SAMPLE App Initialized. Version %d.%d.%d.%d", + SAMPLE_APP_MAJOR_VERSION, + SAMPLE_APP_MINOR_VERSION, + SAMPLE_APP_REVISION, + SAMPLE_APP_MISSION_REV); + + return ( CFE_SUCCESS ); + } /* End of SAMPLE_AppInit() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ @@ -138,26 +255,27 @@ void SAMPLE_AppInit(void) /* command pipe. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SAMPLE_ProcessCommandPacket(void) +void SAMPLE_ProcessCommandPacket( CFE_SB_MsgPtr_t Msg ) { CFE_SB_MsgId_t MsgId; - MsgId = CFE_SB_GetMsgId(SAMPLEMsgPtr); + MsgId = CFE_SB_GetMsgId(Msg); switch (MsgId) { case SAMPLE_APP_CMD_MID: - SAMPLE_ProcessGroundCommand(); + SAMPLE_ProcessGroundCommand(Msg); break; case SAMPLE_APP_SEND_HK_MID: - SAMPLE_ReportHousekeeping(); + SAMPLE_ReportHousekeeping((CCSDS_CommandPacket_t *)Msg); break; default: - SAMPLE_HkTelemetryPkt.sample_command_error_count++; - CFE_EVS_SendEvent(SAMPLE_COMMAND_ERR_EID,CFE_EVS_EventType_ERROR, - "SAMPLE: invalid command packet,MID = 0x%x", MsgId); + CFE_EVS_SendEvent(SAMPLE_INVALID_MSGID_ERR_EID, + CFE_EVS_ERROR, + "SAMPLE: invalid command packet,MID = 0x%x", + MsgId); break; } @@ -170,37 +288,56 @@ void SAMPLE_ProcessCommandPacket(void) /* SAMPLE_ProcessGroundCommand() -- SAMPLE ground commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ - -void SAMPLE_ProcessGroundCommand(void) +void SAMPLE_ProcessGroundCommand( CFE_SB_MsgPtr_t Msg ) { uint16 CommandCode; - CommandCode = CFE_SB_GetCmdCode(SAMPLEMsgPtr); + CommandCode = CFE_SB_GetCmdCode(Msg); - /* Process "known" SAMPLE app ground commands */ + /* + ** Process "known" SAMPLE app ground commands + */ switch (CommandCode) { case SAMPLE_APP_NOOP_CC: - SAMPLE_HkTelemetryPkt.sample_command_count++; - CFE_EVS_SendEvent(SAMPLE_COMMANDNOP_INF_EID, - CFE_EVS_EventType_INFORMATION, - "SAMPLE: NOOP command"); + if (SAMPLE_VerifyCmdLength(Msg, sizeof(SAMPLE_Noop_t))) + { + SAMPLE_NoopCmd((SAMPLE_Noop_t *)Msg); + } + break; case SAMPLE_APP_RESET_COUNTERS_CC: - SAMPLE_ResetCounters(); + if (SAMPLE_VerifyCmdLength(Msg, sizeof(SAMPLE_ResetCounters_t))) + { + SAMPLE_ResetCounters((SAMPLE_ResetCounters_t *)Msg); + } + + break; + + case SAMPLE_APP_PROCESS_CC: + if (SAMPLE_VerifyCmdLength(Msg, sizeof(SAMPLE_Process_t))) + { + SAMPLE_ProcessCC((SAMPLE_Process_t *)Msg); + } + break; /* default case already found during FC vs length test */ default: + CFE_EVS_SendEvent(SAMPLE_COMMAND_ERR_EID, + CFE_EVS_ERROR, + "Invalid ground command code: CC = %d", + CommandCode); break; } + return; } /* End of SAMPLE_ProcessGroundCommand() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* Name: SAMPLE_ReportHousekeeping */ +/* Name: SAMPLE_ReportHousekeeping */ /* */ /* Purpose: */ /* This function is triggered in response to a task telemetry request */ @@ -208,14 +345,56 @@ void SAMPLE_ProcessGroundCommand(void) /* telemetry, packetize it and send it to the housekeeping task via */ /* the software bus */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SAMPLE_ReportHousekeeping(void) +void SAMPLE_ReportHousekeeping( const CCSDS_CommandPacket_t *Msg ) { - CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &SAMPLE_HkTelemetryPkt); - CFE_SB_SendMsg((CFE_SB_Msg_t *) &SAMPLE_HkTelemetryPkt); + int i; + + /* + ** Get command execution counters... + */ + Sample_AppData.SAMPLE_HkTelemetryPkt.sample_command_error_count = Sample_AppData.CmdCounter; + Sample_AppData.SAMPLE_HkTelemetryPkt.sample_command_count = Sample_AppData.ErrCounter; + + /* + ** Send housekeeping telemetry packet... + */ + CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &Sample_AppData.SAMPLE_HkTelemetryPkt); + CFE_SB_SendMsg((CFE_SB_Msg_t *) &Sample_AppData.SAMPLE_HkTelemetryPkt); + + /* + ** Manage any pending table loads, validations, etc. + */ + for (i=0; iInt1, + TblPtr->Int2); + + SAMPLE_GetCrc(TableName); + + return; + +} /* End of SAMPLE_ProcessCC */ + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* SAMPLE_VerifyCmdLength() -- Verify command packet length */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -bool SAMPLE_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength) -{ +bool SAMPLE_VerifyCmdLength( CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength ) +{ bool result = true; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(msg); + uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); /* ** Verify the command packet length. */ if (ExpectedLength != ActualLength) { - CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(msg); - uint16 CommandCode = CFE_SB_GetCmdCode(msg); + CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(Msg); + uint16 CommandCode = CFE_SB_GetCmdCode(Msg); + + CFE_EVS_SendEvent(SAMPLE_LEN_ERR_EID, + CFE_EVS_ERROR, + "Invalid Msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d", + MessageID, + CommandCode, + ActualLength, + ExpectedLength); - CFE_EVS_SendEvent(SAMPLE_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d", - MessageID, CommandCode, ActualLength, ExpectedLength); result = false; - SAMPLE_HkTelemetryPkt.sample_command_error_count++; + + Sample_AppData.ErrCounter++; } - return(result); + return( result ); } /* End of SAMPLE_VerifyCmdLength() */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* SAMPLE_TblValidationFunc -- Verify contents of First Table */ +/* buffer contents */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 SAMPLE_TblValidationFunc( void *TblData ) +{ + int32 ReturnCode = CFE_SUCCESS; + SampleTable_t *TblDataPtr = (SampleTable_t *)TblData; + + /* + ** Sample Table Validation + */ + if (TblDataPtr->Int1 > SAMPLE_TBL_ELEMENT_1_MAX) + { + /* First element is out of range, return an appropriate error code */ + ReturnCode = SAMPLE_TABLE_OUT_OF_RANGE_ERR_CODE; + } + + return ReturnCode; + +} /* End of Sample_TblValidationFunc*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* SAMPLE_GetCrc -- Output CRC */ +/* */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SAMPLE_GetCrc( const char *TableName ) +{ + int32 status; + uint32 Crc; + CFE_TBL_Info_t TblInfoPtr; + + status = CFE_TBL_GetInfo(&TblInfoPtr, TableName); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Getting Table Info"); + } + else + { + Crc = TblInfoPtr.Crc; + CFE_ES_WriteToSysLog("Sample App: CRC: 0x%08X\n\n", Crc); + } + + return; + +} /* End of SAMPLE_GetCrc */ diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 5f51d3c..04c978f 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -38,17 +38,61 @@ #include "cfe_sb.h" #include "cfe_es.h" -#include -#include -#include +#include "sample_app_perfids.h" +#include "sample_app_msgids.h" +#include "sample_app_msg.h" /***********************************************************************/ +#define SAMPLE_PIPE_DEPTH 32 /* Depth of the Command Pipe for Application */ -#define SAMPLE_PIPE_DEPTH 32 +#define NUMBER_OF_TABLES 1 /* Number of Table(s) */ +/* Define filenames of default data images for tables */ +#define SAMPLE_TABLE_FILE "/cf/sample_table.tbl" + +#define SAMPLE_TABLE_OUT_OF_RANGE_ERR_CODE -1 + +#define SAMPLE_TBL_ELEMENT_1_MAX 10 /************************************************************************ ** Type Definitions *************************************************************************/ +/* +** Global Data +*/ +typedef struct +{ + /* + ** Command interface counters... + */ + uint8 CmdCounter; + uint8 ErrCounter; + + /* + ** Housekeeping telemetry packet... + */ + sample_hk_tlm_t SAMPLE_HkTelemetryPkt; + + /* + ** Run Status variable used in the main processing loop + */ + uint32 RunStatus; + + /* + ** Operational data (not reported in housekeeping)... + */ + CFE_SB_PipeId_t SAMPLE_CommandPipe; + CFE_SB_MsgPtr_t SAMPLEMsgPtr; + + /* + ** Initialization data (not reported in housekeeping)... + */ + char PipeName[16]; + uint16 PipeDepth; + + CFE_EVS_BinFilter_t SAMPLE_EventFilters[SAMPLE_EVENT_COUNTS]; + CFE_TBL_Handle_t TblHandles[NUMBER_OF_TABLES]; + +} Sample_AppData_t; /****************************************************************************/ /* @@ -57,13 +101,18 @@ ** Note: Except for the entry point (SAMPLE_AppMain), these ** functions are not called from any other source module. */ -void SAMPLE_AppMain(void); -void SAMPLE_AppInit(void); -void SAMPLE_ProcessCommandPacket(void); -void SAMPLE_ProcessGroundCommand(void); -void SAMPLE_ReportHousekeeping(void); -void SAMPLE_ResetCounters(void); - -bool SAMPLE_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength); +void SAMPLE_AppMain(void); +int32 SAMPLE_AppInit(void); +void SAMPLE_ProcessCommandPacket(CFE_SB_MsgPtr_t Msg); +void SAMPLE_ProcessGroundCommand(CFE_SB_MsgPtr_t Msg); +void SAMPLE_ReportHousekeeping(const CCSDS_CommandPacket_t *Msg); +void SAMPLE_ResetCounters(const SAMPLE_ResetCounters_t *Msg); +void SAMPLE_ProcessCC(const SAMPLE_Process_t *Msg); +void SAMPLE_NoopCmd(const SAMPLE_Noop_t *Msg); +void SAMPLE_GetCrc(const char *TableName); + +int32 SAMPLE_TblValidationFunc(void *TblData); + +bool SAMPLE_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength); #endif /* _sample_app_h_ */ diff --git a/fsw/src/sample_app_events.h b/fsw/src/sample_app_events.h index 6a0cea7..8e6bdaa 100644 --- a/fsw/src/sample_app_events.h +++ b/fsw/src/sample_app_events.h @@ -18,26 +18,28 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ** -** File: sample_app_events.h +** File: sample_app_events.h ** -** Purpose: +** Purpose: ** Define SAMPLE App Events IDs ** ** Notes: ** -** *************************************************************************/ #ifndef _sample_app_events_h_ #define _sample_app_events_h_ -#define SAMPLE_RESERVED_EID 0 -#define SAMPLE_STARTUP_INF_EID 1 -#define SAMPLE_COMMAND_ERR_EID 2 -#define SAMPLE_COMMANDNOP_INF_EID 3 -#define SAMPLE_COMMANDRST_INF_EID 4 -#define SAMPLE_INVALID_MSGID_ERR_EID 5 -#define SAMPLE_LEN_ERR_EID 6 +#define SAMPLE_RESERVED_EID 0 +#define SAMPLE_STARTUP_INF_EID 1 +#define SAMPLE_COMMAND_ERR_EID 2 +#define SAMPLE_COMMANDNOP_INF_EID 3 +#define SAMPLE_COMMANDRST_INF_EID 4 +#define SAMPLE_INVALID_MSGID_ERR_EID 5 +#define SAMPLE_LEN_ERR_EID 6 +#define SAMPLE_PIPE_ERR_EID 7 + +#define SAMPLE_EVENT_COUNTS 7 #endif /* _sample_app_events_h_ */ diff --git a/fsw/src/sample_app_msg.h b/fsw/src/sample_app_msg.h index c6c7b40..b333a57 100644 --- a/fsw/src/sample_app_msg.h +++ b/fsw/src/sample_app_msg.h @@ -18,9 +18,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ** -** File: sample_app_msg.h +** File: sample_app_msg.h ** -** Purpose: +** Purpose: ** Define SAMPLE App Messages and info ** ** Notes: @@ -35,8 +35,10 @@ */ #define SAMPLE_APP_NOOP_CC 0 #define SAMPLE_APP_RESET_COUNTERS_CC 1 +#define SAMPLE_APP_PROCESS_CC 2 /*************************************************************************/ + /* ** Type definition (generic "no arguments" command) */ @@ -46,20 +48,39 @@ typedef struct } SAMPLE_NoArgsCmd_t; +/* +** The following commands all share the "NoArgs" format +** +** They are each given their own type name matching the command name, which_open_mode +** allows them to change independently in the future without changing the prototype +** of the handler function +*/ +typedef SAMPLE_NoArgsCmd_t SAMPLE_Noop_t; +typedef SAMPLE_NoArgsCmd_t SAMPLE_ResetCounters_t; +typedef SAMPLE_NoArgsCmd_t SAMPLE_Process_t; + /*************************************************************************/ /* ** Type definition (SAMPLE App housekeeping) */ -typedef struct +typedef struct { uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; uint8 sample_command_error_count; uint8 sample_command_count; uint8 spare[2]; -} OS_PACK sample_hk_tlm_t ; +} OS_PACK sample_hk_tlm_t; + +/* +** Table structure +*/ +typedef struct +{ + uint16 Int1; + uint16 Int2; -#define SAMPLE_APP_HK_TLM_LNGTH sizeof ( sample_hk_tlm_t ) +} SampleTable_t; #endif /* _sample_app_msg_h_ */ diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index 1aa9db0..4c18a54 100644 --- a/fsw/src/sample_app_version.h +++ b/fsw/src/sample_app_version.h @@ -20,7 +20,7 @@ ** ** File: sample_app_version.h ** -** Purpose: +** Purpose: ** The Sample Application header file containing version number ** ** Notes: @@ -30,11 +30,13 @@ #ifndef _sample_app_version_h_ #define _sample_app_version_h_ -#define SAMPLE_APP_MAJOR_VERSION 1 -#define SAMPLE_APP_MINOR_VERSION 1 -#define SAMPLE_APP_REVISION 0 -#define SAMPLE_APP_MISSION_REV 0 - + +#define SAMPLE_APP_MAJOR_VERSION 1 +#define SAMPLE_APP_MINOR_VERSION 1 +#define SAMPLE_APP_REVISION 0 +#define SAMPLE_APP_MISSION_REV 0 + + #endif /* _sample_app_version_h_ */ /************************/ diff --git a/fsw/src/sample_table.c b/fsw/src/sample_table.c new file mode 100644 index 0000000..7715ee0 --- /dev/null +++ b/fsw/src/sample_table.c @@ -0,0 +1,49 @@ +/* +** +** GSC-18128-1, "Core Flight Executive Version 6.6" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** +*/ + +#include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ + +/* +** The following is an example of a data structure the application may have declared +** as the format of their table. +*/ +typedef struct +{ + uint16 Int1; + uint16 Int2; + +} SampleTable_t; + +/* +** The following is an example of the declaration statement that defines the desired +** contents of the table image. +*/ +SampleTable_t sampleTable = { 1, 2}; + +/* +** The macro below identifies: +** 1) the data structure type to use as the table image format +** 2) the name of the table to be placed into the cFE Table File Header +** 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(sampleTable, SAMPLE_APP.SampleTable, Table Utility Test Table, sample_table.tbl )