diff --git a/README.md b/README.md index d7270409c..0de722f20 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,21 @@ The detailed cFE user's guide can be viewed at and + ### Development Build: v6.8.0-rc1+dev762 - Change CI to use Test Log. diff --git a/docs/cFE Application Developers Guide.md b/docs/cFE Application Developers Guide.md index cbbcd522a..324a2189e 100644 --- a/docs/cFE Application Developers Guide.md +++ b/docs/cFE Application Developers Guide.md @@ -980,14 +980,14 @@ The specific size of the management structure depends on the platform architecture word size and alignment requirements, and padding may be added as necessary to meet the system requirements. For illustrative purposes, the examples below use sizes that are respresentative of a -32-bit CPU with 32-bit buffer alignment with no extra alignment padding +32-bit CPU with 32-bit buffer alignment with no extra alignment padding added. The pool overhead will increase on a 64-bit CPU with 64-bit alignment, or if pool alignment configured greater than 32 bits. For -more information on pool buffer alignment, see the description of +more information on pool buffer alignment, see the description of the `CFE_PLATFORM_ES_MEMPOOL_ALIGN_SIZE_MIN` configuration parameter. It should also be noted that while 64-bit CPU architectures are fully -supported by the memory pool internal implementation in current CFE +supported by the memory pool internal implementation in current CFE versions, the API is carried over from older CFE versions in order to be backward compatible. Some memory pool API functions (e.g. `CFE_ES_GetPoolBufInfo`, `CFE_ES_PutPoolBuf`, etc) return a buffer size @@ -1893,7 +1893,7 @@ SAMPLE_AppData_t SAMPLE_AppData; /* Instantiate Task Data */ CFE_SB_TransmitMsg(&SAMPLE_APP_Data.HkTlm.TlmHeader.Msg, true); ... } -``` +``` ## 6.7 Receiving Software Bus Messages @@ -2057,7 +2057,7 @@ SAMPLE_AppData_t SAMPLE_AppData; /* Instantiate Task Data */ ## 6.9 Best Practices for using Software Bus -The following are recommended "best practices" for applications using EVS. +The following are recommended "best practices" for applications using SB. 1. Applications should use the Software Bus for all communication with other applications. 2. Pipe depth and message limits are dependent on the entire software system. diff --git a/docs/cFE_FunctionalRequirements.csv b/docs/cFE_FunctionalRequirements.csv index 8cdc5d2f4..3cc9009ae 100644 --- a/docs/cFE_FunctionalRequirements.csv +++ b/docs/cFE_FunctionalRequirements.csv @@ -95,11 +95,10 @@ ES: Analyzer Log Trigger Mask,cES1031,"Upon receipt of a Command, the cFE shall ES: Task Status Record To File,cES1032,"Upon receipt of a Command, the cFE shall generate a Command specified file that contains the cFE Task information.",Provide capability to write all cFE task data to a file for system status and management. ES: Task Status Record To File - Default Filename,cES1032.1,"If a file is not specified, the cFE shall use the `` filename.",Provide a default file name. ES: Get Memory Pool Statistics,cES1033,"Upon receipt of a Command, the cFE shall generate a message that contains the requested memory pool statistics.",Supports memory pool management. -ES: Register Application,cES1300,"Upon receipt of a Request, the cFE shall register the calling cFE Application with the system.",cFE Applications must register with the cFE in order to allow the cFE to track the Application's resources. This function also allows the system to synchronize the application startup. The cFE Application will wait in this function until the cFE starts up. ES: Report Last Reset,cES1301,"Upon receipt of a Request, the cFE shall provide the type of last reset performed by the processor.",cFE Applications may perform processing that is specific to each reset type. ES: Report Last Reset - Types,cES1301.1,The reset types include: Power On Reset Processor Reset.,cFE Applications may perform processing that is specific to each reset type. ES: Report Application ID,cES1304,"Upon receipt of a Request, the cFE shall provide the cFE Application ID of the calling cFE Application.",A cFE Application needs to determine its own Application ID. -ES: Report Task and Application Name,cES1305,"Upon receipt of a Request, the cFE shall provide the cFE Task Name and cFE Application Name which corresponds to the specified cFE Task ID.",The command will provide a way to find the cFE Task Name and the parent cFE Application name from any cFE Application or Child task. +ES: Get Task Information,cES1305,Upon receipt of a Request the cFE shall provide information for the requested task.,Allows query of task information for reporting or management. ES: Report Application ID,cES1306,"Upon receipt of a Request, the cFE shall provide the cFE Application ID which corresponds to the specified cFE Application Name.",The Executive Services will assign an Application ID. The Application Name is specified when the cFE Application is created. This Request will provide a way to determine the cFE Application ID when the pre-determined Application Name is passed in. ES: Report Application Name,cES1307,"Upon receipt of a Request, the cFE shall provide the cFE Application Name which corresponds to the specified cFE Application ID.",The Executive Services will assign an Application ID. This Request will provide a way to determine an Application's name from its Application ID. ES: Delete Application,cES1309,"Upon receipt of a Request, the cFE shall delete the specified Application including all child tasks.",Need to be able to stop the execution of an Application and remove its System Resources. The delete will clean-up the application's main task and all of its child tasks. Note: other cFE components are required to have cleanup routines that ES calls. @@ -113,7 +112,6 @@ ES: Create Child Task - Report Error,cES1311.1,"In the event that the cFE Child ES: Create Child Task - Invalid From Child Task,cES1311.2,"In the event a child task attempts to create another child task, the cFE shall record the error in the System Log, and return an error code.",Only the cFE Application's main task can create a child task. This prevents confusion with parent/child task relationships and the allocation/deallocation of resources. ES: Delete Child Task,cES1312,"Upon receipt of a Request, the cFE shall delete the specified cFE Child Task within the cFE Application that owns the task.","As part of a cFE Application cleanup, the Application needs to be able to delete each child task." ES: Delete Child Task - Error If Application Main Task,cES1312.1,"If the specified task is the cFE Application Main Task, the request shall record the error in the System Log, and return an error code.",Cannot use Child Task Exit or Delete on the cFE Application Main Task. -ES: Register Child Task,cES1313,"Upon receipt of a Request, the cFE shall register the calling cFE Child Task with the system.","Just like cFE Applications, Child Tasks must be registered to work properly in the cFE. This function call is intended to be called by the newly created cFE Child Task." ES: End Child Task,cES1314,"Upon receipt of a Request, the cFE shall end execution of the calling cFE Child Task.", cFE Child Task needs to be able to exit and end execution. ES: End Child Task - Error If Application Main Task,cES1314.1,"If the calling task is the cFE Application Main Task, the cFE shall record the error in the System Log, and return an error code.",Cannot use Child Task Exit or Delete on the cFE Application Main Task. ES: Reserve Critical Data Store,cES1315,"Upon receipt of a Request, the cFE shall reserve the Request specified amount of memory in the Critical Data Store for the cFE Application using the Request specified name.",The Critical Data Store will be used by Applications to store critical parameters that will be preserved after an application or processor restart. ES will allocate the memory for the application. A pointer or memory address will be provided to the alloc. @@ -155,6 +153,9 @@ ES: Increment Generic Counter,cES1340,Upon receipt of a Request the cFE shall in ES: Set Generic Counter,cES1341,Upon receipt of a Request the cFE shall set the requested counter to the requested value.,Generic counter management. ES: Get Generic Counter,cES1342,Upon receipt of a Request the cFE shall provide the counter value for the requested generic counter.,Generic counter management. ES: Get Generic Counter ID By Name,cES1343,Upon receipt of a Request the cFE shall provide the generic counter ID for the requested generic counter name.,Generic counter management. +ES: Get Library Information,cES1344,Upon receipt of a Request the cFE shall provide information for the requested library.,Allows query of library information for reporting or management. +ES: Delete Memory Pool,cES1345,"Upon receipt of a Request, the cFE shall delete a Memory Pool.","Allows for management of memory resources, delete of pool once no longer needed." +ES: Get Generic Counter Name,cES1346,Upon receipt of a Request the cFE shall provide the generic counter name.,Generic counter management. ES: Power On Reset Identify Sub-Type,cES1500,"Upon a Power-on Reset, the cFE shall identify the Power On reset sub-type.",Each mission may want to further distinguish between Processor reset types in order to tailor their system's behavior. For example a mission may want to take different behavior for a watchdog time out and the execution of the processor's reset instructions. ES: Power On Reset Clear System Log,cES1501,"Upon a Power-On Reset, the cFE shall clear the Executive Services System Log.",Want to be able to determine what errors are logged by the cFE. This log is not preserved on a Power-On reset. ES: Power On Reset Clear Exception and Reset Log,cES1502,"Upon a Power-On Reset, the cFE shall clear the Executive Services Exception and Reset Log.",Want to be able to get a snapshot of some critical parameters prior to a reset as well as log the resets that have occurred. @@ -199,6 +200,8 @@ FS: Initialize File Header,cES1601,Upon receipt of a Request the cFE shall initi FS: Write File Header,cES1602,Upon receipt of a Request the cFE shall write the requested header information to the requested file.,File management support. FS: Set File Timestamp,cES1603,Upon receipt of a Request the cFE shall set the requested timestamp on the requested file.,File management support. FS: Extract Filename From Path,cES1604,Upon receipt of a Request the cFE shall provide the file name portion of the requested full path.,File management support. +FS: Filename Auto-Complete,cES1605,Upon receipt of a Request the cFE shall auto-complete a filename.,Supports filename abstraction (extensions and mount point) to support portability. +FS: Background File Dump,cES1606,Upon receipt of a Request cFE shall write the requested file in the background.,Generic background (low priority) file write capability avoids stalling out apps and services with large file writes. ES: Maximum Processor Resets,cES1709,"If the cFE Core goes through `` Maximum Processor Resets, the cFE shall initiate a Power-On Reset of the cFE.","After a number of Processor Resets, the cFE will attempt to recover by doing a Power-on Reset." EVS: Control Message By Event Type,cEVS3000,"Upon receipt of Command the cFE shall enable/disable, as specified in the Command, the future generation of Event Messages for the Command-specified Event Type.",Filtering by type allows the system to behave differently for different users. EVS: Set Event Format Mode,cEVS3001,"Upon receipt of Command, the cFE shall set the Event Format Mode to the command specified value, either Long or Short.",Providing a short format accommodates missions with limited telemetry bandwidth. A long format is desirable because it contains the most information. @@ -331,6 +334,7 @@ SB: Enable Subscription Reporting,cSB4011,"Upon receipt of a Message, the cFE sh SB: Disable Subscription Reporting,cSB4012,"Upon receipt of a Message, the cFE shall disable generation of a message when a subscription is received.",Subscription reporting intended for use by software bus network class of applications. SB: Send Previous Subscriptions,cSB4013,"Upon receipt of a Message, the cFE shall generation messages for current subscriptions.",Subscription reporting intended for use by software bus network class of applications. SB: Create Pipe,cSB4301,"Upon receipt of a Request to create a Pipe, the cFE shall create a Pipe with the Request-specified Pipe Depth and the Request-specified name.",Run time creation of Pipes supports the cFE goals of easy Application integration and system reconfiguration. +SB: Delete Pipe,cSB4302,"Upon receipt of a Request to delete a Pipe, the cFE shall Unsubscribe all messages to the Request-specified Pipe, then remove the Pipe from the Routing Information.",An Application must be capable of freeing its own resources. SB: Subscribe To Message,cSB4303,"Upon receipt of a Request to Subscribe to an SB message, the cFE shall establish a route using the Request-specified Message ID, the Request-specified Pipe ID, the Request-specified MsgId-to-Pipe limit and the Request-specified QoS.",Run time subscription supports the cFE goals of easy system integration and run time reconfigurations. SB: Subscribe To Message - Duplicate,cSB4303.1,If the Subscription is a duplicate of a previous subscription then the cFE shall issue an event message.,"Duplicate subscriptions are still a success, however, want to notify the ground." SB: Unsubscribe To Message,cSB4304,"Upon receipt of a Request to Unsubscribe to an SB Message, the cFE shall remove the route corresponding to the Request-specified Message Id and the Request-specified Pipe Id from the Routing Information.","Allow an Application to dynamically change what Messages it receives. Since the ground can manipulate the state of the routing, it is not considered an error if the Message is not currently being subscribed to when an unsubscribe request is made." @@ -352,8 +356,6 @@ SB: Set Message ID,cSB4312,"Upon receipt of a Request, the cFE shall set the rec SB: Get Message String,cSB4313,"Upon receipt of a Request, the cFE shall provide the requested string from the requested message.",Message management utility. SB: Set Message String,cSB4314,"Upon receipt of a Request, the cFE shall set the requested message with the requested string.",Message management utility. SB: Initialize Message,cSB4315,"Upon receipt of a Request, the cFE shall initialize the requested message with the requested message ID and length.",Message management utility. -SB: Initialize Message - Clear,cSB4315.1,"If requested to clear the packet, the cFE shall fill the sequence counter and packet data with zeros.",Message management utility. -SB: Initialize Message - No Clear,cSB4315.2,"If requested to not clear the packet, the cFE shall retain the provided sequence counter and packet data.",Message management utility. SB: Get User Data Pointer,cSB4316,"Upon receipt of a Request, the cFE shall provide a pointer to the user data of the requested message.",Message management utility. SB: Get User Data Length,cSB4317,"Upon receipt of a Request, the cFE shall provide the user data length of the requested message.",Message management utility. SB: Set User Data Length,cSB4318,"Upon receipt of a Request, the cFE shall set the requested message with the requested user data length.",Message management utility. @@ -364,7 +366,6 @@ SB: Set Message Time,cSB4322,"Upon receipt of a Request, the cFE shall set the r SB: Time Stamp Message,cSB4323,"Upon receipt of a Request, the cFE shall set the requested message with the current time.",Message management utility. SB: Get Command Code,cSB4324,"Upon receipt of a Request, the cFE shall provide the command code from the requested message.",Message management utility. SB: Set Command Code,cSB4325,"Upon receipt of a Request, the cFE shall set the requested message with the requested command code.",Message management utility. -SB: Get Checksum,cSB4326,"Upon receipt of a Request, the cFE shall provide the checksum from the requested message.",Message management utility. SB: Generate Checksum,cSB4327,"Upon receipt of a Request, the cFE shall set the requested message with the current checksum.",Message management utility. SB: Validate Checksum,cSB4328,"Upon receipt of a Request, the cFE shall provide the checksum validation result of the requested message.",Message management utility. SB: Set Pipe Options,cSB4329,"Upon receipt of a Request, the cFE shall set the requested pipe with the requested options.",Pipe management utility. @@ -384,6 +385,13 @@ SB: Zero Copy Send Message,cSB4342,"Upon receipt of a Request, the cFE shall rou SB: Zero Copy Pass Message,cSB4343,"Upon receipt of a Request, the cFE shall route the requested zero copy message to all subscribed pipes without updating the message sequence counter.",Zero copy message passing support for reduced overhead at the cost of additional pointer management. SB: Get Packet Type,cSB4344,"Upon receipt of a Request, the CFE shall provide the message packet type.",Provides abstraction for apps to get the packet type (command or telemetry). SB: Validate Message ID,cSB4345,"Upon receipt of a Request, the cFE shall provide the validation status of the message ID.",Provides abstraction for apps to validate a message ID. +SB: Set Packet Type,cSB4346,"Upon receipt of a Request, the CFE shall set the message packet type.",Provides abstraction for apps to set the packet type (command or telemetry). +SB: Get Header Field,cSB4347,"Upon receipt of a Request, the CFE shall provide the requested message header field.",Provides abstraction for apps to get implementation defined header fields. +SB: Set Header Field,cSB4348,"Upon receipt of a Request, the CFE shall set the requested message header field.",Provides abstraction for apps to set implementation defined header fields. +SB: Get Sequence Count,cSB4349,"Upon receipt of a Request, the CFE shall provide the message sequence count.",Provides abstraction for apps to get the message sequence count. +SB: Set Sequence Count,cSB4350,"Upon receipt of a Request, the CFE shall set the message sequence count.",Provides abstraction for apps to set the message sequence count. +SB: Get Next Sequence Count,cSB4351,"Upon receipt of a Request, the CFE shall provide the next message sequence count.",Provides abstraction for apps to get the next message sequence count value such that rollovers are handled based on the implemented field size. +SB: Get Type From MsgId,cSB4352,"Upon receipt of a Request, the CFE shall provide the message type associated with the requested message ID.","Provides abstraction for apps to get the message type given only the message ID. Supports a variety of implementations allowing for efficient message ID use (supports bit, range, table, or other logic)." SB: Initialize Routing On Power On Reset,cSB4500,Upon a Power-on Reset the cFE shall initialize the Routing Information and clear all error counters.,The cFE must initialize to a known state. SB: Initialize Routing On Processor Reset,cSB4501,Upon a Processor Reset the cFE shall initialize the Routing Information and clear all error counters,The cFE must initialize to a known state. TBL: Load Inactive Table From File,cTBL6000,Upon receipt of Command the cFE shall load an Inactive Table Image with the contents of the Command specified File.,Loading from a file allows for multiple versions of a table to be stored on board and loaded to the active table when appropriate. The file header will identify the Table that the file contents are for. diff --git a/docs/src/cfe_es.dox b/docs/src/cfe_es.dox index 593c41f3b..b8b95a8b7 100644 --- a/docs/src/cfe_es.dox +++ b/docs/src/cfe_es.dox @@ -404,7 +404,7 @@ Or the #CFE_ES_QUERY_ALL_CC command can be used to get information about all the applications that are currently registered with ES. This command - writes the application data to a file and has a one parameter which + writes the application data to a file and has a one parameter which specifies the path and filename of the output file. For either command, the following Application information is made available: @@ -825,6 +825,13 @@ /** \page cfeescmds cFE Executive Services Commands + Upon receipt of any command, the Executive Services application will confirm that the + message length embedded within the header (from `CFE_MSG_GetSize()`) matches the expected + length of that message, based on the size of the C structure defining that command. + If there is any discrepancy between the expected and actual message size, ES will generate + the #CFE_ES_LEN_ERR_EID event, increment the command error counter (\ES_CMDEC), and the + command will _not_ be accepted for processing. + The following is a list of commands that are processed by the cFE Executive Services Task. **/ diff --git a/docs/src/cfe_evs.dox b/docs/src/cfe_evs.dox index 9f0404320..7587a9ef6 100644 --- a/docs/src/cfe_evs.dox +++ b/docs/src/cfe_evs.dox @@ -108,7 +108,7 @@ EVS can be configured to control the Local Event Log to either discard or overwrite the contents of the log when it becomes full. If the mode is set to overwrite, the log is treated like a circular buffer, overwriting the oldest event message contained - in the log first. This control is configured by default in the cfe_platform_cfg.h + in the log first. This control is configured by default in the cfe_platform_cfg.h file but can be modified by \link #CFE_EVS_SET_LOG_MODE_CC a command \endlink. @@ -170,7 +170,7 @@ the events that it wants to register for filtering along with the \ref cfeevsugmsgfilter (only the Binary Filtering Scheme exists currently). Note that applications are limited in the number of events that - they can register for filtering (see #CFE_PLATFORM_EVS_MAX_EVENT_FILTERS in cfe_platform_cfg.h + they can register for filtering (see #CFE_PLATFORM_EVS_MAX_EVENT_FILTERS in cfe_platform_cfg.h for the mission defined limit). The filtering method uses a mask to determine if the message is forwarded to the software bus, making it available in telemetry (see \ref cfeevsugmsgfilter for a description on filtering). Commands are available to @@ -500,6 +500,13 @@ /** ** \page cfeevscmds cFE Event Services Commands ** +** Upon receipt of any command, the Event Services application will confirm that the +** message length embedded within the header (from `CFE_MSG_GetSize()`) matches the expected +** length of that message, based on the size of the C structure defining that command. +** If there is any discrepancy between the expected and actual message size, EVS will generate +** the #CFE_EVS_LEN_ERR_EID event, increment the command error counter (\EVS_CMDEC), and the +** command will _not_ be accepted for processing. +** ** The following is a list of commands that are processed by the cFE Event Services Task. **/ @@ -515,4 +522,3 @@ ** The following are configuration parameters used to configure the cFE Event Services ** either for each platform or for a mission as a whole. **/ - diff --git a/docs/src/cfe_sb.dox b/docs/src/cfe_sb.dox index 2212c01fe..0f07d62fd 100644 --- a/docs/src/cfe_sb.dox +++ b/docs/src/cfe_sb.dox @@ -584,6 +584,13 @@ /** ** \page cfesbcmds cFE Software Bus Commands ** +** Upon receipt of any command, the Software Bus application will confirm that the +** message length embedded within the header (from `CFE_MSG_GetSize()`) matches the expected +** length of that message, based on the size of the C structure defining that command. +** If there is any discrepancy between the expected and actual message size, SB will generate +** the #CFE_SB_LEN_ERR_EID event, increment the command error counter (\SB_CMDEC), and the +** command will _not_ be accepted for processing. +** ** The following is a list of commands that are processed by the cFE Software Bus Task. **/ diff --git a/docs/src/cfe_tbl.dox b/docs/src/cfe_tbl.dox index 59121495f..cdbe6ca38 100644 --- a/docs/src/cfe_tbl.dox +++ b/docs/src/cfe_tbl.dox @@ -39,7 +39,7 @@ updated (or in the case of dump-only tables, dumped). Most Applications perform this periodic management at the same time as housekeeping requests are processed. This table management is performed by the cFE Application that "owns" a table (ie - the cFE Application that registered - the table with cFE Table Services). It is possible for cFE Applications to "share" a table with + the table with cFE Table Services). It is possible for cFE Applications to "share" a table with other cFE Applications. An Application that shares a table does not typically perform any of the management duties associated with that table. @@ -414,6 +414,13 @@ /** ** \page cfetblcmds cFE Table Services Commands ** +** Upon receipt of any command, the Table Services application will confirm that the +** message length embedded within the header (from `CFE_MSG_GetSize()`) matches the expected +** length of that message, based on the size of the C structure defining that command. +** If there is any discrepancy between the expected and actual message size, TBL will generate +** the #CFE_TBL_LEN_ERR_EID event, increment the command error counter (\TBL_CMDEC), and the +** command will _not_ be accepted for processing. +** ** The following is a list of commands that are processed by the cFE Table Services Task. **/ @@ -429,4 +436,3 @@ ** The following are configuration parameters used to configure the cFE Table Services ** either for each platform or for a mission as a whole. **/ - diff --git a/docs/src/cfe_time.dox b/docs/src/cfe_time.dox index f12ffa796..faa177754 100644 --- a/docs/src/cfe_time.dox +++ b/docs/src/cfe_time.dox @@ -215,7 +215,7 @@ In the third system, the MET is located on hardware connected via spacewire. When MET seconds increment, a spacewire time tick triggers a local processor interrupt to signal the tone. Shortly after announcing the tone, the hardware containing the MET also generates a spacewire - data packet containing the MET value corresponding to the tone. TIME must wait until both + data packet containing the MET value corresponding to the tone. TIME must wait until both the tone and data packet have been received before validating the tone. The tone must have occurred approximately one second after the previous tone signal and the data packet must have been received within a specified window in time following the tone. @@ -766,7 +766,7 @@ that can be made to the STCF to compensate for oscillator drift. Mission specific ground correlation should be used to assist in determining the proper values to use. The Leap Seconds should be - set to the current TAI-UTC. Note that the International Earth + set to the current TAI-UTC. Note that the International Earth Rotation and Reference Systems Service Bulletin C, which defines the current difference, reports it as UTC-TAI, and thus that value must be negated. The Leap Seconds value will always be a positive @@ -825,6 +825,13 @@ /** ** \page cfetimecmds cFE Time Services Commands ** +** Upon receipt of any command, the Time Services application will confirm that the +** message length embedded within the header (from `CFE_MSG_GetSize()`) matches the expected +** length of that message, based on the size of the C structure defining that command. +** If there is any discrepancy between the expected and actual message size, TIME will generate +** the #CFE_TIME_LEN_ERR_EID event, increment the command error counter (\TIME_CMDEC), and the +** command will _not_ be accepted for processing. +** ** The following is a list of commands that are processed by the cFE Time Services Task. **/ @@ -840,4 +847,3 @@ ** The following are configuration parameters used to configure the cFE Time Services ** either for each platform or for a mission as a whole. **/ - diff --git a/modules/cfe_assert/src/cfe_assert_io.c b/modules/cfe_assert/src/cfe_assert_io.c index f07a38d96..b16a0377f 100644 --- a/modules/cfe_assert/src/cfe_assert_io.c +++ b/modules/cfe_assert/src/cfe_assert_io.c @@ -43,7 +43,7 @@ void UT_BSP_Lock(void) int32 rc; rc = OS_MutSemTake(CFE_Assert_Global.AccessMutex); - if (rc != CFE_SUCCESS) + if (rc != OS_SUCCESS) { CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %d\n", __func__, (int)rc); } @@ -54,7 +54,7 @@ void UT_BSP_Unlock(void) int32 rc; rc = OS_MutSemGive(CFE_Assert_Global.AccessMutex); - if (rc != CFE_SUCCESS) + if (rc != OS_SUCCESS) { CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %d\n", __func__, (int)rc); } diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index 7606c6f64..1318d7926 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -8,7 +8,9 @@ add_cfe_app(cfe_testcase src/es_misc_test.c src/es_mempool_test.c src/fs_header_test.c + src/fs_util_test.c src/sb_pipe_mang_test.c + src/time_arithmetic_test.c src/time_current_test.c ) diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index e9fa16c60..016eadc57 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -51,13 +51,15 @@ void CFE_TestMain(void) /* * Register test cases in UtAssert */ - ESInfoTestSetup(); - ESTaskTestSetup(); ESCDSTestSetup(); - ESMiscTestSetup(); + ESInfoTestSetup(); ESMemPoolTestSetup(); + ESMiscTestSetup(); + ESTaskTestSetup(); FSHeaderTestSetup(); + FSUtilTestSetup(); SBPipeMangSetup(); + TimeArithmeticTestSetup(); TimeCurrentTestSetup(); /* diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index 0d8a77058..e661c6849 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -43,6 +43,11 @@ #include "uttest.h" #include "utassert.h" +typedef struct +{ + CFE_FS_FileWriteMetaData_t FuncTestState; +} CFE_FT_Global_t; + /** * Name of log file to write * @@ -73,13 +78,15 @@ #define cFE_FTAssert_VOIDCALL(func) (func, UtAssert(true, #func, __FILE__, __LINE__)) void CFE_TestMain(void); -void ESInfoTestSetup(void); -void ESTaskTestSetup(void); void ESCDSTestSetup(void); -void ESMiscTestSetup(void); +void ESInfoTestSetup(void); void ESMemPoolTestSetup(void); +void ESMiscTestSetup(void); +void ESTaskTestSetup(void); void FSHeaderTestSetup(void); +void FSUtilTestSetup(void); void SBPipeMangSetup(void); +void TimeArithmeticTestSetup(void); void TimeCurrentTestSetup(void); #endif /* CFE_TEST_H */ diff --git a/modules/cfe_testcase/src/fs_util_test.c b/modules/cfe_testcase/src/fs_util_test.c new file mode 100644 index 000000000..8e7d865c0 --- /dev/null +++ b/modules/cfe_testcase/src/fs_util_test.c @@ -0,0 +1,162 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-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: es_info_test.c +** +** Purpose: +** Functional test of FS File Utility APIs +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +CFE_FT_Global_t CFE_FT_Global; + +void TestFileCategory(void) +{ + UtPrintf("Testing: CFE_FS_GetDefaultMountPoint, CFE_FS_GetDefaultExtension"); + + UtAssert_NULL(CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_UNKNOWN)); + UtAssert_NULL(CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_UNKNOWN)); +} + +void TestInputFile(void) +{ + char NameBuf[OS_MAX_PATH_LEN]; + char OutNameBuf[OS_MAX_PATH_LEN]; + const char Name[] = "FileName"; + char InNameBuf[] = "BufferName"; + const char Path[] = "/func"; + const char Ext[] = ".test"; + const char ExpectedName[] = "/func/FileName.test"; + const char ExpectedBuf[] = "/func/BufferName.test"; + + UtPrintf("Testing: CFE_FS_ParseInputFileName, CFE_FS_ParseInputFileNameEX"); + + UtAssert_INT32_EQ(CFE_FS_ParseInputFileName(NameBuf, Name, sizeof(NameBuf), CFE_FS_FileCategory_SCRIPT), + CFE_SUCCESS); + UtAssert_NOT_NULL(strstr(NameBuf, Name)); + + UtAssert_INT32_EQ(CFE_FS_ParseInputFileName(NULL, Name, sizeof(NameBuf), CFE_FS_FileCategory_SCRIPT), + CFE_FS_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_FS_ParseInputFileName(NameBuf, NULL, sizeof(NameBuf), CFE_FS_FileCategory_SCRIPT), + CFE_FS_INVALID_PATH); + UtAssert_INT32_EQ(CFE_FS_ParseInputFileName(NameBuf, Name, 0, CFE_FS_FileCategory_SCRIPT), CFE_FS_BAD_ARGUMENT); + + UtAssert_INT32_EQ( + CFE_FS_ParseInputFileNameEx(OutNameBuf, InNameBuf, sizeof(OutNameBuf), sizeof(InNameBuf), Name, Path, Ext), + CFE_SUCCESS); + UtAssert_StrCmp(ExpectedBuf, OutNameBuf, "Parse Input EX: %s", OutNameBuf); + UtAssert_INT32_EQ( + CFE_FS_ParseInputFileNameEx(OutNameBuf, NULL, sizeof(OutNameBuf), sizeof(InNameBuf), Name, Path, Ext), + CFE_SUCCESS); + UtAssert_StrCmp(ExpectedName, OutNameBuf, "Parse Input EX: %s", OutNameBuf); + UtAssert_INT32_EQ(CFE_FS_ParseInputFileNameEx(OutNameBuf, InNameBuf, sizeof(OutNameBuf), 0, Name, Path, Ext), + CFE_SUCCESS); + UtAssert_StrCmp(ExpectedName, OutNameBuf, "Parse Input EX: %s", OutNameBuf); + UtAssert_INT32_EQ( + CFE_FS_ParseInputFileNameEx(OutNameBuf, InNameBuf, sizeof(OutNameBuf), sizeof(InNameBuf), NULL, Path, Ext), + CFE_SUCCESS); + UtAssert_StrCmp(ExpectedBuf, OutNameBuf, "Parse Input EX: %s", OutNameBuf); + + UtAssert_INT32_EQ( + CFE_FS_ParseInputFileNameEx(NULL, InNameBuf, sizeof(OutNameBuf), sizeof(InNameBuf), Name, Path, Ext), + CFE_FS_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_FS_ParseInputFileNameEx(OutNameBuf, InNameBuf, 0, sizeof(InNameBuf), Name, Path, Ext), + CFE_FS_BAD_ARGUMENT); + UtAssert_INT32_EQ( + CFE_FS_ParseInputFileNameEx(OutNameBuf, NULL, sizeof(OutNameBuf), sizeof(InNameBuf), NULL, Path, Ext), + CFE_FS_INVALID_PATH); + UtAssert_INT32_EQ(CFE_FS_ParseInputFileNameEx(OutNameBuf, InNameBuf, sizeof(OutNameBuf), 0, NULL, Path, Ext), + CFE_FS_INVALID_PATH); +} + +void TestFileName(void) +{ + const char Path[] = "/func/FileName.test"; + char Name[OS_MAX_FILE_NAME]; + const char ExpectedName[] = "FileName.test"; + + UtPrintf("Testing: CFE_FS_ExtractFilenameFromPath"); + + UtAssert_INT32_EQ(CFE_FS_ExtractFilenameFromPath(Path, Name), CFE_SUCCESS); + UtAssert_StrCmp(Name, ExpectedName, "Extract Filename: %s", Name); + + UtAssert_INT32_EQ(CFE_FS_ExtractFilenameFromPath(NULL, Name), CFE_FS_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_FS_ExtractFilenameFromPath(Path, NULL), CFE_FS_BAD_ARGUMENT); +} + +/* FT helper stub compatible with background file write DataGetter */ +bool FS_DataGetter(void *Meta, uint32 RecordNum, void **Buffer, size_t *BufSize) +{ + *Buffer = NULL; + *BufSize = 0; + return true; +} + +/* FT helper stub compatible with background file write OnEvent */ +void FS_OnEvent(void *Meta, CFE_FS_FileWriteEvent_t Event, int32 Status, uint32 RecordNum, size_t BlockSize, + size_t Position) +{ +} + +void TestFileDump(void) +{ + memset(&CFE_FT_Global.FuncTestState, 0, sizeof(CFE_FT_Global.FuncTestState)); + CFE_FT_Global.FuncTestState.FileSubType = 2; + CFE_FT_Global.FuncTestState.GetData = FS_DataGetter; + CFE_FT_Global.FuncTestState.OnEvent = FS_OnEvent; + strncpy(CFE_FT_Global.FuncTestState.FileName, "/ram/FT.bin", sizeof(CFE_FT_Global.FuncTestState.FileName)); + strncpy(CFE_FT_Global.FuncTestState.Description, "FT", sizeof(CFE_FT_Global.FuncTestState.Description)); + int count = 0; + int MaxWait = 20; + + UtPrintf("Testing: CFE_FS_BackgroundFileDumpRequest, CFE_FS_BackgroundFileDumpIsPending"); + + UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), false); + UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(&CFE_FT_Global.FuncTestState), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), true); + + /* Wait for background task to complete */ + while (CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState) && count < MaxWait) + { + OS_TaskDelay(100); + count++; + } + + UtAssert_True(count < MaxWait, "count (%i) < MaxWait (%i)", count, MaxWait); + + UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(NULL), CFE_FS_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(NULL), false); +} + +void FSUtilTestSetup(void) +{ + UtTest_Add(TestFileCategory, NULL, NULL, "Test File Category"); + UtTest_Add(TestInputFile, NULL, NULL, "Test Input File"); + UtTest_Add(TestFileName, NULL, NULL, "Test File Name"); + UtTest_Add(TestFileDump, NULL, NULL, "Test File Dump"); +} diff --git a/modules/cfe_testcase/src/time_arithmetic_test.c b/modules/cfe_testcase/src/time_arithmetic_test.c new file mode 100644 index 000000000..9834829e7 --- /dev/null +++ b/modules/cfe_testcase/src/time_arithmetic_test.c @@ -0,0 +1,129 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-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: time_arithmetic_test.c +** +** Purpose: +** Functional test of basic Time Arithmetic APIs +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +void TestTimeAdd(void) +{ + UtPrintf("Testing: CFE_TIME_Add"); + CFE_TIME_SysTime_t time1 = {1000, 0}; + CFE_TIME_SysTime_t time2 = {0, 1000}; + CFE_TIME_SysTime_t timeAdded = CFE_TIME_Add(time1, time2); + CFE_TIME_SysTime_t timeExpected = {1000, 1000}; + + UtAssert_UINT32_EQ(timeAdded.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeAdded.Subseconds, timeExpected.Subseconds); + + time1.Seconds = UINT32_MAX; + time1.Subseconds = UINT32_MAX; + time2.Seconds = 0; + time2.Subseconds = 1; + timeAdded = CFE_TIME_Add(time1, time2); + timeExpected.Seconds = 0; + timeExpected.Subseconds = 0; + UtAssert_UINT32_EQ(timeAdded.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeAdded.Subseconds, timeExpected.Subseconds); + + time1.Seconds = UINT32_MAX; + time1.Subseconds = UINT32_MAX; + time2.Seconds = UINT32_MAX; + time2.Subseconds = UINT32_MAX; + timeAdded = CFE_TIME_Add(time1, time2); + timeExpected.Seconds = UINT32_MAX; + timeExpected.Subseconds = UINT32_MAX - 1; + UtAssert_UINT32_EQ(timeAdded.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeAdded.Subseconds, timeExpected.Subseconds); +} + +void TestTimeSubtract(void) +{ + UtPrintf("Testing: CFE_TIME_Subtract"); + CFE_TIME_SysTime_t time1 = {1000, 1000}; + CFE_TIME_SysTime_t time2 = {999, 999}; + CFE_TIME_SysTime_t timeSubtracted = CFE_TIME_Subtract(time1, time2); + CFE_TIME_SysTime_t timeExpected = {1, 1}; + + UtAssert_UINT32_EQ(timeSubtracted.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeSubtracted.Subseconds, timeExpected.Subseconds); + + time1.Seconds = 0; + time1.Subseconds = 0; + time2.Seconds = UINT32_MAX; + time2.Subseconds = UINT32_MAX; + timeSubtracted = CFE_TIME_Subtract(time1, time2); + timeExpected.Seconds = 0; + timeExpected.Subseconds = 1; + UtAssert_UINT32_EQ(timeSubtracted.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeSubtracted.Subseconds, timeExpected.Subseconds); + + time1.Seconds = 0; + time1.Subseconds = 0; + time2.Seconds = 0; + time2.Subseconds = 1; + timeSubtracted = CFE_TIME_Subtract(time1, time2); + timeExpected.Seconds = UINT32_MAX; + timeExpected.Subseconds = UINT32_MAX; + UtAssert_UINT32_EQ(timeSubtracted.Seconds, timeExpected.Seconds); + UtAssert_UINT32_EQ(timeSubtracted.Subseconds, timeExpected.Subseconds); +} + +void TestTimeCompare(void) +{ + UtPrintf("Testing: CFE_TIME_Compare"); + CFE_TIME_SysTime_t time1 = {1000, 1000}; + CFE_TIME_SysTime_t time2 = {999, 999}; + UtAssert_UINT32_EQ(CFE_TIME_Compare(time1, time2), CFE_TIME_A_GT_B); + UtAssert_UINT32_EQ(CFE_TIME_Compare(time2, time1), CFE_TIME_A_LT_B); + + time1.Seconds = 500; + time1.Subseconds = 1; + time2.Seconds = 500; + time2.Subseconds = 1; + UtAssert_UINT32_EQ(CFE_TIME_Compare(time1, time2), CFE_TIME_EQUAL); + UtAssert_UINT32_EQ(CFE_TIME_Compare(time2, time1), CFE_TIME_EQUAL); + + // time1 > time2 here due to the roll over handling of the comparison + time1.Seconds = 1; + time1.Subseconds = 1; + time2.Seconds = UINT32_MAX; + time2.Subseconds = UINT32_MAX; + UtAssert_UINT32_EQ(CFE_TIME_Compare(time1, time2), CFE_TIME_A_GT_B); + UtAssert_UINT32_EQ(CFE_TIME_Compare(time2, time1), CFE_TIME_A_LT_B); +} + +void TimeArithmeticTestSetup(void) +{ + UtTest_Add(TestTimeAdd, NULL, NULL, "Test Time Addition"); + UtTest_Add(TestTimeSubtract, NULL, NULL, "Test Time Subtraction"); + UtTest_Add(TestTimeCompare, NULL, NULL, "Test Time Comparison"); +} diff --git a/modules/core_api/fsw/inc/cfe_fs.h b/modules/core_api/fsw/inc/cfe_fs.h index 1fd3d1bd1..c89a884ed 100644 --- a/modules/core_api/fsw/inc/cfe_fs.h +++ b/modules/core_api/fsw/inc/cfe_fs.h @@ -64,7 +64,11 @@ ** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate ** that is associated with the file whose header is to be read. ** -** \return Bytes read or error status, see \ref CFEReturnCodes +** \return Bytes read or error status from OSAL +** +** \note This function invokes OSAL API routines and the current implementation may return +** OSAL error codes to the caller if failure occurs. In a future version of CFE, the +** status codes will be converted to a value in \ref CFEReturnCodes. ** ** \sa #CFE_FS_WriteHeader ** @@ -124,7 +128,11 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub ** filled with the contents of the Standard cFE File Header. *Hdr is the contents of the ** Standard cFE File Header for the specified file. ** -** \return Bytes written or error status, see \ref CFEReturnCodes +** \return Bytes read or error status from OSAL +** +** \note This function invokes OSAL API routines and the current implementation may return +** OSAL error codes to the caller if failure occurs. In a future version of CFE, the +** status codes will be converted to a value in \ref CFEReturnCodes. ** ** \sa #CFE_FS_ReadHeader ** @@ -151,7 +159,11 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr); ** \param[in] NewTimestamp A #CFE_TIME_SysTime_t data structure containing the desired time ** to be put into the file's Standard cFE File Header. ** -** \return Execution status, see \ref CFEReturnCodes +** \return Execution status, see \ref CFEReturnCodes, or OSAL status +** +** \note This function invokes OSAL API routines and the current implementation may return +** OSAL error codes to the caller if failure occurs. In a future version of CFE, the +** status codes will be converted to a value in \ref CFEReturnCodes. ** ******************************************************************************/ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp); @@ -291,8 +303,8 @@ CFE_Status_t CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *File ** Puts the previously-initialized metadata into the pending request queue ** ** \par Assumptions, External Events, and Notes: -** Metadata structure should be stored in a static memory area (not on heap) as it -** must persist and be accessible by the file writer task throughout the asynchronous +** Metadata structure should be stored in a persistent memory area (not on stack) as +** it must remain accessible by the file writer task throughout the asynchronous ** job operation. ** ** \param[inout] Meta The background file write persistent state object diff --git a/modules/core_api/fsw/inc/cfe_fs_api_typedefs.h b/modules/core_api/fsw/inc/cfe_fs_api_typedefs.h index 0e7a80594..604c1ffb8 100644 --- a/modules/core_api/fsw/inc/cfe_fs_api_typedefs.h +++ b/modules/core_api/fsw/inc/cfe_fs_api_typedefs.h @@ -84,6 +84,18 @@ typedef enum * Data Getter routine provided by requester * * Outputs a data block. Should return true if the file is complete (last record/EOF), otherwise return false. + * + * \param[inout] Meta Pointer to the metadata object + * \param[in] RecordNum Incrementing record number counter + * \param[out] Buffer Pointer to buffer data block, should be set by implementation + * \param[out] BufSize Pointer to buffer data size, should be set by implementation + * + * \returns End of file status + * \retval true if at last data record, and output file should be closed + * \retval false if not at last record, more data records to write + * + * \note The implementation of this function must always set the "Buffer" and "BufSize" outputs. If + * no data is avaliable, they may be set to NULL and 0, respectively. */ typedef bool (*CFE_FS_FileWriteGetData_t)(void *Meta, uint32 RecordNum, void **Buffer, size_t *BufSize); @@ -92,6 +104,14 @@ typedef bool (*CFE_FS_FileWriteGetData_t)(void *Meta, uint32 RecordNum, void **B * * Invoked from certain points in the file write process. Implementation may invoke CFE_EVS_SendEvent() appropriately * to inform of progress. + * + * \param[inout] Meta Pointer to the metadata object + * \param[in] Event Generalized type of event to report (not actual event ID) + * \param[in] Status Generalized status code (may be from OSAL or CFE) + * \param[in] RecordNum Record number counter at which event occurred + * \param[in] BlockSize Size of record being processed when event occured (if applicable) + * \param[in] Position File position/size when event occurred + * */ typedef void (*CFE_FS_FileWriteOnEvent_t)(void *Meta, CFE_FS_FileWriteEvent_t Event, int32 Status, uint32 RecordNum, size_t BlockSize, size_t Position); diff --git a/modules/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index aebe481bc..07583ddc9 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -28,7 +28,7 @@ #define CFE_VERSION_H /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 762 /**< @brief Development: Number of development commits since baseline */ +#define CFE_BUILD_NUMBER 789 /**< @brief Development: Number of development commits since baseline */ #define CFE_BUILD_BASELINE "v6.8.0-rc1" /**< @brief Development: Reference git tag for build number */ /* Version Macro Definitions updated for official releases only */ diff --git a/modules/es/fsw/inc/cfe_es_msg.h b/modules/es/fsw/inc/cfe_es_msg.h index a52965c4c..50c5aab76 100644 --- a/modules/es/fsw/inc/cfe_es_msg.h +++ b/modules/es/fsw/inc/cfe_es_msg.h @@ -64,6 +64,8 @@ ** following telemetry: ** - \b \c \ES_CMDPC - command execution counter will ** increment +** - The #CFE_ES_BUILD_INF_EID informational event message will +** be generated ** - The #CFE_ES_NOOP_INF_EID informational event message will ** be generated ** @@ -98,18 +100,16 @@ ** \par Command Verification ** Successful execution of this command may be verified with ** the following telemetry: -** - \b \c \ES_CMDPC - command execution counter will -** increment +** - \b \c \ES_CMDPC - command execution counter and error counter will +** be reset to zero ** - The #CFE_ES_RESET_INF_EID informational event message will be ** generated ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - the #CFE_ES_LEN_ERR_EID error event message will be generated +** There are no error conditions for this command. If the Executive +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. ** ** \par Criticality ** This command is not inherently dangerous. However, it is @@ -140,9 +140,12 @@ ** #CFE_ES_RestartCmd_t ** ** \par Command Verification -** Successful execution of this command (as a Processor Reset) -** may be verified with the following telemetry: -** - \b \c \ES_PROCRESETCNT - processor reset counter will increment +** Successful execution of this command may be verified with the +** following telemetry: +** - \b \c \ES_PROCRESETCNT - processor reset counter will increment (processor +** reset) or reset to zero (power-on reset) +** - \b \c \ES_RESETTYPE - processor reset type will be updated +** - \b \c \ES_RESETSUBTYPE - processor reset subtype will be updated ** - New entries in the Exception Reset Log and System Log can be found
** NOTE: Verification of a Power-On Reset is shown through the loss of ** data nominally retained through a Processor Reset
@@ -152,7 +155,6 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The \link #CFE_ES_RestartCmd_Payload_t Restart Type \endlink was ** not a recognized value. ** @@ -192,13 +194,10 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application filename string is either a NULL string -** or less than four characters in length -** - The specified application entry point is a NULL string -** - The specified application name is a NULL string -** - The specified stack size is less than #CFE_PLATFORM_ES_DEFAULT_STACK_SIZE -** - The specified priority is greater than MAX_PRIORITY (as defined in osapi.c) +** - The specified application filename string cannot be parsed +** - The specified application entry point is an empty string +** - The specified application name is an empty string +** - The specified priority is greater than 255 ** - The specified exception action is neither #CFE_ES_ExceptionAction_RESTART_APP (0) or ** #CFE_ES_ExceptionAction_PROC_RESTART (1) ** - The Operating System was unable to load the specified application file @@ -239,15 +238,18 @@ ** increment ** - The #CFE_ES_STOP_DBG_EID debug event message will be ** generated. NOTE: This event message only identifies that the -** stop has been started, not that is has completed. +** stop request has been initiated, not that is has completed. ** - Once the stop has successfully completed, the list of Applications ** and Tasks created in response to the \b \c \ES_WRITEAPPINFO2FILE, ** \b \c \ES_WRITETASKINFO2FILE should no longer contain the ** specified application. +** - \b \c \ES_REGTASKS - number of tasks will decrease after tasks +** associated with app (main task and any child tasks) are stopped +** - \b \c \ES_REGEXTAPPS - external application counter will decrement +** after app is cleaned up ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The specified application name is not recognized as an active application ** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) ** @@ -289,11 +291,10 @@ ** increment ** - The #CFE_ES_RESTART_APP_DBG_EID debug event message will be ** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. +** restart process has been initiated, not that is has completed. ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The original file is missing ** - The specified application name is not recognized as an active application ** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) @@ -336,12 +337,11 @@ ** increment ** - The #CFE_ES_RELOAD_APP_DBG_EID debug event message will be ** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. +** reload process has been initiated, not that is has completed. ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The reload file is missing +** - The specified application filename string cannot be parsed ** - The specified application name is not recognized as an active application ** - The specified application is one of the cFE's Core applications (ES, EVS, SB, TBL, TIME) ** @@ -361,11 +361,11 @@ */ #define CFE_ES_RELOAD_APP_CC 7 -/** \cfeescmd Request Executive Services Information on a Specified Application +/** \cfeescmd Request Executive Services Information on a specified module ** ** \par Description ** This command takes the information kept by Executive Services on the -** specified application and telemeters it to the ground. +** specified application or library and telemeters it to the ground. ** ** \cfecmdmnemonic \ES_QUERYAPP ** @@ -378,14 +378,12 @@ ** - \b \c \ES_CMDPC - command execution counter will ** increment ** - The #CFE_ES_ONE_APP_EID debug event message will be -** generated. NOTE: This event message only identifies that the -** act of stopping the application has begun, not that is has completed. +** generated. ** - Receipt of the #CFE_ES_OneAppTlm_t telemetry packet ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified application name is not recognized as an active application +** - The specified name is not recognized as an active application or library ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \ES_CMDEC - command error counter will increment @@ -399,11 +397,11 @@ */ #define CFE_ES_QUERY_ONE_CC 8 -/** \cfeescmd Writes all Executive Services Information on All Applications to a File +/** \cfeescmd Writes all Executive Services Information on all loaded modules to a File ** ** \par Description ** This command takes the information kept by Executive Services on all of the -** registered applications and writes it to the specified file. +** registered applications and libraries and writes it to the specified file. ** ** \cfecmdmnemonic \ES_WRITEAPPINFO2FILE ** @@ -423,7 +421,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect +** - The specified FileName cannot be parsed ** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: @@ -462,13 +460,10 @@ ** - \b \c \ES_SYSLOGENTRIES - Number of System Log Entries will go to zero ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases +** There are no error conditions for this command. If the Executive +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. ** ** \par Criticality ** This command is not dangerous. However, any previously logged data @@ -503,7 +498,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect +** - The specified FileName cannot be parsed ** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: @@ -543,13 +538,10 @@ ** - \b \c \ES_ERLOGINDEX - Index into Exception Reset Log goes to zero ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases +** There are no error conditions for this command. If the Executive +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. ** ** \par Criticality ** This command is not dangerous. However, any previously logged data @@ -583,7 +575,8 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect +** - A previous request to write the ER log has not yet completed +** - The specified FileName cannot be parsed ** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: @@ -630,7 +623,6 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - A previous #CFE_ES_STOP_PERF_DATA_CC command has not completely finished. ** - An invalid trigger mode is requested. ** @@ -647,10 +639,11 @@ */ #define CFE_ES_START_PERF_DATA_CC 14 -/** \cfeescmd Stop Performance Analyzer +/** \cfeescmd Stop Performance Analyzer and write data file ** ** \par Description -** This command stops the Performance Analyzer from collecting any more data. +** This command stops the Performance Analyzer from collecting any more data, +** and writes all previously collected performance data to a log file. ** ** \cfecmdmnemonic \ES_STOPLADATA ** @@ -665,26 +658,32 @@ ** - \b \c \ES_PERFSTATE - Current performance analyzer state will change to ** IDLE. ** - The #CFE_ES_PERF_STOPCMD_EID debug event message will be -** generated. +** generated to indicate that data collection has been stopped. +** NOTE: Performance log data is written to the file as a background job. +** This event indicates that the file write process is initiated, not that +** it has completed. ** - The file specified in the command (or the default specified ** by the #CFE_PLATFORM_ES_DEFAULT_PERF_DUMP_FILENAME configuration parameter) will be ** updated with the lastest information. ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - A previous Stop Performance Analyzer command is still in process -** - An error occurred while spawning the child task responsible for -** dumping the Performance Analyzer data to a file +** - The file name specified could not be parsed +** - Log data from a previous Stop Performance Analyzer command is still +** being written to a file. ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \ES_CMDEC - command error counter will increment ** - A command specific error event message is issued for all error ** cases ** +** NOTE: The performance analyzer data collection will still be stopped +** in the event of an error parsing the log file name or writing the log file. +** ** \par Criticality -** This command is not inherently dangerous. An additional low priority child -** task will be spawned, however, to dump the performance analyzer data to a file. +** This command is not inherently dangerous. However, depending on configuration, +** performance data log files may be large in size and thus may fill the available +** storage. ** ** \sa #CFE_ES_START_PERF_DATA_CC, #CFE_ES_SET_PERF_FILTER_MASK_CC, #CFE_ES_SET_PERF_TRIGGER_MASK_CC */ @@ -712,7 +711,6 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The Filter Mask ID number is out of range ** ** Evidence of failure may be found in the following telemetry: @@ -750,7 +748,6 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The Trigger Mask ID number is out of range ** ** Evidence of failure may be found in the following telemetry: @@ -790,7 +787,6 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The desired mode is neither #CFE_ES_LogMode_OVERWRITE or #CFE_ES_LogMode_DISCARD ** ** Evidence of failure may be found in the following telemetry: @@ -830,13 +826,10 @@ ** generated. ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases +** There are no error conditions for this command. If the Executive +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. ** ** \par Criticality ** This command is not critical. The only impact would be that the system @@ -869,13 +862,10 @@ ** generated. ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - The command packet length is incorrect -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \ES_CMDEC - command error counter will increment -** - A command specific error event message is issued for all error -** cases +** There are no error conditions for this command. If the Executive +** Services receives the command, the event is sent (although it +** may be filtered by EVS) and the counter is incremented +** unconditionally. ** ** \par Criticality ** If the operator were to set the Maximum Processor Reset Count to too high a value, @@ -911,8 +901,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect -** - The specified CDS is the CDS portion of a Critical Table. See #CFE_TBL_DELETE_CDS_CC. +** - The specified CDS is the CDS portion of a Critical Table ** - The specified CDS is not found in the CDS Registry ** - The specified CDS is associated with an Application that is still active ** - An error occurred while accessing the CDS memory (see the System Log for more details) @@ -954,10 +943,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect ** - The specified handle is not associated with a known memory pool -** - The specified handle caused a processor exception because it improperly -** identified a segment of memory ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \ES_CMDEC - command error counter will increment @@ -997,7 +983,8 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - Error occurred while trying to create the dump file +** - The file name specified could not be parsed +** - Error occurred while creating or writing to the dump file ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \ES_CMDEC - command error counter will increment @@ -1038,7 +1025,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - The command packet length is incorrect +** - The file name specified could not be parsed ** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: @@ -1204,7 +1191,7 @@ typedef struct CFE_ES_StartApp **/ typedef struct CFE_ES_AppNameCmd_Payload { - char Application[CFE_MISSION_MAX_API_LEN]; /**< \brief ASCII text string containing Application Name */ + char Application[CFE_MISSION_MAX_API_LEN]; /**< \brief ASCII text string containing Application or Library Name */ } CFE_ES_AppNameCmd_Payload_t; /** diff --git a/modules/es/fsw/src/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c index a5235e17d..f43bfc024 100644 --- a/modules/es/fsw/src/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -2174,6 +2174,11 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) return CFE_ES_ERR_RESOURCEID_NOT_VALID; } + if (Idx == NULL) + { + return CFE_ES_BAD_ARGUMENT; + } + OsalID = CFE_ES_TaskId_ToOSAL(TaskID); if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) { diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index e886ebbd8..4c2585caf 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -188,7 +188,7 @@ int32 CFE_ES_BackgroundInit(void) CFE_ES_BACKGROUND_CHILD_STACK_SIZE, CFE_ES_BACKGROUND_CHILD_PRIORITY, CFE_ES_BACKGROUND_CHILD_FLAGS); - if (status != OS_SUCCESS) + if (status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("%s: Failed to create background task: %08lx\n", __func__, (unsigned long)status); return status; diff --git a/modules/es/fsw/src/cfe_es_cds.c b/modules/es/fsw/src/cfe_es_cds.c index f173dec77..bf61381e9 100644 --- a/modules/es/fsw/src/cfe_es_cds.c +++ b/modules/es/fsw/src/cfe_es_cds.c @@ -488,7 +488,7 @@ int32 CFE_ES_ValidateCDS(void) /* Perform 2 checks to validate the CDS Memory Pool */ /* First, determine if the first validity check field is correct */ Status = CFE_ES_CDS_CacheFetch(&CDS->Cache, CDS_SIG_BEGIN_OFFSET, SIG_CDS_SIZE); - if (Status != CFE_PSP_SUCCESS) + if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("%s: 1st ReadFromCDS Failed. Status=0x%X\n", __func__, (unsigned int)Status); return Status; @@ -504,7 +504,7 @@ int32 CFE_ES_ValidateCDS(void) TrailerOffset -= sizeof(CFE_ES_CDS_PersistentTrailer_t); Status = CFE_ES_CDS_CacheFetch(&CDS->Cache, TrailerOffset, SIG_CDS_SIZE); - if (Status != CFE_PSP_SUCCESS) + if (Status != CFE_SUCCESS) { /* BSP reported an error reading from CDS */ CFE_ES_WriteToSysLog("%s: 2nd ReadFromCDS Failed. Status=0x%X\n", __func__, (unsigned int)Status); @@ -599,7 +599,7 @@ int32 CFE_ES_InitCDSSignatures(void) CFE_ES_CDS_CachePreload(&CDS->Cache, CFE_ES_CDS_SIGNATURE_END, SigOffset, CFE_ES_CDS_SIGNATURE_LEN); Status = CFE_ES_CDS_CacheFlush(&CDS->Cache); - if (Status != CFE_PSP_SUCCESS) + if (Status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("%s: '_CDSEnd_' write failed. Status=0x%08X\n", __func__, (unsigned int)CDS->Cache.AccessStatus); diff --git a/modules/es/fsw/src/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c index 6cd5ede42..3a72bfbcd 100644 --- a/modules/es/fsw/src/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -794,7 +794,7 @@ void CFE_ES_CreateObjects(void) */ CFE_ES_LockSharedData(__func__, __LINE__); - if (ReturnCode == OS_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { CFE_ES_AppRecordSetUsed(AppRecPtr, PendingAppId); @@ -802,7 +802,6 @@ void CFE_ES_CreateObjects(void) ** Increment the Core App counter. */ CFE_ES_Global.RegisteredCoreApps++; - ReturnCode = CFE_SUCCESS; } else { diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index 08f2fca00..d4beafa40 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -1998,7 +1998,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_BINARY_DATA_DUMP), CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_BINARY_DATA_DUMP)); - if (Status != OS_SUCCESS) + if (Status != CFE_SUCCESS) { CFE_EVS_SendEvent(CFE_ES_CREATING_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, "Error parsing CDS dump filename, Status=0x%08X", (unsigned int)Status); diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index af84fab8e..ca7156b5c 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -520,7 +520,7 @@ void ES_UT_SetupSingleCDSRegistry(const char *CDSName, size_t BlockSize, bool Is int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { - osal_id_t ObjList[7]; + osal_id_t ObjList[8]; /* On the first call, Use the stub functions to generate one object of * each type @@ -534,6 +534,7 @@ int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, uint32 CallCoun OS_CountSemCreate(&ObjList[4], NULL, 0, 0); OS_TimerCreate(&ObjList[5], NULL, NULL, NULL); OS_OpenCreate(&ObjList[6], NULL, 0, 0); + OS_ModuleLoad(&ObjList[7], NULL, NULL, 0); UT_SetDataBuffer((UT_EntryKey_t)&OS_ForEachObject, ObjList, sizeof(ObjList), true); } @@ -1208,6 +1209,17 @@ void TestApps(void) UtAssert_INT32_EQ(UtAppRecPtr->ControlReq.AppTimerMsec, 0); CFE_UtAssert_EVENTSENT(CFE_ES_PCR_ERR2_EID); + /* Test scanning and acting on the application table where the application + * is running and is ready to exit + */ + ES_ResetUnitTest(); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); + UtAppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_APP_EXIT; + UtAppRecPtr->ControlReq.AppTimerMsec = 0; + CFE_ES_RunAppTableScan(0, &CFE_ES_Global.BackgroundAppScanState); + UtAssert_INT32_EQ(UtAppRecPtr->ControlReq.AppTimerMsec, + CFE_PLATFORM_ES_APP_KILL_TIMEOUT * CFE_PLATFORM_ES_APP_SCAN_RATE); + /* Test scanning and acting on the application table where the application * has stopped and is ready to be acted on */ @@ -1418,6 +1430,11 @@ void TestApps(void) AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); UtAssert_INT32_EQ(CFE_ES_CleanUpApp(AppId), CFE_ES_APP_CLEANUP_ERR); + /* Test deleting an application when AppId and Record don't match */ + ES_ResetUnitTest(); + ES_UT_SetupForOSCleanup(); + UtAssert_INT32_EQ(CFE_ES_CleanUpApp(CFE_ES_APPID_UNDEFINED), CFE_ES_APP_CLEANUP_ERR); + /* Test deleting an application and cleaning up its resources with a * mutex delete failure */ @@ -1511,6 +1528,16 @@ void TestApps(void) UT_SetDefaultReturnValue(UT_KEY(OS_close), OS_ERROR); UtAssert_INT32_EQ(CFE_ES_CleanupTaskResources(TaskId), CFE_ES_APP_CLEANUP_ERR); + /* Test cleaning up the OS resources for an unidentified object */ + ES_ResetUnitTest(); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, NULL, &UtTaskRecPtr); + TaskId = CFE_ES_TaskRecordGetID(UtTaskRecPtr); + ES_UT_SetupForOSCleanup(); + UT_SetDeferredRetcode(UT_KEY(OS_TimerGetInfo), 1, OS_ERROR); + UT_SetDefaultReturnValue(UT_KEY(OS_IdentifyObject), OS_OBJECT_TYPE_UNDEFINED); + /* Since object is invalid, no need to delete it so function returns success */ + CFE_UtAssert_SUCCESS(CFE_ES_CleanupTaskResources(TaskId)); + /* Test cleaning up the OS resources for a task with a failure * to delete the task */ @@ -1538,6 +1565,16 @@ void TestApps(void) CFE_UtAssert_SUCCESS(CFE_ES_ParseFileEntry(TokenList, 8)); } + /* Test parsing the startup script for a cFE application with a priority + * number greater than MAX + */ + ES_ResetUnitTest(); + { + const char *TokenList[] = {"CFE_APP", "/cf/apps/tst_lib.bundle", "TST_LIB_Init", "TST_LIB", "999", "0", "0x0", + "0"}; + CFE_UtAssert_SUCCESS(CFE_ES_ParseFileEntry(TokenList, 8)); + } + /* Test scanning and acting on the application table where the timer * expires for a waiting application */ @@ -1575,6 +1612,19 @@ void TestApps(void) CFE_UtAssert_TRUE(CFE_ES_TaskRecordIsUsed(UtTaskRecPtr)); CFE_UtAssert_FALSE(CFE_ES_MemPoolRecordIsUsed(UtPoolRecPtr)); + /* Test deleting an application and cleaning up its resources where the + * main task and child task need to be swapped + */ + ES_ResetUnitTest(); + ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); + ES_UT_SetupMemPoolId(&UtPoolRecPtr); + UtPoolRecPtr->OwnerAppID = CFE_ES_AppRecordGetID(UtAppRecPtr); + ES_UT_SetupChildTaskId(UtAppRecPtr, NULL, &UtTaskRecPtr); + AppId = CFE_ES_AppRecordGetID(UtAppRecPtr); + /* Set MainTask to Child task's ID. Cleanup code will swap the order. */ + UtAppRecPtr->MainTaskId = UtTaskRecPtr->TaskId; + CFE_UtAssert_SUCCESS(CFE_ES_CleanUpApp(AppId)); + /* Test deleting an application and cleaning up its resources where the * memory pool deletion fails */ @@ -1769,6 +1819,11 @@ void TestLibs(void) UtAssert_INT32_EQ(CFE_ES_LoadLibrary(&Id, "LibName", &LoadParams), CFE_ES_NO_RESOURCE_IDS_AVAILABLE); CFE_UtAssert_PRINTF(UT_OSP_MESSAGES[UT_OSP_LIBRARY_SLOTS]); + /* Test loading module with a base different than APP or LIB */ + ES_ResetUnitTest(); + UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_GetBase), CFE_ES_CDSBLOCKID_BASE); + CFE_UtAssert_SUCCESS(CFE_ES_LoadLibrary(&Id, "TST_LIB", &LoadParams)); + /* check operation of the CFE_ES_CheckLibIdSlotUsed() function */ CFE_ES_Global.LibTable[1].LibId = CFE_ES_LIBID_C(ES_UT_MakeLibIdForIndex(1)); CFE_ES_Global.LibTable[2].LibId = CFE_ES_LIBID_UNDEFINED; diff --git a/modules/evs/fsw/inc/cfe_evs_msg.h b/modules/evs/fsw/inc/cfe_evs_msg.h index 8e7c04d62..949c6869b 100644 --- a/modules/evs/fsw/inc/cfe_evs_msg.h +++ b/modules/evs/fsw/inc/cfe_evs_msg.h @@ -94,8 +94,10 @@ ** \par Command Verification ** Successful execution of this command may be verified with ** the following telemetry: -** - \b \c \EVS_CMDPC - command execution counter will -** increment +** - \b \c \EVS_CMDPC - command execution counter +** will be reset to 0 +** - \b \c \EVS_CMDEC - command error counter +** will be reset to 0 ** - The #CFE_EVS_RSTCNT_EID debug event message will be ** generated ** @@ -146,8 +148,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** -** Invalid Event Type selection +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -195,9 +196,8 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set ** -** - Invalid Event Type selection - ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment ** - An Error specific event message @@ -245,9 +245,8 @@ ** - The generation of #CFE_EVS_SETEVTFMTMOD_EID debug message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** Invalid SB message (command) length -** Invalid MODE selection +** This command may fail for the following reason(s): +** - Invalid MsgFormat mode selection ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -295,8 +294,9 @@ ** - The generation of #CFE_EVS_ENAAPPEVTTYPE_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid Event Type Selection +** This command may fail for the following reason(s): +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -346,8 +346,9 @@ ** - The clearing of the Event Type Active Flag in The Event Type Active Flag in EVS App Data File ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid Event Type Selection +** This command may fail for the following reason(s): +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -386,10 +387,8 @@ ** - The setting of the Active Flag in The Active Flag in EVS App Data File ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -426,10 +425,8 @@ ** - The generation of #CFE_EVS_DISAPPEVT_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -467,10 +464,8 @@ ** - The generation of #CFE_EVS_RSTEVTCNT_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -506,10 +501,9 @@ ** - The generation of #CFE_EVS_SETFILTERMSK_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services +** - Specified event ID is not found in the application event filter ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -553,9 +547,8 @@ ** - The generation of #CFE_EVS_ENAPORT_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid PORT selection +** This command may fail for the following reason(s): +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -593,9 +586,8 @@ ** - The generation of #CFE_EVS_DISPORT_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid PORT selection +** This command may fail for the following reason(s): +** - BitMask field invalid - mask cannot be zero, and only bits 0-3 may be set ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -628,10 +620,9 @@ ** - The generation of #CFE_EVS_RSTFILTER_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services +** - Specified event ID is not found in the application event filter ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -665,10 +656,8 @@ ** - The generation of #CFE_EVS_RSTALLFILTER_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -701,10 +690,10 @@ ** - The generation of #CFE_EVS_ADDFILTER_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services +** - Specified event ID is already added to the application event filter +** - Maximum number of event IDs already added to filter ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -737,10 +726,9 @@ ** - The generation of #CFE_EVS_DELFILTER_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Application selected is not registered to receive Event Service -** - Application ID is out of range +** This command may fail for the following reason(s): +** - Application name is not valid or not registered with event services +** - Specified event ID is not found in the application event filter ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -771,11 +759,14 @@ ** - \b \c \EVS_CMDPC - command execution counter will ** increment ** - The generation of #CFE_EVS_WRDAT_EID debug event message -** - The generation of the file written to +** - The file specified in the command (or the default specified +** by the #CFE_PLATFORM_EVS_DEFAULT_APP_DATA_FILE configuration parameter) will be +** updated with the lastest information. ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length +** This command may fail for the following reason(s): +** - The specified FileName cannot be parsed +** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -808,8 +799,9 @@ ** - The generation of #CFE_EVS_WRLOG_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length +** This command may fail for the following reason(s): +** - The specified FileName cannot be parsed +** - An Error occurs while trying to write to the file ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -841,9 +833,9 @@ ** - The generation of #CFE_EVS_LOGMODE_EID debug event message ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** - Invalid MODE selected +** This command may fail for the following reason(s): +** - Invalid LogMode selected - must be either #CFE_EVS_LogMode_OVERWRITE +** or #CFE_EVS_LogMode_DISCARD ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \EVS_CMDEC - command error counter will increment @@ -874,21 +866,21 @@ ** the following telemetry: ** - \b \c \EVS_CMDPC - command execution counter will ** increment +** - \b \c \EVS_LOGFULL - The LogFullFlag in the Housekeeping +** telemetry will be cleared +** - \b \c \EVS_LOGOVERFLOWC - The LogOverflowCounter in the +** Housekeeping telemetry will be reset to 0 ** ** \par Error Conditions -** This command may fail for the following reason(s): -** - Invalid SB message (command) length -** -** Evidence of failure may be found in the following telemetry: -** - \b \c \EVS_CMDEC - command error counter will increment -** - An Error specific event message +** There are no error conditions for this command. If the Event +** Services receives the command, the log is cleared. ** ** \par Criticality ** Clearing the local event log is not particularly hazardous, as the -** result may be making available space to record valuable event data. -** However, inappropriately clearing the local event log could result -** in a loss of critical information. Note: the event log is a back-up -** log to the on-board recorder. +** result may be making available space to record valuable event data. +** However, inappropriately clearing the local event log could result +** in a loss of critical information. Note: the event log is a back-up +** log to the on-board recorder. ** ** \sa #CFE_EVS_WRITE_LOG_DATA_FILE_CC, #CFE_EVS_SET_LOG_MODE_CC */ diff --git a/modules/evs/fsw/src/cfe_evs_log.c b/modules/evs/fsw/src/cfe_evs_log.c index 9ae504ed3..e1004577e 100644 --- a/modules/evs/fsw/src/cfe_evs_log.c +++ b/modules/evs/fsw/src/cfe_evs_log.c @@ -144,7 +144,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_BINARY_DATA_DUMP), CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_BINARY_DATA_DUMP)); - if (Result != OS_SUCCESS) + if (Result != CFE_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, "Write Log File Command Error: CFE_FS_ParseInputFileNameEx() = 0x%08X", (unsigned int)Result); diff --git a/modules/sb/fsw/inc/cfe_sb_msg.h b/modules/sb/fsw/inc/cfe_sb_msg.h index 93a9de958..ecf415951 100644 --- a/modules/sb/fsw/inc/cfe_sb_msg.h +++ b/modules/sb/fsw/inc/cfe_sb_msg.h @@ -84,6 +84,15 @@ ** Bus housekeeping telemetry: ** - Command Execution Counter (\SB_CMDPC) ** - Command Error Counter (\SB_CMDEC) +** - No Subscribers Counter (\SB_NOSUBEC) +** - Duplicate Subscriptions Counter (\SB_DUPSUBCNT) +** - Msg Send Error Counter (\SB_MSGSNDEC) +** - Msg Receive Error Counter (\SB_MSGRECEC) +** - Internal Error Counter (\SB_INTERNALEC) +** - Create Pipe Error Counter (\SB_NEWPIPEEC) +** - Subscribe Error Counter (\SB_SUBSCREC) +** - Pipe Overflow Error Counter (\SB_PIPEOVREC) +** - Msg Limit Error Counter (\SB_MSGLIMEC) ** ** \cfecmdmnemonic \SB_RESETCTRS ** @@ -94,7 +103,8 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will -** increment +** be reset to 0 +** - All other counters listed in description will be reset to 0 ** - The #CFE_SB_CMD1_RCVD_EID informational event message will ** be generated ** @@ -132,8 +142,7 @@ ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment ** - Receipt of statistics packet with MsgId #CFE_SB_STATS_TLM_MID -** - The #CFE_SB_SND_STATS_EID debug event message will be generated. All -** debug events are filtered by default. +** - The #CFE_SB_SND_STATS_EID debug event message will be generated ** ** \par Error Conditions ** There are no error conditions for this command. If the Software @@ -170,14 +179,17 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. +** NOTE: the command counter is incremented when the request is accepted, +** before writing the file, which is performed as a background task. +** - The file specified in the command (or the default specified +** by the #CFE_PLATFORM_SB_DEFAULT_ROUTING_FILENAME configuration parameter) will be +** updated with the lastest information. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated ** ** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. +** This command may fail for the following reason(s): +** - A previous request to write a software bus information file has not yet completed +** - The specified FileName cannot be parsed ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \SB_CMDEC - command error counter will increment @@ -211,14 +223,14 @@ ** - \b \c \SB_CMDPC - command execution counter will increment ** - View routing information #CFE_SB_WRITE_ROUTING_INFO_CC to verify ** enable/disable state change -** - The #CFE_SB_ENBL_RTE2_EID debug event message will be generated. All -** debug events are filtered by default. -** - Destination will begin receiving messages. +** - The #CFE_SB_ENBL_RTE2_EID debug event message will be generated +** - Destination will begin receiving messages ** ** \par Error Conditions -** An Error may occur if the MsgId or PipeId parmaters do not pass -** validation or the destination does not exist. - +** This command may fail for the following reason(s): +** - the MsgId or PipeId parmaters do not pass validation +** - the destination does not exist. +** ** Evidence of failure may be found in the following telemetry: ** - \b \c \SB_CMDEC - command error counter will increment ** - A command specific error event message is issued for all error @@ -247,14 +259,14 @@ ** - \b \c \SB_CMDPC - command execution counter will increment ** - View routing information #CFE_SB_WRITE_ROUTING_INFO_CC to verify ** enable/disable state change -** - The #CFE_SB_DSBL_RTE2_EID debug event message will be generated. All -** debug events are filtered by default. -** - Destination will stop receiving messages. +** - The #CFE_SB_DSBL_RTE2_EID debug event message will be generated +** - Destination will stop receiving messages ** ** \par Error Conditions -** An Error may occur if the MsgId or PipeId parmaters do not pass -** validation or the destination does not exist. - +** This command may fail for the following reason(s): +** - the MsgId or PipeId parmaters do not pass validation +** - the destination does not exist. +** ** Evidence of failure may be found in the following telemetry: ** - \b \c \SB_CMDEC - command error counter will increment ** - A command specific error event message is issued for all error @@ -291,14 +303,17 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. +** NOTE: the command counter is incremented when the request is accepted, +** before writing the file, which is performed as a background task. +** - The file specified in the command (or the default specified +** by the #CFE_PLATFORM_SB_DEFAULT_PIPE_FILENAME configuration parameter) will be +** updated with the lastest information. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated ** ** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. +** This command may fail for the following reason(s): +** - A previous request to write a software bus information file has not yet completed +** - The specified FileName cannot be parsed ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \SB_CMDEC - command error counter will increment @@ -334,14 +349,17 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \SB_CMDPC - command execution counter will increment. -** - Specified filename created at specified location. See description. -** - The #CFE_SB_SND_RTG_EID debug event message will be generated. All -** debug events are filtered by default. +** NOTE: the command counter is incremented when the request is accepted, +** before writing the file, which is performed as a background task. +** - The file specified in the command (or the default specified +** by the #CFE_PLATFORM_SB_DEFAULT_MAP_FILENAME configuration parameter) will be +** updated with the lastest information. +** - The #CFE_SB_SND_RTG_EID debug event message will be generated ** ** \par Error Conditions -** - Errors may occur during write operations to the file. Possible -** causes might be insufficient space in the file system or the -** filename or file path is improperly specified. +** This command may fail for the following reason(s): +** - A previous request to write a software bus information file has not yet completed +** - The specified FileName cannot be parsed ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \SB_CMDEC - command error counter will increment diff --git a/modules/tbl/fsw/inc/cfe_tbl_msg.h b/modules/tbl/fsw/inc/cfe_tbl_msg.h index 99e86f051..38b53c4bc 100644 --- a/modules/tbl/fsw/inc/cfe_tbl_msg.h +++ b/modules/tbl/fsw/inc/cfe_tbl_msg.h @@ -91,6 +91,7 @@ ** - Successful Table Validations Counter (\TBL_VALSUCCESSCTR) ** - Failed Table Validations Counter (\TBL_VALFAILEDCTR) ** - Number of Table Validations Requested (\TBL_VALREQCTR) +** - Number of completed table validations (\TBL_VALCOMPLTDCTR) ** ** \cfecmdmnemonic \TBL_RESETCTRS ** @@ -101,7 +102,7 @@ ** Successful execution of this command may be verified with ** the following telemetry: ** - \b \c \TBL_CMDPC - command execution counter will -** increment +** be reset to 0 ** - The #CFE_TBL_RESET_INF_EID debug event message will be ** generated ** @@ -145,16 +146,12 @@ ** - Table name found in table image file's table header is not found ** in table registry (ie - The table associated with the table image ** in the file has not been registered by an application). -** - The table image file's header indicates the file contains 'x' -** number of bytes of data but the file contains less. +** - The table image file has an invalid or incorrect size. The size of +** the image file must match the size field within in the header, and +** must also match the expected size of the table indicated in the registry. ** - No working buffers are available for the load. This would indicate ** that too many single-buffered table loads are in progress at the same ** time. -** - The table image file's header indicates the data to be loaded is -** beyond the size of the table. Either the number of bytes in the -** file are too many or the starting offset into the table is too high. -** - The table image file's header indicates there is no data in the -** file (ie - Number of bytes to load is zero). ** - An attempt is being made to load an uninitialized table with a file ** containing only a partial table image. ** - The table image file was unable to be opened. Either the file does @@ -254,7 +251,7 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - A single buffered table's inactive buffer was requested to be dumped +** - A single buffered table's inactive buffer was requested to be validated ** and no such buffer is currently allocated. ** - Too many validations have been requested simultaneously. The operator ** must wait for one or more applications to perform their table validation @@ -298,9 +295,9 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): -** - A single buffered table's inactive buffer was requested to be -** dumped and no such buffer is currently allocated. ** - The specified table name was not found in the table registry. +** - The table was registered as a "dump only" type and thus cannot be activated +** - The table buffer has not been validated. ** ** Evidence of failure may be found in the following telemetry: ** - \b \c \TBL_CMDEC - command error counter will increment @@ -340,6 +337,8 @@ ** ** \par Error Conditions ** This command may fail for the following reason(s): +** - A table registry dump is already in progress, not yet completed +** - The specified DumpFilename could not be parsed ** - Error occurred during write operation to file. Possible ** causes might be insufficient space in the file system ** or the filename or file path is improperly specified. diff --git a/modules/time/fsw/inc/cfe_time_msg.h b/modules/time/fsw/inc/cfe_time_msg.h index 3924fe4ec..2bebb1d97 100644 --- a/modules/time/fsw/inc/cfe_time_msg.h +++ b/modules/time/fsw/inc/cfe_time_msg.h @@ -106,13 +106,14 @@ ** \par Command Verification ** Successful execution of this command may be verified with the ** following telemetry: -** - \b \c \TIME_CMDPC - command execution counter will increment +** - \b \c \TIME_CMDPC - command execution counter will reset to 0 +** - \b \c \TIME_CMDEC - command error counter will reset to 0 ** - The #CFE_TIME_RESET_EID informational event message will be generated ** ** \par Error Conditions ** There are no error conditions for this command. If the Time ** Services receives the command, the event is sent (although it -** may be filtered by EVS) and the counter is incremented +** may be filtered by EVS) and the counter is reset ** unconditionally. ** ** \par Criticality @@ -238,7 +239,7 @@ ** Successful execution of this command may be verified with the ** following telemetry: ** - \b \c \TIME_CMDPC - command execution counter will increment -** - \b \c \TIME_STATEFLG - Housekeeping Telemetry point "may"l indicate the +** - \b \c \TIME_STATEFLG - Housekeeping Telemetry point "may" indicate the ** command specified value (see above) ** - The #CFE_TIME_STATE_EID informational event message will be generated ** diff --git a/modules/time/fsw/src/cfe_time_task.c b/modules/time/fsw/src/cfe_time_task.c index c4f3a2a63..61d11c01c 100644 --- a/modules/time/fsw/src/cfe_time_task.c +++ b/modules/time/fsw/src/cfe_time_task.c @@ -145,7 +145,7 @@ int32 CFE_TIME_TaskInit(void) Status = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, CFE_TIME_SEM_OPTIONS); - if (Status != CFE_SUCCESS) + if (Status != OS_SUCCESS) { CFE_ES_WriteToSysLog("%s: Error creating tone semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); return Status; @@ -153,7 +153,7 @@ int32 CFE_TIME_TaskInit(void) Status = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, CFE_TIME_SEM_OPTIONS); - if (Status != CFE_SUCCESS) + if (Status != OS_SUCCESS) { CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); return Status; diff --git a/modules/time/ut-coverage/time_UT.c b/modules/time/ut-coverage/time_UT.c index 7623b7f1a..fd8bea75d 100644 --- a/modules/time/ut-coverage/time_UT.c +++ b/modules/time/ut-coverage/time_UT.c @@ -388,18 +388,17 @@ void Test_Init(void) */ void Test_GetTime(void) { - int result; - uint16 StateFlags; - char timeBuf[sizeof("yyyy-ddd-hh:mm:ss.xxxxx_")]; - /* Note: Time is in seconds + microseconds since 1980-001-00:00:00:00000 */ - /* The time below equals 2013-001-02:03:04.56789 */ - int seconds = 1041472984; - int microsecs = 567890; - const char * expectedMET = "2013-001-02:03:14.56789"; - const char * expectedTAI = "2013-001-03:03:14.56789"; - const char * expectedUTC = "2013-001-03:02:42.56789"; - const char * expectedSTCF = "1980-001-01:00:00.00000"; + unsigned int result; + uint16 StateFlags; + /* Note: Time is in seconds + microseconds since epoch */ + unsigned int seconds = 1041472984; + unsigned int microsecs = 567890; volatile CFE_TIME_ReferenceState_t *RefState; + CFE_TIME_SysTime_t time; + CFE_TIME_SysTime_t expectedMET = {.Seconds = 1041472994, .Subseconds = 2439068978}; + CFE_TIME_SysTime_t expectedTAI = {.Seconds = 1041476594, .Subseconds = 2439068978}; + CFE_TIME_SysTime_t expectedUTC = {.Seconds = 1041476562, .Subseconds = 2439068978}; + CFE_TIME_SysTime_t expectedSTCF = {.Seconds = 3600, .Subseconds = 0}; UtPrintf("Begin Test Get Time"); @@ -420,8 +419,9 @@ void Test_GetTime(void) RefState->AtToneLatch.Subseconds = 0; RefState->ClockSetState = CFE_TIME_SetState_NOT_SET; /* Force invalid time */ CFE_TIME_FinishReferenceUpdate(RefState); - CFE_TIME_Print(timeBuf, CFE_TIME_GetMET()); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedMET, strlen(expectedMET)); + time = CFE_TIME_GetMET(); + UtAssert_UINT32_EQ(time.Seconds, expectedMET.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedMET.Subseconds); /* Test successfully retrieving the mission elapsed time (seconds * portion) @@ -446,24 +446,28 @@ void Test_GetTime(void) /* Test successfully retrieving the international atomic time (TAI) */ UT_InitData(); UT_SetBSP_Time(seconds, microsecs); - CFE_TIME_Print(timeBuf, CFE_TIME_GetTAI()); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedTAI, strlen(expectedTAI)); + time = CFE_TIME_GetTAI(); + UtAssert_UINT32_EQ(time.Seconds, expectedTAI.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedTAI.Subseconds); /* Test successfully retrieving the coordinated universal time (UTC) */ UT_InitData(); UT_SetBSP_Time(seconds, microsecs); - CFE_TIME_Print(timeBuf, CFE_TIME_GetUTC()); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedUTC, strlen(expectedUTC)); + time = CFE_TIME_GetUTC(); + UtAssert_UINT32_EQ(time.Seconds, expectedUTC.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedUTC.Subseconds); /* Test successfully retrieving the default time (UTC or TAI) */ UT_InitData(); UT_SetBSP_Time(seconds, microsecs); - CFE_TIME_Print(timeBuf, CFE_TIME_GetTime()); + time = CFE_TIME_GetTime(); #if (CFE_MISSION_TIME_CFG_DEFAULT_TAI == true) - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedTAI, strlen(expectedTAI)); + UtAssert_UINT32_EQ(time.Seconds, expectedTAI.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedTAI.Subseconds); #else - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedUTC, strlen(expectedUTC)); + UtAssert_UINT32_EQ(time.Seconds, expectedUTC.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedUTC.Subseconds); #endif /* Test successfully retrieving the spacecraft time correlation @@ -471,8 +475,9 @@ void Test_GetTime(void) */ UT_InitData(); UT_SetBSP_Time(seconds, microsecs); - CFE_TIME_Print(timeBuf, CFE_TIME_GetSTCF()); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedSTCF, strlen(expectedSTCF)); + time = CFE_TIME_GetSTCF(); + UtAssert_UINT32_EQ(time.Seconds, expectedSTCF.Seconds); + UtAssert_UINT32_EQ(time.Subseconds, expectedSTCF.Subseconds); /* Test retrieving the time status (invalid time is expected) */ UT_InitData(); @@ -752,18 +757,11 @@ void Test_TimeOp(void) */ void Test_ConvertTime(void) { - char timeBuf[sizeof("yyyy-ddd-hh:mm:ss.xxxxx_")]; CFE_TIME_SysTime_t METTime; + CFE_TIME_SysTime_t resultTime; + CFE_TIME_SysTime_t expectedMET2SCTime; volatile CFE_TIME_ReferenceState_t *RefState; -#if (CFE_MISSION_TIME_CFG_DEFAULT_TAI == true) - /* TAI time derived = MET + STCF */ - const char *expectedSCTime = "1980-001-02:00:40.00000"; -#else - /* UTC time derived = MET + STCF - Leaps */ - const char *expectedSCTime = "1980-001-02:00:08.00000"; -#endif - UtPrintf("Begin Test Convert Time"); UT_InitData(); @@ -772,13 +770,20 @@ void Test_ConvertTime(void) METTime.Subseconds = 0; RefState = CFE_TIME_StartReferenceUpdate(); RefState->AtToneSTCF.Seconds = 7240; /* 01:00:00.00000 */ - RefState->AtToneSTCF.Subseconds = 0; + RefState->AtToneSTCF.Subseconds = 45; RefState->AtToneLeapSeconds = 32; +#if (CFE_MISSION_TIME_CFG_DEFAULT_TAI == true) + /* TAI time derived = MET + STCF */ + expectedMET2SCTime.Seconds = 7240; +#else + /* UTC time derived = MET + STCF - Leaps */ + expectedMET2SCTime.Seconds = 7208; +#endif + expectedMET2SCTime.Subseconds = 45; CFE_TIME_FinishReferenceUpdate(RefState); - CFE_TIME_Print(timeBuf, CFE_TIME_MET2SCTime(METTime)); - - /* SC = MET + SCTF [- Leaps for UTC] */ - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedSCTime, strlen(expectedSCTime)); + resultTime = CFE_TIME_MET2SCTime(METTime); + UtAssert_UINT32_EQ(resultTime.Seconds, expectedMET2SCTime.Seconds); + UtAssert_UINT32_EQ(resultTime.Subseconds, expectedMET2SCTime.Subseconds); /* NOTE: Microseconds <-> Subseconds conversion routines are implemented * as part of OS_time_t in OSAL, and are coverage tested there. CFE time @@ -820,16 +825,33 @@ void Test_Print(void) char timeBuf[CFE_TIME_PRINTED_STRING_SIZE]; char expectedBuf[CFE_TIME_PRINTED_STRING_SIZE]; CFE_TIME_SysTime_t time; + bool usingDefaultEpoch = true; UtPrintf("Begin Test Print"); + if (CFE_MISSION_TIME_EPOCH_YEAR != 1980 || CFE_MISSION_TIME_EPOCH_DAY != 1 || CFE_MISSION_TIME_EPOCH_HOUR != 0 || + CFE_MISSION_TIME_EPOCH_MINUTE != 0 || CFE_MISSION_TIME_EPOCH_SECOND != 0) + { + UtPrintf("Custom epoch time requires manual inspection for CFE_TIME_Print"); + usingDefaultEpoch = false; + } + /* Test with zero time value */ time.Subseconds = 0; time.Seconds = 0; CFE_TIME_Print(timeBuf, time); - strcpy(expectedBuf, "1980-001-00:00:00.00000"); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + if (usingDefaultEpoch) + { + strcpy(expectedBuf, "1980-001-00:00:00.00000"); + CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + } + else + { + UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, + "Confirm adding seconds = %u, subseconds = %u to configured EPOCH results in time %s", time.Seconds, + time.Subseconds, timeBuf); + } /* Test with a time value that causes seconds >= 60 when * CFE_MISSION_TIME_EPOCH_SECOND > 0 @@ -838,24 +860,51 @@ void Test_Print(void) time.Seconds = 59; CFE_TIME_Print(timeBuf, time); - strcpy(expectedBuf, "1980-001-00:00:59.00000"); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + if (usingDefaultEpoch) + { + strcpy(expectedBuf, "1980-001-00:00:59.00000"); + CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + } + else + { + UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, + "Confirm adding seconds = %u, subseconds = %u to configured EPOCH results in time %s", time.Seconds, + time.Subseconds, timeBuf); + } /* Test with mission representative time values */ time.Subseconds = 215000; time.Seconds = 1041472984; CFE_TIME_Print(timeBuf, time); - strcpy(expectedBuf, "2013-001-02:03:04.00005"); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + if (usingDefaultEpoch) + { + strcpy(expectedBuf, "2013-001-02:03:04.00005"); + CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + } + else + { + UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, + "Confirm adding seconds = %u, subseconds = %u to configured EPOCH results in time %s", time.Seconds, + time.Subseconds, timeBuf); + } /* Test with maximum seconds and subseconds values */ time.Subseconds = 0xffffffff; time.Seconds = 0xffffffff; CFE_TIME_Print(timeBuf, time); - strcpy(expectedBuf, "2116-038-06:28:15.99999"); - CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + if (usingDefaultEpoch) + { + strcpy(expectedBuf, "2116-038-06:28:15.99999"); + CFE_UtAssert_STRINGBUF_EQ(timeBuf, sizeof(timeBuf), expectedBuf, sizeof(expectedBuf)); + } + else + { + UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, + "Confirm adding seconds = %u, subseconds = %u to configured EPOCH results in time %s", time.Seconds, + time.Subseconds, timeBuf); + } } /*