From 4f252e6e54295ce135294316f8986809fd6ae048 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Wed, 3 Jun 2020 12:32:11 -0700 Subject: [PATCH] fix #70 - reorg the table file --- CMakeLists.txt | 3 +-- .../sample_app_table.h} | 12 +++++----- fsw/src/sample_app.c | 23 +++++++++---------- fsw/src/sample_app.h | 6 ++--- .../sample_app_tbl.c} | 7 +++--- 5 files changed, 25 insertions(+), 26 deletions(-) rename fsw/{src/sample_table.h => platform_inc/sample_app_table.h} (87%) rename fsw/{src/sample_table.c => tables/sample_app_tbl.c} (88%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5514ac..c37119c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include_directories(${sample_lib_MISSION_DIR}/fsw/public_inc) add_cfe_app(sample_app fsw/src/sample_app.c) # Add table -add_cfe_tables(sampleTable fsw/src/sample_table.c) +add_cfe_tables(sampleAppTable fsw/tables/sample_app_tbl.c) # If UT is enabled, then add the tests from the subdirectory # Note that this is an app, and therefore does not provide @@ -21,4 +21,3 @@ add_cfe_tables(sampleTable fsw/src/sample_table.c) if (ENABLE_UNIT_TESTS) add_subdirectory(unit-test) endif (ENABLE_UNIT_TESTS) - diff --git a/fsw/src/sample_table.h b/fsw/platform_inc/sample_app_table.h similarity index 87% rename from fsw/src/sample_table.h rename to fsw/platform_inc/sample_app_table.h index 9458cc3..62637b9 100644 --- a/fsw/src/sample_table.h +++ b/fsw/platform_inc/sample_app_table.h @@ -18,17 +18,17 @@ ** See the License for the specific language governing permissions and ** limitations under the License. ** -** File: sample_table.h +** File: sample_app_table.h ** ** Purpose: -** Define sample table +** Define sample app table ** ** Notes: ** ** *******************************************************************************/ -#ifndef _sample_table_h_ -#define _sample_table_h_ +#ifndef _sample_app_table_h_ +#define _sample_app_table_h_ /* ** Table structure @@ -38,9 +38,9 @@ typedef struct uint16 Int1; uint16 Int2; -} SAMPLE_Table_t; +} SAMPLE_APP_Table_t; -#endif /* _sample_table_h_ */ +#endif /* _sample_app_table_h_ */ /************************/ /* End of File Comment */ diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 1686c5d..6c4e269 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -31,7 +31,7 @@ #include "sample_app_events.h" #include "sample_app_version.h" #include "sample_app.h" -#include "sample_table.h" +#include "sample_app_table.h" /* The sample_lib module provides the SAMPLE_Function() prototype */ #include @@ -220,14 +220,13 @@ int32 SAMPLE_AppInit( void ) ** Register Table(s) */ status = CFE_TBL_Register(&SAMPLE_AppData.TblHandles[0], - "SampleTable", - sizeof(SAMPLE_Table_t), + "SampleAppTable", + sizeof(SAMPLE_APP_Table_t), CFE_TBL_OPT_DEFAULT, SAMPLE_TblValidationFunc); if ( status != CFE_SUCCESS ) { - CFE_ES_WriteToSysLog("Sample App: Error Registering \ - Table, RC = 0x%08lX\n", (unsigned long)status); + CFE_ES_WriteToSysLog("Sample App: Error Registering Table, RC = 0x%08lX\n", (unsigned long)status); return ( status ); } @@ -235,7 +234,7 @@ int32 SAMPLE_AppInit( void ) { status = CFE_TBL_Load(SAMPLE_AppData.TblHandles[0], CFE_TBL_SRC_FILE, - SAMPLE_TABLE_FILE); + SAMPLE_APP_TABLE_FILE); } CFE_EVS_SendEvent (SAMPLE_STARTUP_INF_EID, @@ -430,8 +429,8 @@ int32 SAMPLE_ResetCounters( const SAMPLE_ResetCounters_t *Msg ) int32 SAMPLE_Process( const SAMPLE_Process_t *Msg ) { int32 status; - SAMPLE_Table_t *TblPtr; - const char *TableName = "SAMPLE_APP.SampleTable"; + SAMPLE_APP_Table_t *TblPtr; + const char *TableName = "SAMPLE_APP.SampleAppTable"; /* Sample Use of Table */ @@ -511,20 +510,20 @@ bool SAMPLE_VerifyCmdLength( CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength ) int32 SAMPLE_TblValidationFunc( void *TblData ) { int32 ReturnCode = CFE_SUCCESS; - SAMPLE_Table_t *TblDataPtr = (SAMPLE_Table_t *)TblData; + SAMPLE_APP_Table_t *TblDataPtr = (SAMPLE_APP_Table_t *)TblData; /* ** Sample Table Validation */ - if (TblDataPtr->Int1 > SAMPLE_TBL_ELEMENT_1_MAX) + if (TblDataPtr->Int1 > SAMPLE_APP_TBL_ELEMENT_1_MAX) { /* First element is out of range, return an appropriate error code */ - ReturnCode = SAMPLE_TABLE_OUT_OF_RANGE_ERR_CODE; + ReturnCode = SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE; } return ReturnCode; -} /* End of Sample_TblValidationFunc*/ +} /* End of SAMPLE_TBLValidationFunc() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index a7c2c47..46703e3 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -48,11 +48,11 @@ #define SAMPLE_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_APP_TABLE_FILE "/cf/sample_app_tbl.tbl" -#define SAMPLE_TABLE_OUT_OF_RANGE_ERR_CODE -1 +#define SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE -1 -#define SAMPLE_TBL_ELEMENT_1_MAX 10 +#define SAMPLE_APP_TBL_ELEMENT_1_MAX 10 /************************************************************************ ** Type Definitions *************************************************************************/ diff --git a/fsw/src/sample_table.c b/fsw/tables/sample_app_tbl.c similarity index 88% rename from fsw/src/sample_table.c rename to fsw/tables/sample_app_tbl.c index 331d796..8319693 100644 --- a/fsw/src/sample_table.c +++ b/fsw/tables/sample_app_tbl.c @@ -21,13 +21,13 @@ */ #include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ -#include "sample_table.h" +#include "sample_app_table.h" /* ** The following is an example of the declaration statement that defines the desired ** contents of the table image. */ -SAMPLE_Table_t sampleTable = { 1, 2}; +SAMPLE_APP_Table_t SampleAppTable = {1, 2}; /* ** The macro below identifies: @@ -36,4 +36,5 @@ SAMPLE_Table_t sampleTable = { 1, 2}; ** 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 ) +CFE_TBL_FILEDEF( SampleAppTable, SAMPLE_APP.SampleAppTable, Table Utility Test Table, sample_app_tbl.tbl ) +