Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #70, Reorg the table file #73

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

12 changes: 6 additions & 6 deletions fsw/src/sample_table.h → fsw/platform_inc/sample_app_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down
23 changes: 11 additions & 12 deletions fsw/src/sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string.h>
Expand Down Expand Up @@ -220,22 +220,21 @@ 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 );
}
else
{
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,
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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() */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/sample_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*************************************************************************/
Expand Down
7 changes: 4 additions & 3 deletions fsw/src/sample_table.c → fsw/tables/sample_app_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 )