├── .gitignore ├── fsw ├── unit_test │ ├── .gitignore │ ├── ut-assert │ │ ├── doc │ │ │ ├── ut Design.docx │ │ │ ├── ut_design.ppt │ │ │ ├── Ut Users Guide.docx │ │ │ ├── ut Requirements.docx │ │ │ ├── UT_Tool_Users_Guide.doc │ │ │ └── Writing Better Unit Tests.ppt │ │ ├── inc │ │ │ ├── ut_cfe_es_hooks.h │ │ │ ├── uttest.h │ │ │ ├── ut_cfe_time_stubs.h │ │ │ ├── ut_cfe_evs_stubs.h │ │ │ ├── ut_cfe_tbl_hooks.h │ │ │ ├── ut_cfe_fs_stubs.h │ │ │ ├── ut_cfe_evs_hooks.h │ │ │ ├── ut_cfe_tbl_stubs.h │ │ │ ├── uttools.h │ │ │ ├── ut_osfileapi_stubs.h │ │ │ ├── ut_osapi_stubs.h │ │ │ ├── ut_cfe_sb_hooks.h │ │ │ ├── utassert.h │ │ │ ├── ut_cfe_es_stubs.h │ │ │ ├── utlist.h │ │ │ └── ut_cfe_sb_stubs.h │ │ └── src │ │ │ ├── ut_cfe_es_hooks.c │ │ │ ├── utassert.c │ │ │ ├── ut_cfe_psp_memutils_stubs.c │ │ │ ├── uttest.c │ │ │ ├── ut_cfe_time_stubs.c │ │ │ ├── ut_cfe_fs_stubs.c │ │ │ ├── ut_cfe_evs_hooks.c │ │ │ ├── utlist.c │ │ │ ├── ut_cfe_evs_stubs.c │ │ │ ├── uttools.c │ │ │ ├── ut_cfe_tbl_hooks.c │ │ │ ├── ut_cfe_tbl_stubs.c │ │ │ ├── ut_osfileapi_stubs.c │ │ │ └── ut_cfe_es_stubs.c │ ├── ci_testrunner.c │ ├── ci_stubs.h │ ├── Readme.txt │ ├── ci_stubs.c │ └── makefile ├── src │ ├── ci_msgdefs.h │ ├── ci_events.h │ ├── ci_hktlm.h │ ├── ci_utils.c │ └── ci_custom.c ├── platform_inc │ ├── ci_msgids.h │ └── ci_platform_cfg.h ├── examples │ ├── README │ ├── rs422 │ │ ├── ci_platform_cfg.h │ │ ├── MISSION_ci_types.h │ │ └── ci_custom.c │ ├── udp │ │ ├── MISSION_ci_types.h │ │ ├── ci_platform_cfg.h │ │ └── ci_custom.c │ ├── multi_tf │ │ ├── MISSION_ci_types.h │ │ └── ci_platform_cfg.h │ ├── multi │ │ ├── MISSION_ci_types.h │ │ └── ci_platform_cfg.h │ └── setup.sh ├── mission_inc │ ├── ci_perf_ids.h │ └── ci_mission_cfg.h └── for_build │ └── Makefile ├── Command_Ingest_NOSA.pdf ├── docs ├── SDD_Generic_CI-TO_V1_5.doc └── SDD_Generic_CI-TO_V1_5.pdf ├── analysis └── run_cppcheck_ci.sh ├── CMakeLists.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings/ 4 | 5 | -------------------------------------------------------------------------------- /fsw/unit_test/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.exe 3 | *.gcov 4 | *.out 5 | *.gcno 6 | -------------------------------------------------------------------------------- /fsw/src/ci_msgdefs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/src/ci_msgdefs.h -------------------------------------------------------------------------------- /Command_Ingest_NOSA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/Command_Ingest_NOSA.pdf -------------------------------------------------------------------------------- /fsw/platform_inc/ci_msgids.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/platform_inc/ci_msgids.h -------------------------------------------------------------------------------- /docs/SDD_Generic_CI-TO_V1_5.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/docs/SDD_Generic_CI-TO_V1_5.doc -------------------------------------------------------------------------------- /docs/SDD_Generic_CI-TO_V1_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/docs/SDD_Generic_CI-TO_V1_5.pdf -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut Design.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/ut Design.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut_design.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/ut_design.ppt -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/Ut Users Guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/Ut Users Guide.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut Requirements.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/ut Requirements.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/UT_Tool_Users_Guide.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/UT_Tool_Users_Guide.doc -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/Writing Better Unit Tests.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_CI/master/fsw/unit_test/ut-assert/doc/Writing Better Unit Tests.ppt -------------------------------------------------------------------------------- /analysis/run_cppcheck_ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Runs cppcheck on CI 3 | 4 | ci_app="../fsw" 5 | io_lib="../../io_lib/fsw" 6 | 7 | output_file="./cppcheck_ci.txt" 8 | error_file="./cppcheck_errors_ci.txt" 9 | 10 | command -v cppcheck >/dev/null 2>&1 || { echo >&2 "Error: Requires cppcheck but it's not installed. Aborting."; exit 1; } 11 | 12 | paths_to_check="$ci_app/src/ $ci_app/examples/multi/ $ci_app/examples/multi_tf/ $ci_app/examples/rs422/ $ci_app/examples/udp/" 13 | 14 | include_dirs="-I $ci_app/platform_inc/ -I $ci_app/mission_inc -I $io_lib/public_inc" 15 | 16 | flags="-v --report-progress --std=c89" 17 | 18 | cppcheck $flags $include_dirs $paths_to_check 2> $error_file > $output_file 19 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6.4) 2 | project(CI C) 3 | 4 | include_directories(fsw/mission_inc) 5 | include_directories(fsw/platform_inc) 6 | include_directories(fsw/src) 7 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 8 | include_directories(${MISSION_SOURCE_DIR}/apps/inc) 9 | include_directories(${MISSION_SOURCE_DIR}/apps/to/fsw/platform_inc) 10 | include_directories(${MISSION_SOURCE_DIR}/apps/to/fsw/mission_inc) 11 | include_directories(${MISSION_SOURCE_DIR}/apps/to/fsw/src) 12 | include_directories(${MISSION_SOURCE_DIR}/apps/io_lib/fsw/public_inc/) 13 | 14 | aux_source_directory(fsw/src APP_SRC_FILES) 15 | 16 | # Create the app module 17 | add_cfe_app(ci ${APP_SRC_FILES}) 18 | -------------------------------------------------------------------------------- /fsw/unit_test/ci_testrunner.c: -------------------------------------------------------------------------------- 1 | 2 | void CI_AddTestCase(void); 3 | 4 | /* 5 | * Filename: ci_testrunner.c 6 | * 7 | * Copyright 2017 United States Government as represented by the Administrator 8 | * of the National Aeronautics and Space Administration. No copyright is 9 | * claimed in the United States under Title 17, U.S. Code. 10 | * All Other Rights Reserved. 11 | * 12 | * Purpose: This file contains a unit test runner for the CI Application. 13 | * 14 | */ 15 | 16 | /* 17 | * Includes 18 | */ 19 | 20 | #include "uttest.h" 21 | 22 | /* 23 | * Function Definitions 24 | */ 25 | 26 | int main(void) 27 | { 28 | /* Call AddTestSuite or AddTestCase functions here */ 29 | CI_AddTestCase(); 30 | return(UtTest_Run()); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /fsw/unit_test/ci_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ci_stubs.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * Purpose: 10 | * Provide stubs for unit testing CI 11 | * 12 | * History: 13 | * Jan 15, 2015 dasp 14 | * * 15 | */ 16 | 17 | #ifndef Ut_CI_STUBS_H 18 | #define Ut_CI_STUBS_H 19 | 20 | #include "uttools.h" 21 | 22 | typedef enum 23 | { 24 | UT_CI_CUSTOMINIT_INDEX, 25 | UT_CI_CUSTOMAPPCMDS_INDEX, 26 | UT_CI_MAX_INDEX 27 | } Ut_CI_INDEX_t; 28 | 29 | typedef struct 30 | { 31 | int32 Value; 32 | uint32 Count; 33 | } Ut_CI_ReturnCodeTable_t; 34 | 35 | 36 | void Ut_CI_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 37 | boolean Ut_CI_UseReturnCode(uint32 Index); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /fsw/unit_test/Readme.txt: -------------------------------------------------------------------------------- 1 | This directory holds the unit tests for the CI application. 2 | 3 | To build and run the unit tests: 4 | 1. Be sure an appropriate *_ci_types.h is in the apps/inc directory by: 5 | a. cd ../examples 6 | b. ./setup.sh -m CFS_TST udp (see below) 7 | c. cd ../unit_test 8 | 2. Do the same for TO. Be sure an appropriate *_to_types.h is in the 9 | apps/inc directory by: 10 | a. cd ../../../to/fsw/examples 11 | b. ./setup.sh -m CFS_TST udp (see below) 12 | c. cd ../../../ci/fsw/unit_test 13 | 3. make clean 14 | 4. make 15 | 5. make run 16 | 6. make gcov 17 | 18 | Background: 19 | The unit tests also expect (like the apps) to find the 20 | apps/inc/CFS_TST_ci_types.h 21 | apps/inc/CFS_TST_to_types.h 22 | where the mission name, CFS_TST, is assumed by default. 23 | 24 | These are put into place by the [ci/to]/fsw/examples/setup.py scripts. 25 | Choose the appropriate name for your code to compile if you aren't 26 | using "CFS_TST". 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Command Ingest 2 | 3 | NASA core Flight System Command Ingest Application 4 | 5 | ## Description 6 | 7 | Command Ingest (CI) application is a core Flight System (cFS) application that is a plug in to the Core Flight Executive (cFE) component of the cFS. 8 | 9 | The cFS is a platform and project independent reusable software framework and set of reusable applications developed by NASA Goddard Space Flight Center. This framework is used as the basis for the flight software for satellite data systems and instruments, but can be used on other embedded systems. More information on the cFS can be found at http://cfs.gsfc.nasa.gov 10 | 11 | The Command Ingest (CI) Application is responsible for receiving commands from an external source (such as a ground station) over a transport channel, and to forward the command to the appropriate application over the cFE Software Bus (SB). 12 | 13 | ## License 14 | 15 | This software is licensed under the NASA Open Source Agreement. 16 | http://ti.arc.nasa.gov/opensource/nosa 17 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_es_hooks.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_es_hooks.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_es_hooks.h 1.1 2011/05/04 11:20:17EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test header file for cFE Executive Services hooks. 13 | ** 14 | ** $Log: ut_cfe_es_hooks.h $ 15 | ** Revision 1.1 2011/05/04 11:20:17EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:51EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.1 2011/03/07 17:54:46EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_CFE_ES_HOOKS_H_ 28 | #define UT_CFE_ES_HOOKS_H_ 29 | 30 | #include "cfe.h" 31 | 32 | int32 Ut_CFE_ES_RunLoopHook(uint32 *ExitStatus); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_es_hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_es_hooks.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_es_hooks.c 1.1 2011/05/04 11:20:51EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test hooks for cFE Executive Services routines 13 | ** 14 | ** $Log: ut_cfe_es_hooks.c $ 15 | ** Revision 1.1 2011/05/04 11:20:51EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:36EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.1 2011/03/07 17:54:30EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 24 | ** 25 | */ 26 | 27 | #include "cfe.h" 28 | 29 | int32 Ut_CFE_ES_RunLoopHook(uint32 *ExitStatus) 30 | { 31 | if (*ExitStatus == CFE_ES_APP_RUN) { 32 | return(TRUE); 33 | } 34 | else { /* CFE_ES_APP_EXIT, CFE_ES_APP_ERROR */ 35 | return(FALSE); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fsw/examples/README: -------------------------------------------------------------------------------- 1 | # Author: Guy de Carufel (Odyssey Space Research) 2 | # Date: Jan 26, 2016 3 | 4 | This directory holds example implementations of the custom layer for this application. 5 | 6 | To make use of an example, use the setup.sh 7 | > ./setup.sh -h 8 | 9 | The normal setup is to copy the files in the appropriate locations and then modify then 10 | according to your mission needs. 11 | For the "ci_lab" application equivalent, use the udp example. 12 | >./setup.sh udp 13 | 14 | You can link to files in the examples in this directory rather than making copies 15 | by using the -l option 16 | >./setup.sh -l udp 17 | 18 | 19 | DEVELOPERS NOTE: 20 | 1. Always revert back to the udp example as a copy (not a link) before comitting to 21 | the repo if you made changes to example files. 22 | We want to keep the udp to_custom.c as the default example. 23 | >./setup.sh udp 24 | 25 | 2. If you add examples, make sure to name the directory the same in both CI & TO. 26 | 27 | 28 | USEFUL TIP: 29 | Add the following to your .bashrc to update both CI/TO at the same time: 30 | 31 | setCustomLink() { 32 | cd ${MISSION_HOME}/apps/ci/fsw/examples/ 33 | ./setup.sh -l $1 34 | cd ${MISSION_HOME}/apps/to/fsw/examples/ 35 | ./setup.sh -l $1 36 | } 37 | 38 | setCustomCopy() { 39 | cd ${MISSION_HOME}/apps/ci/fsw/examples/ 40 | ./setup.sh $1 41 | cd ${MISSION_HOME}/apps/to/fsw/examples/ 42 | ./setup.sh $1 43 | } 44 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/utassert.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: utassert.c 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains a standard set of asserts for use in unit tests. 11 | * 12 | */ 13 | 14 | /* 15 | * Includes 16 | */ 17 | 18 | #include "common_types.h" 19 | #include "utassert.h" 20 | #include "uttools.h" 21 | 22 | /* 23 | * Local Data 24 | */ 25 | 26 | uint32 UtAssertPassCount = 0; 27 | uint32 UtAssertFailCount = 0; 28 | 29 | /* 30 | * Function Definitions 31 | */ 32 | 33 | uint32 UtAssert_GetPassCount(void) 34 | { 35 | return(UtAssertPassCount); 36 | } 37 | 38 | uint32 UtAssert_GetFailCount(void) 39 | { 40 | return(UtAssertFailCount); 41 | } 42 | 43 | boolean UtAssert(boolean Expression, char *Description, char *File, uint32 Line) 44 | { 45 | if (Expression) { 46 | #ifdef UT_VERBOSE 47 | printf("PASS: %s\n", Description); 48 | #endif 49 | UtAssertPassCount++; 50 | return(TRUE); 51 | } 52 | else { 53 | printf("FAIL: %s, File: %s, Line: %u\n", Description, File, Line); 54 | UtAssertFailCount++; 55 | return(FALSE); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/uttest.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: uttest.h 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a standard way to execute unit tests. 11 | * 12 | * Design Notes: 13 | * By default the only output that is printed to the console is assert failures 14 | * and a summary of the test results after all tests have executed. To enable additional 15 | * test output define the macro UT_VERBOSE. 16 | * 17 | * References: 18 | * 19 | */ 20 | 21 | #ifndef _uttest_ 22 | #define _uttest_ 23 | 24 | /* 25 | * Exported Functions 26 | */ 27 | 28 | /* Adds a new unit test to the test database. */ 29 | void UtTest_Add(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), char *TestName); 30 | 31 | /* Executes all unit tests contained in the test database. Once all tests have finished executing 32 | * a results summary is printed to the console and the test database is deleted. This function also 33 | * returns a boolean status indicating if any of the tests failed. (TRUE = at least one test failure 34 | * has occurred, FALSE = all tests passed) */ 35 | int UtTest_Run(void); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /fsw/mission_inc/ci_perf_ids.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** File: 3 | ** ci_perfids.h 4 | ** 5 | ** Copyright © 2016 United States Government as represented by the 6 | ** Administrator of the National Aeronautics and Space Administration. 7 | ** All Other Rights Reserved. 8 | ** 9 | ** This software was created at NASA's Johnson Space Center. 10 | ** This software is governed by the NASA Open Source Agreement and may be 11 | ** used, distributed and modified only pursuant to the terms of that 12 | ** agreement. 13 | ** 14 | ** Purpose: 15 | ** This file contains the cFE performance ID's used by Command Ingest 16 | ** 17 | ** References: 18 | ** Flight Software Branch C Coding Standard Version 1.2 19 | ** CFS Development Standards Document 20 | ** 21 | ** Notes: 22 | ** 1) XXX_PERF_ID is used to measure an application's performance on 23 | ** various functions. 24 | ** 25 | ** \par Modification History: 26 | ** - 2016-05-11 | Allen Brown | Initial Version 27 | ** 28 | *************************************************************************/ 29 | #ifndef _CI_PERF_IDS_H_ 30 | #define _CI_PERF_IDS_H_ 31 | 32 | #define CI_MAIN_TASK_PERF_ID 0x0070 33 | #define CI_CUSTOM_TASK_PERF_ID 0x0071 34 | 35 | #endif /* _CI_PERF_IDS_H_ */ 36 | 37 | /*======================================================================================= 38 | ** End of file ci_perf_ids.h 39 | **=====================================================================================*/ 40 | 41 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_psp_memutils_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_psp_memutils_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_psp_memutils_stubs.c 1.1 2011/05/04 11:20:54EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE PSP Memory Utilities routines 13 | ** 14 | ** $Log: ut_cfe_psp_memutils_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:20:54EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:39EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.1 2011/02/15 11:13:02EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 24 | ** 25 | */ 26 | 27 | /* 28 | ** Include Files 29 | */ 30 | #include "cfe.h" 31 | #include 32 | 33 | int32 CFE_PSP_MemCpy(void *Dest, void *Src, uint32 Size) 34 | { 35 | memcpy(Dest, Src, Size); 36 | return(CFE_PSP_SUCCESS); 37 | } 38 | 39 | int32 CFE_PSP_MemSet(void *Dest, uint8 Value, uint32 Size) 40 | { 41 | memset(Dest, Value, Size); 42 | return(CFE_PSP_SUCCESS); 43 | } 44 | -------------------------------------------------------------------------------- /fsw/src/ci_events.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_events.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief ID Header File for CI Application 12 | * 13 | * \par 14 | * This header file contains definitions of the CI Event IDs 15 | * 16 | * \par Modification History: 17 | * - 2015-01-09 | Guy de Carufel | Code Started 18 | *******************************************************************************/ 19 | 20 | #ifndef _CI_EVENTS_H_ 21 | #define _CI_EVENTS_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** Event IDs */ 28 | typedef enum 29 | { 30 | CI_RESERVED_EID = 0, 31 | CI_INF_EID = 1, 32 | CI_INIT_INF_EID = 2, 33 | CI_CMD_INF_EID = 3, 34 | CI_CUSTOM_INF_EID = 4, 35 | CI_ERR_EID = 5, 36 | CI_INIT_ERR_EID = 6, 37 | CI_CMD_ERR_EID = 7, 38 | CI_PIPE_ERR_EID = 8, 39 | CI_MSGID_ERR_EID = 9, 40 | CI_MSGLEN_ERR_EID = 10, 41 | CI_CUSTOM_ERR_EID = 11, 42 | CI_EVT_CNT 43 | } CI_Events_t; 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* _CI_EVENTS_H_ */ 50 | 51 | /*============================================================================== 52 | ** End of file ci_events.h 53 | **============================================================================*/ 54 | 55 | -------------------------------------------------------------------------------- /fsw/src/ci_hktlm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_hktlm.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Default HK Telemetry 12 | * 13 | * \par 14 | * This header contains the definition of the default HK Telemetry. 15 | * 16 | * \par Limitations, Assumptions, External Events, and Notes: 17 | * - Include this file in your MISSION_ci_types.h or define your own. 18 | * - If a custom HK tlm is required, make sure to include all parameters 19 | * in this default HK packet in your custom implementation. 20 | * 21 | * \par Modification History: 22 | * - 2015-10-16 | Guy de Carufel | Code Started 23 | *******************************************************************************/ 24 | #ifndef _CI_HKTLM_H_ 25 | #define _CI_HKTLM_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include "cfe.h" 32 | 33 | typedef struct 34 | { 35 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 36 | uint16 usCmdCnt; /**< Count of all commands received */ 37 | uint16 usCmdErrCnt; /**< Count of command errors */ 38 | } CI_HkTlm_t; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* _CI_HKTLM_H_ */ 45 | 46 | /*============================================================================== 47 | ** End of file ci_hktlm.h 48 | **============================================================================*/ 49 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_time_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_time_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_time_stubs.h 1.1 2011/05/04 11:20:23EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE Time Services Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_time_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:23EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:57EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.1 2011/02/15 11:12:35EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_CFE_TIME_STUBS_H_ 28 | #define UT_CFE_TIME_STUBS_H_ 29 | 30 | typedef enum 31 | { 32 | UT_CFE_TIME_GETTIME_INDEX, 33 | UT_CFE_TIME_MAX_INDEX 34 | } Ut_CFE_TIME_INDEX_t; 35 | 36 | typedef struct 37 | { 38 | CFE_TIME_SysTime_t (*CFE_TIME_GetTime)(void); 39 | } Ut_CFE_TIME_HookTable_t; 40 | 41 | typedef struct 42 | { 43 | int32 Value; 44 | uint32 Count; 45 | } Ut_CFE_TIME_ReturnCodeTable_t; 46 | 47 | void Ut_CFE_TIME_Reset(void); 48 | void Ut_CFE_TIME_SetFunctionHook(uint32 Index, void *FunPtr); 49 | void Ut_CFE_TIME_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /fsw/mission_inc/ci_mission_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_mission_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Mission Configuration Header File for CI Application 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - All Mission configuration files should be defined in apps/inc folder. 15 | * 16 | * \par Modification History: 17 | * - 2015-01-09 | Guy de Carufel | Code Started 18 | * - 2016-05-11 | Allen Brown | Updated headers 19 | *******************************************************************************/ 20 | #ifndef _CI_MISSION_CFG_H_ 21 | #define _CI_MISSION_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | 35 | /* 36 | ** Include Files 37 | */ 38 | #include "cfe.h" 39 | 40 | #include "ci_perf_ids.h" 41 | #include "ci_msgids.h" 42 | #include "ci_msgdefs.h" 43 | 44 | /* Note, this header uses a mission name prefix convention. 45 | This include may need to be altered. */ 46 | #include "CFS_TST_ci_types.h" 47 | 48 | /* 49 | ** Local Structure Declarations 50 | */ 51 | 52 | /* 53 | ** External Global Variables 54 | */ 55 | 56 | /* 57 | ** Global Variables 58 | */ 59 | 60 | /* 61 | ** Local Variables 62 | */ 63 | 64 | /* 65 | ** Local Function Prototypes 66 | */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* _CI_MISSION_CFG_H_ */ 73 | 74 | /*============================================================================== 75 | ** End of file ci_mission_cfg.h 76 | **============================================================================*/ 77 | 78 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_evs_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_evs_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_evs_stubs.h 1.1 2011/05/04 11:20:19EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE Event Services Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_evs_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:19EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:53EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.1 2011/02/15 11:12:33EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_CFE_EVS_STUBS_H_ 28 | #define UT_CFE_EVS_STUBS_H_ 29 | 30 | typedef enum 31 | { 32 | UT_CFE_EVS_REGISTER_INDEX, 33 | UT_CFE_EVS_SENDEVENT_INDEX, 34 | UT_CFE_EVS_SENDTIMEDEVENT_INDEX, 35 | UT_CFE_EVS_SENDEVENTWITHAPPID_INDEX, 36 | UT_CFE_EVS_MAX_INDEX 37 | } Ut_CFE_EVS_INDEX_t; 38 | 39 | typedef struct 40 | { 41 | int32 (*CFE_EVS_Register)(void *Filters, uint16 NumEventFilters, uint16 FilterScheme); 42 | int32 (*CFE_EVS_SendEvent)(uint16 EventID, uint16 EventType, char *EventText); 43 | } Ut_CFE_EVS_HookTable_t; 44 | 45 | typedef struct 46 | { 47 | int32 Value; 48 | uint32 Count; 49 | } Ut_CFE_EVS_ReturnCodeTable_t; 50 | 51 | void Ut_CFE_EVS_Reset(void); 52 | void Ut_CFE_EVS_SetFunctionHook(uint32 Index, void *FunPtr); 53 | void Ut_CFE_EVS_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_tbl_hooks.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_tbl_hooks.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_tbl_hooks.h 1.1 2011/05/04 11:20:22EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test header file for cFE Table Services hooks. 13 | ** 14 | ** $Log: ut_cfe_tbl_hooks.h $ 15 | ** Revision 1.1 2011/05/04 11:20:22EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:56EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.2 2011/02/18 15:57:43EST sslegel 22 | ** Added new hooks and return codes 23 | ** Changed Ut_CFE_TBL_LoadHook to automatically call the table validate function 24 | ** Revision 1.1 2011/02/15 11:12:34EST sslegel 25 | ** Initial revision 26 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 27 | ** 28 | */ 29 | 30 | #ifndef UT_CFE_TBL_HOOKS_H_ 31 | #define UT_CFE_TBL_HOOKS_H_ 32 | 33 | #include "cfe.h" 34 | 35 | void Ut_CFE_TBL_ClearTables(void); 36 | int32 Ut_CFE_TBL_RegisterTable(const char *Name, uint32 Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); 37 | int32 Ut_CFE_TBL_AddTable(char *Filename, void *TablePtr); 38 | int32 Ut_CFE_TBL_LoadTable(CFE_TBL_Handle_t TblHandle, void *SrcDataPtr); 39 | int32 Ut_CFE_TBL_FindTable(char *Filename); 40 | void *Ut_CFE_TBL_GetAddress(CFE_TBL_Handle_t TblHandle); 41 | int32 Ut_CFE_TBL_RegisterHook(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, uint32 Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); 42 | int32 Ut_CFE_TBL_LoadHook(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr); 43 | int32 Ut_CFE_TBL_GetAddressHook(void **TblPtr, CFE_TBL_Handle_t TblHandle); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /fsw/examples/rs422/ci_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_platform_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Sample config file for CI Application with RS422 device 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - Make use of the setup.sh script to move / link this file to the 15 | * {MISSION_HOME}/apps/to/fsw/platform_inc folder. 16 | * 17 | * \par Modification History: 18 | * - 2015-01-09 | Guy de Carufel | Code Started 19 | *******************************************************************************/ 20 | #ifndef _CI_PLATFORM_CFG_H_ 21 | #define _CI_PLATFORM_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | /* Check new commands every 1s if not scheduled */ 35 | #define CI_WAKEUP_TIMEOUT 1000 36 | 37 | #define CI_SCH_PIPE_DEPTH 10 38 | #define CI_CMD_PIPE_DEPTH 10 39 | #define CI_TLM_PIPE_DEPTH 10 40 | 41 | #define CI_CONFIG_SERIAL_PORT "/dev/ttyS6" 42 | #define CI_CONFIG_BAUD_RATE 921600 43 | #define CI_CONFIG_TIMEOUT 100 44 | #define CI_CONFIG_MINBYTES 6 45 | 46 | #define CI_CUSTOM_BUFFER_SIZE 1000 47 | 48 | #define CI_CUSTOM_TASK_STACK_PTR NULL 49 | #define CI_CUSTOM_TASK_STACK_SIZE 0x4000 50 | #define CI_CUSTOM_TASK_PRIO 118 51 | 52 | /* 53 | ** Include Files 54 | */ 55 | 56 | /* 57 | ** Local Structure Declarations 58 | */ 59 | 60 | /* 61 | ** External Global Variables 62 | */ 63 | 64 | /* 65 | ** Global Variables 66 | */ 67 | 68 | /* 69 | ** Local Variables 70 | */ 71 | 72 | /* 73 | ** Local Function Prototypes 74 | */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* _CI_PLATFORM_CFG_H_ */ 81 | 82 | /*============================================================================== 83 | ** End of file ci_platform_cfg.h 84 | **============================================================================*/ 85 | 86 | -------------------------------------------------------------------------------- /fsw/examples/udp/MISSION_ci_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_ci_types.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Command and telemetry data strucutres for CI application 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for CI applications for the UDP transport protocol example. 16 | * 17 | * \par Limitations, Assumptions, External Events, and Notes: 18 | * - Make use of the setup.sh script to move / link this file to the 19 | * {MISSION_HOME}/apps/inc/ folder. 20 | * - Default HK Telemetry structure is defined in ci_hktlm.h 21 | * 22 | * \par Modification History: 23 | * - 2015-01-09 | Guy de Carufel | Code Started 24 | * - 2015-10-16 | Guy de Carufel | Moved hktlm to ci_hktlm.h 25 | *******************************************************************************/ 26 | #ifndef _MISSION_CI_TYPES_H_ 27 | #define _MISSION_CI_TYPES_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* 34 | ** Pragmas 35 | */ 36 | 37 | /* 38 | ** Include Files 39 | */ 40 | #include "cfe.h" 41 | #include "../ci/fsw/src/ci_hktlm.h" 42 | #include "../to/fsw/mission_inc/to_mission_cfg.h" 43 | 44 | /* 45 | ** Local Defines 46 | */ 47 | 48 | /* 49 | ** Local Structure Declarations 50 | */ 51 | typedef struct 52 | { 53 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 54 | } CI_NoArgCmd_t; 55 | 56 | typedef TO_EnableOutputCmd_t CI_EnableTOCmd_t; 57 | 58 | 59 | /* NOTE: In this example, the OutData is empty (not used.) */ 60 | typedef struct 61 | { 62 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 63 | } CI_OutData_t; 64 | 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* _CI_TO_DEV_CI_TYPES_H_ */ 71 | 72 | /*============================================================================== 73 | ** End of file MISSION_ci_types.h 74 | **============================================================================*/ 75 | 76 | -------------------------------------------------------------------------------- /fsw/examples/udp/ci_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_platform_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Sample config file for CI Application with UDP socket 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - Make use of the setup.sh script to move / link this file to the 15 | * {MISSION_HOME}/apps/to/fsw/platform_inc folder. 16 | * 17 | * \par Modification History: 18 | * - 2015-01-09 | Guy de Carufel | Code Started 19 | *******************************************************************************/ 20 | #ifndef _CI_PLATFORM_CFG_H_ 21 | #define _CI_PLATFORM_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | /* Check new commands every 1s if not scheduled */ 35 | #define CI_WAKEUP_TIMEOUT 1000 36 | 37 | #define CI_SCH_PIPE_DEPTH 10 38 | #define CI_CMD_PIPE_DEPTH 10 39 | #define CI_TLM_PIPE_DEPTH 10 40 | 41 | 42 | #define CI_CUSTOM_UDP_PORT 5010 43 | #define CI_CUSTOM_UDP_ADDR IO_TRANS_UDP_INADDR_ANY 44 | #define CI_CUSTOM_UDP_TIMEOUT 100 45 | #define CI_CUSTOM_MAX_IP_STRING_SIZE 16 46 | 47 | #define CI_CUSTOM_BUFFER_SIZE 1000 48 | 49 | #define CI_CUSTOM_TASK_STACK_PTR NULL 50 | #define CI_CUSTOM_TASK_STACK_SIZE 0x4000 51 | #define CI_CUSTOM_TASK_PRIO 118 52 | 53 | /* 54 | ** Include Files 55 | */ 56 | 57 | /* 58 | ** Local Structure Declarations 59 | */ 60 | 61 | /* 62 | ** External Global Variables 63 | */ 64 | 65 | /* 66 | ** Global Variables 67 | */ 68 | 69 | /* 70 | ** Local Variables 71 | */ 72 | 73 | /* 74 | ** Local Function Prototypes 75 | */ 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* _CI_PLATFORM_CFG_H_ */ 82 | 83 | /*============================================================================== 84 | ** End of file ci_platform_cfg.h 85 | **============================================================================*/ 86 | 87 | -------------------------------------------------------------------------------- /fsw/platform_inc/ci_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_platform_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Sample config file for CI Application with UDP socket 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - Make use of the setup.sh script to move / link this file to the 15 | * {MISSION_HOME}/apps/to/fsw/platform_inc folder. 16 | * 17 | * \par Modification History: 18 | * - 2015-01-09 | Guy de Carufel | Code Started 19 | *******************************************************************************/ 20 | #ifndef _CI_PLATFORM_CFG_H_ 21 | #define _CI_PLATFORM_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | /* Check new commands every 1s if not scheduled */ 35 | #define CI_WAKEUP_TIMEOUT 1000 36 | 37 | #define CI_SCH_PIPE_DEPTH 10 38 | #define CI_CMD_PIPE_DEPTH 10 39 | #define CI_TLM_PIPE_DEPTH 10 40 | 41 | 42 | #define CI_CUSTOM_UDP_PORT 5010 43 | #define CI_CUSTOM_UDP_ADDR IO_TRANS_UDP_INADDR_ANY 44 | #define CI_CUSTOM_UDP_TIMEOUT 100 45 | #define CI_CUSTOM_MAX_IP_STRING_SIZE 16 46 | 47 | #define CI_CUSTOM_BUFFER_SIZE 1000 48 | 49 | #define CI_CUSTOM_TASK_STACK_PTR NULL 50 | #define CI_CUSTOM_TASK_STACK_SIZE 0x4000 51 | #define CI_CUSTOM_TASK_PRIO 118 52 | 53 | /* 54 | ** Include Files 55 | */ 56 | 57 | /* 58 | ** Local Structure Declarations 59 | */ 60 | 61 | /* 62 | ** External Global Variables 63 | */ 64 | 65 | /* 66 | ** Global Variables 67 | */ 68 | 69 | /* 70 | ** Local Variables 71 | */ 72 | 73 | /* 74 | ** Local Function Prototypes 75 | */ 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* _CI_PLATFORM_CFG_H_ */ 82 | 83 | /*============================================================================== 84 | ** End of file ci_platform_cfg.h 85 | **============================================================================*/ 86 | 87 | -------------------------------------------------------------------------------- /fsw/examples/rs422/MISSION_ci_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_ci_types.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Command and telemetry data strucutres for CI application 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for CI applications for the RS422 transport protocol example. 16 | * 17 | * \par Limitations, Assumptions, External Events, and Notes: 18 | * - Make use of the setup.sh script to move / link this file to the 19 | * {MISSION_HOME}/apps/inc/ folder. 20 | * - Default HK Telemetry structure is defined in ci_hktlm.h 21 | * 22 | * \par Modification History: 23 | * - 2015-01-09 | Guy de Carufel | Code Started 24 | * - 2015-10-16 | Guy de Carufel | Moved hktlm to ci_hktlm.h 25 | *******************************************************************************/ 26 | #ifndef _MISSION_CI_TYPES_H_ 27 | #define _MISSION_CI_TYPES_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* 34 | ** Pragmas 35 | */ 36 | 37 | /* 38 | ** Include Files 39 | */ 40 | #include "cfe.h" 41 | #include "../ci/fsw/src/ci_hktlm.h" 42 | #include "../to/fsw/mission_inc/to_mission_cfg.h" 43 | 44 | /* 45 | ** Local Defines 46 | */ 47 | 48 | /* 49 | ** Local Structure Declarations 50 | */ 51 | typedef struct 52 | { 53 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 54 | } CI_NoArgCmd_t; 55 | 56 | typedef struct 57 | { 58 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 59 | } CI_EnableTOCmd_t; 60 | 61 | /* NOTE: In this example, the OutData is empty (not used.) */ 62 | typedef struct 63 | { 64 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 65 | } CI_OutData_t; 66 | 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* _CI_TO_DEV_CI_TYPES_H_ */ 73 | 74 | /*============================================================================== 75 | ** End of file MISSION_ci_types.h 76 | **============================================================================*/ 77 | 78 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_fs_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_fs_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_fs_stubs.h 1.1 2011/05/04 11:20:20EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE File System Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_fs_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:20EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:54EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.1 2011/02/15 11:12:33EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_CFE_FS_STUBS_H_ 28 | #define UT_CFE_FS_STUBS_H_ 29 | 30 | typedef enum 31 | { 32 | UT_CFE_FS_READHDR_INDEX, 33 | UT_CFE_FS_WRITEHDR_INDEX, 34 | UT_CFE_FS_SETTIMESTAMP_INDEX, 35 | UT_CFE_FS_ISGZFILE_INDEX, 36 | UT_CFE_FS_EXTRACTFILENAMEFROMPATH_INDEX, 37 | UT_CFE_FS_DECOMPRESS_INDEX, 38 | UT_CFE_FS_MAX_INDEX 39 | } Ut_CFE_FS_INDEX_t; 40 | 41 | typedef struct 42 | { 43 | int32 (*CFE_FS_ReadHeader)(CFE_FS_Header_t *Hdr, int32 FileDes); 44 | int32 (*CFE_FS_WriteHeader)(int32 FileDes, CFE_FS_Header_t *Hdr); 45 | int32 (*CFE_FS_SetTimestamp)(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp); 46 | int32 (*CFE_FS_IsGzFile)(char *FileName); 47 | int32 (*CFE_FS_ExtractFilenameFromPath)(char *OriginalPath, char *FileNameOnly); 48 | int32 (*CFE_FS_Decompress)( char * SourceFile, char * DestinationFile ); 49 | } Ut_CFE_FS_HookTable_t; 50 | 51 | typedef struct 52 | { 53 | int32 Value; 54 | uint32 Count; 55 | } Ut_CFE_FS_ReturnCodeTable_t; 56 | 57 | void Ut_CFE_FS_Reset(void); 58 | void Ut_CFE_FS_SetFunctionHook(uint32 Index, void *FunPtr); 59 | void Ut_CFE_FS_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /fsw/unit_test/ci_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ci_stubs.c 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * Purpose: 10 | * Stub out various functions not stubbed out by the UT-Assert code, including standard socket library functions 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "cfe.h" 18 | #include "ci_app.h" 19 | #include "ci_stubs.h" 20 | 21 | 22 | extern CI_AppData_t g_CI_AppData; 23 | 24 | Ut_CI_ReturnCodeTable_t Ut_CI_ReturnCodeTable[UT_CI_MAX_INDEX]; 25 | 26 | void Ut_CI_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 27 | { 28 | if (Index < UT_CI_MAX_INDEX) { 29 | Ut_CI_ReturnCodeTable[Index].Value = RtnVal; 30 | Ut_CI_ReturnCodeTable[Index].Count = CallCnt; 31 | } 32 | else { 33 | printf("Unsupported Index In SetReturnCode Call %u\n", Index); 34 | } 35 | } 36 | 37 | 38 | boolean Ut_CI_UseReturnCode(uint32 Index) 39 | { 40 | if (Ut_CI_ReturnCodeTable[Index].Count > 0) { 41 | Ut_CI_ReturnCodeTable[Index].Count--; 42 | if (Ut_CI_ReturnCodeTable[Index].Count == 0) 43 | return(TRUE); 44 | } 45 | 46 | return(FALSE); 47 | } 48 | 49 | 50 | 51 | /* Functions normally declared in Custom File (ci_custom.c) */ 52 | int32 CI_CustomInit(void) 53 | { 54 | if (Ut_CI_UseReturnCode(UT_CI_CUSTOMINIT_INDEX)) 55 | return Ut_CI_ReturnCodeTable[UT_CI_CUSTOMINIT_INDEX].Value; 56 | 57 | return CI_SUCCESS; 58 | } 59 | 60 | 61 | int32 CI_CustomAppCmds(CFE_SB_MsgPtr_t pCmdMsg) 62 | { 63 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pCmdMsg); 64 | 65 | if (Ut_CI_UseReturnCode(UT_CI_CUSTOMAPPCMDS_INDEX)) 66 | return Ut_CI_ReturnCodeTable[UT_CI_CUSTOMAPPCMDS_INDEX].Value; 67 | 68 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 69 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 70 | "Received Custom Cmd (%d)", 71 | uiCmdCode); 72 | 73 | return CI_SUCCESS; 74 | } 75 | 76 | 77 | void CI_CustomEnableTO(CFE_SB_MsgPtr_t pCmdMsg) 78 | { 79 | return; 80 | } 81 | 82 | 83 | void CI_CustomCleanup(void) 84 | { 85 | return; 86 | } 87 | -------------------------------------------------------------------------------- /fsw/examples/multi_tf/MISSION_ci_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_ci_types.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Command and telemetry data strucutres for CI application 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for CI applications for the RS422 transport protocol example. 16 | * 17 | * \par Limitations, Assumptions, External Events, and Notes: 18 | * - Make use of the setup.sh script to move / link this file to the 19 | * {MISSION_HOME}/apps/inc/ folder. 20 | * - Default HK Telemetry structure is defined in ci_hktlm.h 21 | * 22 | * \par Modification History: 23 | * - 2015-01-09 | Guy de Carufel | Code Started 24 | * - 2015-10-16 | Guy de Carufel | Moved hktlm to ci_hktlm.h 25 | *******************************************************************************/ 26 | #ifndef _MISSION_CI_TYPES_H_ 27 | #define _MISSION_CI_TYPES_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* 34 | ** Pragmas 35 | */ 36 | 37 | /* 38 | ** Include Files 39 | */ 40 | #include "cfe.h" 41 | #include "../ci/fsw/src/ci_hktlm.h" 42 | #include "../to/fsw/mission_inc/to_mission_cfg.h" 43 | 44 | /* 45 | ** Local Defines 46 | */ 47 | 48 | /* 49 | ** Local Structure Declarations 50 | */ 51 | typedef struct 52 | { 53 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 54 | } CI_NoArgCmd_t; 55 | 56 | typedef struct 57 | { 58 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 59 | char cDestIp[TO_MAX_IP_STRING_SIZE]; /* Destination Socket IP */ 60 | uint16 usDestPort; /* Destination Socket Port */ 61 | } CI_EnableTOCmd_t; 62 | 63 | 64 | typedef struct 65 | { 66 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 67 | } CI_OutData_t; 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* _CI_TO_DEV_CI_TYPES_H_ */ 75 | 76 | /*============================================================================== 77 | ** End of file MISSION_ci_types.h 78 | **============================================================================*/ 79 | 80 | -------------------------------------------------------------------------------- /fsw/examples/multi/MISSION_ci_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_ci_types.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Command and telemetry data strucutres for CI application 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for CI applications for the RS422 transport protocol example. 16 | * 17 | * \par Limitations, Assumptions, External Events, and Notes: 18 | * - Make use of the setup.sh script to move / link this file to the 19 | * {MISSION_HOME}/apps/inc/ folder. 20 | * - Default HK Telemetry structure is defined in ci_hktlm.h 21 | * 22 | * \par Modification History: 23 | * - 2015-01-09 | Guy de Carufel | Code Started 24 | * - 2015-10-16 | Guy de Carufel | Moved hktlm to ci_hktlm.h 25 | *******************************************************************************/ 26 | #ifndef _MISSION_CI_TYPES_H_ 27 | #define _MISSION_CI_TYPES_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* 34 | ** Pragmas 35 | */ 36 | 37 | /* 38 | ** Include Files 39 | */ 40 | #include "cfe.h" 41 | #include "../ci/fsw/src/ci_hktlm.h" 42 | #include "../to/fsw/mission_inc/to_mission_cfg.h" 43 | 44 | /* 45 | ** Local Defines 46 | */ 47 | 48 | /* 49 | ** Local Structure Declarations 50 | */ 51 | typedef struct 52 | { 53 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 54 | } CI_NoArgCmd_t; 55 | 56 | typedef struct 57 | { 58 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 59 | char cDestIp[TO_MAX_IP_STRING_SIZE]; /* Destination Socket IP */ 60 | uint16 usDestPort; /* Destination Socket Port */ 61 | } CI_EnableTOCmd_t; 62 | 63 | 64 | /* NOTE: In this example, the OutData is empty (not used.) */ 65 | typedef struct 66 | { 67 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 68 | } CI_OutData_t; 69 | 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* _CI_TO_DEV_CI_TYPES_H_ */ 76 | 77 | /*============================================================================== 78 | ** End of file MISSION_ci_types.h 79 | **============================================================================*/ 80 | 81 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_evs_hooks.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_evs_hooks.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_evs_hooks.h 1.1 2011/05/04 11:20:18EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test header file for cFE Event Services hooks. 13 | ** 14 | ** $Log: ut_cfe_evs_hooks.h $ 15 | ** Revision 1.1 2011/05/04 11:20:18EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:52EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.3 2011/03/10 11:16:45EST sslegel 22 | ** Added EventNotSent and PacketNotSent asserts 23 | ** Revision 1.2 2011/02/16 17:06:44EST rmcgraw 24 | ** Added "extern UtListHead_t EventQueue;" to ut_cfe_evs_hooks.h 25 | ** Revision 1.1 2011/02/15 11:12:32EST sslegel 26 | ** Initial revision 27 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 28 | ** 29 | */ 30 | 31 | #ifndef UT_CFE_EVS_HOOKS_H_ 32 | #define UT_CFE_EVS_HOOKS_H_ 33 | 34 | #include "cfe.h" 35 | #include "utassert.h" 36 | #include "utlist.h" 37 | 38 | extern UtListHead_t EventQueue; 39 | 40 | #define UtAssert_EventSent(EventID, EventType, EventText, Description) \ 41 | UtAssert(Ut_CFE_EVS_EventSent(EventID, EventType, EventText), Description, __FILE__, __LINE__) 42 | 43 | #define UtAssert_EventNotSent(EventID, EventType, EventText, Description) \ 44 | UtAssert(Ut_CFE_EVS_EventSent(EventID, EventType, EventText) == FALSE, Description, __FILE__, __LINE__) 45 | 46 | #define UtAssert_NoEventSent(Description) \ 47 | UtAssert(UtList_IsEmpty(&EventQueue), Description, __FILE__, __LINE__) 48 | 49 | void Ut_CFE_EVS_ClearEventQueue(void); 50 | uint32 Ut_CFE_EVS_GetEventQueueDepth(void); 51 | uint32 Ut_CFE_EVS_GetEventCount(uint16 EventID, uint16 EventType, char *EventText); 52 | int32 Ut_CFE_EVS_SendEventHook(uint16 EventID, uint16 EventType, char *EventText); 53 | boolean Ut_CFE_EVS_EventSent(uint16 EventID, uint16 EventType, char *EventText); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /fsw/examples/multi/ci_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_platform_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Sample config file for CI Application with RS422 device 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - Make use of the setup.sh script to move / link this file to the 15 | * {MISSION_HOME}/apps/to/fsw/platform_inc folder. 16 | * 17 | * \par Modification History: 18 | * - 2015-01-09 | Guy de Carufel | Code Started 19 | *******************************************************************************/ 20 | #ifndef _CI_PLATFORM_CFG_H_ 21 | #define _CI_PLATFORM_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | /* Check new commands every 1s if not scheduled */ 35 | #define CI_WAKEUP_TIMEOUT 1000 36 | 37 | #define CI_SCH_PIPE_DEPTH 10 38 | #define CI_CMD_PIPE_DEPTH 10 39 | #define CI_TLM_PIPE_DEPTH 10 40 | 41 | //swdev - Loopback 42 | #define CI_CONFIG_SERIAL_PORT "/dev/ttyS6" 43 | //#define CI_CONFIG_SERIAL_PORT "/tyCo/2" 44 | #define CI_CONFIG_BAUD_RATE 921600 45 | #define CI_CONFIG_TIMEOUT 100 46 | #define CI_CONFIG_MINBYTES 6 47 | 48 | #define CI_CUSTOM_UDP_PORT 5010 49 | #define CI_CUSTOM_UDP_ADDR IO_TRANS_UDP_INADDR_ANY 50 | #define CI_CUSTOM_UDP_TIMEOUT 100 51 | #define CI_CUSTOM_MAX_IP_STRING_SIZE 16 52 | 53 | #define CI_CUSTOM_BUFFER_SIZE 1000 54 | 55 | #define CI_CUSTOM_TASK_STACK_PTR NULL 56 | #define CI_CUSTOM_TASK_STACK_SIZE 0x4000 57 | #define CI_CUSTOM_TASK_PRIO 118 58 | 59 | /* 60 | ** Include Files 61 | */ 62 | 63 | /* 64 | ** Local Structure Declarations 65 | */ 66 | 67 | /* 68 | ** External Global Variables 69 | */ 70 | 71 | /* 72 | ** Global Variables 73 | */ 74 | 75 | /* 76 | ** Local Variables 77 | */ 78 | 79 | /* 80 | ** Local Function Prototypes 81 | */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* _CI_PLATFORM_CFG_H_ */ 88 | 89 | /*============================================================================== 90 | ** End of file ci_platform_cfg.h 91 | **============================================================================*/ 92 | 93 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_tbl_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_tbl_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_tbl_stubs.h 1.1 2011/05/04 11:20:23EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE Table Services Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_tbl_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:23EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:56EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.2 2011/02/18 15:57:43EST sslegel 22 | ** Added new hooks and return codes 23 | ** Changed Ut_CFE_TBL_LoadHook to automatically call the table validate function 24 | ** Revision 1.1 2011/02/15 11:12:35EST sslegel 25 | ** Initial revision 26 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 27 | ** 28 | */ 29 | 30 | #ifndef UT_CFE_TBL_STUBS_H_ 31 | #define UT_CFE_TBL_STUBS_H_ 32 | 33 | typedef enum 34 | { 35 | UT_CFE_TBL_REGISTER_INDEX, 36 | UT_CFE_TBL_LOAD_INDEX, 37 | UT_CFE_TBL_MANAGE_INDEX, 38 | UT_CFE_TBL_GETADDRESS_INDEX, 39 | UT_CFE_TBL_GETADDRESSES_INDEX, 40 | UT_CFE_TBL_GETSTATUS_INDEX, 41 | UT_CFE_TBL_GETINFO_INDEX, 42 | UT_CFE_TBL_MAX_INDEX 43 | } Ut_CFE_TBL_INDEX_t; 44 | 45 | typedef struct 46 | { 47 | int32 (*CFE_TBL_Register)(CFE_TBL_Handle_t*, const char *,uint32, uint16, CFE_TBL_CallbackFuncPtr_t); 48 | int32 (*CFE_TBL_Load)(CFE_TBL_Handle_t, CFE_TBL_SrcEnum_t, const void *); 49 | int32 (*CFE_TBL_Manage)(CFE_TBL_Handle_t); 50 | int32 (*CFE_TBL_GetAddress)(void **, CFE_TBL_Handle_t); 51 | int32 (*CFE_TBL_GetAddresses)(void **[], uint16, const CFE_TBL_Handle_t []); 52 | int32 (*CFE_TBL_GetInfo)(CFE_TBL_Info_t *TblInfoPtr, const char *TblName); 53 | } Ut_CFE_TBL_HookTable_t; 54 | 55 | typedef struct 56 | { 57 | int32 Value; 58 | uint32 Count; 59 | } Ut_CFE_TBL_ReturnCodeTable_t; 60 | 61 | void Ut_CFE_TBL_Reset(void); 62 | void Ut_CFE_TBL_SetFunctionHook(uint32 Index, void *FunPtr); 63 | void Ut_CFE_TBL_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /fsw/examples/multi_tf/ci_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_platform_cfg.h 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Sample config file for CI Application with RS422 device with COP1 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * - Make use of the setup.sh script to copy / link this file to the 15 | * {MISSION_HOME}/apps/to/fsw/platform_inc folder. 16 | * 17 | * \par Modification History: 18 | * - 2015-08-01 | Guy de Carufel | Code Started 19 | *******************************************************************************/ 20 | #ifndef _CI_PLATFORM_CFG_H_ 21 | #define _CI_PLATFORM_CFG_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | ** Pragmas 29 | */ 30 | 31 | /* 32 | ** Local Defines 33 | */ 34 | /* Check new commands every 1s if not scheduled */ 35 | #define CI_WAKEUP_TIMEOUT 1000 36 | 37 | #define CI_SCH_PIPE_DEPTH 10 38 | #define CI_CMD_PIPE_DEPTH 10 39 | #define CI_TLM_PIPE_DEPTH 10 40 | 41 | #define CI_CUSTOM_SERIAL_PORT "/dev/ttyS6" 42 | #define CI_CUSTOM_BAUD_RATE 921600 43 | #define CI_CUSTOM_TIMEOUT 300 44 | #define CI_CUSTOM_MINBYTES 6 45 | 46 | #define CI_CUSTOM_UDP_PORT 5010 47 | #define CI_CUSTOM_UDP_ADDR IO_TRANS_UDP_INADDR_ANY 48 | #define CI_CUSTOM_UDP_TIMEOUT 100 49 | #define CI_CUSTOM_MAX_IP_STRING_SIZE 16 50 | 51 | #define CI_CUSTOM_CLTU_RANDOM_UDP 0 52 | #define CI_CUSTOM_CLTU_RANDOM_SERIAL 0 53 | 54 | #define CI_CUSTOM_CLTU_BUFF_SIZE 1000 55 | #define CI_CUSTOM_TF_BUFF_SIZE 1000 56 | #define CI_CUSTOM_BUFFER_SIZE 1000 57 | 58 | #define CI_CUSTOM_TASK_STACK_PTR NULL 59 | #define CI_CUSTOM_TASK_STACK_SIZE 0x4000 60 | #define CI_CUSTOM_TASK_PRIO 118 61 | 62 | #define CI_CUSTOM_TF_CHANNELS 1 63 | 64 | /* 65 | ** Include Files 66 | */ 67 | 68 | /* 69 | ** Local Structure Declarations 70 | */ 71 | 72 | /* 73 | ** External Global Variables 74 | */ 75 | 76 | /* 77 | ** Global Variables 78 | */ 79 | 80 | /* 81 | ** Local Variables 82 | */ 83 | 84 | /* 85 | ** Local Function Prototypes 86 | */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* _CI_PLATFORM_CFG_H_ */ 93 | 94 | /*============================================================================== 95 | ** End of file ci_platform_cfg.h 96 | **============================================================================*/ 97 | 98 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/uttest.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: uttest.c 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a standard way to execute unit tests. 11 | * 12 | */ 13 | 14 | /* 15 | * Includes 16 | */ 17 | 18 | #include "common_types.h" 19 | #include "utassert.h" 20 | #include "utlist.h" 21 | 22 | /* 23 | * Type Definitions 24 | */ 25 | 26 | typedef struct { 27 | void (*Test)(void); 28 | void (*Setup)(void); 29 | void (*Teardown)(void); 30 | char *TestName; 31 | } UtTestDataBaseEntry_t; 32 | 33 | /* 34 | * Local Data 35 | */ 36 | 37 | UtListHead_t UtTestDataBase; 38 | uint32 UtTestsExecutedCount = 0; 39 | 40 | /* 41 | * Function Definitions 42 | */ 43 | 44 | void UtTest_Add(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), char *TestName) 45 | { 46 | UtTestDataBaseEntry_t UtTestDataBaseEntry; 47 | 48 | UtTestDataBaseEntry.Test = Test; 49 | UtTestDataBaseEntry.Setup = Setup; 50 | UtTestDataBaseEntry.Teardown = Teardown; 51 | UtTestDataBaseEntry.TestName = TestName; 52 | UtList_Add(&UtTestDataBase, &UtTestDataBaseEntry, sizeof(UtTestDataBaseEntry_t), 0); 53 | } 54 | 55 | int UtTest_Run(void) 56 | { 57 | uint32 i; 58 | UtListNode_t *UtListNode; 59 | UtTestDataBaseEntry_t *UtTestDataBaseEntry; 60 | 61 | if (UtTestDataBase.NumberOfEntries > 0) { 62 | 63 | UtListNode = UtTestDataBase.First; 64 | for (i=0; i < UtTestDataBase.NumberOfEntries; i++) { 65 | 66 | UtTestDataBaseEntry = UtListNode->Data; 67 | 68 | #ifdef UT_VERBOSE 69 | if (strlen(UtTestDataBaseEntry->TestName) > 0) { printf("\nRunning Test: %s\n", UtTestDataBaseEntry->TestName); } 70 | #endif 71 | 72 | if (UtTestDataBaseEntry->Setup) { UtTestDataBaseEntry->Setup(); } 73 | if (UtTestDataBaseEntry->Test) { UtTestDataBaseEntry->Test(); UtTestsExecutedCount++; } 74 | if (UtTestDataBaseEntry->Teardown) { UtTestDataBaseEntry->Teardown(); } 75 | 76 | UtListNode = UtListNode->Next; 77 | } 78 | } 79 | 80 | printf("\n"); 81 | printf("Tests Executed: %u\n", UtTestsExecutedCount); 82 | printf("Assert Pass Count: %u\n", UtAssert_GetPassCount()); 83 | printf("Assert Fail Count: %u\n", UtAssert_GetFailCount()); 84 | 85 | UtList_Reset(&UtTestDataBase); 86 | 87 | return (UtAssert_GetFailCount() > 0); 88 | } 89 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/uttools.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: uttools.h 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a set of tools for use in unit testing. 11 | * 12 | * Design Notes: 13 | * 14 | * References: 15 | * 16 | */ 17 | 18 | #ifndef _uttools_ 19 | #define _uttools_ 20 | 21 | /* 22 | * Includes 23 | */ 24 | 25 | #include "common_types.h" 26 | 27 | /* 28 | * Macro Definitions 29 | */ 30 | 31 | #define UtMemSet memset 32 | 33 | /* 34 | * Exported Functions 35 | */ 36 | 37 | /* Copies a region of memory to a binary file. This file can be reloaded by calling UtBinFile2Mem or it can be 38 | * used to verify test results by calling UtMem2BinFileCmp. */ 39 | boolean UtMem2BinFile(void *Memory, char *Filename, uint32 Length); 40 | 41 | /* Copies a binary file to a region of memory. */ 42 | boolean UtBinFile2Mem(void *Memory, char *Filename, uint32 Length); 43 | 44 | /* Copies a region of memory to a hex file */ 45 | boolean UtMem2HexFile(void *Memory, char *Filename, uint32 Length); 46 | 47 | /* Fills a region of memory with a byte count pattern. */ 48 | void UtMemFill(void *Memory, uint32 Length); 49 | 50 | /* Just like the standard printf except it will supress its output unless the macro UT_VERBOSE 51 | * is defined. */ 52 | void UtPrintf(char *Spec, ...); 53 | 54 | /* Just like the standard sprintf except it returns a pointer to the result string. The result string 55 | * cannot be larger than 256 bytes. */ 56 | char *UtSprintf(char *Spec, ...); 57 | 58 | /* Calls UtPrintf to print a range of memory as hex bytes. */ 59 | void UtPrintx(void *Memory, uint32 Length); 60 | 61 | /* Compares a region of memory to a static pattern and determines if they are equal. Note: Use UtMemSet to 62 | * fill a region of memory with a static pattern. */ 63 | boolean UtMemCmpValue(void *Memory, uint8 Value, uint32 Length); 64 | 65 | /* Compares a region of memory to a byte count pattern and determines if they are equal. Note: Use UtMemFill to 66 | * fill a region of memory with a byte count pattern. */ 67 | boolean UtMemCmpCount(void *Memory, uint32 Length); 68 | 69 | /* Compares a region of memory with the contents of a binary file and determines if they are equal. Note: Use 70 | * UtMem2BinFile to copy a region of memory to a binary file. */ 71 | boolean UtMem2BinFileCmp(void *Memory, char *Filename); 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_osfileapi_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_osfileapi_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_osfileapi_stubs.h 1.1 2011/05/04 11:20:25EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: OSAPI File Services Header file for unit test stubs. 13 | ** 14 | ** $Log: ut_osfileapi_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:25EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:59EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.3 2011/03/30 09:58:56EDT rmcgraw 22 | ** Added Hook and Return enhancements to Directory APIs 23 | ** Revision 1.2 2011/03/24 13:14:54EDT rmcgraw 24 | ** Added Hook and RtnCode functionality to OS_stat 25 | ** Revision 1.1 2011/02/15 11:12:36EST sslegel 26 | ** Initial revision 27 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 28 | ** 29 | */ 30 | 31 | #ifndef UT_OSFILEAPI_STUBS_H_ 32 | #define UT_OSFILEAPI_STUBS_H_ 33 | 34 | typedef enum 35 | { 36 | UT_OSFILEAPI_CREAT_INDEX, 37 | UT_OSFILEAPI_WRITE_INDEX, 38 | UT_OSFILEAPI_READ_INDEX, 39 | UT_OSFILEAPI_OPENDIR_INDEX, 40 | UT_OSFILEAPI_READDIR_INDEX, 41 | UT_OSFILEAPI_CLOSE_INDEX, 42 | UT_OSFILEAPI_OPEN_INDEX, 43 | UT_OSFILEAPI_CLOSEDIR_INDEX, 44 | UT_OSFILEAPI_STAT_INDEX, 45 | UT_OSFILEAPI_FDGETINFO_INDEX, 46 | UT_OSFILEAPI_MAX_INDEX 47 | } Ut_OSFILEAPI_INDEX_t; 48 | 49 | typedef struct 50 | { 51 | int32 (*OS_creat)(const char *,int32); 52 | int32 (*OS_write)(int32, void *, uint32); 53 | int32 (*OS_read)(int32, void *, uint32); 54 | os_dirp_t (*OS_opendir)(const char *path); 55 | os_dirent_t* (*OS_readdir)(os_dirp_t directory); 56 | int32 (*OS_close)(int32 filedes); 57 | int32 (*OS_open)(const char *path, int32 access, uint32 mode); 58 | int32 (*OS_closedir)(os_dirp_t directory); 59 | int32 (*OS_stat)(const char *path, os_fstat_t *filestats); 60 | int32 (*OS_FDGetInfo) (int32 filedes, OS_FDTableEntry *fd_prop); 61 | 62 | } Ut_OSFILEAPI_HookTable_t; 63 | 64 | typedef struct 65 | { 66 | int32 Value; 67 | uint32 Count; 68 | } Ut_OSFILEAPI_ReturnCodeTable_t; 69 | 70 | void Ut_OSFILEAPI_Reset(void); 71 | void Ut_OSFILEAPI_SetFunctionHook(uint32 Index, void *FunPtr); 72 | void Ut_OSFILEAPI_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_time_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_time_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_time_stubs.c 1.1 2011/05/04 11:20:58EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE Time Services routines 13 | ** 14 | ** $Log: ut_cfe_time_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:20:58EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:43EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.1 2011/02/15 11:13:05EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 24 | ** 25 | */ 26 | 27 | #include "cfe.h" 28 | #include "ut_cfe_time_stubs.h" 29 | #include 30 | 31 | Ut_CFE_TIME_HookTable_t Ut_CFE_TIME_HookTable; 32 | Ut_CFE_TIME_ReturnCodeTable_t Ut_CFE_TIME_ReturnCodeTable[UT_CFE_TIME_MAX_INDEX]; 33 | 34 | void Ut_CFE_TIME_Reset(void) 35 | { 36 | memset(&Ut_CFE_TIME_HookTable, 0, sizeof(Ut_CFE_TIME_HookTable)); 37 | memset(&Ut_CFE_TIME_ReturnCodeTable, 0, sizeof(Ut_CFE_TIME_ReturnCodeTable)); 38 | } 39 | 40 | void Ut_CFE_TIME_SetFunctionHook(uint32 Index, void *FunPtr) 41 | { 42 | if (Index == UT_CFE_TIME_GETTIME_INDEX) { Ut_CFE_TIME_HookTable.CFE_TIME_GetTime = FunPtr; } 43 | else { printf("Unsupported TIME Index In SetFunctionHook Call %u\n", Index); } 44 | } 45 | 46 | void Ut_CFE_TIME_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 47 | { 48 | if (Index < UT_CFE_TIME_MAX_INDEX) { 49 | Ut_CFE_TIME_ReturnCodeTable[Index].Value = RtnVal; 50 | Ut_CFE_TIME_ReturnCodeTable[Index].Count = CallCnt; 51 | } 52 | else { 53 | printf("Unsupported TIME Index In SetReturnCode Call %u\n", Index); 54 | } 55 | } 56 | 57 | boolean Ut_CFE_TIME_UseReturnCode(uint32 Index) 58 | { 59 | if (Ut_CFE_TIME_ReturnCodeTable[Index].Count > 0) { 60 | Ut_CFE_TIME_ReturnCodeTable[Index].Count--; 61 | if (Ut_CFE_TIME_ReturnCodeTable[Index].Count == 0) 62 | return(TRUE); 63 | } 64 | 65 | return(FALSE); 66 | } 67 | 68 | CFE_TIME_SysTime_t CFE_TIME_GetTime(void) 69 | { 70 | CFE_TIME_SysTime_t Time; 71 | 72 | /* Check for Function Hook */ 73 | if (Ut_CFE_TIME_HookTable.CFE_TIME_GetTime) 74 | return Ut_CFE_TIME_HookTable.CFE_TIME_GetTime(); 75 | 76 | Time.Seconds = 0; 77 | Time.Subseconds = 0; 78 | 79 | return Time; 80 | } 81 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_osapi_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_osapi_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_osapi_stubs.h 1.2 2011/05/16 16:25:33EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: OSAPI Header file for unit test stubs 13 | ** 14 | ** $Log: ut_osapi_stubs.h $ 15 | ** Revision 1.2 2011/05/16 16:25:33EDT rmcgraw 16 | ** Added hook functionality to Count Semaphore APIs 17 | ** Revision 1.3 2011/05/16 14:42:41EDT rmcgraw 18 | ** Added SetRtnCode processing to Counting Semaphore APIs 19 | ** Revision 1.2 2011/03/08 15:42:03EST rmcgraw 20 | ** Added OS_CountSemGetIdByName 21 | ** Revision 1.1 2011/02/15 11:12:35EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_OSAPI_STUBS_H_ 28 | #define UT_OSAPI_STUBS_H_ 29 | 30 | typedef enum 31 | { 32 | UT_OSAPI_TASKDELAY_INDEX, 33 | UT_OSAPI_BINSEMTAKE_INDEX, 34 | UT_OSAPI_BINSEMTIMEDWAIT_INDEX, 35 | UT_OSAPI_MUTSEMTAKE_INDEX, 36 | UT_OSAPI_GETLOCALTIME_INDEX, 37 | UT_OSAPI_QUEUEGET_INDEX, 38 | UT_OSAPI_QUEUEPUT_INDEX, 39 | UT_OSAPI_TASKDELETE_INDEX, 40 | UT_OSAPI_BINSEMGIVE_INDEX, 41 | UT_OSAPI_COUNTSEMCREATE_INDEX, 42 | UT_OSAPI_COUNTSEMDELETE_INDEX, 43 | UT_OSAPI_COUNTSEMGIVE_INDEX, 44 | UT_OSAPI_COUNTSEMTAKE_INDEX, 45 | UT_OSAPI_COUNTSEMTIMEDWAIT_INDEX, 46 | UT_OSAPI_COUNTSEMGETIDBYNAME_INDEX, 47 | UT_OSAPI_COUNTSEMGETINFO_INDEX, 48 | UT_OSAPI_MAX_INDEX 49 | } Ut_OSAPI_Index_t; 50 | 51 | typedef struct 52 | { 53 | int32 (*OS_TaskDelay)(uint32); 54 | int32 (*OS_BinSemTake)(uint32); 55 | int32 (*OS_BinSemTimedWait)(uint32, uint32); 56 | int32 (*OS_MutSemTake)(uint32); 57 | int32 (*OS_GetLocalTime)(OS_time_t *); 58 | int32 (*OS_QueueGet)(uint32, void *, uint32, uint32 *, int32); 59 | int32 (*OS_QueuePut)(uint32, void *, uint32, uint32); 60 | int32 (*OS_TaskDelete)(uint32); 61 | int32 (*OS_BinSemGive)(uint32); 62 | int32 (*OS_CountSemCreate)(uint32 *sem_id, const char *sem_name, uint32 sem_initial_value, uint32 options); 63 | int32 (*OS_CountSemDelete)(uint32 sem_id); 64 | int32 (*OS_CountSemGive)(uint32 sem_id); 65 | int32 (*OS_CountSemTake)(uint32 sem_id); 66 | int32 (*OS_CountSemTimedWait)(uint32 sem_id, uint32 msecs); 67 | int32 (*OS_CountSemGetIdByName)(uint32 *sem_id, const char *sem_name); 68 | int32 (*OS_CountSemGetInfo)(uint32 sem_id, OS_count_sem_prop_t *count_prop); 69 | } Ut_OSAPI_HookTable_t; 70 | 71 | typedef struct 72 | { 73 | int32 Value; 74 | uint32 Count; 75 | } Ut_OSAPI_ReturnCodeTable_t; 76 | 77 | void Ut_OSAPI_Reset(void); 78 | void Ut_OSAPI_SetFunctionHook(uint32 Index, void *FunPtr); 79 | void Ut_OSAPI_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /fsw/src/ci_utils.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_utils.c 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Function Definitions of utility functions 12 | * 13 | * \par 14 | * This file defines utility functions used by other CI functions. 15 | * 16 | * \par API Functions Defined: 17 | * - CI_IncrHkCounter() - Increment a HK Counter with memory protection 18 | * - CI_VerifyCmdLength() - Verify length of command message 19 | * 20 | * \par Private Functions Defined: 21 | * 22 | * \par Limitations, Assumptions, External Events, and Notes: 23 | * 24 | * \par Modification History: 25 | * - 2015-01-09 | Guy de Carufel | Code Started 26 | *******************************************************************************/ 27 | 28 | /* 29 | ** Include Files 30 | */ 31 | #include "ci_app.h" 32 | 33 | /* 34 | ** Local Defines 35 | */ 36 | 37 | /* 38 | ** Local Structure Declarations 39 | */ 40 | 41 | 42 | /* 43 | ** External Global Variables 44 | */ 45 | extern CI_AppData_t g_CI_AppData; 46 | 47 | /* 48 | ** Global Variables 49 | */ 50 | 51 | /* 52 | ** Local Variables 53 | */ 54 | 55 | /* 56 | ** Local Function Definitions 57 | */ 58 | 59 | 60 | /******************************************************************************/ 61 | /** \brief Increment a housekeeping packet counter 62 | *******************************************************************************/ 63 | void CI_IncrHkCounter(uint16 * counter) 64 | { 65 | OS_MutSemTake(g_CI_AppData.ciMutex); 66 | *counter = *counter + 1; 67 | OS_MutSemGive(g_CI_AppData.ciMutex); 68 | } 69 | 70 | 71 | /******************************************************************************/ 72 | /** \brief Verify the command length against expected length 73 | *******************************************************************************/ 74 | boolean CI_VerifyCmdLength(CFE_SB_MsgPtr_t pMsg, 75 | uint16 usExpectedLen) 76 | { 77 | boolean bResult=FALSE; 78 | uint16 usMsgLen=0; 79 | 80 | if (pMsg != NULL) 81 | { 82 | usMsgLen = CFE_SB_GetTotalMsgLength(pMsg); 83 | 84 | if (usExpectedLen == usMsgLen) 85 | { 86 | bResult = TRUE; 87 | } 88 | else 89 | { 90 | CFE_SB_MsgId_t MsgId = CFE_SB_GetMsgId(pMsg); 91 | uint16 usCmdCode = CFE_SB_GetCmdCode(pMsg); 92 | 93 | CFE_EVS_SendEvent(CI_MSGLEN_ERR_EID, CFE_EVS_ERROR, 94 | "CI: Rcvd invalid msgLen: msgId=0x%04X, " 95 | "cmdCode=%d, msgLen=%d, expectedLen=%d", 96 | MsgId, usCmdCode, usMsgLen, usExpectedLen); 97 | 98 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdErrCnt); 99 | } 100 | } 101 | 102 | return (bResult); 103 | } 104 | 105 | /*============================================================================== 106 | ** End of file ci_utils.c 107 | **============================================================================*/ 108 | -------------------------------------------------------------------------------- /fsw/for_build/Makefile: -------------------------------------------------------------------------------- 1 | ####################################################################################### 2 | # 3 | # File: CFS Application Makefile 4 | # Author: GSFC/Flight Software Branch/Code 582 5 | # Date: 2008-2010 6 | # 7 | ####################################################################################### 8 | 9 | # 10 | # Subsystem produced by this makefile 11 | # 12 | export APPTARGET = ci 13 | 14 | # 15 | # Entry Point for task 16 | # 17 | ENTRY_PT = CI_AppMain 18 | 19 | # 20 | # Object files required to build subsystem. 21 | # 22 | OBJS = ci_app.o ci_custom.o ci_utils.o 23 | 24 | # 25 | # Source files required to build subsystem; used to generate dependencies. 26 | # As long as there are no assembly files this can be automated. 27 | # 28 | SOURCES = $(OBJS:.o=.c) 29 | 30 | # 31 | # Specify extra C Flags needed to build this subsystem 32 | # 33 | LOCAL_COPTS = 34 | 35 | # 36 | # EXEDIR is defined here, just in case it needs to be different for a custom build 37 | # 38 | EXEDIR=../exe 39 | 40 | # 41 | # Certain OSs and Application Loaders require the following option for shared libraries. 42 | # Currently only needed for vxWorks 5.5 and RTEMS. 43 | # For each shared library that this app depends on, you need to have an entry like the 44 | # following: 45 | # -R../tst_lib/tst_lib.elf 46 | # 47 | SHARED_LIB_LINK = 48 | 49 | #====================================================================================== 50 | # Should not have to change below this line, except for customized mission and cFE 51 | # directory structures 52 | #====================================================================================== 53 | # 54 | # Set build type to CFE_APP. This allows us to 55 | # define different compiler flags for the cFE Core and Apps. 56 | # 57 | BUILD_TYPE = CFE_APP 58 | 59 | # 60 | # Include all necessary cFE make rules 61 | # Any of these can be copied to a local file and changed if needed. 62 | # 63 | # cfe-config.mak contains PSP and OS selection 64 | # 65 | include ../cfe/cfe-config.mak 66 | # 67 | # debug-opts.mak contains debug switches 68 | # 69 | include ../cfe/debug-opts.mak 70 | # 71 | # compiler-opts.mak contains compiler definitions and switches/defines 72 | # 73 | include $(CFE_PSP_SRC)/$(PSP)/make/compiler-opts.mak 74 | 75 | # 76 | # Setup the include path for this subsystem 77 | # The OS specific includes are in the build-rules.make file 78 | # 79 | # If this subsystem needs include files from another app, add the path here. 80 | # 81 | INCLUDE_PATH = -I$(OSAL_SRC)/inc \ 82 | -I$(CFE_CORE_SRC)/inc \ 83 | -I$(CFE_PSP_SRC)/inc \ 84 | -I$(CFE_PSP_SRC)/$(PSP)/inc \ 85 | -I$(CFS_APP_SRC)/inc \ 86 | -I$(CFS_APP_SRC)/io_lib/fsw/public_inc \ 87 | -I$(CFS_APP_SRC)/$(APPTARGET)/fsw/src \ 88 | -I$(CFS_APP_SRC)/$(APPTARGET)/fsw/tables \ 89 | -I$(CFS_MISSION_INC) \ 90 | -I../cfe/inc \ 91 | -I../inc \ 92 | -I$(CFS_APP_SRC)/to/fsw/src \ 93 | # Note: There are explicit TO dependencies from CI. 94 | 95 | # 96 | # Define the VPATH make variable. 97 | # This can be modified to include source from another directory. 98 | # If there is no corresponding app in the cfs-apps directory, then this can be discarded, 99 | # or if the mission chooses to put the src in another directory such as "src", then that 100 | # can be added here as well. 101 | # 102 | VPATH = $(CFS_APP_SRC)/$(APPTARGET)/fsw/src \ 103 | $(CFS_APP_SRC)/$(APPTARGET)/fsw/tables \ 104 | 105 | # 106 | # Include the common make rules for building a cFE Application 107 | # 108 | include $(CFE_CORE_SRC)/make/app-rules.mak 109 | 110 | ####################################################################################### 111 | 112 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_fs_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_fs_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_fs_stubs.c 1.1 2011/05/04 11:20:53EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE File system routines 13 | ** 14 | ** $Log: ut_cfe_fs_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:20:53EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:39EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.2 2011/03/22 14:19:02EDT rmcgraw 22 | ** Use Rtn Code Added to CFE_FS_WriteHeader 23 | ** Revision 1.1 2011/02/15 11:13:02EST sslegel 24 | ** Initial revision 25 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 26 | ** 27 | */ 28 | 29 | #include "cfe.h" 30 | #include "ut_cfe_fs_stubs.h" 31 | #include 32 | 33 | Ut_CFE_FS_HookTable_t Ut_CFE_FS_HookTable; 34 | Ut_CFE_FS_ReturnCodeTable_t Ut_CFE_FS_ReturnCodeTable[UT_CFE_FS_MAX_INDEX]; 35 | 36 | void Ut_CFE_FS_Reset(void) 37 | { 38 | memset(&Ut_CFE_FS_HookTable, 0, sizeof(Ut_CFE_FS_HookTable)); 39 | memset(&Ut_CFE_FS_ReturnCodeTable, 0, sizeof(Ut_CFE_FS_ReturnCodeTable)); 40 | } 41 | 42 | void Ut_CFE_FS_SetFunctionHook(uint32 Index, void *FunPtr) 43 | { 44 | if (Index == UT_CFE_FS_READHDR_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_ReadHeader = FunPtr; } 45 | else if (Index == UT_CFE_FS_WRITEHDR_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_WriteHeader = FunPtr; } 46 | else if (Index == UT_CFE_FS_SETTIMESTAMP_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_SetTimestamp = FunPtr; } 47 | else if (Index == UT_CFE_FS_ISGZFILE_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_IsGzFile = FunPtr; } 48 | else if (Index == UT_CFE_FS_EXTRACTFILENAMEFROMPATH_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_ExtractFilenameFromPath = FunPtr; } 49 | else if (Index == UT_CFE_FS_DECOMPRESS_INDEX) { Ut_CFE_FS_HookTable.CFE_FS_Decompress = FunPtr; } 50 | else { printf("Invalid FS Index In SetFunctionHook Call %u\n", Index); } 51 | } 52 | 53 | void Ut_CFE_FS_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 54 | { 55 | if (Index < UT_CFE_FS_MAX_INDEX) { 56 | Ut_CFE_FS_ReturnCodeTable[Index].Value = RtnVal; 57 | Ut_CFE_FS_ReturnCodeTable[Index].Count = CallCnt; 58 | } 59 | else { 60 | printf("Unsupported FS Index In SetReturnCode Call %u\n", Index); 61 | } 62 | } 63 | 64 | boolean Ut_CFE_FS_UseReturnCode(uint32 Index) 65 | { 66 | if (Ut_CFE_FS_ReturnCodeTable[Index].Count > 0) { 67 | Ut_CFE_FS_ReturnCodeTable[Index].Count--; 68 | if (Ut_CFE_FS_ReturnCodeTable[Index].Count == 0) 69 | return(TRUE); 70 | } 71 | 72 | return(FALSE); 73 | } 74 | 75 | int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) 76 | { 77 | return CFE_SUCCESS; 78 | } 79 | 80 | int32 CFE_FS_WriteHeader(int32 FileDes, CFE_FS_Header_t *Hdr) 81 | { 82 | /* Check for specified return */ 83 | if (Ut_CFE_FS_UseReturnCode(UT_CFE_FS_WRITEHDR_INDEX)) 84 | return Ut_CFE_FS_ReturnCodeTable[UT_CFE_FS_WRITEHDR_INDEX].Value; 85 | 86 | return CFE_SUCCESS; 87 | } 88 | 89 | int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp) 90 | { 91 | return CFE_SUCCESS; 92 | } 93 | 94 | boolean CFE_FS_IsGzFile(const char *FileName) 95 | { 96 | return TRUE; 97 | } 98 | 99 | int32 CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly) 100 | { 101 | return CFE_SUCCESS; 102 | } 103 | 104 | int32 CFE_FS_Decompress( const char * SourceFile, const char * DestinationFile ) 105 | { 106 | return CFE_SUCCESS; 107 | } 108 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_evs_hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_evs_hooks.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_evs_hooks.c 1.1 2011/05/04 11:20:52EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test hooks for cFE Event Services routines 13 | ** 14 | ** $Log: ut_cfe_evs_hooks.c $ 15 | ** Revision 1.1 2011/05/04 11:20:52EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:38EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.2 2011/03/04 14:56:05EST sslegel 22 | ** Added a event text length check 23 | ** Revision 1.1 2011/02/15 11:13:01EST sslegel 24 | ** Initial revision 25 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 26 | ** 27 | */ 28 | 29 | #include "cfe.h" 30 | #include "utlist.h" 31 | #include "uttools.h" 32 | #include 33 | 34 | UtListHead_t EventQueue; 35 | 36 | typedef struct { 37 | uint16 EventID; 38 | uint16 EventType; 39 | char EventText[CFE_EVS_MAX_MESSAGE_LENGTH]; 40 | } Ut_CFE_EVS_Event_t; 41 | 42 | void Ut_CFE_EVS_ClearEventQueue(void) 43 | { 44 | UtList_Reset(&EventQueue); 45 | } 46 | 47 | uint32 Ut_CFE_EVS_GetEventQueueDepth(void) 48 | { 49 | return(UtList_Depth(&EventQueue)); 50 | } 51 | 52 | uint32 Ut_CFE_EVS_GetEventCount(uint16 EventID, uint16 EventType, char *EventText) 53 | { 54 | UtListNode_t *CurrentNode; 55 | Ut_CFE_EVS_Event_t *EventMessagePtr; 56 | uint32 EventCount = 0; 57 | 58 | CurrentNode = UtList_First(&EventQueue); 59 | while (CurrentNode) { 60 | EventMessagePtr = CurrentNode->Data; 61 | if ((EventMessagePtr->EventID == EventID) && 62 | (EventMessagePtr->EventType == EventType) && 63 | (strncmp(EventText, EventMessagePtr->EventText, strlen(EventText)) == 0)) { 64 | EventCount++; 65 | } 66 | CurrentNode = CurrentNode->Next; 67 | } 68 | return(EventCount); 69 | } 70 | 71 | int32 Ut_CFE_EVS_SendEventHook(uint16 EventID, uint16 EventType, char *EventText) 72 | { 73 | Ut_CFE_EVS_Event_t EventMessage; 74 | 75 | if (strlen(EventText) >= CFE_EVS_MAX_MESSAGE_LENGTH) { 76 | UtPrintf("WARNING - Event Message Too Long: %s", EventText); 77 | } 78 | 79 | EventMessage.EventID = EventID; 80 | EventMessage.EventType = EventType; 81 | strncpy(&EventMessage.EventText[0], EventText, CFE_EVS_MAX_MESSAGE_LENGTH); 82 | UtList_Add(&EventQueue, &EventMessage, sizeof(EventMessage), 0); 83 | 84 | if (EventType == CFE_EVS_DEBUG) 85 | UtPrintf("DEBUG EVENT ID=%d %s\n", EventID, EventText); 86 | else if (EventType == CFE_EVS_INFORMATION) 87 | UtPrintf("INFO EVENT ID=%d %s\n", EventID, EventText); 88 | else if (EventType == CFE_EVS_ERROR) 89 | UtPrintf("ERROR EVENT ID=%d %s\n", EventID, EventText); 90 | else if (EventType == CFE_EVS_CRITICAL) 91 | UtPrintf("CRITICAL EVENT ID=%d %s\n", EventID, EventText); 92 | else 93 | UtPrintf("Invalid Event Type %d ID=%d %s\n", EventType, EventID, EventText); 94 | 95 | return CFE_SUCCESS; 96 | } 97 | 98 | boolean Ut_CFE_EVS_EventSent(uint16 EventID, uint16 EventType, char *EventText) 99 | { 100 | UtListNode_t *CurrentNode; 101 | Ut_CFE_EVS_Event_t *EventMessagePtr; 102 | 103 | CurrentNode = UtList_First(&EventQueue); 104 | while (CurrentNode) { 105 | EventMessagePtr = CurrentNode->Data; 106 | if ((EventMessagePtr->EventID == EventID) && 107 | (EventMessagePtr->EventType == EventType) && 108 | (strncmp(EventText, EventMessagePtr->EventText, strlen(EventText)) == 0)) { 109 | return(TRUE); 110 | } 111 | CurrentNode = CurrentNode->Next; 112 | } 113 | return(FALSE); 114 | } 115 | -------------------------------------------------------------------------------- /fsw/examples/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Desc: This Script will copy or link example files to appropriate locations. 3 | # Author: Guy de Carufel, Allen Brown (Odyssey Space Research) 4 | # Date: May 11, 2016 5 | 6 | usage () 7 | { 8 | echo -e "\nHELP TEXT\n" 9 | echo -e "\tScript to cp (or link) example files to appropriate locations." 10 | echo -e "\tNOTE: Target will be overwritten if it already exists.\n" 11 | echo -e "\tOption: -h This help text." 12 | echo -e "\tOption: -l Create symbolic link instead of a copy." 13 | echo -e "\tOption: -m {NAME} Mission name. (default: MISSION_NAME env var)" 14 | echo -e "\t (This controls the *_ci_types.h name.)" 15 | echo -e "\tArg: example (dir) name." 16 | echo -e "\n\tNote: Expects either a MISSION_HOME or APP_DIR env variable " 17 | echo -e "\t to locate apps/inc (which must exist)." 18 | echo -e "\tNote: Either the MISSION_NAME env var or the -m option must be used." 19 | 20 | echo -e "\n\tExample: ./setup.sh -l -m MY_MISSION udp" 21 | echo -e "\n\tWill create following symbolic links:" 22 | echo -e "\tln -s udp/ci_custom.c ../src/" 23 | echo -e "\tln -s udp/ci_platform_cfg.h ../platform_inc/" 24 | echo -e "\tln -s udp/MISSION_ci_types.h MISSION_HOME/apps/inc/MY_MISION_ci_types.h" 25 | echo -e "\t(cp called instead of ln -s if -l option not used.)\n" 26 | } 27 | 28 | link=0 29 | 30 | while [ "$1" != "" ]; do 31 | 32 | echo "===DEBUG In while loop, args: $@ ===" 33 | 34 | case $1 in 35 | -h | --help ) usage 36 | exit 37 | ;; 38 | -l | --link ) link=1 39 | ;; 40 | -m | --mission ) mission=$2 41 | shift 42 | ;; 43 | * ) break 44 | 45 | esac 46 | shift 47 | done 48 | 49 | if [ $# -ne 1 ]; then 50 | echo -e "\tA single argument required. eg. setup.sh udp" 51 | usage 52 | exit 53 | fi 54 | 55 | # Check the CFS_TST way 56 | if [ -z "$MISSION_HOME" ]; then 57 | # Check the gsfc_build/"classic build" way (setvars.sh) 58 | if [ -z "$APP_DIR" ]; then 59 | echo -e "Either the env var MISSION_HOME (CFS_TST build)" 60 | echo -e " or APP_DIR (gsfc ""classic"" build) must be set." 61 | exit 1 62 | fi 63 | else 64 | APP_DIR="${MISSION_HOME}/apps" 65 | fi 66 | 67 | if [ ! -d "$APP_DIR" ]; then 68 | echo -e "\t$APP_DIR does not point to an existing directory." 69 | exit 70 | fi 71 | 72 | if [ ! -d "$APP_DIR/inc" ]; then 73 | echo -e "\t$APP_DIR/inc does not exist. Create directory first." 74 | exit 75 | fi 76 | 77 | if [ -z "$mission" ]; then 78 | if [ -z "$MISSION_NAME" ]; then 79 | echo -e "Need a mission name from the -m option via the MISSION_NAME env var." 80 | exit 1 81 | else 82 | mission=$MISSION_NAME 83 | fi 84 | fi 85 | 86 | mission="${mission^^}" 87 | 88 | if [ ! -d "$PWD/$1" ]; then 89 | echo -e "\tBad example name. ARG should be the name of the example directory." 90 | exit 91 | fi 92 | 93 | echo -e "\tArguments supplied:" 94 | 95 | if [ "$link" -eq 1 ]; then 96 | echo -e "\tOption: -l (create symbolic links)" 97 | fi 98 | echo -e "\tMission name: $mission" 99 | echo -e "\tExample name: $1\n" 100 | 101 | rm -f $PWD/../src/ci_custom.c 102 | rm -f $PWD/../platform_inc/ci_platform_cfg.h 103 | rm -f ${APP_DIR}/inc/${mission}_ci_types.h 104 | echo -e "\tRemoved files:" 105 | echo -e "\t$PWD/../src/ci_custom.c" 106 | echo -e "\t$PWD/../platform_inc/ci_platform_cfg.h" 107 | echo -e "\t${APP_DIR}/inc/${mission}_ci_types.h\n" 108 | 109 | if [ "$link" -eq 1 ]; then 110 | ln -sf $PWD/$1/ci_custom.c $PWD/../src/ci_custom.c 111 | ln -sf $PWD/$1/ci_platform_cfg.h $PWD/../platform_inc/ci_platform_cfg.h 112 | ln -sf $PWD/$1/MISSION_ci_types.h ${APP_DIR}/inc/${mission}_ci_types.h 113 | echo -e "\tCreating Symbolic links:" 114 | else 115 | cp -f $PWD/$1/ci_custom.c $PWD/../src/ci_custom.c 116 | cp -f $PWD/$1/ci_platform_cfg.h $PWD/../platform_inc/ci_platform_cfg.h 117 | cp -f $PWD/$1/MISSION_ci_types.h ${APP_DIR}/inc/${mission}_ci_types.h 118 | echo -e "\tFiles copied:" 119 | fi 120 | 121 | echo -e "\t$PWD/$1/ci_custom.c -> $PWD/../src/ci_custom.c" 122 | echo -e "\t$PWD/$1/ci_platform_cfg.h -> $PWD/../platform_inc/ci_platform_cfg.h" 123 | echo -e "\t$PWD/$1/MISSION_ci_types.h -> ${APP_DIR}/inc/${mission}_ci_types.h\n" 124 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_sb_hooks.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_sb_hooks.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_sb_hooks.h 1.1 2011/05/04 11:20:20EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test header file for cFE Software Bus hooks. 13 | ** 14 | ** $Log: ut_cfe_sb_hooks.h $ 15 | ** Revision 1.1 2011/05/04 11:20:20EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:54EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.2 2011/03/10 11:16:45EST sslegel 22 | ** Added EventNotSent and PacketNotSent asserts 23 | ** Revision 1.1 2011/02/15 11:12:33EST sslegel 24 | ** Initial revision 25 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 26 | ** 27 | */ 28 | 29 | #ifndef UT_CFE_SB_HOOKS_H_ 30 | #define UT_CFE_SB_HOOKS_H_ 31 | 32 | #include "cfe.h" 33 | #include "utassert.h" 34 | #include "utlist.h" 35 | 36 | extern UtListHead_t MsgQueue; 37 | 38 | #define UtAssert_PacketSent(MessageID, Description) \ 39 | UtAssert(Ut_CFE_SB_PacketSent(MessageID), Description, __FILE__, __LINE__) 40 | 41 | #define UtAssert_PacketNotSent(MessageID, Description) \ 42 | UtAssert(Ut_CFE_SB_PacketSent(MessageID) == FALSE, Description, __FILE__, __LINE__) 43 | 44 | #define UtAssert_NoPacketSent(Description) \ 45 | UtAssert(UtList_IsEmpty(&MsgQueue), Description, __FILE__, __LINE__) 46 | 47 | void Ut_CFE_SB_ClearMsgQueue(void); 48 | uint32 Ut_CFE_SB_GetMsgQueueDepth(void); 49 | uint32 Ut_CFE_SB_GetMsgCount(uint16 MessageID); 50 | int32 Ut_CFE_SB_SendMsgHook(CFE_SB_Msg_t *MsgPtr); 51 | boolean Ut_CFE_SB_PacketSent(uint16 MessageID); 52 | void *Ut_CFE_SB_FindPacket(uint16 MessageID, uint32 MessageNumber); 53 | 54 | void Ut_CFE_SB_ClearPipes(void); 55 | int32 Ut_CFE_SB_CreatePipe(char *PipeName); 56 | int32 Ut_CFE_SB_GetPipeDepth(CFE_SB_PipeId_t PipeId); 57 | int32 Ut_CFE_SB_FindPipe(char *PipeName); 58 | void Ut_CFE_SB_AddMsgToPipe(void *MsgPtr, CFE_SB_PipeId_t PipeId); 59 | int32 Ut_CFE_SB_CreatePipeHook(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, char *PipeName); 60 | int32 Ut_CFE_SB_RcvMsgHook(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); 61 | 62 | void Ut_CFE_SB_InitMsgHook(void *MsgPtr,CFE_SB_MsgId_t MsgId, uint16 Length, boolean Clear); 63 | uint16 Ut_CFE_SB_MsgHdrSizeHook(CFE_SB_MsgId_t MsgId); 64 | void *Ut_CFE_SB_GetUserDataHook(CFE_SB_MsgPtr_t MsgPtr); 65 | CFE_SB_MsgId_t Ut_CFE_SB_GetMsgIdHook(CFE_SB_MsgPtr_t MsgPtr); 66 | void Ut_CFE_SB_SetMsgIdHook(CFE_SB_MsgPtr_t MsgPtr,CFE_SB_MsgId_t MsgId); 67 | uint16 Ut_CFE_SB_GetUserDataLengthHook(CFE_SB_MsgPtr_t MsgPtr); 68 | void Ut_CFE_SB_SetUserDataLengthHook(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); 69 | uint16 Ut_CFE_SB_GetTotalMsgLengthHook(CFE_SB_MsgPtr_t MsgPtr); 70 | void Ut_CFE_SB_SetTotalMsgLengthHook(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength); 71 | CFE_TIME_SysTime_t Ut_CFE_SB_GetMsgTimeHook(CFE_SB_MsgPtr_t MsgPtr); 72 | int32 Ut_CFE_SB_SetMsgTimeHook(CFE_SB_MsgPtr_t MsgPtr,CFE_TIME_SysTime_t Time); 73 | void Ut_CFE_SB_TimeStampMsgHook(CFE_SB_MsgPtr_t MsgPtr); 74 | uint16 Ut_CFE_SB_GetCmdCodeHook(CFE_SB_MsgPtr_t MsgPtr); 75 | int32 Ut_CFE_SB_SetCmdCodeHook(CFE_SB_MsgPtr_t MsgPtr,uint16 CmdCode); 76 | uint16 Ut_CFE_SB_GetChecksumHook(CFE_SB_MsgPtr_t MsgPtr); 77 | void Ut_CFE_SB_GenerateChecksumHook(CFE_SB_MsgPtr_t MsgPtr); 78 | boolean Ut_CFE_SB_ValidateChecksumHook(CFE_SB_MsgPtr_t MsgPtr); 79 | 80 | void CCSDS_LoadCheckSum (CCSDS_CmdPkt_t *PktPtr); 81 | void CCSDS_InitPkt (CCSDS_PriHdr_t *PktPtr, uint16 StreamId, uint16 Length, boolean Clear); 82 | boolean CCSDS_ValidCheckSum (CCSDS_CmdPkt_t *PktPtr); 83 | uint8 CCSDS_ComputeCheckSum (CCSDS_CmdPkt_t *PktPtr); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/utassert.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: utassert.h 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains a standard set of asserts for use in unit tests. 11 | * 12 | * Design Notes: 13 | * - All asserts evaluate a expression as TRUE or FALSE to determine if a unit test has 14 | * passed or failed. TRUE means the test passed, FALSE means the test failed. 15 | * - All asserts return a boolen result to indicate the pass fail status. 16 | * - All asserts are implemented as macros to hide the __LINE__ and __FILE__ macros. 17 | * - All asserts must call the function UtAssert. 18 | * 19 | * References: 20 | * 21 | */ 22 | 23 | #ifndef _utassert_ 24 | #define _utassert_ 25 | 26 | /* 27 | * Includes 28 | */ 29 | 30 | #include "common_types.h" 31 | #include "uttools.h" 32 | #include 33 | #include 34 | #include 35 | 36 | /* 37 | * Macro Definitions 38 | */ 39 | 40 | /* Evaluates a expression as either TRUE or FALSE. TRUE means the test passed, FALSE means the test failed. */ 41 | #define UtAssert_True(Expression, Description) \ 42 | UtAssert(Expression, Description, __FILE__, __LINE__) 43 | 44 | /* Evaluates a expression as either TRUE or FALSE. TRUE means the test passed, FALSE means the test failed. */ 45 | #define UtAssert_Bool(Expression, Description) \ 46 | UtAssert(Expression, Description, __FILE__, __LINE__) 47 | 48 | /* Asserts a test failure */ 49 | #define UtAssert_Failed(Description) \ 50 | UtAssert(FALSE, Description, __FILE__, __LINE__) 51 | 52 | /* Compares two floating point numbers and determines if they are equal within a specified absolute tolerance. */ 53 | #define UtAssert_DoubleCmpAbs(x, y, Tolerance, Description) \ 54 | UtAssert((fabs((x) - (y)) <= (Tolerance)), Description, __FILE__, __LINE__) 55 | 56 | /* Compares two floating point numbers and determines if they are equal within a specified relative tolerance. */ 57 | #define UtAssert_DoubleCmpRel(x, y, Ratio, Description) \ 58 | UtAssert((fabs((x) - (y))/(x) <= (Ratio)), Description, __FILE__, __LINE__) 59 | 60 | /* Compares two strings and determines if they are equal. */ 61 | #define UtAssert_StrCmp(String1, String2, Description) \ 62 | UtAssert((strcmp(String1, String2) == 0), Description, __FILE__, __LINE__) 63 | 64 | /* Compares at most Length characters of two strings and determines if they are equal. */ 65 | #define UtAssert_StrnCmp(String1, String2, Length, Description) \ 66 | UtAssert((strncmp(String1, String2, Length) == 0), Description, __FILE__, __LINE__) 67 | 68 | /* Compares two regions of memory and determines if they are equal. */ 69 | #define UtAssert_MemCmp(Memory1, Memory2, Length, Description) \ 70 | UtAssert((memcmp(Memory1, Memory2, Length) == 0), Description, __FILE__, __LINE__) 71 | 72 | /* Compares a region of memory to a static pattern and determines if they are equal. Note: Use UtMemSet to 73 | * fill a region of memory with a static pattern. */ 74 | #define UtAssert_MemCmpValue(Memory, Value, Length, Description) \ 75 | UtAssert((UtMemCmpValue(Memory, Value, Length)), Description, __FILE__, __LINE__) 76 | 77 | /* Compares a region of memory to a byte count pattern and determines if they are equal. Note: Use UtMemFill to 78 | * fill a region of memory with a byte count pattern. */ 79 | #define UtAssert_MemCmpCount(Memory, Length, Description) \ 80 | UtAssert((UtMemCmpCount(Memory, Length)), Description, __FILE__, __LINE__) 81 | 82 | /* Compares a region of memory with the contents of a binary file and determines if they are equal. Note: Use 83 | * UtMem2BinFile to copy a region of memory to a binary file. */ 84 | #define UtAssert_Mem2BinFileCmp(Memory, Filename, Description) \ 85 | UtAssert((UtMem2BinFileCmp(Memory, Filename)), Description, __FILE__, __LINE__) 86 | 87 | /* 88 | * Exported Functions 89 | */ 90 | 91 | /* Returns the number of asserts that have passed. */ 92 | uint32 UtAssert_GetPassCount(void); 93 | 94 | /* Returns the number of asserts that have failed. */ 95 | uint32 UtAssert_GetFailCount(void); 96 | 97 | /* Base assert function. All asserts must call this function. */ 98 | boolean UtAssert(boolean Expression, char *Description, char *File, uint32 Line); 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/utlist.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: utlist.c 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a generic linked list data structure. 11 | * 12 | */ 13 | 14 | /* 15 | * Includes 16 | */ 17 | 18 | #include "common_types.h" 19 | #include "utlist.h" 20 | #include 21 | #include 22 | 23 | /* 24 | * Function Definitions 25 | */ 26 | 27 | UtListHead_t *UtList_Create(void) 28 | { 29 | UtListHead_t *NewList; 30 | 31 | NewList = malloc(sizeof(UtListHead_t)); 32 | NewList->First = NULL; 33 | NewList->Last = NULL; 34 | NewList->NumberOfEntries = 0; 35 | return (NewList); 36 | } 37 | 38 | void UtList_Destroy(UtListHead_t *ListHead) 39 | { 40 | UtList_Reset(ListHead); 41 | free(ListHead); 42 | } 43 | 44 | void UtList_Reset(UtListHead_t *ListHead) 45 | { 46 | while (!UtList_IsEmpty(ListHead)) { 47 | UtList_DeleteFirst(ListHead); 48 | } 49 | } 50 | 51 | void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag) 52 | { 53 | UtListNode_t *NewNode = NULL; 54 | 55 | NewNode = malloc(sizeof(UtListNode_t)); 56 | if (ListHead->NumberOfEntries == 0) { 57 | 58 | ListHead->First = NewNode; 59 | ListHead->Last = NewNode; 60 | ListHead->NumberOfEntries++; 61 | 62 | NewNode->Next = NULL; 63 | NewNode->Prev = NULL; 64 | NewNode->Tag = Tag; 65 | NewNode->DataSize = DataSize; 66 | NewNode->Data = malloc(DataSize); 67 | memcpy(NewNode->Data, Data, DataSize); 68 | } 69 | else { 70 | 71 | NewNode->Next = NULL; 72 | NewNode->Prev = ListHead->Last; 73 | NewNode->Tag = Tag; 74 | NewNode->DataSize = DataSize; 75 | NewNode->Data = malloc(DataSize); 76 | memcpy(NewNode->Data, Data, DataSize); 77 | 78 | ListHead->Last->Next = NewNode; 79 | ListHead->Last = NewNode; 80 | ListHead->NumberOfEntries++; 81 | } 82 | } 83 | 84 | void UtList_DeleteFirst(UtListHead_t *ListHead) 85 | { 86 | UtList_DeleteNode(ListHead, ListHead->First); 87 | } 88 | 89 | void UtList_DeleteLast(UtListHead_t *ListHead) 90 | { 91 | UtList_DeleteNode(ListHead, ListHead->Last); 92 | } 93 | 94 | void UtList_DeleteNode(UtListHead_t *ListHead, UtListNode_t *DeleteNode) 95 | { 96 | 97 | if (!UtList_IsEmpty(ListHead)) { 98 | 99 | if (ListHead->NumberOfEntries == 1) { 100 | ListHead->First = NULL; 101 | ListHead->Last = NULL; 102 | ListHead->NumberOfEntries = 0; 103 | } 104 | else if (DeleteNode == ListHead->First) { 105 | ListHead->First = DeleteNode->Next; 106 | ListHead->First->Prev = NULL; 107 | ListHead->NumberOfEntries--; 108 | } 109 | else if (DeleteNode == ListHead->Last) { 110 | ListHead->Last = DeleteNode->Prev; 111 | ListHead->Last->Next = NULL; 112 | ListHead->NumberOfEntries--; 113 | } 114 | else { 115 | DeleteNode->Prev->Next = DeleteNode->Next; 116 | DeleteNode->Next->Prev = DeleteNode->Prev; 117 | ListHead->NumberOfEntries--; 118 | } 119 | 120 | free(DeleteNode->Data); 121 | free(DeleteNode); 122 | } 123 | } 124 | 125 | void UtList_RemoveFirst(UtListHead_t *ListHead, void *Data) 126 | { 127 | UtList_RemoveNode(ListHead, Data, ListHead->First); 128 | } 129 | 130 | void UtList_RemoveLast(UtListHead_t *ListHead, void *Data) 131 | { 132 | UtList_RemoveNode(ListHead, Data, ListHead->Last); 133 | } 134 | 135 | void UtList_RemoveNode(UtListHead_t *ListHead, void *Data, UtListNode_t *CurrentNode) 136 | { 137 | if (!UtList_IsEmpty(ListHead)) { 138 | memcpy(Data, CurrentNode->Data, CurrentNode->DataSize); 139 | UtList_DeleteNode(ListHead, CurrentNode); 140 | } 141 | } 142 | 143 | UtListNode_t *UtList_First(UtListHead_t *ListHead) 144 | { 145 | return(ListHead->First); 146 | } 147 | 148 | UtListNode_t *UtList_Last(UtListHead_t *ListHead) 149 | { 150 | return(ListHead->Last); 151 | } 152 | 153 | boolean UtList_IsEmpty(UtListHead_t *ListHead) 154 | { 155 | return(ListHead->NumberOfEntries == 0); 156 | } 157 | 158 | uint32 UtList_Depth(UtListHead_t *ListHead) 159 | { 160 | return(ListHead->NumberOfEntries); 161 | } 162 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_evs_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_evs_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_evs_stubs.c 1.1 2011/05/04 11:20:53EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE Event Services routines 13 | ** 14 | ** $Log: ut_cfe_evs_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:20:53EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:38EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.1 2011/02/15 11:13:02EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 24 | ** 25 | */ 26 | 27 | /* 28 | ** Include section 29 | */ 30 | 31 | #include "cfe.h" 32 | #include "ut_cfe_evs_stubs.h" 33 | #include "ut_cfe_evs_hooks.h" 34 | #include 35 | 36 | Ut_CFE_EVS_HookTable_t Ut_CFE_EVS_HookTable; 37 | Ut_CFE_EVS_ReturnCodeTable_t Ut_CFE_EVS_ReturnCodeTable[UT_CFE_EVS_MAX_INDEX]; 38 | 39 | void Ut_CFE_EVS_Reset(void) 40 | { 41 | memset(&Ut_CFE_EVS_HookTable, 0, sizeof(Ut_CFE_EVS_HookTable)); 42 | memset(&Ut_CFE_EVS_ReturnCodeTable, 0, sizeof(Ut_CFE_EVS_ReturnCodeTable)); 43 | 44 | Ut_CFE_EVS_SetFunctionHook(UT_CFE_EVS_SENDEVENT_INDEX, &Ut_CFE_EVS_SendEventHook); 45 | Ut_CFE_EVS_ClearEventQueue(); 46 | } 47 | 48 | void Ut_CFE_EVS_SetFunctionHook(uint32 Index, void *FunPtr) 49 | { 50 | if (Index == UT_CFE_EVS_REGISTER_INDEX) { Ut_CFE_EVS_HookTable.CFE_EVS_Register = FunPtr; } 51 | else if (Index == UT_CFE_EVS_SENDEVENT_INDEX) { Ut_CFE_EVS_HookTable.CFE_EVS_SendEvent = FunPtr; } 52 | else { printf("Unsupported EVS Index In SetFunctionHook Call %u", Index); } 53 | } 54 | 55 | void Ut_CFE_EVS_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 56 | { 57 | if (Index < UT_CFE_EVS_MAX_INDEX) { 58 | Ut_CFE_EVS_ReturnCodeTable[Index].Value = RtnVal; 59 | Ut_CFE_EVS_ReturnCodeTable[Index].Count = CallCnt; 60 | } 61 | else { 62 | printf("Unsupported EVS Index In SetReturnCode Call %u\n", Index); 63 | } 64 | } 65 | 66 | boolean Ut_CFE_EVS_UseReturnCode(uint32 Index) 67 | { 68 | if (Ut_CFE_EVS_ReturnCodeTable[Index].Count > 0) { 69 | Ut_CFE_EVS_ReturnCodeTable[Index].Count--; 70 | if (Ut_CFE_EVS_ReturnCodeTable[Index].Count == 0) 71 | return(TRUE); 72 | } 73 | 74 | return(FALSE); 75 | } 76 | 77 | int32 CFE_EVS_Register (void *Filters, uint16 NumEventFilters, uint16 FilterScheme) 78 | { 79 | if (Ut_CFE_EVS_UseReturnCode(UT_CFE_EVS_REGISTER_INDEX)) 80 | return Ut_CFE_EVS_ReturnCodeTable[UT_CFE_EVS_REGISTER_INDEX].Value; 81 | 82 | if (Ut_CFE_EVS_HookTable.CFE_EVS_Register) 83 | return(Ut_CFE_EVS_HookTable.CFE_EVS_Register(Filters, NumEventFilters, FilterScheme)); 84 | 85 | return CFE_SUCCESS; 86 | } 87 | 88 | int32 CFE_EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... ) 89 | { 90 | char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; 91 | va_list Ptr; 92 | 93 | va_start(Ptr, Spec); 94 | vsprintf(BigBuf, Spec, Ptr); 95 | va_end(Ptr); 96 | 97 | if (Ut_CFE_EVS_UseReturnCode(UT_CFE_EVS_SENDEVENT_INDEX)) 98 | return Ut_CFE_EVS_ReturnCodeTable[UT_CFE_EVS_SENDEVENT_INDEX].Value; 99 | 100 | if (Ut_CFE_EVS_HookTable.CFE_EVS_SendEvent) 101 | return(Ut_CFE_EVS_HookTable.CFE_EVS_SendEvent(EventID, EventType, BigBuf)); 102 | 103 | return CFE_SUCCESS; 104 | } 105 | 106 | int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ... ) 107 | { 108 | if (Ut_CFE_EVS_UseReturnCode(UT_CFE_EVS_SENDTIMEDEVENT_INDEX)) 109 | return Ut_CFE_EVS_ReturnCodeTable[UT_CFE_EVS_SENDTIMEDEVENT_INDEX].Value; 110 | 111 | return CFE_SUCCESS; 112 | } 113 | 114 | int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType,uint32 AppID, const char *Spec, ... ) 115 | { 116 | if (Ut_CFE_EVS_UseReturnCode(UT_CFE_EVS_SENDEVENTWITHAPPID_INDEX)) 117 | return Ut_CFE_EVS_ReturnCodeTable[UT_CFE_EVS_SENDEVENTWITHAPPID_INDEX].Value; 118 | 119 | return CFE_SUCCESS; 120 | } 121 | 122 | int32 CFE_EVS_CleanUpApp (uint32 AppId) 123 | { 124 | return CFE_SUCCESS; 125 | } 126 | -------------------------------------------------------------------------------- /fsw/unit_test/makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | ## GNU Makefile for building UT unit tests 3 | 4 | # 5 | # Supported MAKEFILE targets: 6 | # clean - deletes object files, executables, output files, and gcov files 7 | # all - makes utf_test_runner.exe 8 | # run - runs utf_test_runner.exe 9 | # gcov - prints a GCOV coverage report (make all, make run, make gcov) 10 | # 11 | # GCOV is disabled by default. If you are using the source level debugger you will want to 12 | # disable GCOV. To enable GCOV you can override the ENABLE_GCOV variable on the command line 13 | # by setting it to TRUE. For example "make ENABLE_GCOV=TRUE". 14 | # 15 | 16 | APP=ci 17 | 18 | CFE_PATH = $(CFE_FSW)/cfe-core 19 | OSAL_PATH = $(OSAL_DIR) 20 | PSP_PATH = $(PSP_DIR) 21 | # Note, CI has an explicit dependency on the TO app 22 | APP_PATH = $(APP_DIR) 23 | 24 | # 25 | # VPATH specifies the search paths for source files outside of the current directory. Note that 26 | # all object files will be created in the current directory even if the source file is not in the 27 | # current directory. 28 | # 29 | VPATH := ../src 30 | VPATH += ./ut-assert/src 31 | 32 | # 33 | # INCLUDES specifies the search paths for include files outside of the current directory. 34 | # Note that the -I is required. 35 | # 36 | INCLUDES := -I. 37 | INCLUDES += -I.. 38 | INCLUDES += -I../src 39 | INCLUDES += -I../platform_inc 40 | INCLUDES += -I../mission_inc 41 | INCLUDES += -I../../../inc 42 | #INCLUDES += -I../../../io_lib/fsw/public_inc 43 | INCLUDES += -I./ut-assert/inc 44 | INCLUDES += -I$(CFE_PATH)/os/inc 45 | INCLUDES += -I$(CFE_PATH)/src/inc 46 | INCLUDES += -I$(CFE_PATH)/src/time 47 | INCLUDES += -I$(CFE_PATH)/src/sb 48 | INCLUDES += -I$(CFE_PATH)/src/es 49 | INCLUDES += -I$(CFE_PATH)/src/evs 50 | INCLUDES += -I$(CFE_PATH)/src/fs 51 | INCLUDES += -I$(CFE_PATH)/src/tbl 52 | INCLUDES += -I$(CFE_PATH)/../mission_inc 53 | INCLUDES += -I$(CFE_PATH)/../platform_inc/cpu1 54 | INCLUDES += -I$(OSAL_PATH)/src/os/inc 55 | INCLUDES += -I$(OSAL_PATH)/build/inc 56 | INCLUDES += -I$(OSAL_PATH)/src/bsp/pc-linux/config 57 | INCLUDES += -I$(PSP_PATH)/fsw/inc 58 | INCLUDES += -I$(PSP_PATH)/fsw/pc-linux/inc 59 | INCLUDES += -I$(APP_PATH)/to/fsw/platform_inc 60 | INCLUDES += -I$(APP_PATH)/to/fsw/src 61 | 62 | 63 | # 64 | # APP_OBJS specifies flight software object files. 65 | # 66 | APP_OBJS := $(APP)_app.o $(APP)_utils.o 67 | 68 | 69 | # 70 | # UT_OBJS specifies unit test object files. 71 | # 72 | UT_OBJS := ut_osapi_stubs.o 73 | UT_OBJS += ut_osfileapi_stubs.o 74 | UT_OBJS += ut_cfe_psp_memutils_stubs.o 75 | UT_OBJS += ut_cfe_sb_stubs.o 76 | UT_OBJS += ut_cfe_sb_hooks.o 77 | UT_OBJS += ut_cfe_es_stubs.o 78 | UT_OBJS += ut_cfe_es_hooks.o 79 | UT_OBJS += ut_cfe_evs_stubs.o 80 | UT_OBJS += ut_cfe_evs_hooks.o 81 | UT_OBJS += ut_cfe_tbl_stubs.o 82 | UT_OBJS += ut_cfe_tbl_hooks.o 83 | UT_OBJS += ut_cfe_fs_stubs.o 84 | UT_OBJS += utassert.o 85 | UT_OBJS += utlist.o 86 | UT_OBJS += uttest.o 87 | UT_OBJS += uttools.o 88 | UT_OBJS += $(APP)_testcase.o 89 | UT_OBJS += $(APP)_stubs.o 90 | 91 | ############################################################################### 92 | 93 | COMPILER=gcc 94 | LINKER=gcc 95 | 96 | # 97 | # Compiler and Linker Options 98 | # 99 | ENABLE_GCOV = TRUE 100 | ifeq ($(ENABLE_GCOV), TRUE) 101 | GCOV_COPT = -fprofile-arcs -ftest-coverage -pg -p 102 | GCOV_LOPT = -pg -p -fprofile-arcs -ftest-coverage -lgcov 103 | endif 104 | 105 | #WARNINGS = -Wall -W -ansi -Werror -Wstrict-prototypes -Wundef 106 | WARNINGS = -Wall -Wstrict-prototypes 107 | DEBUGGER = -g 108 | 109 | COPT = $(WARNINGS) $(DEBUGGER) $(GCOV_COPT) -DSOFTWARE_LITTLE_BIT_ORDER -D_EL -D__x86_64__ -DUT_VERBOSE -D_LINUX_OS_ 110 | #COPT = $(WARNINGS) $(DEBUGGER) $(GCOV_COPT) -DSOFTWARE_LITTLE_BIT_ORDER -D_EL -D_ix86_ 111 | 112 | LOPT = $(GCOV_LOPT) 113 | 114 | ############################################################################### 115 | ## Rule to make the specified TARGET 116 | ## 117 | %.exe: %.o 118 | $(LINKER) $(LOPT) $^ -o $*.exe 119 | 120 | ############################################################################### 121 | ## "C" COMPILER RULE 122 | ## 123 | %.o: %.c 124 | $(COMPILER) -c $(COPT) $(INCLUDES) $< 125 | 126 | ############################################################################## 127 | ## 128 | 129 | all:$(APP)_testrunner.exe 130 | 131 | $(APP)_testrunner.exe: $(APP)_testrunner.o $(UT_OBJS) $(APP_OBJS) 132 | 133 | clean :: 134 | rm -f *.o *.exe *.gcda *.gcno *.gcov gmon.out 135 | 136 | run :: 137 | ./$(APP)_testrunner.exe 138 | 139 | #gcov :: 140 | # @echo 141 | # @gcov $(APP_OBJS:.o=.gcda) | sed 'N;s/\n/ /' | \ 142 | # sed -n '/File/p' | sed '/ads/d' | \ 143 | # sed 's/ Lines executed:/ /; s/File/gcov:/; s/of//' 144 | # @rm -f *.gcda *.gcno 145 | # @echo 146 | 147 | gcov :: 148 | @echo 149 | @gcov $(APP_OBJS:.o=.gcda) | sed 'N;s/\n/ /' | \ 150 | sed -n '/File/p' | sed '/ads/d' | sed -e '/\.h/d' | \ 151 | sed 's/ Lines executed:/ /; s/File/gcov:/; s/of// ' 152 | @rm -f *.gcda *.gcno 153 | @echo 154 | 155 | # end of file 156 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/uttools.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: uttools.c 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a set of tools for use in unit testing. 11 | * 12 | */ 13 | 14 | /* 15 | * Includes 16 | */ 17 | 18 | #include "common_types.h" 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /* 26 | * Function Definitions 27 | */ 28 | 29 | boolean UtMem2BinFile(void *Memory, char *Filename, uint32 Length) 30 | { 31 | FILE *fp; 32 | 33 | if ((fp = fopen(Filename, "w"))) { 34 | fwrite(Memory, Length, 1, fp); 35 | fclose(fp); 36 | return(TRUE); 37 | } 38 | else { 39 | printf("UtMem2BinFile: Error Opening File: %s, %s\n", Filename, strerror(errno)); 40 | return(FALSE); 41 | } 42 | } 43 | 44 | boolean UtBinFile2Mem(void *Memory, char *Filename, uint32 Length) 45 | { 46 | FILE *fp; 47 | 48 | if ((fp = fopen(Filename, "r"))) { 49 | fread(Memory, Length, 1, fp); 50 | fclose(fp); 51 | return(TRUE); 52 | } 53 | else { 54 | printf("UtBinFile2Mem: Error Opening File: %s, %s\n", Filename, strerror(errno)); 55 | return(FALSE); 56 | } 57 | } 58 | 59 | boolean UtMem2HexFile(void *Memory, char *Filename, uint32 Length) 60 | { 61 | FILE *fp; 62 | uint32 i; 63 | uint32 j; 64 | 65 | if ((fp = fopen(Filename, "w"))) { 66 | 67 | for (i=0; i < Length; i+=16) { 68 | fprintf(fp, " %06X: ", i); 69 | for (j=0; j < 16; j++) { 70 | if ((i+j) < Length) 71 | fprintf(fp, "%02X ", ((uint8 *)Memory)[i+j]); 72 | else 73 | fprintf(fp, " "); 74 | } 75 | fprintf(fp, " "); 76 | for (j=0; j < 16; j++) { 77 | if ((i+j) < Length) 78 | fprintf(fp, "%c", isprint(((uint8 *)Memory)[i+j]) ? ((uint8 *)Memory)[i+j] : '.'); 79 | } 80 | fprintf(fp, "\n"); 81 | } 82 | fclose(fp); 83 | return(TRUE); 84 | } 85 | else { 86 | printf("UtMem2HexFile: Error Opening File: %s, %s\n", Filename, strerror(errno)); 87 | return(FALSE); 88 | } 89 | } 90 | 91 | void UtMemFill(void *Memory, uint32 Length) 92 | { 93 | uint32 i; 94 | uint8 *Byte_ptr = Memory; 95 | 96 | for(i=0; i < Length; i++) { 97 | Byte_ptr[i] = i; 98 | } 99 | } 100 | 101 | void UtPrintf(char *Spec, ...) 102 | { 103 | #ifdef UT_VERBOSE 104 | va_list Args; 105 | static char Text[256]; 106 | 107 | va_start(Args, Spec); 108 | vsprintf(Text, Spec, Args); 109 | va_end(Args); 110 | 111 | printf("%s", Text); 112 | #else 113 | (void)Spec; 114 | #endif 115 | } 116 | 117 | char *UtSprintf(char *Spec, ...) 118 | { 119 | va_list Args; 120 | static char Text[10][256]; 121 | static uint32 TextIndex = 0; 122 | 123 | if (TextIndex >= 10) TextIndex = 0; 124 | 125 | va_start(Args, Spec); 126 | vsprintf(Text[TextIndex], Spec, Args); 127 | va_end(Args); 128 | 129 | return(Text[TextIndex++]); 130 | } 131 | 132 | void UtPrintx(void *Memory, uint32 Length) 133 | { 134 | uint32 i; 135 | uint8 *Byte_ptr = Memory; 136 | 137 | for (i=0; i < Length; i++) { 138 | UtPrintf("%02X ", Byte_ptr[i]); 139 | } 140 | UtPrintf("\n"); 141 | } 142 | 143 | boolean UtMemCmpValue(void *Memory, uint8 Value, uint32 Length) 144 | { 145 | uint32 i; 146 | uint8 *Byte_ptr = Memory; 147 | 148 | for (i=0; i < Length; i++) { 149 | if (Byte_ptr[i] != Value) { 150 | return(FALSE); 151 | } 152 | } 153 | return (TRUE); 154 | } 155 | 156 | boolean UtMemCmpCount(void *Memory, uint32 Length) 157 | { 158 | uint32 i; 159 | uint8 *Byte_ptr = Memory; 160 | 161 | for (i=0; i < Length; i++) { 162 | if (Byte_ptr[i] != (i & 0xFF)) { 163 | return(FALSE); 164 | } 165 | } 166 | return (TRUE); 167 | } 168 | 169 | boolean UtMem2BinFileCmp(void *Memory, char *Filename) 170 | { 171 | FILE *fp; 172 | uint8 *MemByte = Memory; 173 | int FileByte; 174 | boolean Success; 175 | uint32 i; 176 | 177 | Success = TRUE; 178 | if ((fp = fopen(Filename, "r"))) { 179 | 180 | for (i=0; (FileByte = fgetc(fp)) != EOF; i++) { 181 | if (MemByte[i] != FileByte) { 182 | Success = FALSE; 183 | printf("UtMem2BinFileCmp: Miscompare in file: %s, byte offset: %u, expected: %u, found: %u\n", Filename, i, MemByte[i], FileByte); 184 | break; 185 | } 186 | } 187 | fclose(fp); 188 | } 189 | else { 190 | Success = FALSE; 191 | printf("UtMem2BinFileCmp: Error Opening File: %s, %s\n", Filename, strerror(errno)); 192 | } 193 | 194 | return(Success); 195 | } 196 | 197 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_es_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_es_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_es_stubs.h 1.2 2011/05/04 11:28:00EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE Executive Services Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_es_stubs.h $ 15 | ** Revision 1.2 2011/05/04 11:28:00EDT rmcgraw 16 | ** Changed PoolCreateEx to have new parameter USE_MUTEX 17 | ** Revision 1.1 2011/05/04 11:20:18EDT rmcgraw 18 | ** Initial revision 19 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 20 | ** Revision 1.1 2011/04/08 16:25:51EDT rmcgraw 21 | ** Initial revision 22 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 23 | ** Revision 1.1 2011/02/15 11:12:32EST sslegel 24 | ** Initial revision 25 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 26 | ** 27 | */ 28 | 29 | #ifndef UT_CFE_ES_STUBS_H_ 30 | #define UT_CFE_ES_STUBS_H_ 31 | 32 | typedef enum 33 | { 34 | UT_CFE_ES_RESETCFE_INDEX, 35 | UT_CFE_ES_RESTARTAPP_INDEX, 36 | UT_CFE_ES_RELOADAPP_INDEX, 37 | UT_CFE_ES_DELETEAPP_INDEX, 38 | UT_CFE_ES_EXITAPP_INDEX, 39 | UT_CFE_ES_RUNLOOP_INDEX, 40 | UT_CFE_ES_WAITFORSTARTUPSYNC_INDEX, 41 | UT_CFE_ES_REGISTERAPP_INDEX, 42 | UT_CFE_ES_GETAPPID_INDEX, 43 | UT_CFE_ES_GETAPPIDBYNAME_INDEX, 44 | UT_CFE_ES_GETAPPNAME_INDEX, 45 | UT_CFE_ES_GETAPPINFO_INDEX, 46 | UT_CFE_ES_GETTASKINFO_INDEX, 47 | UT_CFE_ES_REGISTERCHILDTASK_INDEX, 48 | UT_CFE_ES_CREATECHILDTASK_INDEX, 49 | UT_CFE_ES_DELETECHILDTASK_INDEX, 50 | UT_CFE_ES_EXITCHILDTASK_INDEX, 51 | UT_CFE_ES_INCREMENTTASKCOUNTER_INDEX, 52 | UT_CFE_ES_WRITETOSYSLOG_INDEX, 53 | UT_CFE_ES_REGISTERDRIVER_INDEX, 54 | UT_CFE_ES_UNLOADDRIVER_INDEX, 55 | UT_CFE_ES_CALCULATECRC_INDEX, 56 | UT_CFE_ES_REGISTERCDS_INDEX, 57 | UT_CFE_ES_COPYTOCDS_INDEX, 58 | UT_CFE_ES_RESTOREFROMCDS_INDEX, 59 | UT_CFE_ES_POOLCREATE_INDEX, 60 | UT_CFE_ES_POOLCREATEEX_INDEX, 61 | UT_CFE_ES_GETPOOLBUF_INDEX, 62 | UT_CFE_ES_GETPOOLBUFINFO_INDEX, 63 | UT_CFE_ES_PUTPOOLBUF_INDEX, 64 | UT_CFE_ES_GETMEMPOOLSTATS_INDEX, 65 | UT_CFE_ES_PERFLOGADD_INDEX, 66 | UT_CFE_ES_MAX_INDEX 67 | } Ut_CFE_ES_INDEX_t; 68 | 69 | typedef struct 70 | { 71 | int32 (*CFE_ES_ResetCFE)(uint32 ResetType); 72 | int32 (*CFE_ES_RestartApp)(uint32 AppID); 73 | int32 (*CFE_ES_ReloadApp)(uint32 AppID_API, const char *AppFileName); 74 | int32 (*CFE_ES_DeleteApp)(uint32 AppID); 75 | int32 (*CFE_ES_ExitApp)(uint32 ExitStatus); 76 | int32 (*CFE_ES_RunLoop)(uint32 *ExitStatus); 77 | int32 (*CFE_ES_WaitForStartupSync)(uint32 TimeOutMilliseconds); 78 | int32 (*CFE_ES_RegisterApp)(void); 79 | int32 (*CFE_ES_GetAppID)(uint32 *AppIdPtr); 80 | int32 (*CFE_ES_GetAppIDByName)(uint32 *AppIdPtr, char *AppName); 81 | int32 (*CFE_ES_GetAppName)(char *AppName, uint32 AppId, uint32 BufferLength); 82 | int32 (*CFE_ES_GetAppInfo)(CFE_ES_AppInfo_t *AppInfo, uint32 AppId); 83 | int32 (*CFE_ES_GetTaskInfo)(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId); 84 | int32 (*CFE_ES_RegisterChildTask)(void); 85 | int32 (*CFE_ES_CreateChildTask)(uint32 *TaskIdPtr, const char *TaskName, CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr,const uint32 *StackPtr, uint32 StackSize, uint32 Priority, uint32 Flags); 86 | int32 (*CFE_ES_DeleteChildTask)(uint32 TaskId); 87 | int32 (*CFE_ES_ExitChildTask)(void); 88 | int32 (*CFE_ES_IncrementTaskCounter)(void); 89 | int32 (*CFE_ES_WriteToSysLog)(const char *SpecStringPtr, ...); 90 | int32 (*CFE_ES_RegisterDriver)(uint32 *DriverIdPtr, uint32 *DriverDescPtr); 91 | int32 (*CFE_ES_UnloadDriver)(uint32 DriverId); 92 | int32 (*CFE_ES_CalculateCRC)(void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC); 93 | int32 (*CFE_ES_RegisterCDS)(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name); 94 | int32 (*CFE_ES_CopyToCDS)(CFE_ES_CDSHandle_t Handle, void *DataToCopy); 95 | int32 (*CFE_ES_RestoreFromCDS)(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle); 96 | int32 (*CFE_ES_PoolCreate)(uint32 *HandlePtr, uint8 *MemPtr, uint32 Size); 97 | int32 (*CFE_ES_PoolCreateEx)(uint32 *HandlePtr, uint8 *MemPtr, uint32 Size, uint32 NumBlockSizes, uint32 *BlockSizes, uint16 UseMutex); 98 | int32 (*CFE_ES_GetPoolBuf)(uint32 **BufPtr, CFE_ES_MemHandle_t HandlePtr, uint32 Size); 99 | int32 (*CFE_ES_GetPoolBufInfo)(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); 100 | int32 (*CFE_ES_PutPoolBuf)(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr); 101 | int32 (*CFE_ES_GetMemPoolStats)(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle); 102 | int32 (*CFE_ES_PerfLogAdd)(uint32 Marker, uint32 EntryExit); 103 | } Ut_CFE_ES_HookTable_t; 104 | 105 | typedef struct 106 | { 107 | int32 Value; 108 | uint32 Count; 109 | } Ut_CFE_ES_ReturnCodeTable_t; 110 | 111 | void Ut_CFE_ES_Reset(void); 112 | void Ut_CFE_ES_SetFunctionHook(uint32 Index, void *FunPtr); 113 | void Ut_CFE_ES_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/utlist.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Filename: utlist.h 4 | * 5 | * Copyright 2017 United States Government as represented by the Administrator 6 | * of the National Aeronautics and Space Administration. No copyright is 7 | * claimed in the United States under Title 17, U.S. Code. 8 | * All Other Rights Reserved. 9 | * 10 | * Purpose: This file contains functions to implement a generic linked list data structure. 11 | * 12 | * Design Notes: 13 | * 14 | * References: 15 | * 16 | */ 17 | 18 | #ifndef _utlist_ 19 | #define _utlist_ 20 | 21 | /* 22 | * Includes 23 | */ 24 | 25 | #include "common_types.h" 26 | 27 | /* 28 | * Macro Definitions 29 | */ 30 | 31 | /* Macros to redefine list functions to look like stack and queue functions */ 32 | #define UtStack_Push UtList_Add 33 | #define UtStack_Pop UtList_RemoveLast 34 | #define UtStack_IsEmpty UtList_IsEmpty 35 | #define UtStack_Depth UtList_Depth 36 | 37 | #define UtQueue_Add UtList_Add 38 | #define UtQueue_Get UtList_RemoveFirst 39 | #define UtQueue_Look UtList_First 40 | #define UtQueue_Delete UtList_DeleteFirst 41 | #define UtQueue_IsEmpty UtList_IsEmpty 42 | #define UtQueue_Depth UtList_Depth 43 | 44 | /* 45 | * Type Definitions 46 | */ 47 | 48 | typedef struct UtListNodeTag { 49 | struct UtListNodeTag *Next; 50 | struct UtListNodeTag *Prev; 51 | void *Data; 52 | uint32 DataSize; 53 | uint32 Tag; 54 | } UtListNode_t; 55 | 56 | typedef struct { 57 | UtListNode_t *First; 58 | UtListNode_t *Last; 59 | uint32 NumberOfEntries; 60 | } UtListHead_t; 61 | 62 | /* 63 | * Exported Functions 64 | */ 65 | 66 | /* Dynamically allocates a new list head. A list head could also just be declared, this function is useful 67 | * if you need to dynamically allocate memory for a new list head. Note always free list heads allocated by 68 | * this function by calling UtList_Destroy. */ 69 | UtListHead_t *UtList_Create(void); 70 | 71 | /* Frees a list head created by UtList_Create. */ 72 | void UtList_Destroy(UtListHead_t *ListHead); 73 | 74 | /* Deletes all nodes on the list. */ 75 | void UtList_Reset(UtListHead_t *ListHead); 76 | 77 | /* Dynamically adds a new node to the list. Nodes are always added to the end of the list. Memory is dynamically 78 | * allocated for the new node and to hold the data pointed to by Data. A Tag field is also provided to be used to 79 | * store user defined information with the node. */ 80 | void UtList_Add(UtListHead_t *ListHead, void *Data, uint32 DataSize, uint32 Tag); 81 | 82 | /* Deletes the first node from the list. */ 83 | void UtList_DeleteFirst(UtListHead_t *ListHead); 84 | 85 | /* Deletes the last node from the list. */ 86 | void UtList_DeleteLast(UtListHead_t *ListHead); 87 | 88 | /* Deletes the specified node from the list, this will screw up if you do not pass in a valid DeleteNode. I do not 89 | * verify that DeleteNode is a member of the list. */ 90 | void UtList_DeleteNode(UtListHead_t *ListHead, UtListNode_t *DeleteNode); 91 | 92 | /* Removes the first node from the list by first copying the data from the node to the memory buffer pointed to by the 93 | * specified Data pointer and then the node is deleted from the list. Make sure the destination pointer points to a 94 | * memory buffer large enough to hold the data. The size of the data on the node is available by referencing UtListNode->DataSize. */ 95 | void UtList_RemoveFirst(UtListHead_t *ListHead, void *Data); 96 | 97 | /* Removes the last node from the list by first copying the data from the node to the memory buffer pointed to by the 98 | * specified Data pointer and then the node is deleted from the list. Make sure the destination pointer points to a 99 | * memory buffer large enough to hold the data. The size of the data on the node is available by referencing UtListNode->DataSize. */ 100 | void UtList_RemoveLast(UtListHead_t *ListHead, void *Data); 101 | 102 | /* Removes the speciified RemoveNode from the list by first copying the data from the node to the memory buffer pointed to by the 103 | * specified Data pointer and then the node is deleted from the list. Make sure the destination pointer points to a 104 | * memory buffer large enough to hold the data. The size of the data on the node is available by referencing UtListNode->DataSize. */ 105 | void UtList_RemoveNode(UtListHead_t *ListHead, void *Data, UtListNode_t *RemoveNode); 106 | 107 | /* Returns a pointer to the first node on the list. This is the same as (UtListHead->First). */ 108 | UtListNode_t *UtList_First(UtListHead_t *ListHead); 109 | 110 | /* Returns a pointer to the last node on the list. This is the same as (UtListHead->Last). */ 111 | UtListNode_t *UtList_Last(UtListHead_t *ListHead); 112 | 113 | /* Returns TRUE if the list is empty. This is the same as (UtListHead->NumberOfEntries == 0). */ 114 | boolean UtList_IsEmpty(UtListHead_t *ListHead); 115 | 116 | /* Returns the number of nodes on the list. This is the same as (UtListHead->NumberOfEntries). */ 117 | uint32 UtList_Depth(UtListHead_t *ListHead); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/inc/ut_cfe_sb_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_sb_stubs.h 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_sb_stubs.h 1.1 2011/05/04 11:20:21EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: cFE Software Bus Header file for unit test stubs 13 | ** 14 | ** $Log: ut_cfe_sb_stubs.h $ 15 | ** Revision 1.1 2011/05/04 11:20:21EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 18 | ** Revision 1.1 2011/04/08 16:25:55EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/inc/project.pj 21 | ** Revision 1.1 2011/02/15 11:12:34EST sslegel 22 | ** Initial revision 23 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/inc/project.pj 24 | ** 25 | */ 26 | 27 | #ifndef UT_CFE_SB_STUBS_H_ 28 | #define UT_CFE_SB_STUBS_H_ 29 | 30 | typedef enum 31 | { 32 | UT_CFE_SB_CREATEPIPE_INDEX, 33 | UT_CFE_SB_DELETEPIPE_INDEX, 34 | UT_CFE_SB_SUBSCRIBEEX_INDEX, 35 | UT_CFE_SB_SUBSCRIBE_INDEX, 36 | UT_CFE_SB_SUBSCRIBELOCAL_INDEX, 37 | UT_CFE_SB_UNSUBSCRIBE_INDEX, 38 | UT_CFE_SB_UNSUBSCRIBELOCAL_INDEX, 39 | UT_CFE_SB_SENDMSG_INDEX, 40 | UT_CFE_SB_PASSMSG_INDEX, 41 | UT_CFE_SB_RCVMSG_INDEX, 42 | UT_CFE_SB_GETLASTSENDERID_INDEX, 43 | UT_CFE_SB_ZEROCOPYGETPTR_INDEX, 44 | UT_CFE_SB_ZEROCOPYRELEASEPTR_INDEX, 45 | UT_CFE_SB_ZEROCOPYSEND_INDEX, 46 | UT_CFE_SB_ZEROCOPYPASS_INDEX, 47 | UT_CFE_SB_INITMSG_INDEX, 48 | UT_CFE_SB_MSGHDRSIZE_INDEX, 49 | UT_CFE_SB_GETUSERDATA_INDEX, 50 | UT_CFE_SB_GETMSGID_INDEX, 51 | UT_CFE_SB_SETMSGID_INDEX, 52 | UT_CFE_SB_GETUSERDATALENGTH_INDEX, 53 | UT_CFE_SB_SETUSERDATALENGTH_INDEX, 54 | UT_CFE_SB_GETTOTALMSGLENGTH_INDEX, 55 | UT_CFE_SB_SETTOTALMSGLENGTH_INDEX, 56 | UT_CFE_SB_GETMSGTIME_INDEX, 57 | UT_CFE_SB_SETMSGTIME_INDEX, 58 | UT_CFE_SB_TIMESTAMPMSG_INDEX, 59 | UT_CFE_SB_GETCMDCODE_INDEX, 60 | UT_CFE_SB_SETCMDCODE_INDEX, 61 | UT_CFE_SB_GETCHECKSUM_INDEX, 62 | UT_CFE_SB_GENERATECHECKSUM_INDEX, 63 | UT_CFE_SB_VALIDATECHECKSUM_INDEX, 64 | UT_CFE_SB_CLEANUPAPP_INDEX, 65 | UT_CFE_SB_MAX_INDEX 66 | } Ut_CFE_SB_INDEX_t; 67 | 68 | typedef struct 69 | { 70 | int32 (*CFE_SB_CreatePipe)(CFE_SB_PipeId_t *PipeIdPtr,uint16 Depth, char *PipeName); 71 | int32 (*CFE_SB_DeletePipe)(CFE_SB_PipeId_t PipeId); 72 | int32 (*CFE_SB_SubscribeEx)(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId,CFE_SB_Qos_t Quality, uint16 MsgLim); 73 | int32 (*CFE_SB_Subscribe)(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); 74 | int32 (*CFE_SB_SubscribeLocal)(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint16 MsgLim); 75 | int32 (*CFE_SB_Unsubscribe)(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); 76 | int32 (*CFE_SB_UnsubscribeLocal)(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); 77 | int32 (*CFE_SB_SendMsg)(CFE_SB_Msg_t *MsgPtr); 78 | int32 (*CFE_SB_PassMsg)(CFE_SB_Msg_t *MsgPtr); 79 | int32 (*CFE_SB_RcvMsg)(CFE_SB_MsgPtr_t *BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); 80 | int32 (*CFE_SB_GetLastSenderId)(CFE_SB_SenderId_t **Ptr,CFE_SB_PipeId_t PipeId); 81 | int32 (*CFE_SB_ZeroCopyGetPtr)(uint16 MsgSize,CFE_SB_ZeroCopyHandle_t *BufferHandle); 82 | int32 (*CFE_SB_ZeroCopyReleasePtr)(CFE_SB_Msg_t *Ptr2Release,CFE_SB_ZeroCopyHandle_t BufferHandle); 83 | int32 (*CFE_SB_ZeroCopySend)(CFE_SB_Msg_t *MsgPtr,CFE_SB_ZeroCopyHandle_t BufferHandle); 84 | int32 (*CFE_SB_ZeroCopyPass)(CFE_SB_Msg_t *MsgPtr,CFE_SB_ZeroCopyHandle_t BufferHandle); 85 | int32 (*CFE_SB_InitMsg)(void *MsgPtr,CFE_SB_MsgId_t MsgId, uint16 Length, boolean Clear); 86 | int32 (*CFE_SB_MsgHdrSize)(CFE_SB_MsgId_t MsgId); 87 | void *(*CFE_SB_GetUserData)(CFE_SB_MsgPtr_t MsgPtr); 88 | int32 (*CFE_SB_GetMsgId)(CFE_SB_MsgPtr_t MsgPtr); 89 | int32 (*CFE_SB_SetMsgId)(CFE_SB_MsgPtr_t MsgPtr,CFE_SB_MsgId_t MsgId); 90 | int32 (*CFE_SB_GetUserDataLength)(CFE_SB_MsgPtr_t MsgPtr); 91 | int32 (*CFE_SB_SetUserDataLength)(CFE_SB_MsgPtr_t MsgPtr,uint16 DataLength); 92 | int32 (*CFE_SB_GetTotalMsgLength)(CFE_SB_MsgPtr_t MsgPtr); 93 | int32 (*CFE_SB_SetTotalMsgLength)(CFE_SB_MsgPtr_t MsgPtr,uint16 TotalLength); 94 | CFE_TIME_SysTime_t (*CFE_SB_GetMsgTime)(CFE_SB_MsgPtr_t MsgPtr); 95 | int32 (*CFE_SB_SetMsgTime)(CFE_SB_MsgPtr_t MsgPtr,CFE_TIME_SysTime_t Time); 96 | int32 (*CFE_SB_TimeStampMsg)(CFE_SB_MsgPtr_t MsgPtr); 97 | int32 (*CFE_SB_GetCmdCode)(CFE_SB_MsgPtr_t MsgPtr); 98 | int32 (*CFE_SB_SetCmdCode)(CFE_SB_MsgPtr_t MsgPtr,uint16 CmdCode); 99 | int32 (*CFE_SB_GetChecksum)(CFE_SB_MsgPtr_t MsgPtr); 100 | int32 (*CFE_SB_GenerateChecksum)(CFE_SB_MsgPtr_t MsgPtr); 101 | int32 (*CFE_SB_ValidateChecksum)(CFE_SB_MsgPtr_t MsgPtr); 102 | int32 (*CFE_SB_CleanUpApp)(uint32 AppId); 103 | } Ut_CFE_SB_HookTable_t; 104 | 105 | typedef struct 106 | { 107 | int32 Value; 108 | uint32 Count; 109 | } Ut_CFE_SB_ReturnCodeTable_t; 110 | 111 | void Ut_CFE_SB_Reset(void); 112 | void Ut_CFE_SB_SetFunctionHook(uint32 Index, void *FunPtr); 113 | void Ut_CFE_SB_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_tbl_hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_tbl_hooks.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_tbl_hooks.c 1.1 2011/05/04 11:20:57EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test hooks for cFE Table Services routines 13 | ** 14 | ** $Log: ut_cfe_tbl_hooks.c $ 15 | ** Revision 1.1 2011/05/04 11:20:57EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:42EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.5 2011/03/04 14:59:12EST sslegel 22 | ** Added a define for the maximum number of tables 23 | ** Fixed a memory leak in Ut_CFE_TBL_ClearTables 24 | ** Fixed a bug in Ut_CFE_TBL_RegisterTable where the table buffer was not cleared after the memory was allocated 25 | ** Revision 1.4 2011/02/21 16:15:32EST sslegel 26 | ** Renamed global tables 27 | ** Revision 1.3 2011/02/18 15:57:42EST sslegel 28 | ** Added new hooks and return codes 29 | ** Changed Ut_CFE_TBL_LoadHook to automatically call the table validate function 30 | ** Revision 1.2 2011/02/17 16:34:26EST rmcgraw 31 | ** Tbl GetAdr Hook change to return TBL_UPDATED after a TBL load 32 | ** Revision 1.1 2011/02/15 11:13:04EST sslegel 33 | ** Initial revision 34 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 35 | ** 36 | */ 37 | 38 | #include "cfe.h" 39 | #include "utlist.h" 40 | #include 41 | 42 | #define UT_CFE_TBL_MAX_TABLES 32 43 | 44 | typedef struct { 45 | boolean InUse; 46 | boolean TblUpdatedFlag; 47 | void *Buffer; 48 | char Name[CFE_TBL_MAX_FULL_NAME_LEN]; 49 | uint32 Size; 50 | uint16 TblOptionFlags; 51 | CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr; 52 | } Ut_CFE_TBL_Registry_t; 53 | 54 | typedef struct { 55 | boolean InUse; 56 | char Filename[OS_MAX_PATH_LEN]; 57 | void *TablePtr; 58 | } Ut_CFE_TBL_Images_t; 59 | 60 | Ut_CFE_TBL_Images_t Ut_CFE_TBL_Images[UT_CFE_TBL_MAX_TABLES]; 61 | Ut_CFE_TBL_Registry_t Ut_CFE_TBL_Registry[UT_CFE_TBL_MAX_TABLES]; 62 | 63 | int32 Ut_CFE_TBL_RegisterTable(const char *Name, uint32 Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr) 64 | { 65 | uint32 i; 66 | 67 | for (i=0; i < UT_CFE_TBL_MAX_TABLES; i++) { 68 | if (Ut_CFE_TBL_Registry[i].InUse == FALSE) { 69 | Ut_CFE_TBL_Registry[i].InUse = TRUE; 70 | Ut_CFE_TBL_Registry[i].TblUpdatedFlag = FALSE; 71 | Ut_CFE_TBL_Registry[i].Buffer = malloc(Size); 72 | memset(Ut_CFE_TBL_Registry[i].Buffer, 0, Size); 73 | strncpy(Ut_CFE_TBL_Registry[i].Name, Name, CFE_TBL_MAX_FULL_NAME_LEN); 74 | Ut_CFE_TBL_Registry[i].Size = Size; 75 | Ut_CFE_TBL_Registry[i].TblOptionFlags = TblOptionFlags; 76 | Ut_CFE_TBL_Registry[i].TblValidationFuncPtr = TblValidationFuncPtr; 77 | return(i); 78 | } 79 | } 80 | 81 | return(-1); 82 | } 83 | 84 | int32 Ut_CFE_TBL_AddTable(char *Filename, void *TablePtr) 85 | { 86 | uint32 i; 87 | 88 | for (i=0; i < UT_CFE_TBL_MAX_TABLES; i++) { 89 | if (Ut_CFE_TBL_Images[i].InUse == FALSE) { 90 | Ut_CFE_TBL_Images[i].InUse = TRUE; 91 | strncpy(Ut_CFE_TBL_Images[i].Filename, Filename, OS_MAX_PATH_LEN); 92 | Ut_CFE_TBL_Images[i].TablePtr = TablePtr; 93 | return(i); 94 | } 95 | } 96 | 97 | return(-1); 98 | } 99 | 100 | int32 Ut_CFE_TBL_LoadTable(CFE_TBL_Handle_t TblHandle, void *SrcDataPtr) 101 | { 102 | if (Ut_CFE_TBL_Registry[TblHandle].InUse) { 103 | memcpy(Ut_CFE_TBL_Registry[TblHandle].Buffer, SrcDataPtr, Ut_CFE_TBL_Registry[TblHandle].Size); 104 | Ut_CFE_TBL_Registry[TblHandle].TblUpdatedFlag = TRUE; 105 | return(CFE_SUCCESS); 106 | } 107 | else { 108 | return(CFE_TBL_ERR_INVALID_HANDLE); 109 | } 110 | } 111 | 112 | void Ut_CFE_TBL_ClearTables(void) 113 | { 114 | uint32 i; 115 | 116 | for (i=0; i < UT_CFE_TBL_MAX_TABLES; i++) { 117 | if (Ut_CFE_TBL_Registry[i].InUse == TRUE && 118 | Ut_CFE_TBL_Registry[i].Buffer != NULL) { 119 | free(Ut_CFE_TBL_Registry[i].Buffer); 120 | } 121 | } 122 | memset(&Ut_CFE_TBL_Registry, 0, sizeof(Ut_CFE_TBL_Registry)); 123 | memset(&Ut_CFE_TBL_Images, 0, sizeof(Ut_CFE_TBL_Images)); 124 | } 125 | 126 | int32 Ut_CFE_TBL_FindTable(char *Filename) 127 | { 128 | uint32 i; 129 | 130 | for (i=0; i < UT_CFE_TBL_MAX_TABLES; i++) { 131 | if ((Ut_CFE_TBL_Images[i].InUse == TRUE) && 132 | (strncmp(Ut_CFE_TBL_Images[i].Filename, Filename, strlen(Filename)) == 0)) { 133 | return(i); 134 | } 135 | } 136 | return(-1); 137 | } 138 | 139 | void *Ut_CFE_TBL_GetAddress(CFE_TBL_Handle_t TblHandle) 140 | { 141 | if (Ut_CFE_TBL_Registry[TblHandle].InUse) { 142 | return(Ut_CFE_TBL_Registry[TblHandle].Buffer); 143 | } 144 | else { 145 | return(NULL); 146 | } 147 | } 148 | 149 | int32 Ut_CFE_TBL_RegisterHook(CFE_TBL_Handle_t *TblHandlePtr, const char *Name, uint32 Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr) 150 | { 151 | *TblHandlePtr = Ut_CFE_TBL_RegisterTable(Name, Size, TblOptionFlags, TblValidationFuncPtr); 152 | return(CFE_SUCCESS); 153 | } 154 | 155 | int32 Ut_CFE_TBL_LoadHook(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr) 156 | { 157 | int32 TableIndex; 158 | int32 Status; 159 | 160 | TableIndex = Ut_CFE_TBL_FindTable((char *)SrcDataPtr); 161 | if (TableIndex >= 0) { 162 | if (Ut_CFE_TBL_Registry[TblHandle].TblValidationFuncPtr != NULL) { 163 | Status = Ut_CFE_TBL_Registry[TblHandle].TblValidationFuncPtr(Ut_CFE_TBL_Images[TableIndex].TablePtr); 164 | if (Status != CFE_SUCCESS) 165 | return(Status); 166 | } 167 | return(Ut_CFE_TBL_LoadTable(TblHandle, Ut_CFE_TBL_Images[TableIndex].TablePtr)); 168 | } 169 | else { 170 | return(CFE_TBL_ERR_FILE_NOT_FOUND); 171 | } 172 | } 173 | 174 | int32 Ut_CFE_TBL_GetAddressHook(void **TblPtr, CFE_TBL_Handle_t TblHandle) 175 | { 176 | if ((*TblPtr = Ut_CFE_TBL_GetAddress(TblHandle)) != NULL) { 177 | 178 | if(Ut_CFE_TBL_Registry[TblHandle].TblUpdatedFlag == TRUE) { 179 | Ut_CFE_TBL_Registry[TblHandle].TblUpdatedFlag = FALSE; 180 | return (CFE_TBL_INFO_UPDATED); 181 | } 182 | 183 | return(CFE_SUCCESS); 184 | } 185 | else { 186 | 187 | return(CFE_TBL_ERR_INVALID_HANDLE); 188 | } 189 | 190 | } 191 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_tbl_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_tbl_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_tbl_stubs.c 1.1 2011/05/04 11:20:57EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE Table Services routines 13 | ** 14 | ** $Log: ut_cfe_tbl_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:20:57EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:43EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.4 2011/03/10 11:19:20EST sslegel 22 | ** Added return code support to CFE_TBL_GetInfo 23 | ** Revision 1.3 2011/02/18 15:57:42EST sslegel 24 | ** Added new hooks and return codes 25 | ** Changed Ut_CFE_TBL_LoadHook to automatically call the table validate function 26 | ** Revision 1.2 2011/02/17 16:34:27EST rmcgraw 27 | ** Tbl GetAdr Hook change to return TBL_UPDATED after a TBL load 28 | ** Revision 1.1 2011/02/15 11:13:04EST sslegel 29 | ** Initial revision 30 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 31 | ** 32 | */ 33 | 34 | #include "cfe.h" 35 | #include "ut_cfe_tbl_stubs.h" 36 | #include "ut_cfe_tbl_hooks.h" 37 | #include 38 | 39 | Ut_CFE_TBL_HookTable_t Ut_CFE_TBL_HookTable; 40 | Ut_CFE_TBL_ReturnCodeTable_t Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_MAX_INDEX]; 41 | 42 | void Ut_CFE_TBL_Reset(void) 43 | { 44 | memset(&Ut_CFE_TBL_HookTable, 0, sizeof(Ut_CFE_TBL_HookTable)); 45 | memset(&Ut_CFE_TBL_ReturnCodeTable, 0, sizeof(Ut_CFE_TBL_ReturnCodeTable)); 46 | 47 | Ut_CFE_TBL_SetFunctionHook(UT_CFE_TBL_REGISTER_INDEX, (void *)&Ut_CFE_TBL_RegisterHook); 48 | Ut_CFE_TBL_SetFunctionHook(UT_CFE_TBL_LOAD_INDEX, (void *)&Ut_CFE_TBL_LoadHook); 49 | Ut_CFE_TBL_SetFunctionHook(UT_CFE_TBL_GETADDRESS_INDEX, (void *)&Ut_CFE_TBL_GetAddressHook); 50 | 51 | Ut_CFE_TBL_ClearTables(); 52 | } 53 | 54 | void Ut_CFE_TBL_SetFunctionHook(uint32 Index, void *FunPtr) 55 | { 56 | if (Index == UT_CFE_TBL_REGISTER_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_Register = FunPtr; } 57 | else if (Index == UT_CFE_TBL_LOAD_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_Load = FunPtr; } 58 | else if (Index == UT_CFE_TBL_MANAGE_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_Manage = FunPtr; } 59 | else if (Index == UT_CFE_TBL_GETADDRESS_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_GetAddress = FunPtr; } 60 | else if (Index == UT_CFE_TBL_GETADDRESSES_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_GetAddresses = FunPtr; } 61 | else if (Index == UT_CFE_TBL_GETINFO_INDEX) { Ut_CFE_TBL_HookTable.CFE_TBL_GetInfo = FunPtr; } 62 | else { printf("Unsupported TBL Index In SetFunctionHook Call %u\n", Index); } 63 | } 64 | 65 | void Ut_CFE_TBL_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 66 | { 67 | if (Index < UT_CFE_TBL_MAX_INDEX) { 68 | Ut_CFE_TBL_ReturnCodeTable[Index].Value = RtnVal; 69 | Ut_CFE_TBL_ReturnCodeTable[Index].Count = CallCnt; 70 | } 71 | else { 72 | printf("Unsupported TBL Index In SetReturnCode Call %u\n", Index); 73 | } 74 | } 75 | 76 | boolean Ut_CFE_TBL_UseReturnCode(uint32 Index) 77 | { 78 | if (Ut_CFE_TBL_ReturnCodeTable[Index].Count > 0) { 79 | Ut_CFE_TBL_ReturnCodeTable[Index].Count--; 80 | if (Ut_CFE_TBL_ReturnCodeTable[Index].Count == 0) 81 | return(TRUE); 82 | } 83 | 84 | return(FALSE); 85 | } 86 | 87 | int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, 88 | const char *Name, 89 | uint32 Size, 90 | uint16 TblOptionFlags, 91 | CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) 92 | { 93 | /* Check for specified return */ 94 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_REGISTER_INDEX)) 95 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_REGISTER_INDEX].Value; 96 | 97 | /* Check for Function Hook */ 98 | if (Ut_CFE_TBL_HookTable.CFE_TBL_Register) 99 | return(Ut_CFE_TBL_HookTable.CFE_TBL_Register(TblHandlePtr, Name, Size, TblOptionFlags,TblValidationFuncPtr)); 100 | 101 | return CFE_SUCCESS; 102 | } 103 | 104 | int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ 105 | const char *TblName ) 106 | { 107 | return CFE_SUCCESS; 108 | } 109 | 110 | int32 CFE_TBL_Unregister ( CFE_TBL_Handle_t TblHandle ) 111 | { 112 | return CFE_SUCCESS; 113 | } 114 | 115 | int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, 116 | CFE_TBL_SrcEnum_t SrcType, 117 | const void *SrcDataPtr ) 118 | { 119 | /* Check for specified return */ 120 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_LOAD_INDEX)) 121 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_LOAD_INDEX].Value; 122 | 123 | /* Check for Function Hook */ 124 | if (Ut_CFE_TBL_HookTable.CFE_TBL_Load) 125 | return(Ut_CFE_TBL_HookTable.CFE_TBL_Load(TblHandle, SrcType, SrcDataPtr)); 126 | 127 | return CFE_SUCCESS; 128 | } 129 | 130 | int32 CFE_TBL_Update( CFE_TBL_Handle_t TblHandle ) 131 | { 132 | return CFE_SUCCESS; 133 | } 134 | 135 | int32 CFE_TBL_GetAddress( void **TblPtr, 136 | CFE_TBL_Handle_t TblHandle ) 137 | { 138 | /* Check for specified return */ 139 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETADDRESS_INDEX)) 140 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETADDRESS_INDEX].Value; 141 | 142 | /* Check for Function Hook */ 143 | if (Ut_CFE_TBL_HookTable.CFE_TBL_GetAddress) 144 | return(Ut_CFE_TBL_HookTable.CFE_TBL_GetAddress(TblPtr, TblHandle)); 145 | 146 | return CFE_SUCCESS; 147 | } 148 | 149 | int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) 150 | { 151 | return CFE_SUCCESS; 152 | } 153 | 154 | int32 CFE_TBL_GetAddresses( void **TblPtrs[], 155 | uint16 NumTables, 156 | const CFE_TBL_Handle_t TblHandles[] ) 157 | { 158 | /* Check for specified return */ 159 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETADDRESSES_INDEX)) 160 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETADDRESSES_INDEX].Value; 161 | 162 | /* Check for Function Hook */ 163 | if (Ut_CFE_TBL_HookTable.CFE_TBL_GetAddresses) 164 | return(Ut_CFE_TBL_HookTable.CFE_TBL_GetAddresses(TblPtrs, NumTables, TblHandles)); 165 | 166 | return CFE_SUCCESS; 167 | } 168 | 169 | int32 CFE_TBL_ReleaseAddresses( uint16 NumTables, 170 | const CFE_TBL_Handle_t TblHandles[] ) 171 | { 172 | return CFE_SUCCESS; 173 | } 174 | 175 | int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) 176 | { 177 | return CFE_SUCCESS; 178 | } 179 | 180 | int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ) 181 | { 182 | /* Check for specified return */ 183 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_MANAGE_INDEX)) 184 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_MANAGE_INDEX].Value; 185 | 186 | /* Check for Function Hook */ 187 | if (Ut_CFE_TBL_HookTable.CFE_TBL_Manage) 188 | return(Ut_CFE_TBL_HookTable.CFE_TBL_Manage(TblHandle)); 189 | 190 | return CFE_SUCCESS; 191 | } 192 | 193 | int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) 194 | { 195 | /* Check for specified return */ 196 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETSTATUS_INDEX)) 197 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETSTATUS_INDEX].Value; 198 | 199 | return CFE_SUCCESS; 200 | } 201 | 202 | int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) 203 | { 204 | /* Check for specified return */ 205 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETINFO_INDEX)) 206 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETINFO_INDEX].Value; 207 | 208 | /* Check for Function Hook */ 209 | if (Ut_CFE_TBL_HookTable.CFE_TBL_GetInfo) 210 | return(Ut_CFE_TBL_HookTable.CFE_TBL_GetInfo(TblInfoPtr, TblName)); 211 | 212 | return CFE_SUCCESS; 213 | } 214 | 215 | int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ) 216 | { 217 | return CFE_SUCCESS; 218 | } 219 | 220 | int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) 221 | { 222 | return CFE_SUCCESS; 223 | } 224 | 225 | int32 CFE_TBL_CleanUpApp (uint32 AppId) 226 | { 227 | return CFE_SUCCESS; 228 | } 229 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_osfileapi_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2017 United States Government as represented by the Administrator 4 | ** of the National Aeronautics and Space Administration. No copyright is 5 | ** claimed in the United States under Title 17, U.S. Code. 6 | ** All Other Rights Reserved. 7 | ** 8 | ** File: ut_osfileapi_stubs.c 9 | ** 10 | ** $Id: ut_osfileapi_stubs.c 1.1 2011/05/04 11:21:00EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for the OSAPI File Services routines 13 | ** 14 | ** $Log: ut_osfileapi_stubs.c $ 15 | ** Revision 1.1 2011/05/04 11:21:00EDT rmcgraw 16 | ** Initial revision 17 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 18 | ** Revision 1.1 2011/04/08 16:26:45EDT rmcgraw 19 | ** Initial revision 20 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 21 | ** Revision 1.6 2011/03/31 14:53:05EDT rmcgraw 22 | ** Added functionality and supressed compiler warnings 23 | ** Revision 1.5 2011/03/30 09:58:57EDT rmcgraw 24 | ** Added Hook and Return enhancements to Directory APIs 25 | ** Revision 1.4 2011/03/24 13:14:55EDT rmcgraw 26 | ** Added Hook and RtnCode functionality to OS_stat 27 | ** Revision 1.3 2011/03/23 17:18:08EDT rmcgraw 28 | ** correct OS_read return value 29 | ** Revision 1.2 2011/03/23 17:08:19EDT rmcgraw 30 | ** OS_FS_ERROR to OS_FS_SUCCESS for some OS file sys apis 31 | ** Revision 1.1 2011/02/15 11:13:05EST sslegel 32 | ** Initial revision 33 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 34 | ** 35 | */ 36 | 37 | #include "cfe.h" 38 | #include "ut_osfileapi_stubs.h" 39 | #include 40 | 41 | Ut_OSFILEAPI_HookTable_t Ut_OSFILEAPI_HookTable; 42 | Ut_OSFILEAPI_ReturnCodeTable_t Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_MAX_INDEX]; 43 | 44 | void Ut_OSFILEAPI_Reset(void) 45 | { 46 | memset(&Ut_OSFILEAPI_HookTable, 0, sizeof(Ut_OSFILEAPI_HookTable)); 47 | memset(&Ut_OSFILEAPI_ReturnCodeTable, 0, sizeof(Ut_OSFILEAPI_ReturnCodeTable)); 48 | } 49 | 50 | void Ut_OSFILEAPI_SetFunctionHook(uint32 Index, void *FunPtr) 51 | { 52 | if (Index == UT_OSFILEAPI_CREAT_INDEX) { Ut_OSFILEAPI_HookTable.OS_creat = FunPtr; } 53 | else if (Index == UT_OSFILEAPI_WRITE_INDEX) { Ut_OSFILEAPI_HookTable.OS_write = FunPtr; } 54 | else if (Index == UT_OSFILEAPI_READ_INDEX) { Ut_OSFILEAPI_HookTable.OS_read = FunPtr; } 55 | else if (Index == UT_OSFILEAPI_OPENDIR_INDEX) { Ut_OSFILEAPI_HookTable.OS_opendir = FunPtr; } 56 | else if (Index == UT_OSFILEAPI_READDIR_INDEX) { Ut_OSFILEAPI_HookTable.OS_readdir = FunPtr; } 57 | else if (Index == UT_OSFILEAPI_CLOSE_INDEX) { Ut_OSFILEAPI_HookTable.OS_close = FunPtr; } 58 | else if (Index == UT_OSFILEAPI_OPEN_INDEX) { Ut_OSFILEAPI_HookTable.OS_open = FunPtr; } 59 | else if (Index == UT_OSFILEAPI_CLOSEDIR_INDEX) { Ut_OSFILEAPI_HookTable.OS_closedir = FunPtr; } 60 | else if (Index == UT_OSFILEAPI_STAT_INDEX) { Ut_OSFILEAPI_HookTable.OS_stat = FunPtr; } 61 | else if (Index == UT_OSFILEAPI_FDGETINFO_INDEX){ Ut_OSFILEAPI_HookTable.OS_FDGetInfo = FunPtr; } 62 | else { printf("Unsupported OSFILEAPI Index In SetFunctionHook Call %u\n", Index); } 63 | } 64 | 65 | void Ut_OSFILEAPI_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 66 | { 67 | if (Index < UT_OSFILEAPI_MAX_INDEX) { 68 | Ut_OSFILEAPI_ReturnCodeTable[Index].Value = RtnVal; 69 | Ut_OSFILEAPI_ReturnCodeTable[Index].Count = CallCnt; 70 | } 71 | else { 72 | printf("Unsupported OSFILEAPI Index In SetReturnCode Call %u\n", Index); 73 | } 74 | } 75 | 76 | boolean Ut_OSFILEAPI_UseReturnCode(uint32 Index) 77 | { 78 | if (Ut_OSFILEAPI_ReturnCodeTable[Index].Count > 0) { 79 | Ut_OSFILEAPI_ReturnCodeTable[Index].Count--; 80 | if (Ut_OSFILEAPI_ReturnCodeTable[Index].Count == 0) 81 | return(TRUE); 82 | } 83 | 84 | return(FALSE); 85 | } 86 | 87 | /* 88 | ** Standard File system API 89 | */ 90 | 91 | int32 OS_creat (const char *path, int32 access) 92 | { 93 | /* Check for specified return */ 94 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_CREAT_INDEX)) 95 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_CREAT_INDEX].Value; 96 | 97 | /* Check for Function Hook */ 98 | if (Ut_OSFILEAPI_HookTable.OS_creat) 99 | return Ut_OSFILEAPI_HookTable.OS_creat(path, access); 100 | 101 | return OS_FS_ERROR; 102 | } 103 | 104 | int32 OS_open (const char *path, int32 access, uint32 mode) 105 | { 106 | /* Check for specified return */ 107 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_OPEN_INDEX)) 108 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_OPEN_INDEX].Value; 109 | 110 | /* Check for Function Hook */ 111 | if (Ut_OSFILEAPI_HookTable.OS_open) 112 | return Ut_OSFILEAPI_HookTable.OS_open(path, access, mode); 113 | 114 | return OS_FS_ERROR; 115 | } 116 | 117 | int32 OS_close (int32 filedes) 118 | { 119 | /* Check for specified return */ 120 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_CLOSE_INDEX)) 121 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_CLOSE_INDEX].Value; 122 | 123 | /* Check for Function Hook */ 124 | if (Ut_OSFILEAPI_HookTable.OS_close) 125 | return Ut_OSFILEAPI_HookTable.OS_close(filedes); 126 | 127 | return OS_FS_SUCCESS; 128 | } 129 | 130 | int32 OS_read (int32 filedes, void *buffer, uint32 nbytes) 131 | { 132 | /* Check for specified return */ 133 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_READ_INDEX)) 134 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_READ_INDEX].Value; 135 | 136 | /* Check for Function Hook */ 137 | if (Ut_OSFILEAPI_HookTable.OS_read) 138 | return Ut_OSFILEAPI_HookTable.OS_read(filedes, buffer, nbytes); 139 | 140 | return OS_FS_ERROR; 141 | } 142 | 143 | int32 OS_write (int32 filedes, void *buffer, uint32 nbytes) 144 | { 145 | /* Check for specified return */ 146 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_WRITE_INDEX)) 147 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_WRITE_INDEX].Value; 148 | 149 | /* Check for Function Hook */ 150 | if (Ut_OSFILEAPI_HookTable.OS_write) 151 | return Ut_OSFILEAPI_HookTable.OS_write(filedes, buffer, nbytes); 152 | 153 | return nbytes; 154 | } 155 | 156 | int32 OS_chmod (const char *path, uint32 access) 157 | { 158 | return OS_FS_SUCCESS; 159 | } 160 | 161 | int32 OS_stat (const char *path, os_fstat_t *filestats) 162 | { 163 | /* Check for specified return */ 164 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_STAT_INDEX)) 165 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_STAT_INDEX].Value; 166 | 167 | /* Check for Function Hook */ 168 | if (Ut_OSFILEAPI_HookTable.OS_stat) 169 | return Ut_OSFILEAPI_HookTable.OS_stat(path, filestats); 170 | 171 | return OS_FS_ERROR; 172 | } 173 | 174 | int32 OS_lseek (int32 filedes, int32 offset, uint32 whence) 175 | { 176 | return OS_FS_SUCCESS; 177 | } 178 | 179 | int32 OS_remove (const char *path) 180 | { 181 | return OS_FS_SUCCESS; 182 | } 183 | 184 | int32 OS_rename (const char *old, const char *new) 185 | { 186 | return OS_FS_SUCCESS; 187 | } 188 | 189 | int32 OS_cp (const char *src, const char *dest) 190 | { 191 | return OS_FS_SUCCESS; 192 | } 193 | 194 | int32 OS_mv (const char *src, const char *dest) 195 | { 196 | return OS_FS_SUCCESS; 197 | } 198 | 199 | /* 200 | ** Directory API 201 | */ 202 | 203 | int32 OS_mkdir (const char *path, uint32 access) 204 | { 205 | return OS_FS_SUCCESS; 206 | } 207 | 208 | os_dirp_t OS_opendir (const char *path) 209 | { 210 | /* Check for specified return */ 211 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_OPENDIR_INDEX)) 212 | return (os_dirp_t)Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_OPENDIR_INDEX].Value; 213 | 214 | /* Check for Function Hook */ 215 | if (Ut_OSFILEAPI_HookTable.OS_opendir) 216 | return Ut_OSFILEAPI_HookTable.OS_opendir(path); 217 | 218 | return NULL; 219 | } 220 | 221 | int32 OS_closedir (os_dirp_t directory) 222 | { 223 | /* Check for specified return */ 224 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_CLOSEDIR_INDEX)) 225 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_CLOSEDIR_INDEX].Value; 226 | 227 | /* Check for Function Hook */ 228 | if (Ut_OSFILEAPI_HookTable.OS_closedir) 229 | return Ut_OSFILEAPI_HookTable.OS_closedir(directory); 230 | 231 | return OS_FS_SUCCESS; 232 | } 233 | 234 | os_dirent_t * OS_readdir (os_dirp_t directory) 235 | { 236 | /* Check for specified return */ 237 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_READDIR_INDEX)) 238 | return (os_dirent_t *)Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_READDIR_INDEX].Value; 239 | 240 | /* Check for Function Hook */ 241 | if (Ut_OSFILEAPI_HookTable.OS_readdir) 242 | return Ut_OSFILEAPI_HookTable.OS_readdir(directory); 243 | 244 | return NULL; 245 | } 246 | 247 | int32 OS_rmdir (const char *path) 248 | { 249 | return OS_FS_ERROR; 250 | } 251 | 252 | int32 OS_check_name_length(const char *path) 253 | { 254 | return OS_FS_SUCCESS; 255 | } 256 | 257 | int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd) 258 | { 259 | return OS_FS_SUCCESS; 260 | } 261 | 262 | int32 OS_FDGetInfo (int32 filedes, OS_FDTableEntry *fd_prop) 263 | { 264 | /* Check for specified return */ 265 | if (Ut_OSFILEAPI_UseReturnCode(UT_OSFILEAPI_FDGETINFO_INDEX)) 266 | return Ut_OSFILEAPI_ReturnCodeTable[UT_OSFILEAPI_FDGETINFO_INDEX].Value; 267 | 268 | /* Check for Function Hook */ 269 | if (Ut_OSFILEAPI_HookTable.OS_FDGetInfo) 270 | return Ut_OSFILEAPI_HookTable.OS_FDGetInfo(filedes,fd_prop); 271 | 272 | return OS_FS_ERR_INVALID_FD; 273 | } 274 | -------------------------------------------------------------------------------- /fsw/src/ci_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_custom.c 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Function Definitions for Custom Layer of CI Application for UDP 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the CI application over a UDP socket. 16 | * 17 | * \par API Functions Defined: 18 | * - CI_CustomInit() - Initialize the transport protocol, create child task 19 | * - CI_CustomAppCmds() - Process custom App Commands 20 | * - CI_CustomEnableTO() - Send msg to TO to enable downlink 21 | * - CI_CustomCleanup() - Cleanup callback to close transport channel. 22 | * - CI_CustomMain() - Main entry point for the custom child task. 23 | * - CI_CustomGateCmds() - Process custom Gate Commands 24 | * 25 | * \par Private Functions Defined: 26 | * 27 | * \par Limitations, Assumptions, External Events, and Notes: 28 | * - All input messages are CCSDS messages 29 | * - CI and TO makes use of seperate UDP sockets 30 | * - All config macros defined in ci_platform_cfg.h 31 | * - ciMutex must be used whenever g_CI_AppData is accessed. 32 | * 33 | * \par Modification History: 34 | * - 2015-01-09 | Guy de Carufel | Code Started 35 | * - 2015-06-02 | Guy de Carufel | Revised for new UDP API 36 | *******************************************************************************/ 37 | 38 | /* 39 | ** Pragmas 40 | */ 41 | 42 | /* 43 | ** Include Files 44 | */ 45 | #include "cfe.h" 46 | #include "network_includes.h" 47 | #include "trans_udp.h" 48 | 49 | #include "ci_app.h" 50 | #include "ci_platform_cfg.h" 51 | 52 | /* 53 | ** Local Defines 54 | */ 55 | 56 | /* 57 | ** Local Structure Declarations 58 | */ 59 | typedef struct 60 | { 61 | IO_TransUdp_t udp; /**< UDP working */ 62 | TO_EnableOutputCmd_t toEnableCmd; /**< TO Enable CMD msg */ 63 | uint8 buffer[CI_CUSTOM_BUFFER_SIZE]; /**< buffer */ 64 | } CI_CustomData_t; 65 | 66 | 67 | /* 68 | ** External Global Variables 69 | */ 70 | /* NOTE: Make use of ciMutex when accessing data shared by the main task. */ 71 | extern CI_AppData_t g_CI_AppData; 72 | 73 | /* 74 | ** Global Variables 75 | */ 76 | 77 | /* 78 | ** Local Variables 79 | */ 80 | static CI_CustomData_t g_CI_CustomData; 81 | 82 | /* 83 | ** Local Function Definitions 84 | */ 85 | 86 | 87 | /******************************************************************************* 88 | ** Custom Application Functions (Executed by Main Task) 89 | *******************************************************************************/ 90 | 91 | /******************************************************************************/ 92 | /** \brief Custom Initialization 93 | *******************************************************************************/ 94 | int32 CI_CustomInit(void) 95 | { 96 | int32 iStatus = CI_ERROR; 97 | uint32 taskId = 0; 98 | IO_TransUdpConfig_t config; 99 | 100 | /* Set Config parameters */ 101 | CFE_PSP_MemSet((void *) &config, 0x0, sizeof(IO_TransUdpConfig_t)); 102 | strncpy(config.cAddr, CI_CUSTOM_UDP_ADDR, 16); 103 | config.usPort = CI_CUSTOM_UDP_PORT; 104 | config.timeoutRcv = CI_CUSTOM_UDP_TIMEOUT; 105 | 106 | if (IO_TransUdpInit(&config, &g_CI_CustomData.udp) < 0) 107 | { 108 | goto end_of_function; 109 | } 110 | 111 | iStatus = CFE_ES_CreateChildTask(&taskId, 112 | "CI Custom Main Task", 113 | CI_CustomMain, 114 | CI_CUSTOM_TASK_STACK_PTR, 115 | CI_CUSTOM_TASK_STACK_SIZE, 116 | CI_CUSTOM_TASK_PRIO, 117 | 0); 118 | end_of_function: 119 | return (iStatus); 120 | } 121 | 122 | 123 | /******************************************************************************/ 124 | /** \brief Custom app command response 125 | *******************************************************************************/ 126 | int32 CI_CustomAppCmds(CFE_SB_MsgPtr_t cmdMsgPtr) 127 | { 128 | int32 iStatus = CI_SUCCESS; 129 | uint32 uiCmdCode = CFE_SB_GetCmdCode(cmdMsgPtr); 130 | switch (uiCmdCode) 131 | { 132 | /* Example of a valid custom command. Declare at top of file. 133 | case CI_CUSTOM_EXAMPLE_CC: 134 | if (CI_VerifyCmdLength(cmdMsgPtr, sizeof(CI_CustomExampleCmd_t))) 135 | { 136 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 137 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 138 | "CI: Recvd example custom app cmd (%d)", uiCmdCode); 139 | } 140 | break; 141 | */ 142 | 143 | default: 144 | iStatus = CI_ERROR; 145 | break; 146 | } 147 | 148 | return iStatus; 149 | } 150 | 151 | 152 | /******************************************************************************/ 153 | /** \brief Custom response to CI_ENABLE_TO_CC cmd code 154 | *******************************************************************************/ 155 | void CI_CustomEnableTO(CFE_SB_MsgPtr_t cmdMsgPtr) 156 | { 157 | /* NOTE: In this case, we are simply piping the cmd to TO. */ 158 | CFE_PSP_MemCpy((void *) &g_CI_CustomData.toEnableCmd, 159 | (void *) cmdMsgPtr, sizeof(TO_EnableOutputCmd_t)); 160 | 161 | /* Setup the toEnableCmd */ 162 | CFE_SB_InitMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 163 | TO_APP_CMD_MID, sizeof(TO_EnableOutputCmd_t), FALSE); 164 | CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 165 | TO_ENABLE_OUTPUT_CC); 166 | CFE_SB_GenerateChecksum((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 167 | 168 | /* Send the TO Enable Telemetry Output Message */ 169 | CFE_SB_SendMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 170 | return; 171 | } 172 | 173 | 174 | /******************************************************************************/ 175 | /** \brief Custom Cleanup 176 | *******************************************************************************/ 177 | void CI_CustomCleanup(void) 178 | { 179 | IO_TransUdpCloseSocket(&g_CI_CustomData.udp); 180 | } 181 | 182 | 183 | /******************************************************************************* 184 | ** Custom Functions (Executed by Custom child task) 185 | *******************************************************************************/ 186 | 187 | /******************************************************************************/ 188 | /** \brief Entry Point of custom child task 189 | *******************************************************************************/ 190 | void CI_CustomMain(void) 191 | { 192 | int32 size = 0; 193 | CFE_SB_MsgPtr_t sbMsg; 194 | CFE_SB_MsgId_t msgId; 195 | 196 | if (g_CI_CustomData.udp.sockId < 0) 197 | { 198 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 199 | "CI: Socket ID not set. Check init. " 200 | "Quitting CI_CustomMain."); 201 | return; 202 | } 203 | 204 | sbMsg = (CFE_SB_MsgPtr_t) &g_CI_CustomData.buffer[0]; 205 | 206 | while(size >= 0) 207 | { 208 | size = IO_TransUdpRcvTimeout(&g_CI_CustomData.udp, 209 | &g_CI_CustomData.buffer[0], 210 | CI_CUSTOM_BUFFER_SIZE, 211 | IO_TRANS_PEND_FOREVER); 212 | 213 | if (size > 0) 214 | { 215 | /* Get Msg ID */ 216 | msgId = CFE_SB_GetMsgId(sbMsg); 217 | 218 | /* NOTE: For this simple UDP example, the Checksum validation is 219 | not included as to be able to test with cmdUtils tool. */ 220 | 221 | /* CCSDS command checksum check. */ 222 | /* 223 | if (CFE_SB_ValidateChecksum(sbMsg) == FALSE) 224 | { 225 | uint16 cmdCode = CFE_SB_GetCmdCode(sbMsg); 226 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 227 | "CI: MID:0x%04x - Cmd Checksum failed. CmdCode:%u", 228 | msgId, cmdCode); 229 | continue; 230 | } 231 | */ 232 | 233 | /* If command is GATE command, execute immediately. */ 234 | if (msgId == CI_GATE_CMD_MID) 235 | { 236 | CI_CustomGateCmds(sbMsg); 237 | } 238 | /* Any other message is passed through to the SB. */ 239 | else if (size > 0) 240 | { 241 | CFE_SB_SendMsg(sbMsg); 242 | } 243 | } 244 | } 245 | 246 | if (size < 0) 247 | { 248 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 249 | "CI: Error occured on socket read. " 250 | "Quitting CI_CustomMain."); 251 | } 252 | 253 | return; 254 | } 255 | 256 | 257 | /******************************************************************************/ 258 | /** \brief Custom Gate command response 259 | *******************************************************************************/ 260 | void CI_CustomGateCmds(CFE_SB_MsgPtr_t cmdMsgPtr) 261 | { 262 | uint32 uiCmdCode = 0; 263 | 264 | uiCmdCode = CFE_SB_GetCmdCode(cmdMsgPtr); 265 | switch (uiCmdCode) 266 | { 267 | /* Example of a valid custom command. 268 | case CI_EXAMPLE_GATE_CC: 269 | if (CI_VerifyCmdLength(cmdMsgPtr, sizeof(CI_CustomExampleCmd_t))) 270 | { 271 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 272 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 273 | "CI: Recvd example custom gate cmd (%d)", uiCmdCode); 274 | } 275 | break; 276 | */ 277 | 278 | default: 279 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdErrCnt); 280 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 281 | "CI: Recvd invalid Gate cmd (%d)", uiCmdCode); 282 | break; 283 | } 284 | 285 | return; 286 | } 287 | 288 | /*============================================================================== 289 | ** End of file ci_custom.c 290 | **============================================================================*/ 291 | -------------------------------------------------------------------------------- /fsw/examples/udp/ci_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_custom.c 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Function Definitions for Custom Layer of CI Application for UDP 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the CI application over a UDP socket. 16 | * 17 | * \par API Functions Defined: 18 | * - CI_CustomInit() - Initialize the transport protocol, create child task 19 | * - CI_CustomAppCmds() - Process custom App Commands 20 | * - CI_CustomEnableTO() - Send msg to TO to enable downlink 21 | * - CI_CustomCleanup() - Cleanup callback to close transport channel. 22 | * - CI_CustomMain() - Main entry point for the custom child task. 23 | * - CI_CustomGateCmds() - Process custom Gate Commands 24 | * 25 | * \par Private Functions Defined: 26 | * 27 | * \par Limitations, Assumptions, External Events, and Notes: 28 | * - All input messages are CCSDS messages 29 | * - CI and TO makes use of seperate UDP sockets 30 | * - All config macros defined in ci_platform_cfg.h 31 | * - ciMutex must be used whenever g_CI_AppData is accessed. 32 | * 33 | * \par Modification History: 34 | * - 2015-01-09 | Guy de Carufel | Code Started 35 | * - 2015-06-02 | Guy de Carufel | Revised for new UDP API 36 | *******************************************************************************/ 37 | 38 | /* 39 | ** Pragmas 40 | */ 41 | 42 | /* 43 | ** Include Files 44 | */ 45 | #include "cfe.h" 46 | #include "network_includes.h" 47 | #include "trans_udp.h" 48 | 49 | #include "ci_app.h" 50 | #include "ci_platform_cfg.h" 51 | 52 | /* 53 | ** Local Defines 54 | */ 55 | 56 | /* 57 | ** Local Structure Declarations 58 | */ 59 | typedef struct 60 | { 61 | IO_TransUdp_t udp; /**< UDP working */ 62 | TO_EnableOutputCmd_t toEnableCmd; /**< TO Enable CMD msg */ 63 | uint8 buffer[CI_CUSTOM_BUFFER_SIZE]; /**< buffer */ 64 | } CI_CustomData_t; 65 | 66 | 67 | /* 68 | ** External Global Variables 69 | */ 70 | /* NOTE: Make use of ciMutex when accessing data shared by the main task. */ 71 | extern CI_AppData_t g_CI_AppData; 72 | 73 | /* 74 | ** Global Variables 75 | */ 76 | 77 | /* 78 | ** Local Variables 79 | */ 80 | static CI_CustomData_t g_CI_CustomData; 81 | 82 | /* 83 | ** Local Function Definitions 84 | */ 85 | 86 | 87 | /******************************************************************************* 88 | ** Custom Application Functions (Executed by Main Task) 89 | *******************************************************************************/ 90 | 91 | /******************************************************************************/ 92 | /** \brief Custom Initialization 93 | *******************************************************************************/ 94 | int32 CI_CustomInit(void) 95 | { 96 | int32 iStatus = CI_ERROR; 97 | uint32 taskId = 0; 98 | IO_TransUdpConfig_t config; 99 | 100 | /* Set Config parameters */ 101 | CFE_PSP_MemSet((void *) &config, 0x0, sizeof(IO_TransUdpConfig_t)); 102 | strncpy(config.cAddr, CI_CUSTOM_UDP_ADDR, 16); 103 | config.usPort = CI_CUSTOM_UDP_PORT; 104 | config.timeoutRcv = CI_CUSTOM_UDP_TIMEOUT; 105 | 106 | if (IO_TransUdpInit(&config, &g_CI_CustomData.udp) < 0) 107 | { 108 | goto end_of_function; 109 | } 110 | 111 | iStatus = CFE_ES_CreateChildTask(&taskId, 112 | "CI Custom Main Task", 113 | CI_CustomMain, 114 | CI_CUSTOM_TASK_STACK_PTR, 115 | CI_CUSTOM_TASK_STACK_SIZE, 116 | CI_CUSTOM_TASK_PRIO, 117 | 0); 118 | end_of_function: 119 | return (iStatus); 120 | } 121 | 122 | 123 | /******************************************************************************/ 124 | /** \brief Custom app command response 125 | *******************************************************************************/ 126 | int32 CI_CustomAppCmds(CFE_SB_MsgPtr_t cmdMsgPtr) 127 | { 128 | int32 iStatus = CI_SUCCESS; 129 | uint32 uiCmdCode = CFE_SB_GetCmdCode(cmdMsgPtr); 130 | switch (uiCmdCode) 131 | { 132 | /* Example of a valid custom command. Declare at top of file. 133 | case CI_CUSTOM_EXAMPLE_CC: 134 | if (CI_VerifyCmdLength(cmdMsgPtr, sizeof(CI_CustomExampleCmd_t))) 135 | { 136 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 137 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 138 | "CI: Recvd example custom app cmd (%d)", uiCmdCode); 139 | } 140 | break; 141 | */ 142 | 143 | default: 144 | iStatus = CI_ERROR; 145 | break; 146 | } 147 | 148 | return iStatus; 149 | } 150 | 151 | 152 | /******************************************************************************/ 153 | /** \brief Custom response to CI_ENABLE_TO_CC cmd code 154 | *******************************************************************************/ 155 | void CI_CustomEnableTO(CFE_SB_MsgPtr_t cmdMsgPtr) 156 | { 157 | /* NOTE: In this case, we are simply piping the cmd to TO. */ 158 | CFE_PSP_MemCpy((void *) &g_CI_CustomData.toEnableCmd, 159 | (void *) cmdMsgPtr, sizeof(TO_EnableOutputCmd_t)); 160 | 161 | /* Setup the toEnableCmd */ 162 | CFE_SB_InitMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 163 | TO_APP_CMD_MID, sizeof(TO_EnableOutputCmd_t), FALSE); 164 | CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 165 | TO_ENABLE_OUTPUT_CC); 166 | CFE_SB_GenerateChecksum((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 167 | 168 | /* Send the TO Enable Telemetry Output Message */ 169 | CFE_SB_SendMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 170 | return; 171 | } 172 | 173 | 174 | /******************************************************************************/ 175 | /** \brief Custom Cleanup 176 | *******************************************************************************/ 177 | void CI_CustomCleanup(void) 178 | { 179 | IO_TransUdpCloseSocket(&g_CI_CustomData.udp); 180 | } 181 | 182 | 183 | /******************************************************************************* 184 | ** Custom Functions (Executed by Custom child task) 185 | *******************************************************************************/ 186 | 187 | /******************************************************************************/ 188 | /** \brief Entry Point of custom child task 189 | *******************************************************************************/ 190 | void CI_CustomMain(void) 191 | { 192 | int32 size = 0; 193 | CFE_SB_MsgPtr_t sbMsg; 194 | CFE_SB_MsgId_t msgId; 195 | 196 | if (g_CI_CustomData.udp.sockId < 0) 197 | { 198 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 199 | "CI: Socket ID not set. Check init. " 200 | "Quitting CI_CustomMain."); 201 | return; 202 | } 203 | 204 | sbMsg = (CFE_SB_MsgPtr_t) &g_CI_CustomData.buffer[0]; 205 | 206 | while(size >= 0) 207 | { 208 | size = IO_TransUdpRcvTimeout(&g_CI_CustomData.udp, 209 | &g_CI_CustomData.buffer[0], 210 | CI_CUSTOM_BUFFER_SIZE, 211 | IO_TRANS_PEND_FOREVER); 212 | 213 | if (size > 0) 214 | { 215 | /* Get Msg ID */ 216 | msgId = CFE_SB_GetMsgId(sbMsg); 217 | 218 | /* NOTE: For this simple UDP example, the Checksum validation is 219 | not included as to be able to test with cmdUtils tool. */ 220 | 221 | /* CCSDS command checksum check. */ 222 | /* 223 | if (CFE_SB_ValidateChecksum(sbMsg) == FALSE) 224 | { 225 | uint16 cmdCode = CFE_SB_GetCmdCode(sbMsg); 226 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 227 | "CI: MID:0x%04x - Cmd Checksum failed. CmdCode:%u", 228 | msgId, cmdCode); 229 | continue; 230 | } 231 | */ 232 | 233 | /* If command is GATE command, execute immediately. */ 234 | if (msgId == CI_GATE_CMD_MID) 235 | { 236 | CI_CustomGateCmds(sbMsg); 237 | } 238 | /* Any other message is passed through to the SB. */ 239 | else if (size > 0) 240 | { 241 | CFE_SB_SendMsg(sbMsg); 242 | } 243 | } 244 | } 245 | 246 | if (size < 0) 247 | { 248 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 249 | "CI: Error occured on socket read. " 250 | "Quitting CI_CustomMain."); 251 | } 252 | 253 | return; 254 | } 255 | 256 | 257 | /******************************************************************************/ 258 | /** \brief Custom Gate command response 259 | *******************************************************************************/ 260 | void CI_CustomGateCmds(CFE_SB_MsgPtr_t cmdMsgPtr) 261 | { 262 | uint32 uiCmdCode = 0; 263 | 264 | uiCmdCode = CFE_SB_GetCmdCode(cmdMsgPtr); 265 | switch (uiCmdCode) 266 | { 267 | /* Example of a valid custom command. 268 | case CI_EXAMPLE_GATE_CC: 269 | if (CI_VerifyCmdLength(cmdMsgPtr, sizeof(CI_CustomExampleCmd_t))) 270 | { 271 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 272 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 273 | "CI: Recvd example custom gate cmd (%d)", uiCmdCode); 274 | } 275 | break; 276 | */ 277 | 278 | default: 279 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdErrCnt); 280 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 281 | "CI: Recvd invalid Gate cmd (%d)", uiCmdCode); 282 | break; 283 | } 284 | 285 | return; 286 | } 287 | 288 | /*============================================================================== 289 | ** End of file ci_custom.c 290 | **============================================================================*/ 291 | -------------------------------------------------------------------------------- /fsw/examples/rs422/ci_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file ci_custom.c 3 | * 4 | * Copyright 2017 United States Government as represented by the Administrator 5 | * of the National Aeronautics and Space Administration. No copyright is 6 | * claimed in the United States under Title 17, U.S. Code. 7 | * All Other Rights Reserved. 8 | * 9 | * \author Guy de Carufel (Odyssey Space Research), NASA, JSC, ER6 10 | * 11 | * \brief Function Definitions for Custom Layer of CI Application for RS422 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the CI application over an RS422 serial port. 16 | * 17 | * \par API Functions Defined: 18 | * - CI_CustomInit() - Initialize the transport protocol, create child task 19 | * - CI_CustomAppCmds() - Process custom App Commands 20 | * - CI_CustomEnableTO() - Send msg to TO to enable downlink 21 | * - CI_CustomCleanup() - Cleanup callback to close transport channel. 22 | * - CI_CustomMain() - Main entry point for the custom child task. 23 | * - CI_CustomGateCmds() - Process custom Gate Commands 24 | * 25 | * \par Private Functions Defined: 26 | * - CI_CustomProcessUpMsg() - Process new uplink message 27 | * 28 | * \par Limitations, Assumptions, External Events, and Notes: 29 | * - All input messages are CCSDS messages 30 | * - Both CI and TO makes use of the same RS422 device 31 | * - All config macros defined in ci_platform_cfg.h 32 | * - ciMutex must be used whenever g_CI_AppData is accessed. 33 | * 34 | * \par Modification History: 35 | * - 2015-01-09 | Guy de Carufel | Code Started 36 | *******************************************************************************/ 37 | 38 | /* 39 | ** Pragmas 40 | */ 41 | 42 | /* 43 | ** Include Files 44 | */ 45 | #include 46 | #include 47 | #include 48 | 49 | #include "cfe.h" 50 | #include "network_includes.h" 51 | #include "trans_rs422.h" 52 | 53 | #include "ci_app.h" 54 | #include "ci_platform_cfg.h" 55 | #include "to_mission_cfg.h" 56 | 57 | /* 58 | ** Local Defines 59 | */ 60 | 61 | /* 62 | ** Local Structure Declarations 63 | */ 64 | typedef struct 65 | { 66 | int32 iFileDesc; /**< File Descriptor of port */ 67 | TO_EnableOutputCmd_t toEnableCmd; /**< TO Enable CMD msg */ 68 | uint8 buffer[CI_CUSTOM_BUFFER_SIZE]; /**< buffer */ 69 | } CI_CustomData_t; 70 | 71 | /* 72 | ** External Global Variables 73 | */ 74 | extern CI_AppData_t g_CI_AppData; 75 | 76 | /* 77 | ** Global Variables 78 | */ 79 | CI_CustomData_t g_CI_CustomData; 80 | 81 | /* 82 | ** Local Variables 83 | */ 84 | 85 | /* 86 | ** Local Function Definitions 87 | */ 88 | void CI_CustomProcessUpMsg(CFE_SB_MsgPtr_t pSbMsg, CFE_SB_MsgId_t msgId); 89 | 90 | 91 | /******************************************************************************* 92 | ** Custom Application Functions (Executed by Main Task) 93 | *******************************************************************************/ 94 | 95 | /******************************************************************************/ 96 | /** \brief Custom Initialization 97 | *******************************************************************************/ 98 | int32 CI_CustomInit(void) 99 | { 100 | int32 iStatus = CI_ERROR; 101 | uint32 taskId = 0; 102 | IO_TransRS422Config_t config; 103 | 104 | /*Initialize a RS422 Port */ 105 | strncpy((char *) &config.device, CI_CONFIG_SERIAL_PORT, 106 | PORT_NAME_SIZE); 107 | config.baudRate = CI_CONFIG_BAUD_RATE; 108 | config.timeout = CI_CONFIG_TIMEOUT; 109 | config.minBytes = CI_CONFIG_MINBYTES; 110 | 111 | g_CI_CustomData.iFileDesc = IO_TransRS422Init(&config); 112 | 113 | if (g_CI_CustomData.iFileDesc < 0) 114 | { 115 | goto end_of_function; 116 | } 117 | 118 | /* Setup the toEnableCmd */ 119 | CFE_SB_InitMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 120 | TO_APP_CMD_MID, sizeof(TO_EnableOutputCmd_t), TRUE); 121 | CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd, 122 | TO_ENABLE_OUTPUT_CC); 123 | g_CI_CustomData.toEnableCmd.iFileDesc = g_CI_CustomData.iFileDesc; 124 | CFE_SB_GenerateChecksum((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 125 | 126 | iStatus = CFE_ES_CreateChildTask(&taskId, 127 | "CI Custom Main Task", 128 | CI_CustomMain, 129 | CI_CUSTOM_TASK_STACK_PTR, 130 | CI_CUSTOM_TASK_STACK_SIZE, 131 | CI_CUSTOM_TASK_PRIO, 132 | 0); 133 | end_of_function: 134 | return (iStatus); 135 | } 136 | 137 | 138 | /******************************************************************************/ 139 | /** \brief Custom app command response 140 | *******************************************************************************/ 141 | int32 CI_CustomAppCmds(CFE_SB_MsgPtr_t pCmdMsg) 142 | { 143 | int32 iStatus = CI_SUCCESS; 144 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pCmdMsg); 145 | switch (uiCmdCode) 146 | { 147 | /* Example of a valid custom command. Declare at top of file. 148 | case CI_CUSTOM_EXAMPLE_CC: 149 | if (CI_VerifyCmdLength(pCmdMsg, sizeof(CI_CustomExampleCmd_t))) 150 | { 151 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 152 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 153 | "CI: Recvd example custom app cmd (%d)", uiCmdCode); 154 | } 155 | break; 156 | */ 157 | 158 | default: 159 | iStatus = CI_ERROR; 160 | break; 161 | } 162 | 163 | return iStatus; 164 | } 165 | 166 | 167 | /******************************************************************************/ 168 | /** \brief Custom response to CI_ENABLE_TO_CC cmd code 169 | *******************************************************************************/ 170 | void CI_CustomEnableTO(CFE_SB_MsgPtr_t pCmdMsg) 171 | { 172 | /* Send the TO Enable Telemetry Output Message */ 173 | CFE_SB_SendMsg((CFE_SB_MsgPtr_t) &g_CI_CustomData.toEnableCmd); 174 | 175 | return; 176 | } 177 | 178 | 179 | /******************************************************************************/ 180 | /** \brief Custom Cleanup 181 | *******************************************************************************/ 182 | void CI_CustomCleanup(void) 183 | { 184 | IO_TransRS422Close(g_CI_CustomData.iFileDesc); 185 | } 186 | 187 | 188 | /******************************************************************************* 189 | ** Custom Functions (Executed by Custom child task) 190 | *******************************************************************************/ 191 | 192 | /******************************************************************************/ 193 | /** \brief Entry Point of custom child task 194 | *******************************************************************************/ 195 | void CI_CustomMain(void) 196 | { 197 | int32 size = 0; 198 | int32 msgSize = 0; 199 | int32 dataSize = 0; 200 | CFE_SB_MsgId_t msgId; 201 | CFE_SB_MsgPtr_t pSbMsg = (CFE_SB_MsgPtr_t) &g_CI_CustomData.buffer[0]; 202 | 203 | if (g_CI_CustomData.iFileDesc == -1) 204 | { 205 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 206 | "CI: Serial Port not set. Check init. " 207 | "Quitting CI_CustomMain."); 208 | return; 209 | } 210 | 211 | while(size >= 0) 212 | { 213 | /* Pend forever, waiting for header of message. */ 214 | size = IO_TransRS422ReadTimeout(g_CI_CustomData.iFileDesc, 215 | &g_CI_CustomData.buffer[0], 6, 216 | IO_TRANS_PEND_FOREVER); 217 | 218 | /* Received CCSDS message. */ 219 | if (size == 6) 220 | { 221 | /* Get Msg ID */ 222 | msgId = CFE_SB_GetMsgId(pSbMsg); 223 | 224 | /* Get message size */ 225 | msgSize = CFE_SB_GetTotalMsgLength(pSbMsg); 226 | dataSize = msgSize - 6; 227 | 228 | if (msgSize > CI_CUSTOM_BUFFER_SIZE) 229 | { 230 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 231 | "CI: Message received larger than buffer. " 232 | "Message ID:0x%x dropped.", msgId); 233 | } 234 | else if (dataSize >= 0) 235 | { 236 | /* Read full message. May timeout based on init config. */ 237 | size = IO_TransRS422Read(g_CI_CustomData.iFileDesc, 238 | &g_CI_CustomData.buffer[6], dataSize); 239 | 240 | if (size != dataSize) 241 | { 242 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 243 | "CI: Incomplete message received. " 244 | "Message ID:0x%x dropped.", msgId); 245 | } 246 | else 247 | { 248 | CI_CustomProcessUpMsg(pSbMsg, msgId); 249 | } 250 | } 251 | else 252 | { 253 | CFE_EVS_SendEvent(CI_CUSTOM_ERR_EID, CFE_EVS_ERROR, 254 | "CI: Error on serial port read. errno:%d", 255 | errno); 256 | } 257 | 258 | } 259 | else 260 | { 261 | /* Deal with messages smaller than CCSDS packets here. */ 262 | } 263 | } 264 | } 265 | 266 | /******************************************************************************/ 267 | /** \brief Custom Process Uplink Msg (Private) 268 | *******************************************************************************/ 269 | void CI_CustomProcessUpMsg(CFE_SB_MsgPtr_t pSbMsg, CFE_SB_MsgId_t msgId) 270 | { 271 | /* CCSDS command checksum check. */ 272 | if (CFE_SB_ValidateChecksum(pSbMsg) == FALSE) 273 | { 274 | uint16 cmdCode = CFE_SB_GetCmdCode(pSbMsg); 275 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 276 | "CI: MID:0x%04x - Cmd Checksum failed. CmdCode:%u", 277 | msgId, cmdCode); 278 | return; 279 | } 280 | 281 | /* If command is GATE command, execute immediately. */ 282 | if (msgId == CI_GATE_CMD_MID) 283 | { 284 | CI_CustomGateCmds(pSbMsg); 285 | } 286 | /* Any other message is passed through to the SB. */ 287 | else 288 | { 289 | CFE_SB_SendMsg(pSbMsg); 290 | } 291 | 292 | return; 293 | } 294 | 295 | /******************************************************************************/ 296 | /** \brief Custom Gate command response 297 | *******************************************************************************/ 298 | void CI_CustomGateCmds(CFE_SB_MsgPtr_t pCmdMsg) 299 | { 300 | uint32 uiCmdCode = 0; 301 | 302 | uiCmdCode = CFE_SB_GetCmdCode(pCmdMsg); 303 | switch (uiCmdCode) 304 | { 305 | /* Example of a valid custom command. 306 | case CI_EXAMPLE_GATE_CC: 307 | if (CI_VerifyCmdLength(pCmdMsg, sizeof(CI_CustomExampleCmd_t))) 308 | { 309 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdCnt); 310 | CFE_EVS_SendEvent(CI_CMD_INF_EID, CFE_EVS_INFORMATION, 311 | "CI: Recvd example custom gate cmd (%d)", uiCmdCode); 312 | } 313 | break; 314 | */ 315 | 316 | default: 317 | CI_IncrHkCounter(&g_CI_AppData.HkTlm.usCmdErrCnt); 318 | CFE_EVS_SendEvent(CI_CMD_ERR_EID, CFE_EVS_ERROR, 319 | "CI: Recvd invalid Gate cmd (%d)", uiCmdCode); 320 | break; 321 | } 322 | 323 | return; 324 | } 325 | 326 | /*============================================================================== 327 | ** End of file ci_custom.c 328 | **============================================================================*/ 329 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/src/ut_cfe_es_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_cfe_es_stubs.c 4 | ** 5 | ** Copyright 2017 United States Government as represented by the Administrator 6 | ** of the National Aeronautics and Space Administration. No copyright is 7 | ** claimed in the United States under Title 17, U.S. Code. 8 | ** All Other Rights Reserved. 9 | ** 10 | ** $Id: ut_cfe_es_stubs.c 1.2 2011/05/04 11:28:00EDT rmcgraw Exp $ 11 | ** 12 | ** Purpose: Unit test stubs for cFE Executive Services routines 13 | ** 14 | ** $Log: ut_cfe_es_stubs.c $ 15 | ** Revision 1.2 2011/05/04 11:28:00EDT rmcgraw 16 | ** Changed PoolCreateEx to have new parameter USE_MUTEX 17 | ** Revision 1.1 2011/05/04 11:20:51EDT rmcgraw 18 | ** Initial revision 19 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 20 | ** Revision 1.1 2011/04/08 16:26:37EDT rmcgraw 21 | ** Initial revision 22 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cf/fsw/unit_test/ut-assert/src/project.pj 23 | ** Revision 1.5 2011/03/31 14:53:04EDT rmcgraw 24 | ** Added functionality and supressed compiler warnings 25 | ** Revision 1.4 2011/03/23 17:08:18EDT rmcgraw 26 | ** OS_FS_ERROR to OS_FS_SUCCESS for some OS file sys apis 27 | ** Revision 1.3 2011/03/09 10:26:12EST rmcgraw 28 | ** Added SetRtnCode logic to PoolCreateEx 29 | ** Revision 1.2 2011/03/07 17:53:39EST sslegel 30 | ** Added a default hook for ES_CFE_RunLoop 31 | ** Added additional return code support 32 | ** Revision 1.1 2011/02/15 11:13:01EST sslegel 33 | ** Initial revision 34 | ** Member added to project c:/MKSDATA/MKS-REPOSITORY/FSW-TOOLS-REPOSITORY/ut-assert/src/project.pj 35 | ** 36 | */ 37 | 38 | /* 39 | ** Include section 40 | */ 41 | 42 | #include "cfe.h" 43 | #include "ut_cfe_es_stubs.h" 44 | #include "ut_cfe_es_hooks.h" 45 | #include 46 | 47 | Ut_CFE_ES_HookTable_t Ut_CFE_ES_HookTable; 48 | Ut_CFE_ES_ReturnCodeTable_t Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_MAX_INDEX]; 49 | 50 | void Ut_CFE_ES_Reset(void) 51 | { 52 | memset(&Ut_CFE_ES_HookTable, 0, sizeof(Ut_CFE_ES_HookTable)); 53 | memset(&Ut_CFE_ES_ReturnCodeTable, 0, sizeof(Ut_CFE_ES_ReturnCodeTable)); 54 | 55 | Ut_CFE_ES_SetFunctionHook(UT_CFE_ES_RUNLOOP_INDEX, &Ut_CFE_ES_RunLoopHook); 56 | } 57 | 58 | void Ut_CFE_ES_SetFunctionHook(uint32 Index, void *FunPtr) 59 | { 60 | if (Index == UT_CFE_ES_RESETCFE_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_ResetCFE = FunPtr; } 61 | else if (Index == UT_CFE_ES_RESTARTAPP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RestartApp = FunPtr; } 62 | else if (Index == UT_CFE_ES_RELOADAPP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_ReloadApp = FunPtr; } 63 | else if (Index == UT_CFE_ES_DELETEAPP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_DeleteApp = FunPtr; } 64 | else if (Index == UT_CFE_ES_EXITAPP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_ExitApp = FunPtr; } 65 | else if (Index == UT_CFE_ES_RUNLOOP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RunLoop = FunPtr; } 66 | else if (Index == UT_CFE_ES_WAITFORSTARTUPSYNC_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_WaitForStartupSync = FunPtr; } 67 | else if (Index == UT_CFE_ES_REGISTERAPP_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RegisterApp = FunPtr; } 68 | else if (Index == UT_CFE_ES_GETAPPID_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetAppID = FunPtr; } 69 | else if (Index == UT_CFE_ES_GETAPPIDBYNAME_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetAppIDByName = FunPtr; } 70 | else if (Index == UT_CFE_ES_GETAPPNAME_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetAppName = FunPtr; } 71 | else if (Index == UT_CFE_ES_GETAPPINFO_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetAppInfo = FunPtr; } 72 | else if (Index == UT_CFE_ES_GETTASKINFO_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetTaskInfo = FunPtr; } 73 | else if (Index == UT_CFE_ES_REGISTERCHILDTASK_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RegisterChildTask = FunPtr; } 74 | else if (Index == UT_CFE_ES_CREATECHILDTASK_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_CreateChildTask = FunPtr; } 75 | else if (Index == UT_CFE_ES_DELETECHILDTASK_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_DeleteChildTask = FunPtr; } 76 | else if (Index == UT_CFE_ES_EXITCHILDTASK_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_ExitChildTask = FunPtr; } 77 | else if (Index == UT_CFE_ES_INCREMENTTASKCOUNTER_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_IncrementTaskCounter = FunPtr; } 78 | else if (Index == UT_CFE_ES_WRITETOSYSLOG_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_WriteToSysLog = FunPtr; } 79 | else if (Index == UT_CFE_ES_REGISTERDRIVER_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RegisterDriver = FunPtr; } 80 | else if (Index == UT_CFE_ES_UNLOADDRIVER_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_UnloadDriver = FunPtr; } 81 | else if (Index == UT_CFE_ES_CALCULATECRC_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_CalculateCRC = FunPtr; } 82 | else if (Index == UT_CFE_ES_REGISTERCDS_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RegisterCDS = FunPtr; } 83 | else if (Index == UT_CFE_ES_COPYTOCDS_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_CopyToCDS = FunPtr; } 84 | else if (Index == UT_CFE_ES_RESTOREFROMCDS_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_RestoreFromCDS = FunPtr; } 85 | else if (Index == UT_CFE_ES_POOLCREATE_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_PoolCreate = FunPtr; } 86 | else if (Index == UT_CFE_ES_POOLCREATEEX_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_PoolCreateEx = FunPtr; } 87 | else if (Index == UT_CFE_ES_GETPOOLBUF_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetPoolBuf = FunPtr; } 88 | else if (Index == UT_CFE_ES_GETPOOLBUFINFO_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetPoolBufInfo = FunPtr; } 89 | else if (Index == UT_CFE_ES_PUTPOOLBUF_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_PutPoolBuf = FunPtr; } 90 | else if (Index == UT_CFE_ES_GETMEMPOOLSTATS_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_GetMemPoolStats = FunPtr; } 91 | else if (Index == UT_CFE_ES_PERFLOGADD_INDEX) { Ut_CFE_ES_HookTable.CFE_ES_PerfLogAdd = FunPtr; } 92 | else { printf("Unsupported ES Index In SetFunctionHook Call %u\n", Index); } 93 | } 94 | 95 | void Ut_CFE_ES_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 96 | { 97 | if (Index < UT_CFE_ES_MAX_INDEX) { 98 | Ut_CFE_ES_ReturnCodeTable[Index].Value = RtnVal; 99 | Ut_CFE_ES_ReturnCodeTable[Index].Count = CallCnt; 100 | } 101 | else { 102 | printf("Unsupported ES Index In SetReturnCode Call %u\n", Index); 103 | } 104 | } 105 | 106 | boolean Ut_CFE_ES_UseReturnCode(uint32 Index) 107 | { 108 | if (Ut_CFE_ES_ReturnCodeTable[Index].Count > 0) { 109 | Ut_CFE_ES_ReturnCodeTable[Index].Count--; 110 | if (Ut_CFE_ES_ReturnCodeTable[Index].Count == 0) 111 | return(TRUE); 112 | } 113 | 114 | return(FALSE); 115 | } 116 | 117 | int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr) 118 | { 119 | return CFE_SUCCESS; 120 | } 121 | 122 | int32 CFE_ES_ResetCFE(uint32 ResetType) 123 | { 124 | /* Check for specified return */ 125 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_RESETCFE_INDEX)) 126 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_RESETCFE_INDEX].Value; 127 | 128 | return CFE_SUCCESS; 129 | } 130 | 131 | int32 CFE_ES_RestartApp(uint32 AppID) 132 | { 133 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_RESTARTAPP_INDEX)) 134 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_RESTARTAPP_INDEX].Value; 135 | 136 | return CFE_SUCCESS; 137 | } 138 | 139 | int32 CFE_ES_ReloadApp(uint32 AppID, const char *AppFileName) 140 | { 141 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_RELOADAPP_INDEX)) 142 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_RELOADAPP_INDEX].Value; 143 | 144 | return CFE_SUCCESS; 145 | } 146 | 147 | int32 CFE_ES_DeleteApp(uint32 AppID) 148 | { 149 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_DELETEAPP_INDEX)) 150 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_DELETEAPP_INDEX].Value; 151 | 152 | return CFE_SUCCESS; 153 | } 154 | 155 | void CFE_ES_ExitApp(uint32 ExitStatus) 156 | { 157 | return; 158 | } 159 | 160 | int32 CFE_ES_RunLoop(uint32 *ExitStatus) 161 | { 162 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_RUNLOOP_INDEX)) 163 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_RUNLOOP_INDEX].Value; 164 | 165 | if (Ut_CFE_ES_HookTable.CFE_ES_RunLoop) 166 | return Ut_CFE_ES_HookTable.CFE_ES_RunLoop(ExitStatus); 167 | 168 | return TRUE; 169 | } 170 | 171 | void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds) 172 | { 173 | return; 174 | } 175 | 176 | int32 CFE_ES_RegisterApp(void) 177 | { 178 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_REGISTERAPP_INDEX)) 179 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_REGISTERAPP_INDEX].Value; 180 | 181 | return CFE_SUCCESS; 182 | } 183 | 184 | int32 CFE_ES_GetAppID(uint32 *AppIdPtr) 185 | { 186 | return CFE_SUCCESS; 187 | } 188 | 189 | int32 CFE_ES_GetAppIDByName(uint32 *AppIdPtr, const char *AppName) 190 | { 191 | return CFE_SUCCESS; 192 | } 193 | 194 | int32 CFE_ES_GetAppName(char *AppName, uint32 AppId, uint32 BufferLength) 195 | { 196 | return CFE_SUCCESS; 197 | } 198 | 199 | int32 CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, uint32 AppId) 200 | { 201 | return CFE_SUCCESS; 202 | } 203 | 204 | int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, uint32 TaskId) 205 | { 206 | return CFE_SUCCESS; 207 | } 208 | 209 | int32 CFE_ES_RegisterChildTask(void) 210 | { 211 | return CFE_SUCCESS; 212 | } 213 | 214 | int32 CFE_ES_CreateChildTask(uint32 *TaskIdPtr, 215 | const char *TaskName, 216 | CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, 217 | uint32 *StackPtr, 218 | uint32 StackSize, 219 | uint32 Priority, 220 | uint32 Flags) 221 | { 222 | /* Check for specified return */ 223 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_CREATECHILDTASK_INDEX)) 224 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_CREATECHILDTASK_INDEX].Value; 225 | 226 | /* Check for Function Hook */ 227 | if (Ut_CFE_ES_HookTable.CFE_ES_CreateChildTask) 228 | return Ut_CFE_ES_HookTable.CFE_ES_CreateChildTask(TaskIdPtr, TaskName, FunctionPtr, StackPtr, StackSize, Priority, Flags); 229 | 230 | return CFE_SUCCESS; 231 | } 232 | 233 | int32 CFE_ES_DeleteChildTask(uint32 TaskId) 234 | { 235 | return CFE_SUCCESS; 236 | } 237 | 238 | void CFE_ES_ExitChildTask(void) 239 | { 240 | return; 241 | } 242 | 243 | void CFE_ES_IncrementTaskCounter(void) 244 | { 245 | return; 246 | } 247 | 248 | int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) 249 | { 250 | return CFE_SUCCESS; 251 | } 252 | 253 | int32 CFE_ES_RegisterDriver(uint32 *DriverIdPtr, uint32 *DriverDescPtr) 254 | { 255 | return CFE_SUCCESS; 256 | } 257 | 258 | int32 CFE_ES_UnloadDriver(uint32 DriverId) 259 | { 260 | return CFE_SUCCESS; 261 | } 262 | 263 | uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC) 264 | { 265 | return CFE_SUCCESS; 266 | } 267 | 268 | int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, int32 BlockSize, const char *Name) 269 | { 270 | return CFE_SUCCESS; 271 | } 272 | 273 | int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy) 274 | { 275 | return CFE_SUCCESS; 276 | } 277 | 278 | int32 CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle) 279 | { 280 | return CFE_SUCCESS; 281 | } 282 | 283 | int32 CFE_ES_PoolCreate(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size) 284 | { 285 | return CFE_SUCCESS; 286 | } 287 | 288 | int32 CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *HandlePtr, uint8 *MemPtr, uint32 Size, uint32 NumBlockSizes, uint32 *BlockSizes, uint16 UseMutex) 289 | { 290 | /* Check for specified return */ 291 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_POOLCREATEEX_INDEX)) 292 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_POOLCREATEEX_INDEX].Value; 293 | 294 | return CFE_SUCCESS; 295 | } 296 | 297 | int32 CFE_ES_GetPoolBuf(uint32 **BufPtr, CFE_ES_MemHandle_t HandlePtr, uint32 Size) 298 | { 299 | /* Check for specified return */ 300 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_GETPOOLBUF_INDEX)) 301 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_GETPOOLBUF_INDEX].Value; 302 | 303 | /* Check for Function Hook */ 304 | if (Ut_CFE_ES_HookTable.CFE_ES_GetPoolBuf) 305 | return Ut_CFE_ES_HookTable.CFE_ES_GetPoolBuf(BufPtr,HandlePtr,Size); 306 | 307 | return CFE_SUCCESS; 308 | } 309 | 310 | int32 CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) 311 | { 312 | return CFE_SUCCESS; 313 | } 314 | 315 | int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t HandlePtr, uint32 *BufPtr) 316 | { 317 | /* Check for specified return */ 318 | if (Ut_CFE_ES_UseReturnCode(UT_CFE_ES_PUTPOOLBUF_INDEX)) 319 | return Ut_CFE_ES_ReturnCodeTable[UT_CFE_ES_PUTPOOLBUF_INDEX].Value; 320 | 321 | return CFE_SUCCESS; 322 | } 323 | 324 | int32 CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle) 325 | { 326 | return CFE_SUCCESS; 327 | } 328 | 329 | void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit) 330 | { 331 | return; 332 | } 333 | --------------------------------------------------------------------------------