diff --git a/CMakeLists.txt b/CMakeLists.txt index f65ef6e..7c6d094 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,5 @@ project(CFS_MD C) -include_directories(fsw/src) -include_directories(fsw/mission_inc) -include_directories(fsw/platform_inc) - set(APP_SRC_FILES fsw/src/md_dwell_tbl.c fsw/src/md_utils.c @@ -15,6 +11,9 @@ set(APP_SRC_FILES # Create the app module add_cfe_app(md ${APP_SRC_FILES}) +# This permits direct access to public headers in the fsw/inc directory +target_include_directories(md PUBLIC fsw/inc) + set(APP_TABLE_FILES fsw/tables/md_dw02.c fsw/tables/md_dw03.c diff --git a/docs/dox_src/md-common.doxyfile.in b/docs/dox_src/md-common.doxyfile.in index 5d3cd6f..fea9c01 100644 --- a/docs/dox_src/md-common.doxyfile.in +++ b/docs/dox_src/md-common.doxyfile.in @@ -5,5 +5,6 @@ # Include front material followed by everything in fsw INPUT += @md_MISSION_DIR@/docs/dox_src/cfs_md.dox INPUT += @md_MISSION_DIR@/fsw +INPUT += @md_MISSION_DIR@/fsw/inc IMAGE_PATH += @md_MISSION_DIR@/docs/dox_src diff --git a/fsw/inc/md_events.h b/fsw/inc/md_events.h new file mode 100644 index 0000000..0bc1828 --- /dev/null +++ b/fsw/inc/md_events.h @@ -0,0 +1,766 @@ +/************************************************************************ + * NASA Docket No. GSC-18,922-1, and identified as “Core Flight + * System (cFS) Memory Dwell Application Version 2.4.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * The CFS Memory Dwell (MD) Application event id header file + */ +#ifndef MD_EVENTS_H +#define MD_EVENTS_H + +/** + * \defgroup cfsmdevents CFS Memory Dwell Event IDs + * \{ + */ + +/** + * \brief MD Initialization Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued upon successful completion of task initialization. + */ +#define MD_INIT_INF_EID 1 + +/** + * \brief MD Read Software Bus Pipe Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued following error return from #CFE_SB_ReceiveBuffer call. + */ +#define MD_PIPE_ERR_EID 2 + +/** + * \brief MD Dwell Table Recovered Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued upon successful recovery of a Dwell Table. + */ +#define MD_RECOVERED_TBL_VALID_INF_EID 3 + +/** + * \brief MD Dwell Table Recovery Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * Issued when a Dwell Table is recovered and found to be invalid. + */ +#define MD_RECOVERED_TBL_NOT_VALID_ERR_EID 4 + +/** + * \brief MD Dwell Table Registration Too Large Event ID + * + * \par Type: CRITICAL + * + * \par Cause: + * + * Issued when a #CFE_TBL_ERR_INVALID_SIZE error message is received from #CFE_TBL_Register call. + * Load structure can be reduced by reducing #MD_DWELL_TABLE_SIZE, number of entries per Dwell Table. + */ +#define MD_DWELL_TBL_TOO_LARGE_CRIT_EID 5 + +/** + * \brief MD Dwell Table Registration Failed Event ID + * + * \par Type: CRITICAL + * + * \par Cause: + * + * Issued when an error message, other than #CFE_TBL_ERR_INVALID_SIZE, is received from #CFE_TBL_Register call. + */ +#define MD_TBL_REGISTER_CRIT_EID 6 + +/** + * \brief MD Dwell Table Initialization Complete Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued at the end of Table Initialization, specifying how many tables were recovered and how many initialized. + */ +#define MD_TBL_INIT_INF_EID 7 + +/** + * \brief MD No-op Command Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued upon receipt of a Memory Dwell no-op command. + */ +#define MD_NOOP_INF_EID 10 + +/** + * \brief MD Reset Counters Command Event ID + * + * \par Type: DEBUG + * + * \par Cause: + * + * Issued upon receipt of a Memory Dwell Reset Counters command. + */ +#define MD_RESET_CNTRS_DBG_EID 11 + +/** + * \brief MD Start Command Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued upon receipt of a Memory Dwell Start command. + * Upon receipt of this command, the specified tables are started for processing. + */ +#define MD_START_DWELL_INF_EID 12 + +/** + * \brief MD Stop Command Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * Issued upon receipt of a Memory Dwell Start command. + * Upon receipt of this command, the specified tables are stopped. + */ +#define MD_STOP_DWELL_INF_EID 13 + +/** + * \brief MD Start Command No Tables Specified Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * None of the valid Table Ids (1..#MD_NUM_DWELL_TABLES) are contained in + * the table mask argument for the Start Dwell or Stop Dwell command. + */ +#define MD_EMPTY_TBLMASK_ERR_EID 14 + +/** + * \brief MD Message ID Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued if the Memory Dwell task receives a message + * with an unrecognized Message ID. + */ +#define MD_MID_ERR_EID 15 + +/** + * \brief MD Command Code Not In Table Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued when a command for the Memory Dwell task is + * received with a function code which is not listed in the internal + * MD_CmdHandlerTbl structure, which is used to associate an expected + * length for the command. + */ +#define MD_CC_NOT_IN_TBL_ERR_EID 16 + +/** + * \brief MD Command Code Not In Command Processing Loop Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued when a command for the Memory Dwell task is + * received with a function code which is not included in the task's + * command code processing loop. + */ +#define MD_CC_NOT_IN_LOOP_ERR_EID 17 + +/** + * \brief MD Dwell Table Get Status Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued on receipt of an unexpected error message from + * CFE_TBL_GetStatus. Normal processing continues; no special action is taken. + */ +#define MD_TBL_STATUS_ERR_EID 20 + +/** + * \brief MD Command Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued when the Memory Dwell task receives a command + * which has a length that is inconsistent with the expected length + * for its command code. + */ +#define MD_CMD_LEN_ERR_EID 21 + +/** + * \brief MD Message Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued when the Memory Dwell task receives a message + * which has a length that is inconsistent with the expected length + * for its message id. + */ +#define MD_MSG_LEN_ERR_EID 22 + +/** + * \brief MD Jam To Dwell Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * This event is issued for a successful jam operation. + */ +#define MD_JAM_DWELL_INF_EID 30 + +/** + * \brief MD Jam Null Dwell Entry Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * This event is issued for a jam operation in which a null dwell entry is specified. + * A null entry is specified when the input dwell length is zero. + * All dwell fields (address, length, and delay) will be set to zero in this case. + */ +#define MD_JAM_NULL_DWELL_INF_EID 31 + +/** + * \brief MD Jam Command Table Id Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when a Jam Dwell Command is received + * with an invalid value for the table id argument. + * Values in the range 1..#MD_NUM_DWELL_TABLES are expected. + */ +#define MD_INVALID_JAM_TABLE_ERR_EID 32 + +/** + * \brief MD Jam Command Entry Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when a Jam Dwell Command is received + * with an invalid value for the entry id argument. + * Values in the range 1..#MD_DWELL_TABLE_SIZE are expected. + */ +#define MD_INVALID_ENTRY_ARG_ERR_EID 33 + +/** + * \brief MD Jam Command Field Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when a Jam Dwell Command is received + * with an invalid value for the field length argument. + */ +#define MD_INVALID_LEN_ARG_ERR_EID 34 + +/** + * \brief MD Jam Command Symbolic Address Resolution Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when symbolic address passed in Jam command + * couldn't be resolved by use of the on-board Symbol Table. + */ +#define MD_CANT_RESOLVE_JAM_ADDR_ERR_EID 35 + +/** + * \brief MD Jam Command Address Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The resolved address (numerical value for symbol + offset) and + * field length specified by the Jam command were found to specify a dwell + * be outside valid ranges. + */ +#define MD_INVALID_JAM_ADDR_ERR_EID 36 + +/** + * \brief MD Jam Command Address Not 32-bit Aligned Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The Jam command specified a 4-byte read, and the resolved address + * (numerical value for symbol + offset) is not on a 4-byte boundary. + */ +#define MD_JAM_ADDR_NOT_32BIT_ERR_EID 37 + +/** + * \brief MD Jam Command Address Not 16-bit Aligned Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The Jam command specified a 2-byte read, and the resolved address + * (numerical value for symbol + offset) is not on a 2-byte boundary. + */ +#define MD_JAM_ADDR_NOT_16BIT_ERR_EID 38 + +/** + * \brief MD Dwell Table Get Address Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued after the following sequence occurs: + * - #CFE_TBL_GetStatus returned #CFE_TBL_INFO_UPDATE_PENDING + * - #CFE_TBL_Update returned #CFE_SUCCESS, a call is made to + * - #CFE_TBL_GetAddress returned something other than #CFE_TBL_INFO_UPDATED. + * + * When this happens, the newly loaded table contents are _not_ copied + * to MD task structures. + */ +#define MD_NO_TBL_COPY_ERR_EID 39 + +/** + * \brief MD Dwell Table Enabled Rate Is Zero Event ID + * + * \par Type: INFORMATIONAL + * + * \par Cause: + * + * - The calculated rate, the total of delays for all active entries equals zero + * - The table is enabled + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_ZERO_RATE_TBL_INF_EID 40 + +/** + * \brief MD Dwell Table Table Symbol Address Unresolved Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The specified symbol wasn't found in the system symbol table. + * This could be either because there is no symbol table, or because + * the symbol isn't present in an existing symbol table. + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_RESOLVE_ERR_EID 41 + +/** + * \brief MD Dwell Table Address Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The specified address was not in allowable memory ranges. + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_RANGE_ERR_EID 42 + +/** + * \brief MD Dwell Table Entry Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The dwell table contains an invalid value for a dwell length. + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_TBL_HAS_LEN_ERR_EID 43 + +/** + * \brief MD Dwell Table Enable Flag Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The dwell table's enable value was neither zero nor one. + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_TBL_ENA_FLAG_EID 44 + +/** + * \brief MD Dwell Table Entry Alignment Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * Either a 4-byte dwell was specified and address is not 4-byte aligned, or + * a 2-byte dwell was specified and address is not 2-byte aligned. + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_TBL_ALIGN_ERR_EID 45 + +/** + * \brief MD Set Signature Command Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * A 'Set Signature' command was received and processed nominally to + * associate a signature with the specified dwell table. All dwell packets + * derived from that dwell table will include the specified signature string. + */ +#define MD_SET_SIGNATURE_INF_EID 46 + +/** + * \brief MD Set Signature Command Table ID Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when a Set Signature Command is received + * with an invalid value for the table id argument. + * Values in the range 1..#MD_NUM_DWELL_TABLES are expected. + */ +#define MD_INVALID_SIGNATURE_TABLE_ERR_EID 47 + +/** + * \brief MD Set Signature Command Signature Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This error event is issued when a Set Signature Command is received + * with a string not containing null termination within the allowable length. + */ +#define MD_INVALID_SIGNATURE_LENGTH_ERR_EID 49 + +/** + * \brief MD Dwell Table Signature Length Invalid Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * The dwell table contains an invalid Signature (not null terminated). + * + * If this load was initiated via ground command, the Table Id will be known + * from the command. If this load was recovered after a reset, a subsequent + * event message will identify the Table Id. + */ +#define MD_TBL_SIG_LEN_ERR_EID 50 + +/** + * \brief MD Dwell Table Enabled With Zero Delay Event ID + * + * \par Type: INFORMATIONAL + * + * \par Cause: + * + * - The calculated rate, the total of delays for all active entries, current equals zero + * - The table is currently enabled + * + * If the command either changes the delay values in the table (such that the total delay is 0) + * while the table is enabled, or if the table is enabled while the total delay value is 0, this + * event will be sent. + */ +#define MD_ZERO_RATE_CMD_INF_EID 51 + +/** + * \brief MD Dwell Table Verification Results Event ID + * + * \par Type: INFORMATION + * + * \par Cause: + * + * This event message is issued when a table validation has been + * completed for memory dwell table load + */ +#define MD_DWELL_TBL_INF_EID 52 + +/** + * \brief MD Dwell Table Update Table Enabled Get Address Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired in + * the #MD_UpdateTableEnabledField function. This event is issued when the + * #CFE_TBL_GetAddress function returns a value other than CFE_SUCCESS or + * CFE_TBL_INFO_UPDATED. + */ +#define MD_UPDATE_TBL_EN_ERR_EID 53 + +/** + * \brief MD Dwell Table Update Dwell Entry Get Address Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired in + * the #MD_UpdateTableDwellEntry function. This event is issued when the + * #CFE_TBL_GetAddress function returns a value other than CFE_SUCCESS or + * CFE_TBL_INFO_UPDATED. + */ +#define MD_UPDATE_TBL_DWELL_ERR_EID 54 + +/** + * \brief MD Dwell Table Update Table Signature Get Address Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired in + * the MD_UpdateTableSignature function. This event is issued when the + * #CFE_TBL_GetAddress function returns a value other than CFE_SUCCESS or + * CFE_TBL_INFO_UPDATED. + */ +#define MD_UPDATE_TBL_SIG_ERR_EID 55 + +/** + * \brief MD Process Start Command Dwell Table Mask Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired for + * one of the tables being started with the #MD_ProcessStartCmd. In addition + * to this summary message, a #MD_UPDATE_TBL_EN_ERR_EID event is issed for each + * failure. + */ +#define MD_START_DWELL_ERR_EID 56 + +/** + * \brief MD Process Stop Command Dwell Table Mask Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired for + * one of the tables being started with the #MD_ProcessStopCmd. In addition + * to this summary message, a #MD_UPDATE_TBL_EN_ERR_EID event is issed for each + * failure. + */ +#define MD_STOP_DWELL_ERR_EID 57 + +/** + * \brief MD Process Signature Command Table Get Address Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table address cannot be acquired + * for the table specified in the #MD_ProcessSignatureCmd. + */ +#define MD_SET_SIGNATURE_ERR_EID 58 + +/** + * \brief MD Jam To Dwell Table Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued for a failed jam operation. + */ +#define MD_JAM_DWELL_ERR_EID 59 + +/** + * \brief MD Jam Null To Dwell Table Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event is issued for a failed jam operation in which a null dwell entry is + * specified. A null entry is specified when the input dwell length is zero. + * All dwell fields (address, length, and delay) will be set to zero in this case. + */ +#define MD_JAM_NULL_DWELL_ERR_EID 60 + +/** + * \brief MD Table Name Generation Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued if the snprintf call used to create the + * TableName in #MD_InitTableServices function fails. + */ +#define MD_INIT_TBL_NAME_ERR_EID 61 + +/** + * \brief MD Table Filename Generation Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued if the snprintf call used to create the + * TblFileName in #MD_InitTableServices function fails. + */ + +#define MD_INIT_TBL_FILENAME_ERR_EID 62 + +/** + * \brief MD Dwell Table Validation Null Pointer Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the table pointer passed to + * #MD_TableValidationFunc is null. + */ +#define MD_TBL_VAL_NULL_PTR_ERR_EID 63 + +/** + * \brief MD Dwell Table Address Read Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when the PSP returns an error when attempting + * to read the memory address of an entry + */ +#define MD_DWELL_LOOP_GET_DWELL_DATA_ERR_EID 70 + +/** + * \brief MD Create Pipe Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when MD cannot create the software bus pipe. + */ +#define MD_CREATE_PIPE_ERR_EID 71 + +/** + * \brief MD Housekeeping Subscribe Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when MD cannot subscribe to housekeeping + * requests. + */ +#define MD_SUB_HK_ERR_EID 72 + +/** + * \brief MD Command Subscribe Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when MD cannot subscribe to commands. + */ +#define MD_SUB_CMD_ERR_EID 73 + +/** + * \brief MD Wakeup Message Subscribe Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when MD cannot subscribe to wakeup + * messages. + */ +#define MD_SUB_WAKEUP_ERR_EID 74 + +/** + * \brief MD Dwell Table Validation Entry Failed Event ID + * + * \par Type: ERROR + * + * \par Cause: + * + * This event message is issued when a dwell table entry is determined + * to be invalid. + * The Table entry field specifies the index of the invalid entry. + * The status field specifies the error generated when validating that + * entry. + */ +#define MD_TBL_ENTRY_ERR_EID 75 + +/**\}*/ + +#endif diff --git a/fsw/inc/md_extern_typedefs.h b/fsw/inc/md_extern_typedefs.h new file mode 100644 index 0000000..93fc456 --- /dev/null +++ b/fsw/inc/md_extern_typedefs.h @@ -0,0 +1,42 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Declarations and prototypes for md_extern_typedefs module + */ + +#ifndef MD_EXTERN_TYPEDEFS_H +#define MD_EXTERN_TYPEDEFS_H + +/************************************************************************ + * Type Definitions + ************************************************************************/ + +/** + * \brief MD enum used for representing values for enable state + */ +enum MD_Dwell_States +{ + MD_DWELL_STREAM_DISABLED, /**< \brief MD Dwell Stream Disabled */ + MD_DWELL_STREAM_ENABLED /**< \brief MD Dwell Stream Enabled */ +}; + +#endif /* MD_EXTERN_TYPEDEFS_H */ \ No newline at end of file diff --git a/fsw/inc/md_msg.h b/fsw/inc/md_msg.h new file mode 100644 index 0000000..5b9a05b --- /dev/null +++ b/fsw/inc/md_msg.h @@ -0,0 +1,172 @@ +/************************************************************************ + * NASA Docket No. GSC-18,922-1, and identified as “Core Flight + * System (cFS) Memory Dwell Application Version 2.4.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the CFS Memory Dwell command and telemetry + * messages. + */ +#ifndef MD_MSG_H +#define MD_MSG_H + +#include "md_platform_cfg.h" +#include "cfe.h" +#include "md_msgdefs.h" + +/************************************************************************ + * Type Definitions + ************************************************************************/ + +/** + * \defgroup cfsmdcmdstructs CFS Memory Dwell Command Structures + * \{ + */ + +/** + * \brief Symbolic Address Type + */ +typedef struct +{ + cpuaddr Offset; /**< \brief Optional offset that is used as the + absolute address if the SymName string is NUL */ + char SymName[OS_MAX_SYM_LEN]; /**< \brief Symbol name string */ +} MD_SymAddr_t; + +/** + * \brief Generic "no arguments" command + * + * This command structure is used for commands that do not have any parameters. + * This includes: + * -# The Housekeeping Request Message + * -# The Wakeup Message + * -# The No-Op Command (For details, see #MD_NOOP_CC) + * -# The Reset Counters Command (For details, see #MD_RESET_CNTRS_CC) + */ +typedef struct +{ + CFE_MSG_CommandHeader_t CmdHeader; /**< Command Header */ + +} MD_NoArgsCmd_t; + +/** + * \brief Start and Stop Dwell Commands + * + * For command details, see #MD_START_DWELL_CC and #MD_STOP_DWELL_CC + */ +typedef struct +{ + CFE_MSG_CommandHeader_t Header; /**< \brief Command header */ + + uint16 TableMask; /**< \brief 0x0001=TBL1 bit, 0x0002=TBL2 bit, 0x0004=TBL3 bit, etc. */ + uint16 Padding; /**< \brief structure padding */ +} MD_CmdStartStop_t; + +/** + * \brief Jam Dwell Command + * + * For command details, see #MD_JAM_DWELL_CC + */ +typedef struct +{ + CFE_MSG_CommandHeader_t Header; /**< \brief Command header */ + + uint16 TableId; /**< \brief Table Id: 1..#MD_NUM_DWELL_TABLES */ + uint16 EntryId; /**< \brief Address index: 1..#MD_DWELL_TABLE_SIZE */ + uint16 FieldLength; /**< \brief Length of Dwell Field : 0, 1, 2, or 4 */ + uint16 DwellDelay; /**< \brief Dwell Delay (number of task wakeup calls before following dwell) */ + MD_SymAddr_t DwellAddress; /**< \brief Dwell Address in #MD_SymAddr_t format */ +} MD_CmdJam_t; + +#if MD_SIGNATURE_OPTION == 1 + +/** + * \brief Set Signature Command + * + * For command details, see #MD_SET_SIGNATURE_CC + */ +typedef struct +{ + CFE_MSG_CommandHeader_t Header; /**< \brief Command Header */ + + uint16 TableId; /**< \brief Table Id: 1..MD_NUM_DWELL_TABLES */ + uint16 Padding; /**< \brief Padding */ + char Signature[MD_SIGNATURE_FIELD_LENGTH]; /**< \brief Sigature */ +} MD_CmdSetSignature_t; + +#endif + +/**\}*/ + +/** + * \defgroup cfsmdtlm CFS Memory Dwell Telemetry + * \{ + */ + +/** + * \brief Memory Dwell HK Telemetry format + */ +typedef struct +{ + CFE_MSG_TelemetryHeader_t TlmHeader; /**< \brief Telemetry header */ + + uint8 InvalidCmdCntr; /**< \brief Count of invalid commands received */ + uint8 ValidCmdCntr; /**< \brief Count of valid commands received */ + uint16 DwellEnabledMask; /**< \brief Dwell table enable bitmask 0x0001=TBL1, etc */ + + uint16 DwellTblAddrCount[MD_NUM_DWELL_TABLES]; /**< \brief Number of dwell addresses in table */ + uint16 NumWaitsPerPkt[MD_NUM_DWELL_TABLES]; /**< \brief Number of delay counts in table */ + uint16 ByteCount[MD_NUM_DWELL_TABLES]; /**< \brief Number of bytes of data specified by table */ + uint16 DwellPktOffset[MD_NUM_DWELL_TABLES]; /**< \brief Current write offset within dwell pkt data region */ + uint16 DwellTblEntry[MD_NUM_DWELL_TABLES]; /**< \brief Next dwell table entry to be processed */ + + uint16 Countdown[MD_NUM_DWELL_TABLES]; /**< \brief Current value of countdown timer */ +} MD_HkTlm_t; + +/** + * \brief Memory Dwell Housekeeping telemetry packet length + */ +#define MD_HK_TLM_LNGTH sizeof(MD_HkTlm_t) + +/** + * \brief Memory Dwell Telemetry Packet format + */ +typedef struct +{ + CFE_MSG_TelemetryHeader_t TlmHeader; /**< \brief Telemetry header */ + + uint8 TableId; /**< \brief TableId from 1 to #MD_NUM_DWELL_TABLES */ + uint8 AddrCount; /**< \brief Number of addresses being sent - 1..#MD_DWELL_TABLE_SIZE valid */ + uint16 ByteCount; /**< \brief Number of bytes of dwell data contained in packet */ + uint32 Rate; /**< \brief Number of counts between packet sends*/ + +#if MD_SIGNATURE_OPTION == 1 + char Signature[MD_SIGNATURE_FIELD_LENGTH]; /**< \brief Signature */ +#endif + + uint8 Data[MD_DWELL_TABLE_SIZE * 4]; /**< \brief Dwell data (can be variable size based on dfn) */ +} MD_DwellPkt_t; + +/** + * \brief Memory Dwell Telemetry maximum packet size + */ +#define MD_DWELL_PKT_LNGTH (sizeof(MD_DwellPkt_t)) + +/**\}*/ + +#endif diff --git a/fsw/inc/md_msgdefs.h b/fsw/inc/md_msgdefs.h new file mode 100644 index 0000000..264f28c --- /dev/null +++ b/fsw/inc/md_msgdefs.h @@ -0,0 +1,310 @@ +/************************************************************************ + * NASA Docket No. GSC-18,922-1, and identified as “Core Flight + * System (cFS) Memory Dwell Application Version 2.4.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the CFS Memory Dwell command and telemetry + * message constant definitions. + * + * @note + * These Macro definitions have been put in this file (instead of + * md_msg.h) so this file can be included directly into ASIST build + * test scripts. ASIST RDL files can accept C language \#defines but + * can't handle type definitions. As a result: DO NOT PUT ANY + * TYPEDEFS OR STRUCTURE DEFINITIONS IN THIS FILE! + * ADD THEM TO md_msg.h IF NEEDED! + */ +#ifndef MD_MSGDEFS_H +#define MD_MSGDEFS_H + +#include "md_platform_cfg.h" + +/** + * \defgroup cfsmdcmdcodes CFS Memory Dwell Command Codes + * \{ + */ + +/** + * \brief Memory Dwell No-Op Command + * + * \par Description + * This command increments the MD application's + * valid command execution counter. + * + * \par Command Structure + * #MD_NoArgsCmd_t + * + * \par Command Verification + * Successful execution of this command may be verified with the + * following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr will increment + * - The #MD_NOOP_INF_EID informational event message will + * be generated + * + * \par Error Conditions + * This command may fail for the following reason(s): + * - Unexpected command length. + * + * Evidence of an unexpected command length error may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr will increment. + * - The #MD_CMD_LEN_ERR_EID error event message will be issued. + * + * \par Criticality + * None + */ +#define MD_NOOP_CC 0 + +/** + * \brief Memory Dwell Reset Counters Command + * + * \par Description + * This command resets the following counters within the + * Memory Dwell housekeeping telemetry: + * - Command Execution Counter + * - Command Error Counter + * + * \par Command Structure + * #MD_NoArgsCmd_t + * + * \par Command Verification + * Successful execution of this command may be verified with + * the following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr will be set to zero. + * - #MD_HkTlm_t.InvalidCmdCntr will be set to zero. + * - The #MD_RESET_CNTRS_DBG_EID debug event message will be generated. + * + * \par Error Conditions + * This command may fail for the following reason(s): + * - Unexpected command length. + * + * Evidence of an unexpected command length error may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr will increment. + * - The #MD_CMD_LEN_ERR_EID error event message will be issued. + * + * \par Criticality + * This command is not inherently dangerous. However, it is + * possible for ground systems and on-board safing procedures + * to be designed such that they react to changes in the counter + * values that are reset by this command. + */ +#define MD_RESET_CNTRS_CC 1 + +/** + * \brief Memory Dwell Start Dwell Command + * + * \par Description + * This command sets the Enabled flag(s) associated with the Dwell Table(s) + * that have been designated by the command's TableMask argument. + * + * When this Enabled flag is set, and the associated Dwell Table has + * one or more dwell specifications defined beginning with the Table's + * first entry, and the Table has a non-zero value for total delays + * (aka as the Rate), dwell processing will occur. + * + * The first dwell occurs on receipt of the first Wakeup Message from + * the Scheduler following the Start Dwell Command. That dwell means + * that a value from memory is read, and inserted into the Dwell Packet. + * + * Dwell Packets are issued at a rate specified by the Rate value + * associated with the Dwell Table. The Rate is a multiple of + * Wakeup Messages issued from the Scheduler. The Rate value is calculated + * as the sum of all the individual delays specified by individual dwell + * entries in a Dwell Table. + * + * Note that the dwell state will not be affected for the Dwell Tables + * _not_ designated by the TableMask argument. Thus, for example, if + * Dwell Table #1 has already been started, and a Start Dwell Command is + * issued to start Dwell Tables #2 and #3, Dwell Table #1 will still be + * in started state following the command. + * + * Note that if this command is issued when the Dwell Table has already + * been started, the effect will be to restart the table. The current + * entry will be set to the first entry and any data previously collected + * will be lost. + * + * Note that the value of the Enabled flag is also updated when a + * Dwell Table is loaded. + * + * \par Command Structure + * #MD_CmdStartStop_t + * + * \par Command Verification + * Successful execution of this command may be verified with + * the following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr will increment. + * - #MD_HkTlm_t.DwellEnabledMask will be enabled (bit 1 = TBL1, etc) + * - The #MD_START_DWELL_INF_EID informational event message + * will be issued. + * + * \par Error Conditions + * This command may fail for the following reasons: + * - Unexpected command length. + * - Dwell Table mask argument contains no valid table values ( 1..#MD_NUM_DWELL_TABLES). + * + * Evidence of an unexpected command length error may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr increments. + * - The #MD_CMD_LEN_ERR_EID error event message is issued. + * + * Evidence of an invalid value for Dwell Table mask argument may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr increments. + * - The #MD_EMPTY_TBLMASK_ERR_EID error event message is issued. + * + ** + * \par Criticality + * None. + * + * \sa #MD_STOP_DWELL_CC + */ +#define MD_START_DWELL_CC 2 + +/** + * \brief Memory Dwell Stop Dwell Command + * + * \par Description + * This command clears the Enabled flag(s) associated with the Dwell Table(s) + * that have been designated by the command's TableMask argument. + * + * When the Enabled flag associated with a Dwell Table is cleared, + * dwell processing cannot occur for that Dwell Table. + * + * Note that the value of the Enabled flag is also updated when a + * Dwell Table is loaded. + * + * Note that the dwell state will not be affected for the Dwell Tables + * _not_ designated by the TableMask argument. Thus, for example, if + * a Stop Dwell Command is issued to stop Dwell Table #2, all _other_ + * Dwell Tables will remain in the same state following the command + * that they were in before the command was received. + * + * \par Command Structure + * #MD_CmdStartStop_t + * + * \par Command Verification + * Successful execution of this command may be verified with + * the following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr increments. + * - #MD_HkTlm_t.DwellEnabledMask will be disabled (bit 1 = TBL1, etc) + * - The #MD_STOP_DWELL_INF_EID informational event message is issued. + * + * \par Error Conditions + * This command may fail for the following reason(s): + * - Unexpected command length. + * - Dwell Table mask argument contains no valid table values ( 1..#MD_NUM_DWELL_TABLES). + * + * Evidence of an unexpected command length error may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr increments. + * - The #MD_CMD_LEN_ERR_EID error event message is issued. + * + * Evidence of an invalid value for Dwell Table argument may be found + * in the following telemetry: + * - #MD_HkTlm_t.InvalidCmdCntr increments. + * - The #MD_EMPTY_TBLMASK_ERR_EID error event message is issued. + * + * \par Criticality + * None. + * + * \sa #MD_START_DWELL_CC + */ +#define MD_STOP_DWELL_CC 3 + +/** + * \brief Jam Dwell + * + * \par Description + * This command inserts the specified dwell parameters (dwell address, + * dwell field length, and delay count) into the specified table, + * at the specified index. + * + * Note that it is safe to send a Jam command to an active Dwell Table. + * ('Active' indicates a Table which is enabled; thus, the Dwell Table + * is actively being used to generate a dwell packet telemetry stream.) + * Note that changes made to a Dwell Table using a Jam command will not + * be saved across process resets in this version of Memory Dwell. + * + * For details on what constitutes a valid Dwell Table see #MD_DwellTableLoad_t. + * In particular, note that a valid entry _may_ be inserted past a terminator entry; + * however it won't be processed as long as it remains following a terminator entry. + * + * \par Command Structure + * #MD_CmdJam_t + * + * \par Command Verification + * Nominal successful execution of this command may be verified with + * the following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr increments. + * - The #MD_JAM_DWELL_INF_EID or #MD_JAM_NULL_DWELL_INF_EID informational event message is issued. + * + * \par Error Conditions + * This command may fail for the following reason(s): + * - Unexpected command length (Event message #MD_CMD_LEN_ERR_EID is issued) + * - Table Id other than 1..MD_NUM_DWELL_TABLES (Event message #MD_INVALID_JAM_TABLE_ERR_EID is issued) + * - Entry Id other than 1..MD_DWELL_TABLE_SIZE (Event message #MD_INVALID_ENTRY_ARG_ERR_EID is issued) + * - Unrecognized Dwell Address symbol (Event message #MD_CANT_RESOLVE_JAM_ADDR_ERR_EID is issued) + * - Dwell Field Length other than 0, 1, 2, or 4 (Event message #MD_INVALID_LEN_ARG_ERR_EID is issued) + * - Specified Dwell Address is out of range (Event message #MD_INVALID_JAM_ADDR_ERR_EID is issued) + * - Specified Dwell Address is not properly aligned for the specified Dwell Length + * (Event message #MD_JAM_ADDR_NOT_32BIT_ERR_EID or #MD_JAM_ADDR_NOT_16BIT_ERR_EID is issued) + * + * Any time the command fails, #MD_HkTlm_t.InvalidCmdCntr increments. + * + * \par Criticality + * None. + */ +#define MD_JAM_DWELL_CC 4 + +#if MD_SIGNATURE_OPTION == 1 + +/** + * \brief Set Signature Command + * + * \par Description + * Associates a signature with the specified Dwell Table. + * + * \par Command Structure + * #MD_CmdSetSignature_t + * + * \par Command Verification + * Successful execution of this command may be verified with + * the following telemetry: + * - #MD_HkTlm_t.ValidCmdCntr will increment. + * + * \par Error Conditions + * This command may fail for the following reason(s): + * - Unexpected command length. (Event message #MD_CMD_LEN_ERR_EID is issued) + * - Signature string argument is not terminated. (Event message #MD_SIGNATURE_TOO_LONG_ERR_EID is issued) + * - Dwell Table ID is invalid. (Event message #MD_INVALID_SIGNATURE_TABLE_ERR_EID is issued) + * + * Any time the command fails, #MD_HkTlm_t.InvalidCmdCntr increments. + * + * \par Criticality + * None. + * \sa #MD_SET_SIGNATURE_CC + */ +#define MD_SET_SIGNATURE_CC 5 + +#endif + +/**\}*/ + +#endif diff --git a/fsw/platform_inc/md_msgids.h b/fsw/inc/md_msgids.h similarity index 100% rename from fsw/platform_inc/md_msgids.h rename to fsw/inc/md_msgids.h diff --git a/fsw/mission_inc/md_perfids.h b/fsw/inc/md_perfids.h similarity index 100% rename from fsw/mission_inc/md_perfids.h rename to fsw/inc/md_perfids.h diff --git a/fsw/platform_inc/md_platform_cfg.h b/fsw/inc/md_platform_cfg.h similarity index 100% rename from fsw/platform_inc/md_platform_cfg.h rename to fsw/inc/md_platform_cfg.h diff --git a/fsw/src/md_tbldefs.h b/fsw/inc/md_tbldefs.h similarity index 100% rename from fsw/src/md_tbldefs.h rename to fsw/inc/md_tbldefs.h diff --git a/fsw/src/md_app.c b/fsw/src/md_app.c index 4d943a5..afd764f 100644 --- a/fsw/src/md_app.c +++ b/fsw/src/md_app.c @@ -34,6 +34,7 @@ #include "md_utils.h" #include "md_perfids.h" #include "md_version.h" +#include "md_extern_typedefs.h" /* Constant Data */ const MD_CmdHandlerTblRec_t MD_CmdHandlerTbl[] = { diff --git a/fsw/src/md_app.h b/fsw/src/md_app.h index 341f3e5..c76cd77 100644 --- a/fsw/src/md_app.h +++ b/fsw/src/md_app.h @@ -67,15 +67,6 @@ * Type Definitions ************************************************************************/ -/** - * \brief MD enum used for representing values for enable state - */ -enum MD_Dwell_States -{ - MD_DWELL_STREAM_DISABLED, /**< \brief MD Dwell Stream Disabled */ - MD_DWELL_STREAM_ENABLED /**< \brief MD Dwell Stream Enabled */ -}; - /** * \brief MD structure for specifying individual memory dwell */ diff --git a/fsw/src/md_cmds.c b/fsw/src/md_cmds.c index 0e9af9b..ba5ebcd 100644 --- a/fsw/src/md_cmds.c +++ b/fsw/src/md_cmds.c @@ -34,6 +34,7 @@ #include "md_app.h" #include "md_events.h" #include "md_dwell_tbl.h" +#include "md_extern_typedefs.h" /* Global Data */ extern MD_AppData_t MD_AppData; diff --git a/fsw/src/md_dwell_pkt.c b/fsw/src/md_dwell_pkt.c index 904d66a..9ba588b 100644 --- a/fsw/src/md_dwell_pkt.c +++ b/fsw/src/md_dwell_pkt.c @@ -30,6 +30,7 @@ #include "md_app.h" #include "md_events.h" #include +#include "md_extern_typedefs.h" extern MD_AppData_t MD_AppData; diff --git a/fsw/src/md_dwell_tbl.c b/fsw/src/md_dwell_tbl.c index a3e6bf6..c27e897 100644 --- a/fsw/src/md_dwell_tbl.c +++ b/fsw/src/md_dwell_tbl.c @@ -32,6 +32,7 @@ #include "md_events.h" #include #include "md_tbldefs.h" +#include "md_extern_typedefs.h" extern MD_AppData_t MD_AppData; diff --git a/fsw/tables/md_dw01.c b/fsw/tables/md_dw01.c index 23729d6..593f333 100644 --- a/fsw/tables/md_dw01.c +++ b/fsw/tables/md_dw01.c @@ -27,7 +27,7 @@ *************************************************************************/ #include "cfe.h" #include "md_tbldefs.h" -#include "md_app.h" +#include "md_extern_typedefs.h" #include "cfe_tbl_filedef.h" #include "md_platform_cfg.h" diff --git a/fsw/tables/md_dw02.c b/fsw/tables/md_dw02.c index 1fe926d..28dd32b 100644 --- a/fsw/tables/md_dw02.c +++ b/fsw/tables/md_dw02.c @@ -27,7 +27,7 @@ *************************************************************************/ #include "cfe.h" #include "md_tbldefs.h" -#include "md_app.h" +#include "md_extern_typedefs.h" #include "cfe_tbl_filedef.h" #include "md_platform_cfg.h" diff --git a/fsw/tables/md_dw03.c b/fsw/tables/md_dw03.c index d4c63f9..341d9b9 100644 --- a/fsw/tables/md_dw03.c +++ b/fsw/tables/md_dw03.c @@ -27,7 +27,7 @@ *************************************************************************/ #include "cfe.h" #include "md_tbldefs.h" -#include "md_app.h" +#include "md_extern_typedefs.h" #include "cfe_tbl_filedef.h" #include "md_platform_cfg.h" diff --git a/fsw/tables/md_dw04.c b/fsw/tables/md_dw04.c index 31fcd8d..e57091d 100644 --- a/fsw/tables/md_dw04.c +++ b/fsw/tables/md_dw04.c @@ -27,7 +27,7 @@ *************************************************************************/ #include "cfe.h" #include "md_tbldefs.h" -#include "md_app.h" +#include "md_extern_typedefs.h" #include "cfe_tbl_filedef.h" #include "md_platform_cfg.h" diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index c782637..96b1f97 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -20,8 +20,10 @@ add_cfe_coverage_stubs(md_internal # Link with the cfe core stubs and unit test assert libs target_link_libraries(coverage-md_internal-stubs ut_core_api_stubs ut_assert) -# Include and expose unit test utilities includes +# Include and expose unit test utilities, fsw/inc, and fsw/src includes target_include_directories(coverage-md_internal-stubs PUBLIC utilities) +target_include_directories(coverage-md_internal-stubs PUBLIC ../fsw/inc) +target_include_directories(coverage-md_internal-stubs PUBLIC ../fsw/src) # Stub includes needed for all targets include_directories(stubs) diff --git a/unit-test/utilities/md_test_utils.h b/unit-test/utilities/md_test_utils.h index 8ef1920..71f05e7 100644 --- a/unit-test/utilities/md_test_utils.h +++ b/unit-test/utilities/md_test_utils.h @@ -29,6 +29,7 @@ #include "md_platform_cfg.h" #include "utstubs.h" #include "cfe_msgids.h" +#include "md_extern_typedefs.h" extern MD_AppData_t MD_AppData;