├── CMakeLists.txt ├── LICENSE ├── README.md └── fsw ├── platform_inc └── skeleton_app_msgids.h └── src ├── skeleton_app.c ├── skeleton_app.h ├── skeleton_app_events.h ├── skeleton_app_msg.h └── skeleton_app_version.h /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6.4) 2 | project(CFE_SKELETON_APP C) 3 | 4 | include_directories(fsw/mission_inc) 5 | include_directories(fsw/platform_inc) 6 | 7 | aux_source_directory(fsw/src APP_SRC_FILES) 8 | 9 | # Create the app module 10 | add_cfe_app(skeleton_app ${APP_SRC_FILES}) 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Core Flight System : Framework : App : Sample 2 | 3 | This repository contains a sample application (sample_app), which is a framework component of the Core Flight System. 4 | 5 | This sample application is a non-flight example application implementation for the cFS Bundle. It is intended to be located in the `apps/sample_app` subdirectory of a cFS Mission Tree. The Core Flight System is bundled at https://github.com/nasa/cFS (which includes sample_app as a submodule), which includes build and execution instructions. 6 | 7 | sample_app is an example for how to build and link an application in cFS. 8 | 9 | ## Version Notes 10 | - 1.1.5 11 | - Fix to build on RASPBIAN OS 12 | - Minor updates (see https://github.com/nasa/sample_app/pull/47) 13 | - 1.1.4 14 | - Fix for a clean build with OMIT_DEPRECATED 15 | - Minor updates (see https://github.com/nasa/sample_app/pull/44) 16 | - 1.1.3 17 | - Minor updates (see https://github.com/nasa/sample_app/pull/34) 18 | - 1.1.2 19 | - Minor updates (see https://github.com/nasa/sample_app/pull/20) 20 | - 1.1.1 21 | - Minor updates (see https://github.com/nasa/sample_app/pull/15) 22 | - **1.1.0 OFFICIAL RELEASE**: 23 | - Minor updates (see https://github.com/nasa/sample_app/pull/11) 24 | - Not backwards compatible with OSAL 4.2.1 25 | - Released as part of cFE 6.7.0, Apache 2.0 26 | - **1.0.0a OFFICIAL RELEASE**: 27 | - Released as part of cFE 6.6.0a, Apache 2.0 28 | 29 | ## Known issues 30 | 31 | As a sample application, extensive testing is not performed prior to release and only minimal functionality is included. Note discrepancies likely exist between this application and the example detailed in the application developer guide. 32 | 33 | ## Getting Help 34 | 35 | For best results, submit issues:questions or issues:help wanted requests at https://github.com/nasa/cFS. 36 | 37 | Official cFS page: http://cfs.gsfc.nasa.gov 38 | -------------------------------------------------------------------------------- /fsw/platform_inc/skeleton_app_msgids.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app_msgids.h 22 | ** 23 | ** Purpose: 24 | ** Define Skeleton App Message IDs 25 | ** 26 | ** Notes: 27 | ** 28 | ** 29 | *************************************************************************/ 30 | #ifndef _skeleton_app_msgids_h_ 31 | #define _skeleton_app_msgids_h_ 32 | 33 | #define SKELETON_APP_CMD_MID 0x1882 34 | #define SKELETON_APP_SEND_HK_MID 0x1883 35 | #define SKELETON_APP_HK_TLM_MID 0x0883 36 | 37 | #endif /* _skeleton_app_msgids_h_ */ 38 | 39 | /************************/ 40 | /* End of File Comment */ 41 | /************************/ 42 | -------------------------------------------------------------------------------- /fsw/src/skeleton_app.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app.c 22 | ** 23 | ** Purpose: 24 | ** This file contains the source code for a skeleton application that does 25 | ** nothing and is the minimum required for a valid cFS application. 26 | ** 27 | *******************************************************************************/ 28 | 29 | /* 30 | ** Include Files: 31 | */ 32 | #include "skeleton_app_events.h" 33 | #include "skeleton_app_version.h" 34 | #include "skeleton_app.h" 35 | 36 | #include 37 | 38 | /* 39 | ** global data 40 | */ 41 | SKELETON_AppData_t SKELETON_AppData; 42 | 43 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 44 | /* SKELETON_AppMain() -- Application entry point and main process loop */ 45 | /* */ 46 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 47 | void SKELETON_AppMain( void ) 48 | { 49 | int32 status; 50 | 51 | /* 52 | ** Register the app with Executive services 53 | */ 54 | CFE_ES_RegisterApp(); 55 | 56 | /* 57 | ** Perform application specific initialization 58 | ** If the Initialization fails, set the RunStatus to 59 | ** CFE_ES_RunStatus_APP_ERROR and the App will not enter the RunLoop 60 | */ 61 | status = SKELETON_AppInit(); 62 | if (status != CFE_SUCCESS) 63 | { 64 | SKELETON_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; 65 | } 66 | 67 | /* 68 | ** SKELETON Runloop 69 | */ 70 | while (CFE_ES_RunLoop(&SKELETON_AppData.RunStatus) == true) 71 | { 72 | status = CFE_SB_RcvMsg(&SKELETON_AppData.MsgPtr, 73 | SKELETON_AppData.CommandPipe, 74 | CFE_SB_PEND_FOREVER); 75 | 76 | 77 | if (status == CFE_SUCCESS) 78 | { 79 | SKELETON_ProcessCommandPacket(SKELETON_AppData.MsgPtr); 80 | } 81 | else 82 | { 83 | CFE_EVS_SendEvent(SKELETON_PIPE_ERR_EID, 84 | CFE_EVS_EventType_ERROR, 85 | "SKELETON APP: SB Pipe Read Error, App Will Exit"); 86 | 87 | SKELETON_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; 88 | } 89 | 90 | } 91 | 92 | CFE_ES_ExitApp(SKELETON_AppData.RunStatus); 93 | 94 | } /* End of SKELETON_AppMain() */ 95 | 96 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 97 | /* */ 98 | /* SKELETON_AppInit() -- initialization */ 99 | /* */ 100 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 101 | int32 SKELETON_AppInit( void ) 102 | { 103 | int32 status; 104 | 105 | SKELETON_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN; 106 | 107 | /* 108 | ** Initialize app command execution counters 109 | */ 110 | SKELETON_AppData.CmdCounter = 0; 111 | SKELETON_AppData.ErrCounter = 0; 112 | 113 | /* 114 | ** Initialize app configuration data 115 | */ 116 | SKELETON_AppData.PipeDepth = SKELETON_PIPE_DEPTH; 117 | 118 | strcpy(SKELETON_AppData.PipeName, "SKELETON_CMD_PIPE"); 119 | 120 | /* 121 | ** Register the events 122 | */ 123 | if ((status = CFE_EVS_Register(NULL, 0, 0)) != CFE_SUCCESS) 124 | { 125 | CFE_ES_WriteToSysLog("Skeleton App: Error Registering Events, RC = %lu\n", 126 | (unsigned long)status); 127 | return ( status ); 128 | } 129 | 130 | /* 131 | ** Initialize housekeeping packet (clear user data area). 132 | */ 133 | CFE_SB_InitMsg(&SKELETON_AppData.HkBuf.MsgHdr, 134 | SKELETON_APP_HK_TLM_MID, 135 | sizeof(SKELETON_AppData.HkBuf), 136 | true); 137 | 138 | /* 139 | ** Create Software Bus message pipe. 140 | */ 141 | status = CFE_SB_CreatePipe(&SKELETON_AppData.CommandPipe, 142 | SKELETON_AppData.PipeDepth, 143 | SKELETON_AppData.PipeName); 144 | if (status != CFE_SUCCESS) 145 | { 146 | CFE_ES_WriteToSysLog("Skeleton App: Error creating pipe, RC = 0x%08lX\n", 147 | (unsigned long)status); 148 | return ( status ); 149 | } 150 | 151 | /* 152 | ** Subscribe to Housekeeping request commands 153 | */ 154 | status = CFE_SB_Subscribe(SKELETON_APP_SEND_HK_MID, 155 | SKELETON_AppData.CommandPipe); 156 | if (status != CFE_SUCCESS) 157 | { 158 | CFE_ES_WriteToSysLog("Skeleton App: Error Subscribing to HK request, RC = 0x%08lX\n", 159 | (unsigned long)status); 160 | return ( status ); 161 | } 162 | 163 | /* 164 | ** Subscribe to ground command packets 165 | */ 166 | status = CFE_SB_Subscribe(SKELETON_APP_CMD_MID, 167 | SKELETON_AppData.CommandPipe); 168 | if (status != CFE_SUCCESS ) 169 | { 170 | CFE_ES_WriteToSysLog("Skeleton App: Error Subscribing to Command, RC = 0x%08lX\n", 171 | (unsigned long)status); 172 | 173 | return ( status ); 174 | } 175 | 176 | CFE_EVS_SendEvent (SKELETON_STARTUP_INF_EID, 177 | CFE_EVS_EventType_INFORMATION, 178 | "SKELETON App Initialized. Version %d.%d.%d.%d", 179 | SKELETON_APP_MAJOR_VERSION, 180 | SKELETON_APP_MINOR_VERSION, 181 | SKELETON_APP_REVISION, 182 | SKELETON_APP_MISSION_REV); 183 | 184 | return ( CFE_SUCCESS ); 185 | 186 | } /* End of SKELETON_AppInit() */ 187 | 188 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 189 | /* Name: SKELETON_ProcessCommandPacket */ 190 | /* */ 191 | /* Purpose: */ 192 | /* This routine will process any packet that is received on the SKELETON */ 193 | /* command pipe. */ 194 | /* */ 195 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 196 | void SKELETON_ProcessCommandPacket( CFE_SB_MsgPtr_t Msg ) 197 | { 198 | CFE_SB_MsgId_t MsgId; 199 | 200 | MsgId = CFE_SB_GetMsgId(Msg); 201 | 202 | switch (MsgId) 203 | { 204 | case SKELETON_APP_CMD_MID: 205 | SKELETON_ProcessGroundCommand(Msg); 206 | break; 207 | 208 | case SKELETON_APP_SEND_HK_MID: 209 | SKELETON_ReportHousekeeping((CCSDS_CommandPacket_t *)Msg); 210 | break; 211 | 212 | default: 213 | CFE_EVS_SendEvent(SKELETON_INVALID_MSGID_ERR_EID, 214 | CFE_EVS_EventType_ERROR, 215 | "SKELETON: invalid command packet,MID = 0x%x", 216 | MsgId); 217 | break; 218 | } 219 | 220 | return; 221 | 222 | } /* End SKELETON_ProcessCommandPacket */ 223 | 224 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 225 | /* */ 226 | /* SKELETON_ProcessGroundCommand() -- SKELETON ground commands */ 227 | /* */ 228 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 229 | void SKELETON_ProcessGroundCommand( CFE_SB_MsgPtr_t Msg ) 230 | { 231 | uint16 CommandCode; 232 | 233 | CommandCode = CFE_SB_GetCmdCode(Msg); 234 | 235 | /* 236 | ** Process "known" SKELETON app ground commands 237 | */ 238 | switch (CommandCode) 239 | { 240 | case SKELETON_APP_NOOP_CC: 241 | if (SKELETON_VerifyCmdLength(Msg, sizeof(SKELETON_Noop_t))) 242 | { 243 | SKELETON_Noop((SKELETON_Noop_t *)Msg); 244 | } 245 | 246 | break; 247 | 248 | case SKELETON_APP_RESET_COUNTERS_CC: 249 | if (SKELETON_VerifyCmdLength(Msg, sizeof(SKELETON_ResetCounters_t))) 250 | { 251 | SKELETON_ResetCounters((SKELETON_ResetCounters_t *)Msg); 252 | } 253 | 254 | break; 255 | 256 | case SKELETON_APP_PROCESS_CC: 257 | if (SKELETON_VerifyCmdLength(Msg, sizeof(SKELETON_Process_t))) 258 | { 259 | SKELETON_Process((SKELETON_Process_t *)Msg); 260 | } 261 | 262 | break; 263 | 264 | /* default case already found during FC vs length test */ 265 | default: 266 | CFE_EVS_SendEvent(SKELETON_COMMAND_ERR_EID, 267 | CFE_EVS_EventType_ERROR, 268 | "Invalid ground command code: CC = %d", 269 | CommandCode); 270 | break; 271 | } 272 | 273 | return; 274 | 275 | } /* End of SKELETON_ProcessGroundCommand() */ 276 | 277 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 278 | /* Name: SKELETON_ReportHousekeeping */ 279 | /* */ 280 | /* Purpose: */ 281 | /* This function is triggered in response to a task telemetry request */ 282 | /* from the housekeeping task. This function will gather the Apps */ 283 | /* telemetry, packetize it and send it to the housekeeping task via */ 284 | /* the software bus */ 285 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 286 | int32 SKELETON_ReportHousekeeping( const CCSDS_CommandPacket_t *Msg ) 287 | { 288 | /* 289 | ** Get command execution counters... 290 | */ 291 | SKELETON_AppData.HkBuf.HkTlm.Payload.CommandErrorCounter = SKELETON_AppData.ErrCounter; 292 | SKELETON_AppData.HkBuf.HkTlm.Payload.CommandCounter = SKELETON_AppData.CmdCounter; 293 | 294 | /* 295 | ** Send housekeeping telemetry packet... 296 | */ 297 | CFE_SB_TimeStampMsg(&SKELETON_AppData.HkBuf.MsgHdr); 298 | CFE_SB_SendMsg(&SKELETON_AppData.HkBuf.MsgHdr); 299 | 300 | return CFE_SUCCESS; 301 | 302 | } /* End of SKELETON_ReportHousekeeping() */ 303 | 304 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 305 | /* */ 306 | /* SKELETON_Noop -- SKELETON NOOP commands */ 307 | /* */ 308 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 309 | int32 SKELETON_Noop( const SKELETON_Noop_t *Msg ) 310 | { 311 | 312 | SKELETON_AppData.CmdCounter++; 313 | 314 | CFE_EVS_SendEvent(SKELETON_COMMANDNOP_INF_EID, 315 | CFE_EVS_EventType_INFORMATION, 316 | "SKELETON: NOOP command Version %d.%d.%d.%d", 317 | SKELETON_APP_MAJOR_VERSION, 318 | SKELETON_APP_MINOR_VERSION, 319 | SKELETON_APP_REVISION, 320 | SKELETON_APP_MISSION_REV); 321 | 322 | return CFE_SUCCESS; 323 | 324 | } /* End of SKELETON_Noop */ 325 | 326 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 327 | /* Name: SKELETON_ResetCounters */ 328 | /* */ 329 | /* Purpose: */ 330 | /* This function resets all the global counter variables that are */ 331 | /* part of the task telemetry. */ 332 | /* */ 333 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 334 | int32 SKELETON_ResetCounters( const SKELETON_ResetCounters_t *Msg ) 335 | { 336 | 337 | SKELETON_AppData.CmdCounter = 0; 338 | SKELETON_AppData.ErrCounter = 0; 339 | 340 | CFE_EVS_SendEvent(SKELETON_COMMANDRST_INF_EID, 341 | CFE_EVS_EventType_INFORMATION, 342 | "SKELETON: RESET command"); 343 | 344 | return CFE_SUCCESS; 345 | 346 | } /* End of SKELETON_ResetCounters() */ 347 | 348 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 349 | /* Name: SKELETON_Process */ 350 | /* */ 351 | /* Purpose: */ 352 | /* This function Process Ground Station Command */ 353 | /* */ 354 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 355 | int32 SKELETON_Process( const SKELETON_Process_t *Msg ) 356 | { 357 | return CFE_SUCCESS; 358 | 359 | } /* End of SKELETON_ProcessCC */ 360 | 361 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 362 | /* */ 363 | /* SKELETON_VerifyCmdLength() -- Verify command packet length */ 364 | /* */ 365 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ 366 | bool SKELETON_VerifyCmdLength( CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength ) 367 | { 368 | bool result = true; 369 | 370 | uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); 371 | 372 | /* 373 | ** Verify the command packet length. 374 | */ 375 | if (ExpectedLength != ActualLength) 376 | { 377 | CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(Msg); 378 | uint16 CommandCode = CFE_SB_GetCmdCode(Msg); 379 | 380 | CFE_EVS_SendEvent(SKELETON_LEN_ERR_EID, 381 | CFE_EVS_EventType_ERROR, 382 | "Invalid Msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d", 383 | MessageID, 384 | CommandCode, 385 | ActualLength, 386 | ExpectedLength); 387 | 388 | result = false; 389 | 390 | SKELETON_AppData.ErrCounter++; 391 | } 392 | 393 | return( result ); 394 | 395 | } /* End of SKELETON_VerifyCmdLength() */ 396 | -------------------------------------------------------------------------------- /fsw/src/skeleton_app.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app.h 22 | ** 23 | ** Purpose: 24 | ** This file is main hdr file for the SKELETON application. 25 | ** 26 | ** 27 | *******************************************************************************/ 28 | 29 | #ifndef _skeleton_app_h_ 30 | #define _skeleton_app_h_ 31 | 32 | /* 33 | ** Required header files. 34 | */ 35 | #include "cfe.h" 36 | #include "cfe_error.h" 37 | #include "cfe_evs.h" 38 | #include "cfe_sb.h" 39 | #include "cfe_es.h" 40 | 41 | #include "skeleton_app_msgids.h" 42 | #include "skeleton_app_msg.h" 43 | 44 | /***********************************************************************/ 45 | #define SKELETON_PIPE_DEPTH 32 /* Depth of the Command Pipe for Application */ 46 | 47 | /************************************************************************ 48 | ** Type Definitions 49 | *************************************************************************/ 50 | 51 | /* 52 | * Buffer to hold telemetry data prior to sending 53 | * Defined as a union to ensure proper alignment for a CFE_SB_Msg_t type 54 | */ 55 | typedef union 56 | { 57 | CFE_SB_Msg_t MsgHdr; 58 | SKELETON_HkTlm_t HkTlm; 59 | } SKELETON_HkBuffer_t; 60 | 61 | /* 62 | ** Global Data 63 | */ 64 | typedef struct 65 | { 66 | /* 67 | ** Command interface counters... 68 | */ 69 | uint8 CmdCounter; 70 | uint8 ErrCounter; 71 | 72 | /* 73 | ** Housekeeping telemetry packet... 74 | */ 75 | SKELETON_HkBuffer_t HkBuf; 76 | 77 | /* 78 | ** Run Status variable used in the main processing loop 79 | */ 80 | uint32 RunStatus; 81 | 82 | /* 83 | ** Operational data (not reported in housekeeping)... 84 | */ 85 | CFE_SB_PipeId_t CommandPipe; 86 | CFE_SB_MsgPtr_t MsgPtr; 87 | 88 | /* 89 | ** Initialization data (not reported in housekeeping)... 90 | */ 91 | char PipeName[16]; 92 | uint16 PipeDepth; 93 | } SKELETON_AppData_t; 94 | 95 | /****************************************************************************/ 96 | /* 97 | ** Local function prototypes. 98 | ** 99 | ** Note: Except for the entry point (SKELETON_AppMain), these 100 | ** functions are not called from any other source module. 101 | */ 102 | void SKELETON_AppMain(void); 103 | int32 SKELETON_AppInit(void); 104 | void SKELETON_ProcessCommandPacket(CFE_SB_MsgPtr_t Msg); 105 | void SKELETON_ProcessGroundCommand(CFE_SB_MsgPtr_t Msg); 106 | int32 SKELETON_ReportHousekeeping(const CCSDS_CommandPacket_t *Msg); 107 | int32 SKELETON_ResetCounters(const SKELETON_ResetCounters_t *Msg); 108 | int32 SKELETON_Process(const SKELETON_Process_t *Msg); 109 | int32 SKELETON_Noop(const SKELETON_Noop_t *Msg); 110 | void SKELETON_GetCrc(const char *TableName); 111 | bool SKELETON_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength); 112 | 113 | #endif /* _skeleton_app_h_ */ 114 | -------------------------------------------------------------------------------- /fsw/src/skeleton_app_events.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app_events.h 22 | ** 23 | ** Purpose: 24 | ** Define skeleton app Events IDs 25 | ** 26 | ** Notes: 27 | ** 28 | *************************************************************************/ 29 | #ifndef _skeleton_app_events_h_ 30 | #define _skeleton_app_events_h_ 31 | 32 | 33 | #define SKELETON_RESERVED_EID 0 34 | #define SKELETON_STARTUP_INF_EID 1 35 | #define SKELETON_COMMAND_ERR_EID 2 36 | #define SKELETON_COMMANDNOP_INF_EID 3 37 | #define SKELETON_COMMANDRST_INF_EID 4 38 | #define SKELETON_INVALID_MSGID_ERR_EID 5 39 | #define SKELETON_LEN_ERR_EID 6 40 | #define SKELETON_PIPE_ERR_EID 7 41 | 42 | #endif /* _skeleton_app_events_h_ */ 43 | 44 | /************************/ 45 | /* End of File Comment */ 46 | /************************/ 47 | -------------------------------------------------------------------------------- /fsw/src/skeleton_app_msg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app_msg.h 22 | ** 23 | ** Purpose: 24 | ** Define SKELETON App Messages and info 25 | ** 26 | ** Notes: 27 | ** 28 | ** 29 | *******************************************************************************/ 30 | #ifndef _skeleton_app_msg_h_ 31 | #define _skeleton_app_msg_h_ 32 | 33 | /* 34 | ** SKELETON App command codes 35 | */ 36 | #define SKELETON_APP_NOOP_CC 0 37 | #define SKELETON_APP_RESET_COUNTERS_CC 1 38 | #define SKELETON_APP_PROCESS_CC 2 39 | 40 | /*************************************************************************/ 41 | 42 | /* 43 | ** Type definition (generic "no arguments" command) 44 | */ 45 | typedef struct 46 | { 47 | uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE]; 48 | 49 | } SKELETON_NoArgsCmd_t; 50 | 51 | /* 52 | ** The following commands all share the "NoArgs" format 53 | ** 54 | ** They are each given their own type name matching the command name, which_open_mode 55 | ** allows them to change independently in the future without changing the prototype 56 | ** of the handler function 57 | */ 58 | typedef SKELETON_NoArgsCmd_t SKELETON_Noop_t; 59 | typedef SKELETON_NoArgsCmd_t SKELETON_ResetCounters_t; 60 | typedef SKELETON_NoArgsCmd_t SKELETON_Process_t; 61 | 62 | /*************************************************************************/ 63 | /* 64 | ** Type definition (SKELETON App housekeeping) 65 | */ 66 | 67 | typedef struct 68 | { 69 | uint8 CommandErrorCounter; 70 | uint8 CommandCounter; 71 | uint8 spare[2]; 72 | } SKELETON_HkTlm_Payload_t; 73 | 74 | typedef struct 75 | { 76 | uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; 77 | SKELETON_HkTlm_Payload_t Payload; 78 | 79 | } OS_PACK SKELETON_HkTlm_t; 80 | 81 | #endif /* _skeleton_app_msg_h_ */ 82 | 83 | /************************/ 84 | /* End of File Comment */ 85 | /************************/ 86 | -------------------------------------------------------------------------------- /fsw/src/skeleton_app_version.h: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | ** 3 | ** GSC-18128-1, "Core Flight Executive Version 6.7" 4 | ** 5 | ** Copyright (c) 2006-2019 United States Government as represented by 6 | ** the Administrator of the National Aeronautics and Space Administration. 7 | ** All Rights Reserved. 8 | ** 9 | ** Licensed under the Apache License, Version 2.0 (the "License"); 10 | ** you may not use this file except in compliance with the License. 11 | ** You may obtain a copy of the License at 12 | ** 13 | ** http://www.apache.org/licenses/LICENSE-2.0 14 | ** 15 | ** Unless required by applicable law or agreed to in writing, software 16 | ** distributed under the License is distributed on an "AS IS" BASIS, 17 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | ** See the License for the specific language governing permissions and 19 | ** limitations under the License. 20 | ** 21 | ** File: skeleton_app_version.h 22 | ** 23 | ** Purpose: 24 | ** The skeleton application version header information. 25 | ** 26 | ** Notes: 27 | ** 28 | ** 29 | *************************************************************************/ 30 | #ifndef _skeleton_app_version_h_ 31 | #define _skeleton_app_version_h_ 32 | 33 | 34 | #define SKELETON_APP_MAJOR_VERSION 1 35 | #define SKELETON_APP_MINOR_VERSION 0 36 | #define SKELETON_APP_REVISION 0 37 | #define SKELETON_APP_MISSION_REV 0 38 | 39 | 40 | #endif /* _skeleton_app_version_h_ */ 41 | 42 | /************************/ 43 | /* End of File Comment */ 44 | /************************/ 45 | --------------------------------------------------------------------------------