├── .gitignore ├── CMakeLists.txt ├── README.md ├── Telemetry_Output_NOSA.pdf ├── analysis ├── cppcheck_errors_to.txt └── run_cppcheck_to.sh ├── docs ├── SDD_Generic_CI-TO_V1_5.doc └── SDD_Generic_CI-TO_V1_5.pdf └── fsw ├── examples ├── README ├── multi │ ├── MISSION_to_types.h │ ├── to_custom.c │ └── to_platform_cfg.h ├── multi_tf │ ├── MISSION_to_types.h │ ├── to_custom.c │ └── to_platform_cfg.h ├── rs422 │ ├── MISSION_to_types.h │ ├── to_custom.c │ └── to_platform_cfg.h ├── setup.sh └── udp │ ├── MISSION_to_types.h │ ├── to_custom.c │ └── to_platform_cfg.h ├── for_build ├── Makefile └── totables.mak ├── mission_inc ├── to_mission_cfg.h └── to_perf_ids.h ├── platform_inc ├── to_msgids.h └── to_platform_cfg.h ├── src ├── to_app.c ├── to_app.h ├── to_cmds.c ├── to_cmds.h ├── to_custom.c ├── to_events.h ├── to_hktlm.h ├── to_msgdefs.h ├── to_tbldefs.h └── to_utils.c ├── tables ├── table_change.sh ├── to_config.c ├── to_config_2.c └── to_grpids.h └── unit_test ├── .gitignore ├── Readme.txt ├── makefile ├── out ├── to_mission_cfg.h ├── to_platform_cfg.h ├── to_stubs.c ├── to_stubs.h ├── to_testcase.c ├── to_testrunner.c └── ut-assert ├── doc ├── UT_Tool_Users_Guide.doc ├── Ut Users Guide.docx ├── Writing Better Unit Tests.ppt ├── ut Design.docx ├── ut Requirements.docx └── ut_design.ppt ├── inc ├── ut_cfe_es_hooks.h ├── ut_cfe_es_stubs.h ├── ut_cfe_evs_hooks.h ├── ut_cfe_evs_stubs.h ├── ut_cfe_fs_stubs.h ├── ut_cfe_sb_hooks.h ├── ut_cfe_sb_stubs.h ├── ut_cfe_tbl_hooks.h ├── ut_cfe_tbl_stubs.h ├── ut_cfe_time_stubs.h ├── ut_osapi_stubs.h ├── ut_osfileapi_stubs.h ├── utassert.h ├── utlist.h ├── uttest.h └── uttools.h └── src ├── ut_cfe_es_hooks.c ├── ut_cfe_es_stubs.c ├── ut_cfe_evs_hooks.c ├── ut_cfe_evs_stubs.c ├── ut_cfe_fs_stubs.c ├── ut_cfe_psp_memutils_stubs.c ├── ut_cfe_sb_hooks.c ├── ut_cfe_sb_stubs.c ├── ut_cfe_tbl_hooks.c ├── ut_cfe_tbl_stubs.c ├── ut_cfe_time_stubs.c ├── ut_osapi_stubs.c ├── ut_osfileapi_stubs.c ├── utassert.c ├── utlist.c ├── uttest.c └── uttools.c /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings/ 4 | 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6.4) 2 | project(TO 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(${ci_MISSION_DIR}/fsw/platform_inc) 9 | include_directories(${ci_MISSION_DIR}/fsw/mission_inc) 10 | include_directories(${ci_MISSION_DIR}/fsw/src) 11 | include_directories(${io_lib_MISSION_DIR}/fsw/public_inc/) 12 | 13 | include_directories(${MISSION_SOURCE_DIR}/apps/inc) 14 | include_directories(${MISSION_SOURCE_DIR}/apps/cf/fsw/platform_inc) 15 | include_directories(${MISSION_SOURCE_DIR}/apps/sch/fsw/platform_inc) 16 | include_directories(${MISSION_SOURCE_DIR}/apps/hs/fsw/platform_inc) 17 | include_directories(${MISSION_SOURCE_DIR}/apps/hk/fsw/platform_inc) 18 | 19 | aux_source_directory(fsw/src APP_SRC_FILES) 20 | 21 | # Create the app module 22 | add_cfe_app(to ${APP_SRC_FILES}) 23 | 24 | if (COMMAND add_cfe_tables) 25 | include_directories(fsw/tables) 26 | aux_source_directory(fsw/tables APP_TBL_FILES) 27 | add_cfe_tables(to fsw/tables/to_config.c) 28 | endif(COMMAND add_cfe_tables) 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telemetry Output 2 | 3 | NASA core Flight System Telemetry Output Application 4 | 5 | ## Description 6 | 7 | Telemetry Output (TO) 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 Telemetry Output (TO) Application is responsible for transmitting telemetry to external destination(s) (such as a ground station) over transport devices(s). 12 | 13 | ## License 14 | 15 | This software is licensed under the NASA Open Source Agreement. 16 | http://ti.arc.nasa.gov/opensource/nosa 17 | -------------------------------------------------------------------------------- /Telemetry_Output_NOSA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/Telemetry_Output_NOSA.pdf -------------------------------------------------------------------------------- /analysis/cppcheck_errors_to.txt: -------------------------------------------------------------------------------- 1 | [../../io_lib/fsw/public_inc/tm_sync.h:33]: (error) Invalid number of character ({) when these macros are defined: '__cplusplus'. 2 | -------------------------------------------------------------------------------- /analysis/run_cppcheck_to.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Runs cppcheck on TO 3 | 4 | to_app="../fsw" 5 | io_lib="../../io_lib/fsw" 6 | 7 | output_file="./cppcheck_to.txt" 8 | error_file="./cppcheck_errors_to.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="$to_app/src/ $to_app/examples/multi/ $to_app/examples/multi_tf/ $to_app/examples/rs422/ $to_app/examples/udp/" 13 | 14 | include_dirs="-I $to_app/platform_inc/ -I $to_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 | -------------------------------------------------------------------------------- /docs/SDD_Generic_CI-TO_V1_5.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/docs/SDD_Generic_CI-TO_V1_5.doc -------------------------------------------------------------------------------- /docs/SDD_Generic_CI-TO_V1_5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/docs/SDD_Generic_CI-TO_V1_5.pdf -------------------------------------------------------------------------------- /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/to_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 multi 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/examples/multi/MISSION_to_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_to_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 TO application (Multi) 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for TO applications for the Multi 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 | * - Standard command messages are defined in to_cmds.h 21 | * - Default HK Telemetry structure is defined in to_hktlm.h 22 | * 23 | * \par Modification History: 24 | * - 2015-06-02 | Guy de Carufel | Code Started 25 | * - 2015-09-22 | Guy de Carufel | Moved hktlm to to_hktlm.h 26 | *******************************************************************************/ 27 | #ifndef _MISSION_TO_TYPES_H_ 28 | #define _MISSION_TO_TYPES_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* 35 | ** Include Files 36 | */ 37 | #include "cfe.h" 38 | #include "../to/fsw/src/to_hktlm.h" 39 | 40 | /* 41 | ** Defines 42 | */ 43 | #define TO_MAX_IP_STRING_SIZE 16 44 | 45 | /* Define enable / disable commands */ 46 | typedef struct 47 | { 48 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 49 | char cDestIp[TO_MAX_IP_STRING_SIZE]; /**< Destination IP */ 50 | uint16 usDestPort; /**< Destination PORT */ 51 | int32 iFileDesc; /**< File Descriptor of Port to use. */ 52 | } TO_EnableOutputCmd_t; 53 | 54 | 55 | typedef struct 56 | { 57 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 58 | } TO_DisableOutputCmd_t; 59 | 60 | 61 | /*************** Telemetry **************/ 62 | typedef struct 63 | { 64 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 65 | } TO_InData_t; 66 | 67 | typedef struct 68 | { 69 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 70 | uint32 uiCounter; 71 | } TO_OutData_t; 72 | 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif /* _MISSION_TO_TYPES_H_ */ 79 | 80 | /*============================================================================== 81 | ** End of file MISSION_to_types.h 82 | **============================================================================*/ 83 | -------------------------------------------------------------------------------- /fsw/examples/multi/to_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Multi Devices 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the TO application with temeletry output to multiple devices 16 | * (RS422 and UDP) 17 | * 18 | * \par API Functions Defined: 19 | * - TO_CustomInit() - Initialize the transport protocol 20 | * - TO_CustomAppCmds() - Process custom App Commands 21 | * - TO_CustomEnableOutputCmd() - Enable telemetry output 22 | * - TO_CustomDisableOutputCmd() - Disable telemetry output 23 | * - TO_CustomCleanup() - Cleanup callback to close transport channel. 24 | * - TO_CustomProcessData() - Send output data over transport protocol. 25 | * 26 | * \par Private Functions Defined: 27 | * - TO_SendDataTypePktCmd() - Send Test packet (Reference to_lab app) 28 | * 29 | * \par Limitations, Assumptions, External Events, and Notes: 30 | * - All input messages are CCSDS messages 31 | * - Both CI and TO makes use of the same RS422 device 32 | * - All config macros defined in to_platform_cfg.h 33 | * 34 | * \par Modification History: 35 | * - 2015-06-03 | Guy de Carufel | Code Started 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 | #include "trans_rs422.h" 49 | 50 | #include "to_app.h" 51 | #include "ci_msgids.h" 52 | 53 | /* 54 | ** Local Defines 55 | */ 56 | 57 | /* 58 | ** Local Structure Declarations 59 | */ 60 | typedef struct 61 | { 62 | int32 iFileDesc; /**< File Descriptor of serial port */ 63 | IO_TransUdp_t udp; /**< UDP working */ 64 | uint8 buffer[2000]; 65 | } TO_CustomData_t; 66 | 67 | /* 68 | ** External Global Variables 69 | */ 70 | extern TO_AppData_t g_TO_AppData; 71 | 72 | /* 73 | ** Global Variables 74 | */ 75 | 76 | /* 77 | ** Local Variables 78 | */ 79 | static TO_CustomData_t g_TO_CustomData; 80 | 81 | /* 82 | ** Local Function Definitions 83 | */ 84 | extern void TO_SendDataTypePktCmd(CFE_SB_MsgPtr_t); 85 | static int32 TO_CustomProcessSizeSent(int32, int32, int32,uint16); 86 | 87 | /******************************************************************************* 88 | ** Custom Application Functions 89 | *******************************************************************************/ 90 | 91 | /******************************************************************************/ 92 | /** \brief Custom Initialization 93 | *******************************************************************************/ 94 | int32 TO_CustomInit(void) 95 | { 96 | int32 iStatus = TO_SUCCESS; 97 | 98 | /* Set Critical Message Ids which must always be 99 | * in config table. */ 100 | g_TO_AppData.criticalMid[0] = TO_HK_TLM_MID; 101 | g_TO_AppData.criticalMid[1] = CI_HK_TLM_MID; 102 | 103 | /* Create socket for outgoing */ 104 | if (IO_TransUdpCreateSocket(&g_TO_CustomData.udp) < 0) 105 | { 106 | iStatus = TO_ERROR; 107 | goto end_of_function; 108 | } 109 | 110 | /* Route 0: Udp */ 111 | g_TO_AppData.routes[0].usExists = 1; 112 | /* Route 1: Serial */ 113 | g_TO_AppData.routes[1].usExists = 1; 114 | 115 | /* Tie route 0 to CF channel 0 */ 116 | g_TO_AppData.routes[0].sCfChnlIdx = 0; 117 | 118 | end_of_function: 119 | return iStatus; 120 | } 121 | 122 | /******************************************************************************/ 123 | /** \brief Process of custom app commands 124 | *******************************************************************************/ 125 | int32 TO_CustomAppCmds(CFE_SB_Msg_t* pMsg) 126 | { 127 | int32 iStatus = TO_SUCCESS; 128 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pMsg); 129 | switch (uiCmdCode) 130 | { 131 | case TO_SEND_DATA_TYPE_CC: 132 | TO_SendDataTypePktCmd(pMsg); 133 | break; 134 | 135 | default: 136 | iStatus = TO_ERROR; 137 | break; 138 | } 139 | 140 | return iStatus; 141 | } 142 | 143 | /******************************************************************************/ 144 | /** \brief Process of output telemetry 145 | *******************************************************************************/ 146 | int32 TO_CustomProcessData(CFE_SB_Msg_t * pMsg, int32 size, int32 iTblIdx, 147 | uint16 usRouteId) 148 | { 149 | int32 iSentSize = 0; 150 | int32 iStatus = TO_SUCCESS; 151 | int32 iReturn = TO_SUCCESS; 152 | 153 | CFE_PSP_MemCpy((void *) &g_TO_CustomData.buffer[0], (void *) pMsg, size); 154 | 155 | /* For route 0, use socket */ 156 | if (usRouteId == 0) 157 | { 158 | iSentSize = IO_TransUdpSnd(&g_TO_CustomData.udp, 159 | &g_TO_CustomData.buffer[0], size); 160 | iStatus = TO_CustomProcessSizeSent(size, iSentSize, iTblIdx, 0); 161 | if (iStatus != TO_SUCCESS) 162 | { 163 | iReturn = TO_ERROR; 164 | } 165 | } 166 | /* For route 1, use serial port */ 167 | if (usRouteId == 1) 168 | { 169 | iSentSize = IO_TransRS422Write(g_TO_CustomData.iFileDesc, 170 | &g_TO_CustomData.buffer[0], size); 171 | iStatus = TO_CustomProcessSizeSent(size, iSentSize, iTblIdx, 1); 172 | if (iStatus != TO_SUCCESS) 173 | { 174 | iReturn = TO_ERROR; 175 | } 176 | } 177 | 178 | return iReturn; 179 | } 180 | 181 | 182 | /******************************************************************************/ 183 | /** \brief Check Data Sent Size (Local) 184 | *******************************************************************************/ 185 | int32 TO_CustomProcessSizeSent(int32 size, int32 iSentSize, int32 iTblIdx, 186 | uint16 routeId) 187 | { 188 | int32 iStatus = TO_SUCCESS; 189 | 190 | if (iSentSize < 0) 191 | { 192 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 193 | "TO Output errno %d. Route ID:%u disabled ", 194 | errno, routeId); 195 | TO_DisableRoute(routeId); 196 | iStatus = TO_ERROR; 197 | } 198 | else if (iSentSize != size) 199 | { 200 | CFE_SB_MsgId_t usMsgId = TO_GetMessageID(iTblIdx); 201 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 202 | "TO sent incomplete message (Insuficient bandwidth likely). " 203 | "MID:%d, ROUTE ID:%u, MsgSize:%d, SentSize:%d. Route disabled.", 204 | usMsgId, routeId, size, iSentSize); 205 | TO_DisableRoute(routeId); 206 | iStatus = TO_ERROR; 207 | } 208 | 209 | return iStatus; 210 | } 211 | 212 | 213 | /******************************************************************************/ 214 | /** \brief Custom Cleanup 215 | *******************************************************************************/ 216 | void TO_CustomCleanup(void) 217 | { 218 | if (g_TO_AppData.usOutputEnabled) 219 | { 220 | CFE_EVS_SendEvent(TO_CUSTOM_INF_EID, CFE_EVS_INFORMATION, 221 | "TO - Closing Socket."); 222 | IO_TransUdpCloseSocket(&g_TO_CustomData.udp); 223 | } 224 | 225 | return; 226 | } 227 | 228 | /******************************************************************************/ 229 | /** \brief Enable Output Command Response 230 | *******************************************************************************/ 231 | int32 TO_CustomEnableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 232 | { 233 | int32 iStatus = IO_TRANS_UDP_NO_ERROR; 234 | int32 routeMask = TO_ERROR; 235 | char cDestIp[TO_MAX_IP_STRING_SIZE]; 236 | uint16 usDestPort = 0; 237 | 238 | TO_EnableOutputCmd_t * pCustomCmd = (TO_EnableOutputCmd_t *) pCmdMsg; 239 | strncpy(cDestIp, pCustomCmd->cDestIp, sizeof(cDestIp)); 240 | 241 | if (pCustomCmd->usDestPort > 0) 242 | { 243 | usDestPort = pCustomCmd->usDestPort; 244 | } 245 | else 246 | { 247 | usDestPort = TO_DEFAULT_DEST_PORT; 248 | } 249 | 250 | iStatus = IO_TransUdpSetDestAddr(&g_TO_CustomData.udp, pCustomCmd->cDestIp, 251 | usDestPort); 252 | if (iStatus < 0) 253 | { 254 | goto end_of_function; 255 | } 256 | 257 | g_TO_CustomData.iFileDesc = pCustomCmd->iFileDesc; 258 | 259 | CFE_EVS_SendEvent(TO_CUSTOM_INF_EID, CFE_EVS_INFORMATION, 260 | "Serial Output Device File Descriptor Set."); 261 | 262 | /* Both routes are now configured */ 263 | TO_SetRouteAsConfigured(0); 264 | TO_SetRouteAsConfigured(1); 265 | 266 | /* Enable both routes 0 and 1. */ 267 | routeMask = 0x0003; 268 | 269 | end_of_function: 270 | return routeMask; 271 | } 272 | 273 | /******************************************************************************/ 274 | /** \brief Disable Output Command Response 275 | *******************************************************************************/ 276 | int32 TO_CustomDisableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 277 | { 278 | /* Disable */ 279 | g_TO_AppData.usOutputEnabled = 0; 280 | return TO_SUCCESS; 281 | } 282 | 283 | 284 | /******************************************************************************* 285 | ** Non standard custom Commands 286 | *******************************************************************************/ 287 | 288 | /*============================================================================== 289 | ** End of file to_custom.c 290 | **============================================================================*/ 291 | -------------------------------------------------------------------------------- /fsw/examples/multi/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application with Multi 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 | 21 | #ifndef _TO_PLATFORM_CFG_H_ 22 | #define _TO_PLATFORM_CFG_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* 29 | ** Pragmas 30 | */ 31 | 32 | /* 33 | ** Local Defines 34 | */ 35 | #define TO_SCH_PIPE_DEPTH 10 36 | #define TO_CMD_PIPE_DEPTH 10 37 | #define TO_TLM_PIPE_DEPTH 10 38 | 39 | #define TO_NUM_CRITICAL_MIDS 3 40 | 41 | #define TO_MAX_TBL_ENTRIES 100 42 | #define TO_WAKEUP_TIMEOUT 500 43 | 44 | #define TO_CONFIG_TABLENAME "to_config" 45 | #define TO_CONFIG_FILENAME "/cf/apps/to_config.tbl" 46 | 47 | #define TO_GROUP_NUMBER_MASK 0xFF000000 48 | #define TO_MULTI_GROUP_MASK 0x00FFFFFF 49 | 50 | #define TO_DEFAULT_DEST_PORT 5011 51 | 52 | #define TO_CF_THROTTLE_SEM_NAME "CFTOSemId" 53 | 54 | /* 55 | ** Include Files 56 | */ 57 | 58 | /* 59 | ** Local Structure Declarations 60 | */ 61 | 62 | /* 63 | ** External Global Variables 64 | */ 65 | 66 | /* 67 | ** Global Variables 68 | */ 69 | 70 | /* 71 | ** Local Variables 72 | */ 73 | 74 | /* 75 | ** Local Function Prototypes 76 | */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* _TO_PLATFORM_CFG_H_ */ 83 | 84 | /*============================================================================== 85 | ** End of file to_platform_cfg.h 86 | **============================================================================*/ 87 | 88 | -------------------------------------------------------------------------------- /fsw/examples/multi_tf/MISSION_to_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_to_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 TO application (Multi) 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for TO applications for the Multi 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 | * - Standard command messages are defined in to_cmds.h 21 | * - Default HK Telemetry structure is defined in to_hktlm.h 22 | * 23 | * \par Modification History: 24 | * - 2015-06-02 | Guy de Carufel | Code Started 25 | * - 2015-09-22 | Guy de Carufel | Moved hktlm to to_hktlm.h 26 | *******************************************************************************/ 27 | #ifndef _MISSION_TO_TYPES_H_ 28 | #define _MISSION_TO_TYPES_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* 35 | ** Include Files 36 | */ 37 | #include "cfe.h" 38 | #include "../to/fsw/src/to_hktlm.h" 39 | 40 | #include "cop1.h" 41 | 42 | /* 43 | ** Defines 44 | */ 45 | #define TO_MAX_IP_STRING_SIZE 16 46 | 47 | /* Define enable / disable commands */ 48 | typedef struct 49 | { 50 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 51 | char cDestIp[TO_MAX_IP_STRING_SIZE]; /**< Destination IP */ 52 | uint16 usDestPort; /**< Destination PORT */ 53 | int32 iFileDesc; /**< File Descriptor of Port to use. */ 54 | } TO_EnableOutputCmd_t; 55 | 56 | 57 | typedef struct 58 | { 59 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 60 | } TO_DisableOutputCmd_t; 61 | 62 | 63 | typedef struct 64 | { 65 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 66 | COP1_Clcw_t clcw; /**< COP-1 CLCW Data */ 67 | } TO_CustomSetOcfCmd_t; 68 | 69 | 70 | /*************** Telemetry **************/ 71 | typedef struct 72 | { 73 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 74 | } TO_InData_t; 75 | 76 | typedef struct 77 | { 78 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 79 | uint32 uiCounter; 80 | } TO_OutData_t; 81 | 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* _MISSION_TO_TYPES_H_ */ 88 | 89 | /*============================================================================== 90 | ** End of file MISSION_to_types.h 91 | **============================================================================*/ 92 | -------------------------------------------------------------------------------- /fsw/examples/multi_tf/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application with Multi 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 | 21 | #ifndef _TO_PLATFORM_CFG_H_ 22 | #define _TO_PLATFORM_CFG_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* 29 | ** Pragmas 30 | */ 31 | 32 | /* 33 | ** Local Defines 34 | */ 35 | #define TO_FRAMING_ENABLED 1 36 | 37 | #define TO_SCH_PIPE_DEPTH 10 38 | #define TO_CMD_PIPE_DEPTH 10 39 | #define TO_TLM_PIPE_DEPTH 10 40 | 41 | #define TO_NUM_CRITICAL_MIDS 3 42 | 43 | #define TO_MAX_TBL_ENTRIES 100 44 | #define TO_WAKEUP_TIMEOUT 500 45 | 46 | #define TO_CONFIG_TABLENAME "to_config" 47 | #define TO_CONFIG_FILENAME "/cf/apps/to_config.tbl" 48 | 49 | #define TO_GROUP_NUMBER_MASK 0xFF000000 50 | #define TO_MULTI_GROUP_MASK 0x00FFFFFF 51 | 52 | #define TO_DEFAULT_DEST_PORT 5011 53 | 54 | #define TO_CF_THROTTLE_SEM_NAME "CFTOSemId" 55 | 56 | #define TO_CUSTOM_TF_SIZE 1000 57 | #define TO_CUSTOM_TF_OVERFLOW_SIZE TO_CUSTOM_TF_SIZE 58 | #define TO_CUSTOM_TF_IDLE_SIZE TO_CUSTOM_TF_SIZE 59 | 60 | #define TO_CUSTOM_NUM_CHNL 2 61 | #define TO_CUSTOM_TF_SCID 0 62 | #define TO_CUSTOM_TF_ERR_CTRL 0 63 | #define TO_CUSTOM_TF_RANDOMIZE 0 64 | 65 | 66 | /* 67 | ** Include Files 68 | */ 69 | 70 | /* 71 | ** Local Structure Declarations 72 | */ 73 | 74 | /* 75 | ** External Global Variables 76 | */ 77 | 78 | /* 79 | ** Global Variables 80 | */ 81 | 82 | /* 83 | ** Local Variables 84 | */ 85 | 86 | /* 87 | ** Local Function Prototypes 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* _TO_PLATFORM_CFG_H_ */ 95 | 96 | /*============================================================================== 97 | ** End of file to_platform_cfg.h 98 | **============================================================================*/ 99 | 100 | -------------------------------------------------------------------------------- /fsw/examples/rs422/MISSION_to_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_to_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 TO application (RS422) 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for TO 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 | * - Standard command messages are defined in to_cmds.h 21 | * - Default HK Telemetry structure is defined in to_hktlm.h 22 | * 23 | * \par Modification History: 24 | * - 2015-01-09 | Guy de Carufel | Code Started 25 | * - 2015-09-22 | Guy de Carufel | Moved hktlm to to_hktlm.h 26 | *******************************************************************************/ 27 | #ifndef _MISSION_TO_TYPES_H_ 28 | #define _MISSION_TO_TYPES_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* 35 | ** Include Files 36 | */ 37 | #include "cfe.h" 38 | #include "../to/fsw/src/to_hktlm.h" 39 | 40 | /* 41 | ** Defines 42 | */ 43 | 44 | /* Define enable / disable commands */ 45 | typedef struct 46 | { 47 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 48 | int32 iFileDesc; /**< File Descriptor of Port to use. */ 49 | } TO_EnableOutputCmd_t; 50 | 51 | 52 | typedef struct 53 | { 54 | uint8 ucCmdHeader[CFE_SB_CMD_HDR_SIZE]; 55 | } TO_DisableOutputCmd_t; 56 | 57 | 58 | 59 | /*************** Telemetry **************/ 60 | typedef struct 61 | { 62 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 63 | } TO_InData_t; 64 | 65 | typedef struct 66 | { 67 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 68 | uint32 uiCounter; 69 | } TO_OutData_t; 70 | 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* _MISSION_TO_TYPES_H_ */ 77 | 78 | /*============================================================================== 79 | ** End of file MISSION_to_types.h 80 | **============================================================================*/ 81 | -------------------------------------------------------------------------------- /fsw/examples/rs422/to_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application for RS422 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the TO application over an RS422 serial port. 16 | * 17 | * \par API Functions Defined: 18 | * - TO_CustomInit() - Initialize the transport protocol 19 | * - TO_CustomAppCmds() - Process custom App Commands 20 | * - TO_CustomEnableOutputCmd() - Enable telemetry output 21 | * - TO_CustomDisableOutputCmd() - Disable telemetry output 22 | * - TO_CustomCleanup() - Cleanup callback to close transport channel. 23 | * - TO_CustomProcessData() - Send output data over transport protocol. 24 | * 25 | * \par Private Functions Defined: 26 | * - TO_SendDataTypePktCmd() - Send Test packet (Reference to_lab app) 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 to_platform_cfg.h 32 | * 33 | * \par Modification History: 34 | * - 2015-01-09 | Guy de Carufel | Code Started 35 | *******************************************************************************/ 36 | 37 | /* 38 | ** Pragmas 39 | */ 40 | 41 | /* 42 | ** Include Files 43 | */ 44 | #include "cfe.h" 45 | #include "network_includes.h" 46 | #include "trans_rs422.h" 47 | 48 | #include "to_app.h" 49 | 50 | /* 51 | ** Local Defines 52 | */ 53 | 54 | /* 55 | ** Local Structure Declarations 56 | */ 57 | typedef struct 58 | { 59 | int32 iFileDesc; /**< File Descriptor of serial port */ 60 | } TO_CustomData_t; 61 | 62 | /* 63 | ** External Global Variables 64 | */ 65 | extern TO_AppData_t g_TO_AppData; 66 | 67 | /* 68 | ** Global Variables 69 | */ 70 | TO_CustomData_t g_TO_CustomData; 71 | 72 | /* 73 | ** Local Variables 74 | */ 75 | 76 | /* 77 | ** Local Function Definitions 78 | */ 79 | extern void TO_SendDataTypePktCmd(CFE_SB_MsgPtr_t); 80 | 81 | /******************************************************************************* 82 | ** Custom Application Functions 83 | *******************************************************************************/ 84 | 85 | /******************************************************************************/ 86 | /** \brief Custom Initialization 87 | *******************************************************************************/ 88 | int32 TO_CustomInit(void) 89 | { 90 | int32 iStatus = TO_SUCCESS; 91 | 92 | /* Set Critical Message Ids which must always be 93 | * in config table. */ 94 | g_TO_AppData.criticalMid[0] = CFE_ES_SHELL_TLM_MID; 95 | g_TO_AppData.criticalMid[1] = CFE_EVS_EVENT_MSG_MID; 96 | g_TO_AppData.criticalMid[2] = CFE_SB_ALLSUBS_TLM_MID; 97 | 98 | /* Route 0: Serial */ 99 | g_TO_AppData.routes[0].usExists = 1; 100 | 101 | /* Tie route 0 to CF channel 0 */ 102 | g_TO_AppData.routes[0].sCfChnlIdx = 0; 103 | 104 | return iStatus; 105 | } 106 | 107 | /******************************************************************************/ 108 | /** \brief Process of custom app commands 109 | *******************************************************************************/ 110 | int32 TO_CustomAppCmds(CFE_SB_Msg_t* pMsg) 111 | { 112 | int32 iStatus = TO_SUCCESS; 113 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pMsg); 114 | switch (uiCmdCode) 115 | { 116 | case TO_SEND_DATA_TYPE_CC: 117 | TO_SendDataTypePktCmd(pMsg); 118 | break; 119 | 120 | default: 121 | iStatus = TO_ERROR; 122 | break; 123 | } 124 | 125 | return iStatus; 126 | } 127 | 128 | /******************************************************************************/ 129 | /** \brief Process of output telemetry 130 | *******************************************************************************/ 131 | int32 TO_CustomProcessData(CFE_SB_Msg_t * pMsg, int32 size, int32 iTblIdx, 132 | uint16 usRouteId) 133 | { 134 | int32 iSentSize = 0; 135 | int32 iStatus = TO_SUCCESS; 136 | 137 | if (usRouteId == 0) 138 | { 139 | iSentSize = IO_TransRS422Write(g_TO_CustomData.iFileDesc, 140 | (uint8 *) pMsg, 141 | size); 142 | if (iSentSize < 0) 143 | { 144 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 145 | "TO RS422 sendto errno %d. " 146 | "Telemetry output disabled.", errno); 147 | g_TO_AppData.usOutputEnabled = 0; 148 | iStatus = TO_ERROR; 149 | } 150 | else if (iSentSize != size) 151 | { 152 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 153 | "TO RS422 sent incomplete message."); 154 | iStatus = TO_ERROR; 155 | } 156 | } 157 | 158 | return iSentSize; 159 | } 160 | 161 | 162 | /******************************************************************************/ 163 | /** \brief Custom Cleanup 164 | *******************************************************************************/ 165 | void TO_CustomCleanup(void) 166 | { 167 | /* Nothing to do here. The fileDescriptor is closed in CI. */ 168 | return; 169 | } 170 | 171 | /******************************************************************************/ 172 | /** \brief Enable Output Command Response 173 | *******************************************************************************/ 174 | int32 TO_CustomEnableOutputCmd(CFE_SB_Msg_t *cmdpMsg) 175 | { 176 | int32 routeMask = 0x0001; 177 | 178 | TO_EnableOutputCmd_t * pCustomCmd = (TO_EnableOutputCmd_t *) cmdpMsg; 179 | g_TO_CustomData.iFileDesc = pCustomCmd->iFileDesc; 180 | TO_SetRouteAsConfigured(0); 181 | 182 | return routeMask; 183 | } 184 | 185 | /******************************************************************************/ 186 | /** \brief Disable Output Command Response 187 | *******************************************************************************/ 188 | int32 TO_CustomDisableOutputCmd(CFE_SB_Msg_t *cmdpMsg) 189 | { 190 | /* Disable */ 191 | g_TO_AppData.usOutputEnabled = 0; 192 | return TO_SUCCESS; 193 | } 194 | 195 | 196 | /******************************************************************************* 197 | ** Non standard custom Commands 198 | *******************************************************************************/ 199 | 200 | 201 | /*============================================================================== 202 | ** End of file to_custom.c 203 | **============================================================================*/ 204 | -------------------------------------------------------------------------------- /fsw/examples/rs422/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO 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 | 21 | #ifndef _TO_PLATFORM_CFG_H_ 22 | #define _TO_PLATFORM_CFG_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* 29 | ** Pragmas 30 | */ 31 | 32 | /* 33 | ** Local Defines 34 | */ 35 | #define TO_SCH_PIPE_DEPTH 10 36 | #define TO_CMD_PIPE_DEPTH 10 37 | #define TO_TLM_PIPE_DEPTH 10 38 | 39 | #define TO_NUM_CRITICAL_MIDS 3 40 | 41 | #define TO_MAX_TBL_ENTRIES 100 42 | #define TO_WAKEUP_TIMEOUT 500 43 | 44 | #define TO_CONFIG_TABLENAME "to_config" 45 | #define TO_CONFIG_FILENAME "/cf/apps/to_config.tbl" 46 | 47 | #define TO_GROUP_NUMBER_MASK 0xFF000000 48 | #define TO_MULTI_GROUP_MASK 0x00FFFFFF 49 | 50 | #define TO_CF_THROTTLE_SEM_NAME "CFTOSemId" 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 /* _TO_PLATFORM_CFG_H_ */ 81 | 82 | /*============================================================================== 83 | ** End of file to_platform_cfg.h 84 | **============================================================================*/ 85 | 86 | -------------------------------------------------------------------------------- /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 *_to_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/to_custom.c ../src/" 23 | echo -e "\tln -s udp/to_platform_cfg.h ../platform_inc/" 24 | echo -e "\tln -s udp/MISSION_to_types.h MISSION_HOME/apps/inc/MY_MISION_to_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/to_custom.c 102 | rm -f $PWD/../platform_inc/to_platform_cfg.h 103 | rm -f ${APP_DIR}/inc/${mission}_to_types.h 104 | echo -e "\tRemoved files:" 105 | echo -e "\t$PWD/../src/to_custom.c" 106 | echo -e "\t$PWD/../platform_inc/to_platform_cfg.h" 107 | echo -e "\t${APP_DIR}/inc/${mission}_to_types.h\n" 108 | 109 | if [ "$link" -eq 1 ]; then 110 | ln -sf $PWD/$1/to_custom.c $PWD/../src/to_custom.c 111 | ln -sf $PWD/$1/to_platform_cfg.h $PWD/../platform_inc/to_platform_cfg.h 112 | ln -sf $PWD/$1/MISSION_to_types.h ${APP_DIR}/inc/${mission}_to_types.h 113 | echo -e "\tCreating Symbolic links:" 114 | else 115 | cp -f $PWD/$1/to_custom.c $PWD/../src/to_custom.c 116 | cp -f $PWD/$1/to_platform_cfg.h $PWD/../platform_inc/to_platform_cfg.h 117 | cp -f $PWD/$1/MISSION_to_types.h ${APP_DIR}/inc/${mission}_to_types.h 118 | echo -e "\tFiles copied:" 119 | fi 120 | 121 | echo -e "\t$PWD/$1/to_custom.c -> $PWD/../src/to_custom.c" 122 | echo -e "\t$PWD/$1/to_platform_cfg.h -> $PWD/../platform_inc/to_platform_cfg.h" 123 | echo -e "\t$PWD/$1/MISSION_to_types.h -> ${APP_DIR}/inc/${mission}_to_types.h\n" 124 | -------------------------------------------------------------------------------- /fsw/examples/udp/MISSION_to_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file MISSION_to_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 TO application (UDP) 12 | * 13 | * \par 14 | * This header file contains definitions of command and telemetry data 15 | * structures for TO 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 | * - Standard command messages are defined in to_cmds.h 21 | * - Default HK Telemetry structure is defined in to_hktlm.h 22 | * 23 | * \par Modification History: 24 | * - 2015-01-09 | Guy de Carufel | Code Started 25 | * - 2015-09-22 | Guy de Carufel | Moved hktlm to to_hktlm.h 26 | *******************************************************************************/ 27 | #ifndef _MISSION_TO_TYPES_H_ 28 | #define _MISSION_TO_TYPES_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* 35 | ** Include Files 36 | */ 37 | #include "cfe.h" 38 | #include "../to/fsw/src/to_hktlm.h" 39 | 40 | /* 41 | ** Defines 42 | */ 43 | #define TO_MAX_IP_STRING_SIZE 16 44 | 45 | 46 | /* Define enable / disable commands */ 47 | typedef struct 48 | { 49 | uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; 50 | char cDestIp[TO_MAX_IP_STRING_SIZE]; /* Destination IP */ 51 | uint16 usDestPort; /* Destination PORT */ 52 | } TO_EnableOutputCmd_t; 53 | 54 | 55 | typedef struct 56 | { 57 | uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; 58 | } TO_DisableOutputCmd_t; 59 | 60 | 61 | 62 | /*************** Telemetry **************/ 63 | typedef struct 64 | { 65 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 66 | } TO_InData_t; 67 | 68 | typedef struct 69 | { 70 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 71 | uint32 uiCounter; 72 | } TO_OutData_t; 73 | 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* _MISSION_TO_TYPES_H_ */ 80 | 81 | /*============================================================================== 82 | ** End of file MISSION_to_types.h 83 | **============================================================================*/ 84 | -------------------------------------------------------------------------------- /fsw/examples/udp/to_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application for UDP 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the TO application over UDP Socket. 16 | * 17 | * \par API Functions Defined: 18 | * - TO_CustomInit() - Initialize the transport protocol 19 | * - TO_CustomAppCmds() - Process custom App Commands 20 | * - TO_CustomEnableOutputCmd() - Enable telemetry output 21 | * - TO_CustomDisableOutputCmd() - Disable telemetry output 22 | * - TO_CustomCleanup() - Cleanup callback to close transport channel. 23 | * - TO_CustomProcessData() - Send output data over transport protocol. 24 | * 25 | * \par Private Functions Defined: 26 | * - TO_SendDataTypePktCmd() - Send Test packet (Reference to_lab app) 27 | * 28 | * \par Limitations, Assumptions, External Events, and Notes: 29 | * - All input messages are CCSDS messages 30 | * - All config macros defined in to_platform_cfg.h 31 | * 32 | * \par Modification History: 33 | * - 2015-01-09 | Guy de Carufel | Code Started 34 | * - 2015-06-02 | Guy de Carufel | Revised for new UDP API 35 | *******************************************************************************/ 36 | 37 | /* 38 | ** Pragmas 39 | */ 40 | 41 | /* 42 | ** Include Files 43 | */ 44 | #include "cfe.h" 45 | #include "network_includes.h" 46 | #include "trans_udp.h" 47 | 48 | #include "to_app.h" 49 | #include "ci_msgids.h" 50 | 51 | /* 52 | ** Local Defines 53 | */ 54 | 55 | /* 56 | ** Local Structure Declarations 57 | */ 58 | typedef struct 59 | { 60 | IO_TransUdp_t udp; /**< UDP working */ 61 | } TO_CustomData_t; 62 | 63 | /* 64 | ** External Global Variables 65 | */ 66 | extern TO_AppData_t g_TO_AppData; 67 | 68 | /* 69 | ** Global Variables 70 | */ 71 | 72 | /* 73 | ** Local Variables 74 | */ 75 | static TO_CustomData_t g_TO_CustomData; 76 | 77 | /* 78 | ** Local Function Definitions 79 | */ 80 | extern void TO_SendDataTypePktCmd(CFE_SB_MsgPtr_t); 81 | 82 | /******************************************************************************* 83 | ** Custom Application Functions 84 | *******************************************************************************/ 85 | 86 | /******************************************************************************/ 87 | /** \brief Custom Initialization 88 | *******************************************************************************/ 89 | int32 TO_CustomInit(void) 90 | { 91 | int32 iStatus = TO_SUCCESS; 92 | 93 | /* Create socket for outgoing */ 94 | if (IO_TransUdpCreateSocket(&g_TO_CustomData.udp) < 0) 95 | { 96 | iStatus = TO_ERROR; 97 | goto end_of_function; 98 | } 99 | 100 | /* NOTE: For this simple UDP example, we are only requiring The following 101 | 3 messages. If more message IDs should be included by default, add them 102 | here and update the TO_NUM_CRITICAL_MIDS value. */ 103 | 104 | /* Set Critical Message Ids which must always be in config table. */ 105 | g_TO_AppData.criticalMid[0] = TO_HK_TLM_MID; 106 | g_TO_AppData.criticalMid[1] = CI_HK_TLM_MID; 107 | g_TO_AppData.criticalMid[2] = CFE_EVS_EVENT_MSG_MID; 108 | 109 | /* Route 0: Udp. Linked to CF Channel Index 0. */ 110 | g_TO_AppData.routes[0].usExists = 1; 111 | g_TO_AppData.routes[0].sCfChnlIdx = 0; 112 | 113 | end_of_function: 114 | return iStatus; 115 | } 116 | 117 | /******************************************************************************/ 118 | /** \brief Process of custom app commands 119 | *******************************************************************************/ 120 | int32 TO_CustomAppCmds(CFE_SB_Msg_t* pMsg) 121 | { 122 | int32 iStatus = TO_SUCCESS; 123 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pMsg); 124 | switch (uiCmdCode) 125 | { 126 | case TO_SEND_DATA_TYPE_CC: 127 | TO_SendDataTypePktCmd(pMsg); 128 | break; 129 | 130 | default: 131 | iStatus = -1; 132 | break; 133 | } 134 | 135 | return iStatus; 136 | } 137 | 138 | /******************************************************************************/ 139 | /** \brief Process of output telemetry 140 | *******************************************************************************/ 141 | int32 TO_CustomProcessData(CFE_SB_Msg_t * pMsg, int32 size, int32 iTblIdx, 142 | uint16 usRouteId) 143 | { 144 | int32 iStatus = 0; 145 | 146 | if (g_TO_AppData.routes[0].usIsEnabled == 0 || usRouteId != 0) 147 | { 148 | goto end_of_function; 149 | } 150 | 151 | iStatus = IO_TransUdpSnd(&g_TO_CustomData.udp, (uint8 *) pMsg, size); 152 | 153 | if (iStatus < 0) 154 | { 155 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 156 | "TO UDP sendto errno %d. Telemetry output disabled.", 157 | errno); 158 | g_TO_AppData.usOutputEnabled = 0; 159 | } 160 | 161 | end_of_function: 162 | return iStatus; 163 | } 164 | 165 | /******************************************************************************/ 166 | /** \brief Custom Cleanup 167 | *******************************************************************************/ 168 | void TO_CustomCleanup(void) 169 | { 170 | if (g_TO_AppData.usOutputEnabled) 171 | { 172 | CFE_EVS_SendEvent(TO_CUSTOM_INF_EID, CFE_EVS_INFORMATION, 173 | "TO - Closing Socket."); 174 | IO_TransUdpCloseSocket(&g_TO_CustomData.udp); 175 | } 176 | 177 | return; 178 | } 179 | 180 | /******************************************************************************/ 181 | /** \brief Enable Output Command Response 182 | *******************************************************************************/ 183 | int32 TO_CustomEnableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 184 | { 185 | int32 iStatus = IO_TRANS_UDP_NO_ERROR; 186 | int32 routeMask = TO_ERROR; 187 | char cDestIp[TO_MAX_IP_STRING_SIZE]; 188 | uint16 usDestPort = 0; 189 | 190 | TO_EnableOutputCmd_t * pCustomCmd = (TO_EnableOutputCmd_t *) pCmdMsg; 191 | strncpy(cDestIp, pCustomCmd->cDestIp, sizeof(cDestIp)); 192 | 193 | if (pCustomCmd->usDestPort > 0) 194 | { 195 | usDestPort = pCustomCmd->usDestPort; 196 | } 197 | else 198 | { 199 | usDestPort = TO_DEFAULT_DEST_PORT; 200 | } 201 | 202 | iStatus = IO_TransUdpSetDestAddr(&g_TO_CustomData.udp, pCustomCmd->cDestIp, 203 | usDestPort); 204 | 205 | if (iStatus < 0) 206 | { 207 | goto end_of_function; 208 | } 209 | 210 | /* We are done configuring route 0 */ 211 | TO_SetRouteAsConfigured(0); 212 | routeMask = 0x0001; 213 | 214 | end_of_function: 215 | return routeMask; 216 | } 217 | 218 | /******************************************************************************/ 219 | /** \brief Disable Output Command Response 220 | *******************************************************************************/ 221 | int32 TO_CustomDisableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 222 | { 223 | /* Disable */ 224 | g_TO_AppData.usOutputEnabled = 0; 225 | return TO_SUCCESS; 226 | } 227 | 228 | 229 | /******************************************************************************* 230 | ** Non standard custom Commands 231 | *******************************************************************************/ 232 | 233 | /*============================================================================== 234 | ** End of file to_custom.c 235 | **============================================================================*/ 236 | -------------------------------------------------------------------------------- /fsw/examples/udp/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application with UDP 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 | * - Overwrite any default settings by defining them here. 17 | * - Define any implementation specific settings. 18 | * 19 | * \par Modification History: 20 | * - 2015-01-09 | Guy de Carufel | Code Started 21 | *******************************************************************************/ 22 | 23 | #ifndef _TO_PLATFORM_CFG_H_ 24 | #define _TO_PLATFORM_CFG_H_ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* 31 | ** Pragmas 32 | */ 33 | 34 | /* 35 | ** Local Defines 36 | */ 37 | #define TO_NUM_CRITICAL_MIDS 3 38 | #define TO_DEFAULT_DEST_PORT 5011 39 | 40 | 41 | /* 42 | ** Include Files 43 | */ 44 | 45 | /* 46 | ** Local Structure Declarations 47 | */ 48 | 49 | /* 50 | ** External Global Variables 51 | */ 52 | 53 | /* 54 | ** Global Variables 55 | */ 56 | 57 | /* 58 | ** Local Variables 59 | */ 60 | 61 | /* 62 | ** Local Function Prototypes 63 | */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* _TO_PLATFORM_CFG_H_ */ 70 | 71 | /*============================================================================== 72 | ** End of file to_platform_cfg.h 73 | **============================================================================*/ 74 | 75 | -------------------------------------------------------------------------------- /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 = to 13 | 14 | # 15 | # Entry Point for task 16 | # 17 | ENTRY_PT = TO_AppMain 18 | 19 | # 20 | # Object files required to build subsystem. 21 | # 22 | OBJS = to_app.o to_cmds.o to_utils.o to_custom.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 | 93 | # 94 | # Define the VPATH make variable. 95 | # This can be modified to include source from another directory. 96 | # If there is no corresponding app in the cfs-apps directory, then this can be discarded, 97 | # or if the mission chooses to put the src in another directory such as "src", then that 98 | # can be added here as well. 99 | # 100 | VPATH = $(CFS_APP_SRC)/$(APPTARGET)/fsw/src \ 101 | $(CFS_APP_SRC)/$(APPTARGET)/fsw/tables 102 | 103 | # 104 | # Include the common make rules for building a cFE Application 105 | # 106 | include $(CFE_CORE_SRC)/make/app-rules.mak 107 | 108 | ####################################################################################### 109 | 110 | -------------------------------------------------------------------------------- /fsw/for_build/totables.mak: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # File: CFS Application Table Makefile 3 | # 4 | # 5 | # History: 6 | # 7 | ############################################################################### 8 | # 9 | # The Application needs to be specified here 10 | # 11 | APPTARGET = to 12 | 13 | # 14 | # List the tables that are generated here. 15 | # Restrictions: 16 | # 1. The table file name must be the same as the C source file name 17 | # 2. There must be a single C source file for each table 18 | # 19 | TABLES = to_config.tbl to_config_2.tbl 20 | 21 | ################################################################################## 22 | # Normally, nothing has to be changed below this line 23 | # The following are changes that may have to be made for a custom app environment: 24 | # 1. INCLUDE_PATH - This may be customized to tailor the include path for an app 25 | # 2. VPATH - This may be customized to tailor the location of the table sources. 26 | # For example: if the tables were stored in a "tables" subdirectory 27 | # ( build/cpu1/sch/tables ) 28 | ################################################################################# 29 | 30 | # 31 | # Object files required for tables 32 | # 33 | OBJS = $(TABLES:.tbl=.o) 34 | 35 | # 36 | # Source files required to build tables. 37 | # 38 | SOURCES = $(OBJS:.o=.c) 39 | 40 | ## 41 | ## Specify extra C Flags needed to build this subsystem 42 | ## 43 | LOCAL_COPTS = 44 | 45 | ## 46 | ## EXEDIR is defined here, just in case it needs to be different for a custom 47 | ## build 48 | ## 49 | EXEDIR=../exe 50 | 51 | ######################################################################## 52 | # Should not have to change below this line, except for customized 53 | # Mission and cFE directory structures 54 | ######################################################################## 55 | 56 | # 57 | # Set build type to CFE_APP. This allows us to 58 | # define different compiler flags for the cFE Core and Apps. 59 | # 60 | BUILD_TYPE = CFE_TABLE 61 | 62 | ## 63 | ## Include all necessary cFE make rules 64 | ## Any of these can be copied to a local file and 65 | ## changed if needed. 66 | ## 67 | ## 68 | ## cfe-config.mak contians arch, BSP, and OS selection 69 | ## 70 | include ../cfe/cfe-config.mak 71 | 72 | ## 73 | ## debug-opts.mak contains debug switches -- Note that the table must be 74 | ## built with -g for the elf2tbl utility to work. 75 | ## 76 | include ../cfe/debug-opts.mak 77 | 78 | ## 79 | ## compiler-opts.mak contains compiler definitions and switches/defines 80 | ## 81 | include $(CFE_PSP_SRC)/$(PSP)/make/compiler-opts.mak 82 | 83 | ## 84 | ## Setup the include path for this subsystem 85 | ## The OS specific includes are in the build-rules.make file 86 | ## 87 | ## If this subsystem needs include files from another app, add the path here. 88 | ## 89 | INCLUDE_PATH = \ 90 | -I$(OSAL_SRC)/inc \ 91 | -I$(CFE_CORE_SRC)/inc \ 92 | -I$(CFE_PSP_SRC)/$(PSP)/inc \ 93 | -I$(CFE_PSP_SRC)/inc \ 94 | -I$(CFS_APP_SRC)/inc \ 95 | -I$(CFS_APP_SRC)/$(APPTARGET)/fsw/src \ 96 | -I$(CFS_MISSION_INC) \ 97 | -I../cfe/inc \ 98 | -I../inc 99 | 100 | ## 101 | ## Define the VPATH make variable. 102 | ## This can be modified to include source from another directory. 103 | ## If there is no corresponding app in the cfe-apps directory, then this can be discarded, or 104 | ## if the mission chooses to put the src in another directory such as "src", then that can be 105 | ## added here as well. 106 | ## 107 | VPATH = $(CFS_APP_SRC)/$(APPTARGET)/fsw/tables 108 | 109 | ## 110 | ## Include the common make rules for building a cFE Application 111 | ## 112 | include $(CFE_CORE_SRC)/make/table-rules.mak 113 | -------------------------------------------------------------------------------- /fsw/mission_inc/to_mission_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO 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 _TO_MISSION_CFG_H_ 21 | #define _TO_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 "to_perf_ids.h" 41 | #include "to_msgids.h" 42 | #include "to_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_to_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 /* _TO_MISSION_CFG_H_ */ 73 | 74 | /*============================================================================== 75 | ** End of file to_mission_cfg.h 76 | **============================================================================*/ 77 | 78 | -------------------------------------------------------------------------------- /fsw/mission_inc/to_perf_ids.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | ** File: 3 | ** to_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 Telemetry Output 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 | #ifndef _TO_PERF_IDS_H_ 29 | #define _TO_PERF_IDS_H_ 30 | 31 | #define TO_MAIN_TASK_PERF_ID 0x0072 32 | 33 | #endif /* _TO_PERF_IDS_H_ */ 34 | 35 | /*======================================================================================= 36 | ** End of file ci_perf_ids.h 37 | **=====================================================================================*/ 38 | 39 | -------------------------------------------------------------------------------- /fsw/platform_inc/to_msgids.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/platform_inc/to_msgids.h -------------------------------------------------------------------------------- /fsw/platform_inc/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application with UDP 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 | * - Overwrite any default settings by defining them here. 17 | * - Define any implementation specific settings. 18 | * 19 | * \par Modification History: 20 | * - 2015-01-09 | Guy de Carufel | Code Started 21 | *******************************************************************************/ 22 | 23 | #ifndef _TO_PLATFORM_CFG_H_ 24 | #define _TO_PLATFORM_CFG_H_ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* 31 | ** Pragmas 32 | */ 33 | 34 | /* 35 | ** Local Defines 36 | */ 37 | #define TO_NUM_CRITICAL_MIDS 3 38 | #define TO_DEFAULT_DEST_PORT 5011 39 | 40 | 41 | /* 42 | ** Include Files 43 | */ 44 | 45 | /* 46 | ** Local Structure Declarations 47 | */ 48 | 49 | /* 50 | ** External Global Variables 51 | */ 52 | 53 | /* 54 | ** Global Variables 55 | */ 56 | 57 | /* 58 | ** Local Variables 59 | */ 60 | 61 | /* 62 | ** Local Function Prototypes 63 | */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* _TO_PLATFORM_CFG_H_ */ 70 | 71 | /*============================================================================== 72 | ** End of file to_platform_cfg.h 73 | **============================================================================*/ 74 | 75 | -------------------------------------------------------------------------------- /fsw/src/to_custom.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application for UDP 12 | * 13 | * \par 14 | * This file defines the functions for a custom implementation of the custom 15 | * layer of the TO application over UDP Socket. 16 | * 17 | * \par API Functions Defined: 18 | * - TO_CustomInit() - Initialize the transport protocol 19 | * - TO_CustomAppCmds() - Process custom App Commands 20 | * - TO_CustomEnableOutputCmd() - Enable telemetry output 21 | * - TO_CustomDisableOutputCmd() - Disable telemetry output 22 | * - TO_CustomCleanup() - Cleanup callback to close transport channel. 23 | * - TO_CustomProcessData() - Send output data over transport protocol. 24 | * 25 | * \par Private Functions Defined: 26 | * - TO_SendDataTypePktCmd() - Send Test packet (Reference to_lab app) 27 | * 28 | * \par Limitations, Assumptions, External Events, and Notes: 29 | * - All input messages are CCSDS messages 30 | * - All config macros defined in to_platform_cfg.h 31 | * 32 | * \par Modification History: 33 | * - 2015-01-09 | Guy de Carufel | Code Started 34 | * - 2015-06-02 | Guy de Carufel | Revised for new UDP API 35 | *******************************************************************************/ 36 | 37 | /* 38 | ** Pragmas 39 | */ 40 | 41 | /* 42 | ** Include Files 43 | */ 44 | #include "cfe.h" 45 | #include "network_includes.h" 46 | #include "trans_udp.h" 47 | 48 | #include "to_app.h" 49 | #include "ci_msgids.h" 50 | 51 | /* 52 | ** Local Defines 53 | */ 54 | 55 | /* 56 | ** Local Structure Declarations 57 | */ 58 | typedef struct 59 | { 60 | IO_TransUdp_t udp; /**< UDP working */ 61 | } TO_CustomData_t; 62 | 63 | /* 64 | ** External Global Variables 65 | */ 66 | extern TO_AppData_t g_TO_AppData; 67 | 68 | /* 69 | ** Global Variables 70 | */ 71 | 72 | /* 73 | ** Local Variables 74 | */ 75 | static TO_CustomData_t g_TO_CustomData; 76 | 77 | /* 78 | ** Local Function Definitions 79 | */ 80 | extern void TO_SendDataTypePktCmd(CFE_SB_MsgPtr_t); 81 | 82 | /******************************************************************************* 83 | ** Custom Application Functions 84 | *******************************************************************************/ 85 | 86 | /******************************************************************************/ 87 | /** \brief Custom Initialization 88 | *******************************************************************************/ 89 | int32 TO_CustomInit(void) 90 | { 91 | int32 iStatus = TO_SUCCESS; 92 | 93 | /* Create socket for outgoing */ 94 | if (IO_TransUdpCreateSocket(&g_TO_CustomData.udp) < 0) 95 | { 96 | iStatus = TO_ERROR; 97 | goto end_of_function; 98 | } 99 | 100 | /* NOTE: For this simple UDP example, we are only requiring The following 101 | 3 messages. If more message IDs should be included by default, add them 102 | here and update the TO_NUM_CRITICAL_MIDS value. */ 103 | 104 | /* Set Critical Message Ids which must always be in config table. */ 105 | g_TO_AppData.criticalMid[0] = TO_HK_TLM_MID; 106 | g_TO_AppData.criticalMid[1] = CI_HK_TLM_MID; 107 | g_TO_AppData.criticalMid[2] = CFE_EVS_EVENT_MSG_MID; 108 | 109 | /* Route 0: Udp. Linked to CF Channel Index 0. */ 110 | g_TO_AppData.routes[0].usExists = 1; 111 | g_TO_AppData.routes[0].sCfChnlIdx = 0; 112 | 113 | end_of_function: 114 | return iStatus; 115 | } 116 | 117 | /******************************************************************************/ 118 | /** \brief Process of custom app commands 119 | *******************************************************************************/ 120 | int32 TO_CustomAppCmds(CFE_SB_Msg_t* pMsg) 121 | { 122 | int32 iStatus = TO_SUCCESS; 123 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pMsg); 124 | switch (uiCmdCode) 125 | { 126 | case TO_SEND_DATA_TYPE_CC: 127 | TO_SendDataTypePktCmd(pMsg); 128 | break; 129 | 130 | default: 131 | iStatus = -1; 132 | break; 133 | } 134 | 135 | return iStatus; 136 | } 137 | 138 | /******************************************************************************/ 139 | /** \brief Process of output telemetry 140 | *******************************************************************************/ 141 | int32 TO_CustomProcessData(CFE_SB_Msg_t * pMsg, int32 size, int32 iTblIdx, 142 | uint16 usRouteId) 143 | { 144 | int32 iStatus = 0; 145 | 146 | if (g_TO_AppData.routes[0].usIsEnabled == 0 || usRouteId != 0) 147 | { 148 | goto end_of_function; 149 | } 150 | 151 | iStatus = IO_TransUdpSnd(&g_TO_CustomData.udp, (uint8 *) pMsg, size); 152 | 153 | if (iStatus < 0) 154 | { 155 | CFE_EVS_SendEvent(TO_CUSTOM_ERR_EID, CFE_EVS_ERROR, 156 | "TO UDP sendto errno %d. Telemetry output disabled.", 157 | errno); 158 | g_TO_AppData.usOutputEnabled = 0; 159 | } 160 | 161 | end_of_function: 162 | return iStatus; 163 | } 164 | 165 | /******************************************************************************/ 166 | /** \brief Custom Cleanup 167 | *******************************************************************************/ 168 | void TO_CustomCleanup(void) 169 | { 170 | if (g_TO_AppData.usOutputEnabled) 171 | { 172 | CFE_EVS_SendEvent(TO_CUSTOM_INF_EID, CFE_EVS_INFORMATION, 173 | "TO - Closing Socket."); 174 | IO_TransUdpCloseSocket(&g_TO_CustomData.udp); 175 | } 176 | 177 | return; 178 | } 179 | 180 | /******************************************************************************/ 181 | /** \brief Enable Output Command Response 182 | *******************************************************************************/ 183 | int32 TO_CustomEnableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 184 | { 185 | int32 iStatus = IO_TRANS_UDP_NO_ERROR; 186 | int32 routeMask = TO_ERROR; 187 | char cDestIp[TO_MAX_IP_STRING_SIZE]; 188 | uint16 usDestPort = 0; 189 | 190 | TO_EnableOutputCmd_t * pCustomCmd = (TO_EnableOutputCmd_t *) pCmdMsg; 191 | strncpy(cDestIp, pCustomCmd->cDestIp, sizeof(cDestIp)); 192 | 193 | if (pCustomCmd->usDestPort > 0) 194 | { 195 | usDestPort = pCustomCmd->usDestPort; 196 | } 197 | else 198 | { 199 | usDestPort = TO_DEFAULT_DEST_PORT; 200 | } 201 | 202 | iStatus = IO_TransUdpSetDestAddr(&g_TO_CustomData.udp, pCustomCmd->cDestIp, 203 | usDestPort); 204 | 205 | if (iStatus < 0) 206 | { 207 | goto end_of_function; 208 | } 209 | 210 | /* We are done configuring route 0 */ 211 | TO_SetRouteAsConfigured(0); 212 | routeMask = 0x0001; 213 | 214 | end_of_function: 215 | return routeMask; 216 | } 217 | 218 | /******************************************************************************/ 219 | /** \brief Disable Output Command Response 220 | *******************************************************************************/ 221 | int32 TO_CustomDisableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 222 | { 223 | /* Disable */ 224 | g_TO_AppData.usOutputEnabled = 0; 225 | return TO_SUCCESS; 226 | } 227 | 228 | 229 | /******************************************************************************* 230 | ** Non standard custom Commands 231 | *******************************************************************************/ 232 | 233 | /*============================================================================== 234 | ** End of file to_custom.c 235 | **============================================================================*/ 236 | -------------------------------------------------------------------------------- /fsw/src/to_events.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO Application 12 | * 13 | * \par 14 | * This header file contains definitions of the TO Event IDs 15 | * 16 | * \par Modification History: 17 | * - 2015-01-09 | Guy de Carufel | Code Started 18 | *******************************************************************************/ 19 | 20 | #ifndef _TO_EVENTS_H_ 21 | #define _TO_EVENTS_H_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Event IDs */ 28 | typedef enum 29 | { 30 | TO_RESERVED_EID = 0, 31 | TO_INF_EID = 1, 32 | TO_INIT_INF_EID = 2, 33 | TO_CMD_INF_EID = 3, 34 | TO_TBL_INF_EID = 4, 35 | TO_CUSTOM_INF_EID = 5, 36 | TO_ERR_EID = 6, 37 | TO_INIT_ERR_EID = 7, 38 | TO_CMD_ERR_EID = 8, 39 | TO_TBL_ERR_EID = 9, 40 | TO_PIPE_ERR_EID = 10, 41 | TO_MSGID_ERR_EID = 11, 42 | TO_MSGLEN_ERR_EID = 12, 43 | TO_CUSTOM_ERR_EID = 13, 44 | TO_EVT_CNT 45 | } TO_Events_t; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | 53 | /*============================================================================== 54 | ** End of file to_events.h 55 | **============================================================================*/ 56 | 57 | -------------------------------------------------------------------------------- /fsw/src/to_hktlm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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_to_types.hh 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 | * - The usMsgSubCnt is not reset on a TO_RESET_CC command. 21 | * 22 | * \par Modification History: 23 | * - 2015-09-22 | Guy de Carufel | Code Started 24 | *******************************************************************************/ 25 | #ifndef _TO_HKTLM_H_ 26 | #define _TO_HKTLM_H_ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #include "cfe.h" 33 | 34 | typedef struct 35 | { 36 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 37 | uint16 usCmdCnt; /**< Count of all commands received */ 38 | uint16 usCmdErrCnt; /**< Count of command errors */ 39 | uint16 usMsgSubCnt; /**< Count of subscribed messages by all 40 | telemetry pipe. */ 41 | uint16 usMsgSubErrCnt; /**< Count of subscription errors */ 42 | uint16 usTblUpdateCnt; /**< Count of table updates through CFE_TBL */ 43 | uint16 usTblErrCnt; /**< Count of table update errors */ 44 | uint16 usConfigRoutes; /**< Current mask of configured routes */ 45 | uint16 usEnabledRoutes; /**< Current mask of enabled routes */ 46 | } TO_HkTlm_t; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _TO_HKTLM_H_ */ 53 | 54 | /*============================================================================== 55 | ** End of file to_hktlm.h 56 | **============================================================================*/ 57 | -------------------------------------------------------------------------------- /fsw/src/to_msgdefs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/src/to_msgdefs.h -------------------------------------------------------------------------------- /fsw/src/to_tbldefs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_tbldefs.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 Define the configuration table for Telemetry Outputs 12 | * 13 | * \par Limitations, Assumptions, External Events, and Notes: 14 | * Each table entry defines: 15 | * 1. The message id 16 | * 2. The qos and msgLength - Used for message subscription 17 | * 3. The routeMask - For output message routing 18 | * 4. The groupData - To modify multiple entries with single command 19 | * 5. The state - The state of the entry (enabled = 1 /disabled = 0) 20 | * A Valid Table: 21 | * 1. No two entries with same MID 22 | * 2. No gaps (all used entries are consecutive) 23 | * 3. All g_TO_AppData.criticalMid are included in the table 24 | * 25 | * \par Modification History: 26 | * - 2015-01-09 | Guy de Carufel | Code Started 27 | *******************************************************************************/ 28 | #ifndef _TO_TBLDEFS_ 29 | #define _TO_TBLDEFS_ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /******************************************************************************* 36 | ** Includes 37 | *******************************************************************************/ 38 | #include "cfe.h" 39 | #include "to_platform_cfg.h" 40 | 41 | /******************************************************************************* 42 | ** Macro Definitions 43 | *******************************************************************************/ 44 | #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 45 | #define TO_UNUSED_ENTRY ((uint32) 0x00FFFFFF+1) 46 | #define TO_REMOVED_ENTRY ((uint32) 0x00FFFFFF+2) 47 | #else 48 | #define TO_UNUSED_ENTRY 0 49 | #define TO_REMOVED_ENTRY 1 50 | #endif 51 | 52 | /** \name Default Table Size */ 53 | /** \{ */ 54 | #ifndef TO_MAX_TBL_ENTRIES 55 | #define TO_MAX_TBL_ENTRIES 100 56 | #endif 57 | /** \} */ 58 | 59 | /******************************************************************************* 60 | ** Type Definitions 61 | *******************************************************************************/ 62 | /** 63 | ** \brief TO Table Entry for message subscription and routing. 64 | */ 65 | typedef struct 66 | { 67 | CFE_SB_MsgId_t usMsgId; /**< Message ID (must be unique) */ 68 | CFE_SB_Qos_t qos; /**< Quality of Service flag */ 69 | uint16 usMsgLimit; /**< Max Num. of this Msgs in pipe */ 70 | uint16 usRouteMask; /**< Bitwize Route Mask */ 71 | uint32 uiGroupData; /**< Group data Mask */ 72 | uint16 usFlag; /**< Custom defined flag */ 73 | uint16 usState; /**< Message ID is enabled = 1 */ 74 | } TO_TableEntry_t; 75 | 76 | /** 77 | ** \brief TO Table definition 78 | */ 79 | typedef struct 80 | { 81 | TO_TableEntry_t entries[TO_MAX_TBL_ENTRIES]; 82 | } TO_ConfigTable_t; 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | 90 | /*============================================================================== 91 | ** End of file to_tbldefs.h 92 | **============================================================================*/ 93 | -------------------------------------------------------------------------------- /fsw/tables/table_change.sh: -------------------------------------------------------------------------------- 1 | ## This is a test script to load and activate to_config_2.tbl to verify table changes. 2 | ## Notes 3 | ## 1: ValidateChecksum checks in ci_custom.c must not be performed as in UDP example. 4 | ## Since cmdUtil does not compute a checksum for commands sent. 5 | ## 2: Ensure that your criticalMsgIds array does not include message ID that 6 | ## Are not included in the to_config_2.tbl, otherwise table validation will 7 | ## fail. 8 | 9 | 10 | # Load to_config_2.tbl 11 | echo "Step 1: Load the to_config_2.tbl through CFE TBL." 12 | cmdUtil --port=5010 --endian=LE --pktid=0x1804 --cmdcode=2 --string="64:/cf/apps/to_config_2.tbl" 13 | sleep 1 14 | # Verify the new inactive table 15 | echo "Step 2: Verify the new table through CFE_TBL." 16 | cmdUtil --port=5010 --endian=LE --pktid=0x1804 --cmdcode=4 --half=0 --string="40:TO.to_config" 17 | sleep 1 18 | # Activate the new table (CFE TBL will call TO_ManageTable 19 | echo "Step 3: Activate the new table through CFE_TBL." 20 | cmdUtil --port=5010 --endian=LE --pktid=0x1804 --cmdcode=5 --string="40:TO.to_config" 21 | sleep 1 22 | -------------------------------------------------------------------------------- /fsw/tables/to_grpids.h: -------------------------------------------------------------------------------- 1 | /*======================================================================================= 2 | ** File Name: to_grpids.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 | ** Title: Group IDs used by the default TO table 10 | **=====================================================================================*/ 11 | 12 | #ifndef _TO_GRP_IDS_H_ 13 | #define _TO_GRP_IDS_H_ 14 | 15 | /* 16 | ** Pragmas 17 | */ 18 | 19 | /* 20 | ** Include Files 21 | */ 22 | 23 | /* 24 | ** Local Defines 25 | */ 26 | /* Define multigroups as bit. Max is TO_MULTI_GROUP_MASK (default: 24-bits) */ 27 | #define TO_MGROUP_NONE 0 28 | #define TO_MGROUP_ONE 1 29 | #define TO_MGROUP_TWO 1 << 1 30 | #define TO_MGROUP_THREE 1 << 2 31 | #define TO_MGROUP_FOUR 1 << 3 32 | #define TO_MGROUP_FIVE 1 << 4 33 | #define TO_MGROUP_SIX 1 << 5 34 | #define TO_MGROUP_SEVEN 1 << 6 35 | #define TO_MGROUP_EIGHT 1 << 7 36 | #define TO_MGROUP_NINE 1 << 8 37 | #define TO_MGROUP_TEN 1 << 9 38 | 39 | /* Define group as Hex based on TO_GROUP_NUMBER_MASK (default: 0x00 << 24 to 0xff << 24) */ 40 | #define TO_GROUP_NONE 0x00000000 41 | #define TO_GROUP_CFE 0x01000000 42 | #define TO_GROUP_APP 0x02000000 43 | #define TO_GROUP_THREE 0x03000000 44 | 45 | #endif /* _TO_GRP_IDS_H_ */ 46 | 47 | /*======================================================================================= 48 | ** End of file sch_grpids.h 49 | **=====================================================================================*/ 50 | 51 | -------------------------------------------------------------------------------- /fsw/unit_test/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.exe 3 | *.gcov 4 | *.out 5 | *.gcno 6 | -------------------------------------------------------------------------------- /fsw/unit_test/Readme.txt: -------------------------------------------------------------------------------- 1 | This directory holds the unit tests for the TO application. 2 | 3 | To build and run the unit tests: 4 | 1. Be sure an appropriate *_to_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. make clean 9 | 3. make 10 | 4. make run 11 | 5. make gcov 12 | 13 | Background: 14 | The unit tests also expect (like the apps) to find the 15 | apps/inc/CFS_TST_ci_types.h 16 | apps/inc/CFS_TST_to_types.h 17 | where the mission name, CFS_TST, is assumed by default. 18 | 19 | These are put into place by the [ci/to]/fsw/examples/setup.py scripts. 20 | Choose the appropriate name for your code to compile if you aren't 21 | using "CFS_TST". 22 | -------------------------------------------------------------------------------- /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=to 17 | 18 | CFE_PATH = $(CFE_FSW)/cfe-core 19 | OSAL_PATH = $(OSAL_DIR) 20 | PSP_PATH = $(PSP_DIR) 21 | 22 | # 23 | # VPATH specifies the search paths for source files outside of the current directory. Note that 24 | # all object files will be created in the current directory even if the source file is not in the 25 | # current directory. 26 | # 27 | VPATH := ../src 28 | VPATH += ./ut-assert/src 29 | 30 | # 31 | # INCLUDES specifies the search paths for include files outside of the current directory. 32 | # Note that the -I is required. 33 | # 34 | INCLUDES := -I. 35 | INCLUDES += -I.. 36 | INCLUDES += -I../src 37 | INCLUDES += -I../tables 38 | INCLUDES += -I../mission_inc 39 | INCLUDES += -I../platform_inc 40 | INCLUDES += -I../../../inc 41 | #INCLUDES += -I../../../io_lib/fsw/public_inc 42 | INCLUDES += -I./ut-assert/inc 43 | INCLUDES += -I$(CFE_PATH)/os/inc 44 | INCLUDES += -I$(CFE_PATH)/src/inc 45 | INCLUDES += -I$(CFE_PATH)/src/time 46 | INCLUDES += -I$(CFE_PATH)/src/sb 47 | INCLUDES += -I$(CFE_PATH)/src/es 48 | INCLUDES += -I$(CFE_PATH)/src/evs 49 | INCLUDES += -I$(CFE_PATH)/src/fs 50 | INCLUDES += -I$(CFE_PATH)/src/tbl 51 | INCLUDES += -I$(CFE_PATH)/../mission_inc 52 | INCLUDES += -I$(CFE_PATH)/../platform_inc/cpu1 53 | INCLUDES += -I$(OSAL_PATH)/src/os/inc 54 | INCLUDES += -I$(OSAL_PATH)/build/inc 55 | INCLUDES += -I$(OSAL_PATH)/src/bsp/pc-linux/config 56 | INCLUDES += -I$(PSP_PATH)/fsw/inc 57 | INCLUDES += -I$(PSP_PATH)/fsw/pc-linux/inc 58 | 59 | # 60 | # UT_OBJS specifies unit test object files. 61 | # 62 | UT_OBJS := ut_osapi_stubs.o 63 | UT_OBJS += ut_osfileapi_stubs.o 64 | UT_OBJS += ut_cfe_psp_memutils_stubs.o 65 | UT_OBJS += ut_cfe_sb_stubs.o 66 | UT_OBJS += ut_cfe_sb_hooks.o 67 | UT_OBJS += ut_cfe_es_stubs.o 68 | UT_OBJS += ut_cfe_es_hooks.o 69 | UT_OBJS += ut_cfe_evs_stubs.o 70 | UT_OBJS += ut_cfe_evs_hooks.o 71 | UT_OBJS += ut_cfe_tbl_stubs.o 72 | UT_OBJS += ut_cfe_tbl_hooks.o 73 | UT_OBJS += ut_cfe_fs_stubs.o 74 | UT_OBJS += utassert.o 75 | UT_OBJS += utlist.o 76 | UT_OBJS += uttest.o 77 | UT_OBJS += uttools.o 78 | UT_OBJS += $(APP)_testcase.o 79 | UT_OBJS += $(APP)_stubs.o 80 | 81 | # 82 | # APP_OBJS specifies flight software object files. 83 | # 84 | APP_OBJS := $(APP)_app.o $(APP)_utils.o $(APP)_cmds.o 85 | 86 | 87 | ############################################################################### 88 | 89 | COMPILER=gcc 90 | LINKER=gcc 91 | 92 | # 93 | # Compiler and Linker Options 94 | # 95 | ENABLE_GCOV = TRUE 96 | ifeq ($(ENABLE_GCOV), TRUE) 97 | GCOV_COPT = -fprofile-arcs -ftest-coverage -pg -p 98 | GCOV_LOPT = -pg -p -fprofile-arcs -ftest-coverage -lgcov 99 | endif 100 | 101 | #WARNINGS = -Wall -W -ansi -Werror -Wstrict-prototypes -Wundef 102 | WARNINGS = -Wall -Wstrict-prototypes 103 | DEBUGGER = -g 104 | 105 | COPT = $(WARNINGS) $(DEBUGGER) $(GCOV_COPT) -DSOFTWARE_LITTLE_BIT_ORDER -D_EL -D__x86_64__ -DUT_VERBOSE -D_LINUX_OS_ 106 | #COPT = $(WARNINGS) $(DEBUGGER) $(GCOV_COPT) -DSOFTWARE_LITTLE_BIT_ORDER -D_EL -D_ix86_ 107 | 108 | LOPT = $(GCOV_LOPT) 109 | 110 | ############################################################################### 111 | ## Rule to make the specified TARGET 112 | ## 113 | %.exe: %.o 114 | $(LINKER) $(LOPT) $^ -o $*.exe 115 | 116 | ############################################################################### 117 | ## "C" COMPILER RULE 118 | ## 119 | %.o: %.c 120 | $(COMPILER) -c $(COPT) $(INCLUDES) $< 121 | 122 | ############################################################################## 123 | ## 124 | 125 | all:$(APP)_testrunner.exe 126 | 127 | $(APP)_testrunner.exe: $(APP)_testrunner.o $(UT_OBJS) $(APP_OBJS) 128 | 129 | clean :: 130 | rm -f *.o *.exe *.gcda *.gcno *.gcov gmon.out 131 | 132 | run :: 133 | ./$(APP)_testrunner.exe 134 | 135 | #gcov :: 136 | # @echo 137 | # @gcov $(APP_OBJS:.o=.gcda) | sed 'N;s/\n/ /' | \ 138 | # sed -n '/File/p' | sed '/ads/d' | \ 139 | # sed 's/ Lines executed:/ /; s/File/gcov:/; s/of//' 140 | # @rm -f *.gcda *.gcno 141 | # @echo 142 | 143 | gcov :: 144 | @echo 145 | @gcov $(APP_OBJS:.o=.gcda) | sed 'N;s/\n/ /' | \ 146 | sed -n '/File/p' | sed '/ads/d' | sed -e '/\.h/d' | \ 147 | sed 's/ Lines executed:/ /; s/File/gcov:/; s/of// ' 148 | @rm -f *.gcda *.gcno 149 | @echo 150 | 151 | # end of file 152 | -------------------------------------------------------------------------------- /fsw/unit_test/to_mission_cfg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | /** \file to_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 TO 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 _TO_MISSION_CFG_H_ 21 | #define _TO_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 "to_perf_ids.h" 41 | #include "to_msgids.h" 42 | #include "to_msgdefs.h" 43 | 44 | 45 | /* Define enable / disable commands. */ 46 | typedef struct 47 | { 48 | uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; 49 | uint16 usRouteMask; /**< Route Mask to enable */ 50 | } TO_EnableOutputCmd_t; 51 | 52 | 53 | typedef struct 54 | { 55 | uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; 56 | uint16 usRouteMask; /**< Route Mask to enable */ 57 | } TO_DisableOutputCmd_t; 58 | 59 | 60 | typedef struct 61 | { 62 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 63 | uint32 uiCounter; 64 | } TO_OutData_t; 65 | 66 | 67 | typedef struct 68 | { 69 | uint8 ucTlmHeader[CFE_SB_TLM_HDR_SIZE]; 70 | uint16 usCmdCnt; /**< Count of all commands received */ 71 | uint16 usCmdErrCnt; /**< Count of command errors */ 72 | uint16 usMsgSubCnt; /**< Count of subscribed messages by all 73 | telemetry pipe. */ 74 | uint16 usMsgSubErrCnt; /**< Count of subscription errors */ 75 | uint16 usTblUpdateCnt; /**< Count of table updates through CFE_TBL */ 76 | uint16 usTblErrCnt; /**< Count of table update errors */ 77 | uint16 usConfigRoutes; /**< Current mask of configured routes */ 78 | uint16 usEnabledRoutes; /**< Current mask of enabled routes */ 79 | uint16 usPktCnt; /**< Count of packet sent */ 80 | uint16 usPktErrCnt; /**< Count of packet processing errors */ 81 | uint16 usFrameErrCnt; /**< Count of frame errors */ 82 | } TO_HkTlm_t; 83 | 84 | 85 | 86 | /* 87 | ** Local Structure Declarations 88 | */ 89 | 90 | /* 91 | ** External Global Variables 92 | */ 93 | 94 | /* 95 | ** Global Variables 96 | */ 97 | 98 | /* 99 | ** Local Variables 100 | */ 101 | 102 | /* 103 | ** Local Function Prototypes 104 | */ 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /* _TO_MISSION_CFG_H_ */ 111 | 112 | /*============================================================================== 113 | ** End of file to_mission_cfg.h 114 | **============================================================================*/ 115 | 116 | -------------------------------------------------------------------------------- /fsw/unit_test/to_platform_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: to_platform_config.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 | * Platform config for unit test. 11 | * 12 | * History: 13 | * Feb 2, 2016 G. de Carufel 14 | * * 15 | */ 16 | 17 | #ifndef _Ut_TO_PLATFORM_CONFIG_H_ 18 | #define _Ut_TO_PLATFORM_CONFIG_H_ 19 | 20 | /* Overwrite settings */ 21 | #define TO_MAX_TBL_ENTRIES 5 22 | #define TO_NUM_CRITICAL_MIDS 3 23 | #define TO_MAX_WAKEUP_COUNT 3 24 | #define TO_FRAMING_ENABLED 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /fsw/unit_test/to_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: to_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 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "cfe.h" 18 | 19 | #include "to_stubs.h" 20 | #include "to_app.h" 21 | #include "to_cmds.h" 22 | 23 | extern TO_AppData_t g_TO_AppData; 24 | extern void TO_SendDataTypePktCmd(CFE_SB_MsgPtr_t); 25 | int32 Ut_OS_CountSemGetInfoHook(uint32 sem_id, OS_count_sem_prop_t *count_prop); 26 | 27 | Ut_TO_ReturnCodeTable_t Ut_TO_ReturnCodeTable[UT_TO_MAX_INDEX]; 28 | 29 | void Ut_TO_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt) 30 | { 31 | if (Index < UT_TO_MAX_INDEX) { 32 | Ut_TO_ReturnCodeTable[Index].Value = RtnVal; 33 | Ut_TO_ReturnCodeTable[Index].Count = CallCnt; 34 | } 35 | else { 36 | printf("Unsupported Index In SetReturnCode Call %u\n", Index); 37 | } 38 | } 39 | 40 | 41 | boolean Ut_TO_UseReturnCode(uint32 Index) 42 | { 43 | if (Ut_TO_ReturnCodeTable[Index].Count > 0) { 44 | Ut_TO_ReturnCodeTable[Index].Count--; 45 | if (Ut_TO_ReturnCodeTable[Index].Count == 0) 46 | return(TRUE); 47 | } 48 | 49 | return(FALSE); 50 | } 51 | 52 | 53 | 54 | /* Functions normally declared in Custom File (to_custom.c) */ 55 | int32 TO_CustomInit(void) 56 | { 57 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMINIT_INDEX)) 58 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMINIT_INDEX].Value; 59 | 60 | /* Set Critical Message Ids which must always be in config table. */ 61 | g_TO_AppData.criticalMid[0] = TO_HK_TLM_MID; 62 | 63 | /* Route 0: Udp. Linked to CF Channel Index 0. */ 64 | g_TO_AppData.routes[0].usExists = 1; 65 | g_TO_AppData.routes[0].sCfChnlIdx = 0; 66 | 67 | return TO_SUCCESS; 68 | } 69 | 70 | 71 | int32 TO_CustomAppCmds(CFE_SB_MsgPtr_t pCmdMsg) 72 | { 73 | uint32 uiCmdCode = CFE_SB_GetCmdCode(pCmdMsg); 74 | 75 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMAPPCMDS_INDEX)) 76 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMAPPCMDS_INDEX].Value; 77 | 78 | switch (uiCmdCode) 79 | { 80 | case TO_SEND_DATA_TYPE_CC: 81 | TO_SendDataTypePktCmd(pCmdMsg); 82 | break; 83 | 84 | default: 85 | g_TO_AppData.HkTlm.usCmdCnt++; 86 | CFE_EVS_SendEvent(TO_CMD_INF_EID, CFE_EVS_INFORMATION, 87 | "Received Custom Cmd (%d)", 88 | uiCmdCode); 89 | break; 90 | } 91 | 92 | return TO_SUCCESS; 93 | } 94 | 95 | 96 | /* This implementation simply outputs packet to console by default. */ 97 | int32 TO_CustomProcessData(CFE_SB_MsgPtr_t pTlmMsg, int32 size, int32 tblIdx, 98 | uint16 usRouteId) 99 | { 100 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMPROCESSDATA_INDEX)) 101 | { 102 | g_TO_AppData.HkTlm.usPktErrCnt++; 103 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMPROCESSDATA_INDEX].Value; 104 | } 105 | 106 | g_TO_AppData.HkTlm.usPktCnt++; 107 | UtPrintf("Packet added to frame %u: ", usRouteId); 108 | UtPrintx(pTlmMsg, size); 109 | 110 | return TO_SUCCESS; 111 | } 112 | 113 | int32 TO_CustomFrameStart(uint16 usRouteId) 114 | { 115 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMFRAMESTART_INDEX)) 116 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMFRAMESTART_INDEX].Value; 117 | 118 | return TO_SUCCESS; 119 | } 120 | 121 | 122 | int32 TO_CustomFrameSend(uint16 usRouteId, int32 iStatus) 123 | { 124 | if (iStatus == TO_ERROR) 125 | { 126 | g_TO_AppData.HkTlm.usFrameErrCnt++; 127 | return iStatus; 128 | } 129 | 130 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMFRAMESEND_INDEX)) 131 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMFRAMESEND_INDEX].Value; 132 | 133 | printf("Frame Sent on route %u.\n", usRouteId); 134 | 135 | return TO_SUCCESS; 136 | } 137 | 138 | 139 | 140 | void TO_CustomCleanup(void) 141 | { 142 | return; 143 | } 144 | 145 | /* Simple set whichever route is received as configured */ 146 | int32 TO_CustomEnableOutputCmd(CFE_SB_MsgPtr_t pCmdMsg) 147 | { 148 | TO_EnableOutputCmd_t * pCustomCmd = (TO_EnableOutputCmd_t *) pCmdMsg; 149 | int32 routeMask = TO_ERROR; 150 | 151 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMENABLEOUTPUTCMD_INDEX)) 152 | return Ut_TO_ReturnCodeTable[UT_TO_CUSTOMENABLEOUTPUTCMD_INDEX].Value; 153 | 154 | if (pCustomCmd->usRouteMask & (1<<0)) 155 | { 156 | routeMask |= (1<<0); 157 | TO_SetRouteAsConfigured(0); 158 | } 159 | if (pCustomCmd->usRouteMask & (1<<1)) 160 | { 161 | routeMask |= (1<<1); 162 | TO_SetRouteAsConfigured(1); 163 | } 164 | 165 | return routeMask; 166 | } 167 | 168 | int32 TO_CustomDisableOutputCmd(CFE_SB_Msg_t *pCmdMsg) 169 | { 170 | TO_DisableOutputCmd_t *pCmd = (TO_DisableOutputCmd_t *) pCmdMsg; 171 | 172 | int32 value; 173 | if (Ut_TO_UseReturnCode(UT_TO_CUSTOMDISABLEOUTPUTCMD_INDEX)) 174 | { 175 | value = Ut_TO_ReturnCodeTable[UT_TO_CUSTOMDISABLEOUTPUTCMD_INDEX].Value; 176 | if (value < 0) 177 | { 178 | g_TO_AppData.HkTlm.usCmdErrCnt++; 179 | } 180 | return value; 181 | } 182 | 183 | g_TO_AppData.usOutputEnabled = 0; 184 | 185 | return pCmd->usRouteMask; 186 | } 187 | 188 | int32 Ut_OS_CountSemGetInfoHook(uint32 sem_id, OS_count_sem_prop_t *count_prop) 189 | { 190 | (void) sem_id; 191 | 192 | count_prop->value = 0; 193 | return OS_SUCCESS; 194 | } 195 | 196 | -------------------------------------------------------------------------------- /fsw/unit_test/to_stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: to_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 TO 11 | * 12 | * History: 13 | * Feb 2, 2016 G. de Carufel 14 | * * 15 | */ 16 | 17 | #ifndef _Ut_TO_STUBS_H_ 18 | #define _Ut_TO_STUBS_H_ 19 | 20 | #include "uttools.h" 21 | 22 | typedef enum 23 | { 24 | UT_TO_CUSTOMINIT_INDEX, 25 | UT_TO_CUSTOMAPPCMDS_INDEX, 26 | UT_TO_CUSTOMPROCESSDATA_INDEX, 27 | UT_TO_CUSTOMENABLEOUTPUTCMD_INDEX, 28 | UT_TO_CUSTOMDISABLEOUTPUTCMD_INDEX, 29 | UT_TO_CUSTOMFRAMESTART_INDEX, 30 | UT_TO_CUSTOMFRAMESEND_INDEX, 31 | UT_TO_MAX_INDEX 32 | } Ut_TO_INDEX_t; 33 | 34 | typedef struct 35 | { 36 | int32 Value; 37 | uint32 Count; 38 | } Ut_TO_ReturnCodeTable_t; 39 | 40 | 41 | void Ut_TO_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 42 | boolean Ut_TO_UseReturnCode(uint32 Index); 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /fsw/unit_test/to_testrunner.c: -------------------------------------------------------------------------------- 1 | 2 | void TO_AddTestCase(void); 3 | 4 | /* 5 | * Filename: to_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 | TO_AddTestCase(); 30 | return(UtTest_Run()); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/UT_Tool_Users_Guide.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/UT_Tool_Users_Guide.doc -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/Ut Users Guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/Ut Users Guide.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/Writing Better Unit Tests.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/Writing Better Unit Tests.ppt -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut Design.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/ut Design.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut Requirements.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/ut Requirements.docx -------------------------------------------------------------------------------- /fsw/unit_test/ut-assert/doc/ut_design.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/CFS_TO/4589edb05c0d61d5e1661b4502f13795a96a1737/fsw/unit_test/ut-assert/doc/ut_design.ppt -------------------------------------------------------------------------------- /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/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/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/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_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/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/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/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/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_RELEASEADDRESS_INDEX, 43 | UT_CFE_TBL_NOTIFYBYMESSAGE_INDEX, 44 | UT_CFE_TBL_MAX_INDEX 45 | } Ut_CFE_TBL_INDEX_t; 46 | 47 | typedef struct 48 | { 49 | int32 (*CFE_TBL_Register)(CFE_TBL_Handle_t*, const char *,uint32, uint16, CFE_TBL_CallbackFuncPtr_t); 50 | int32 (*CFE_TBL_Load)(CFE_TBL_Handle_t, CFE_TBL_SrcEnum_t, const void *); 51 | int32 (*CFE_TBL_Manage)(CFE_TBL_Handle_t); 52 | int32 (*CFE_TBL_GetAddress)(void **, CFE_TBL_Handle_t); 53 | int32 (*CFE_TBL_GetAddresses)(void **[], uint16, const CFE_TBL_Handle_t []); 54 | int32 (*CFE_TBL_GetInfo)(CFE_TBL_Info_t *TblInfoPtr, const char *TblName); 55 | int32 (*CFE_TBL_NotifyByMessage)(CFE_TBL_Handle_t TblHandle, uint32 MsgId, uint16 CommandCode, uint32 Parameter); 56 | } Ut_CFE_TBL_HookTable_t; 57 | 58 | typedef struct 59 | { 60 | int32 Value; 61 | uint32 Count; 62 | } Ut_CFE_TBL_ReturnCodeTable_t; 63 | 64 | void Ut_CFE_TBL_Reset(void); 65 | void Ut_CFE_TBL_SetFunctionHook(uint32 Index, void *FunPtr); 66 | void Ut_CFE_TBL_SetReturnCode(uint32 Index, int32 RtnVal, uint32 CallCnt); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /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/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, const 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/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/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/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/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/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/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/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/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/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_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/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_GetAddresses( void **TblPtrs[], 150 | uint16 NumTables, 151 | const CFE_TBL_Handle_t TblHandles[] ) 152 | { 153 | /* Check for specified return */ 154 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETADDRESSES_INDEX)) 155 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETADDRESSES_INDEX].Value; 156 | 157 | /* Check for Function Hook */ 158 | if (Ut_CFE_TBL_HookTable.CFE_TBL_GetAddresses) 159 | return(Ut_CFE_TBL_HookTable.CFE_TBL_GetAddresses(TblPtrs, NumTables, TblHandles)); 160 | 161 | return CFE_SUCCESS; 162 | } 163 | 164 | int32 CFE_TBL_ReleaseAddress( CFE_TBL_Handle_t TblHandle ) 165 | { 166 | /* Check for specified return */ 167 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_RELEASEADDRESS_INDEX)) 168 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_RELEASEADDRESS_INDEX].Value; 169 | 170 | return CFE_SUCCESS; 171 | } 172 | 173 | 174 | int32 CFE_TBL_ReleaseAddresses( uint16 NumTables, 175 | const CFE_TBL_Handle_t TblHandles[] ) 176 | { 177 | return CFE_SUCCESS; 178 | } 179 | 180 | int32 CFE_TBL_Validate( CFE_TBL_Handle_t TblHandle ) 181 | { 182 | return CFE_SUCCESS; 183 | } 184 | 185 | int32 CFE_TBL_Manage( CFE_TBL_Handle_t TblHandle ) 186 | { 187 | /* Check for specified return */ 188 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_MANAGE_INDEX)) 189 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_MANAGE_INDEX].Value; 190 | 191 | /* Check for Function Hook */ 192 | if (Ut_CFE_TBL_HookTable.CFE_TBL_Manage) 193 | return(Ut_CFE_TBL_HookTable.CFE_TBL_Manage(TblHandle)); 194 | 195 | return CFE_SUCCESS; 196 | } 197 | 198 | int32 CFE_TBL_GetStatus( CFE_TBL_Handle_t TblHandle ) 199 | { 200 | /* Check for specified return */ 201 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETSTATUS_INDEX)) 202 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETSTATUS_INDEX].Value; 203 | 204 | return CFE_SUCCESS; 205 | } 206 | 207 | int32 CFE_TBL_GetInfo( CFE_TBL_Info_t *TblInfoPtr, const char *TblName ) 208 | { 209 | /* Check for specified return */ 210 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_GETINFO_INDEX)) 211 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_GETINFO_INDEX].Value; 212 | 213 | /* Check for Function Hook */ 214 | if (Ut_CFE_TBL_HookTable.CFE_TBL_GetInfo) 215 | return(Ut_CFE_TBL_HookTable.CFE_TBL_GetInfo(TblInfoPtr, TblName)); 216 | 217 | return CFE_SUCCESS; 218 | } 219 | 220 | int32 CFE_TBL_DumpToBuffer( CFE_TBL_Handle_t TblHandle ) 221 | { 222 | return CFE_SUCCESS; 223 | } 224 | 225 | int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle ) 226 | { 227 | return CFE_SUCCESS; 228 | } 229 | 230 | int32 CFE_TBL_CleanUpApp (uint32 AppId) 231 | { 232 | return CFE_SUCCESS; 233 | } 234 | 235 | 236 | int32 CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, uint32 MsgId, uint16 CommandCode, uint32 Parameter) 237 | { 238 | /* Check for specified return */ 239 | if (Ut_CFE_TBL_UseReturnCode(UT_CFE_TBL_NOTIFYBYMESSAGE_INDEX)) 240 | return Ut_CFE_TBL_ReturnCodeTable[UT_CFE_TBL_NOTIFYBYMESSAGE_INDEX].Value; 241 | 242 | /* Check for Function Hook */ 243 | if (Ut_CFE_TBL_HookTable.CFE_TBL_NotifyByMessage) 244 | return (Ut_CFE_TBL_HookTable.CFE_TBL_NotifyByMessage(TblHandle, MsgId, CommandCode, Parameter)); 245 | 246 | return CFE_SUCCESS; 247 | } 248 | -------------------------------------------------------------------------------- /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/src/ut_osfileapi_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ut_osfileapi_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_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/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/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/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/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 | --------------------------------------------------------------------------------