From d669ea2c5a5c327a4737795dea1a11b582e4f07e Mon Sep 17 00:00:00 2001 From: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:29:15 -0800 Subject: [PATCH] Replace FpConfig.h header with FPP model elements (#4393) * Update FpConfig.h * Update AcConstants.fpp * Update FPrimeBasicTypes.hpp * Update BasicTypes.h * Update FpySequencer.hpp * Update FpConfig.h * Update FPrimeBasicTypes.hpp * Update BasicTypes.h * Update BasicTypes.h * Update BasicTypes.h * Update BasicTypes.h * Update BasicTypes.h * Update BasicTypes.h * Update BasicTypes.h * Update FPrimeBasicTypes.hpp * Update FPrimeBasicTypes.hpp * Update FpConfig.h * Update AcConstants.fpp * Revert casts * Add static_cast in asserts, reorganize files per feature * Fix static_assert after merging devel * Add assert to static cast * clean up comments and TODOs * formatting * Fix formatting * Fix RHEL8 error * Other UT cast fix * cast one side only * fix spelling and move assert count to FpConstants * Reorder and comments * rob test * re-add double cast * Revert testing static_cast * Update docs * use SIZE_OF variables instead of hardcoding value * Update FpConfig in CMake tests --------- Co-authored-by: ekswang --- Fw/FPrimeBasicTypes.hpp | 20 +- Os/File.cpp | 2 +- .../test/ut/AssertFatalAdapterTester.cpp | 5 +- Svc/FpySequencer/FpySequencer.hpp | 4 +- .../override/project/FpConfig.fpp | 26 ++- default/config/CMakeLists.txt | 2 + default/config/ComCfg.fpp | 5 +- default/config/FpConfig.fpp | 7 +- default/config/FpConfig.h | 182 ------------------ default/config/FpConstants.fpp | 86 +++++++++ default/config/PlatformCfg.fpp | 45 +++++ docs/reference/numerical-types.md | 4 +- .../framework/configuring-fprime.md | 16 +- 13 files changed, 188 insertions(+), 216 deletions(-) create mode 100644 default/config/FpConstants.fpp create mode 100644 default/config/PlatformCfg.fpp diff --git a/Fw/FPrimeBasicTypes.hpp b/Fw/FPrimeBasicTypes.hpp index a9f6803531..07c6d4469d 100644 --- a/Fw/FPrimeBasicTypes.hpp +++ b/Fw/FPrimeBasicTypes.hpp @@ -35,24 +35,28 @@ extern "C" { // Check that Fw::String is big enough to hold any string that can be given a // default value in FPP. -static_assert(FW_FIXED_LENGTH_STRING_SIZE >= FW_CMD_STRING_MAX_SIZE, +static_assert(FW_FIXED_LENGTH_STRING_SIZE >= static_cast(FW_CMD_STRING_MAX_SIZE), "A generic string should be able to hold a command string"); -static_assert(FW_FIXED_LENGTH_STRING_SIZE >= FW_LOG_STRING_MAX_SIZE, +static_assert(FW_FIXED_LENGTH_STRING_SIZE >= static_cast(FW_LOG_STRING_MAX_SIZE), "A generic string should be able to hold an event string"); -static_assert(FW_FIXED_LENGTH_STRING_SIZE >= FW_TLM_STRING_MAX_SIZE, +static_assert(FW_FIXED_LENGTH_STRING_SIZE >= static_cast(FW_TLM_STRING_MAX_SIZE), "A generic string should be able to hold a telemetry string"); -static_assert(FW_FIXED_LENGTH_STRING_SIZE >= FW_PARAM_STRING_MAX_SIZE, +static_assert(FW_FIXED_LENGTH_STRING_SIZE >= static_cast(FW_PARAM_STRING_MAX_SIZE), "A generic string should be able to hold a parameter string"); // Check that command/telemetry strings are not larger than an argument buffer -static_assert(FW_CMD_STRING_MAX_SIZE + sizeof(FwSizeStoreType) <= FW_CMD_ARG_BUFFER_MAX_SIZE, +static_assert(static_cast(FW_CMD_STRING_MAX_SIZE) + sizeof(FwSizeStoreType) <= + static_cast(FW_CMD_ARG_BUFFER_MAX_SIZE), "FW_CMD_STRING_MAX_SIZE cannot be larger than FW_CMD_ARG_BUFFER_MAX_SIZE"); -static_assert(FW_LOG_STRING_MAX_SIZE + sizeof(FwSizeStoreType) <= FW_LOG_BUFFER_MAX_SIZE, +static_assert(static_cast(FW_LOG_STRING_MAX_SIZE) + sizeof(FwSizeStoreType) <= + static_cast(FW_LOG_BUFFER_MAX_SIZE), "FW_LOG_STRING_MAX_SIZE cannot be larger than FW_LOG_BUFFER_MAX_SIZE"); -static_assert(FW_TLM_STRING_MAX_SIZE + sizeof(FwSizeStoreType) <= FW_TLM_BUFFER_MAX_SIZE, +static_assert(static_cast(FW_TLM_STRING_MAX_SIZE) + sizeof(FwSizeStoreType) <= + static_cast(FW_TLM_BUFFER_MAX_SIZE), "FW_TLM_STRING_MAX_SIZE cannot be larger than FW_TLM_BUFFER_MAX_SIZE"); -static_assert(FW_PARAM_STRING_MAX_SIZE + sizeof(FwSizeStoreType) <= FW_PARAM_BUFFER_MAX_SIZE, +static_assert(static_cast(FW_PARAM_STRING_MAX_SIZE) + sizeof(FwSizeStoreType) <= + static_cast(FW_PARAM_BUFFER_MAX_SIZE), "FW_PARAM_STRING_MAX_SIZE cannot be larger than FW_PARAM_BUFFER_MAX_SIZE"); // Text logging needs the code generator for serializables to generate a stringified version of the diff --git a/Os/File.cpp b/Os/File.cpp index eed3cc344a..10cb0808ab 100644 --- a/Os/File.cpp +++ b/Os/File.cpp @@ -275,7 +275,7 @@ File::Status File::readline(U8* buffer, FwSizeType& size, File::WaitType wait) { FwSizeType read = 0; // Loop reading chunk by chunk for (FwSizeType i = 0; i < size; i += read) { - FwSizeType current_chunk_size = FW_MIN(size - i, FW_FILE_CHUNK_SIZE); + FwSizeType current_chunk_size = FW_MIN(size - i, static_cast(FW_FILE_CHUNK_SIZE)); read = current_chunk_size; status = this->read(buffer + i, read, wait); if (status != File::Status::OP_OK) { diff --git a/Svc/AssertFatalAdapter/test/ut/AssertFatalAdapterTester.cpp b/Svc/AssertFatalAdapter/test/ut/AssertFatalAdapterTester.cpp index 84aac83e4c..1c65324eec 100644 --- a/Svc/AssertFatalAdapter/test/ut/AssertFatalAdapterTester.cpp +++ b/Svc/AssertFatalAdapter/test/ut/AssertFatalAdapterTester.cpp @@ -40,8 +40,9 @@ void AssertFatalAdapterTester::testAsserts() { U32 lineNo; // Apply all truncations to file buffer size - const FwSizeType fileMaxSize = - FW_MIN(FW_MIN(AssertFatalAdapterEventFileSize, FW_LOG_STRING_MAX_SIZE), FW_ASSERT_TEXT_SIZE); + const FwSizeType fileMaxSize = FW_MIN(FW_MIN(static_cast(AssertFatalAdapterEventFileSize), + static_cast(FW_LOG_STRING_MAX_SIZE)), + static_cast(FW_ASSERT_TEXT_SIZE)); char file[Fw::StringBase::BUFFER_SIZE(fileMaxSize)]; Fw::String fileString; diff --git a/Svc/FpySequencer/FpySequencer.hpp b/Svc/FpySequencer/FpySequencer.hpp index e72b8ff7ff..b7e4f0fae6 100644 --- a/Svc/FpySequencer/FpySequencer.hpp +++ b/Svc/FpySequencer/FpySequencer.hpp @@ -29,9 +29,9 @@ static_assert(Svc::Fpy::MAX_SEQUENCE_STATEMENT_COUNT <= std::numeric_limits "Sequence statement count must be below U16 max"); static_assert(Svc::Fpy::MAX_STACK_SIZE <= std::numeric_limits::max(), "Max stack size must be below Svc::Fpy::StackSizeType max"); -static_assert(Svc::Fpy::MAX_STACK_SIZE >= FW_TLM_BUFFER_MAX_SIZE, +static_assert(Svc::Fpy::MAX_STACK_SIZE >= static_cast(FW_TLM_BUFFER_MAX_SIZE), "Max stack size must be greater than max tlm buffer size"); -static_assert(Svc::Fpy::MAX_STACK_SIZE >= FW_PARAM_BUFFER_MAX_SIZE, +static_assert(Svc::Fpy::MAX_STACK_SIZE >= static_cast(FW_PARAM_BUFFER_MAX_SIZE), "Max stack size must be greater than max prm buffer size"); static_assert(Svc::Fpy::FLAG_COUNT < std::numeric_limits::max(), "Flag count must be less than U8 max"); diff --git a/cmake/test/data/TestConfigDeployment/override/project/FpConfig.fpp b/cmake/test/data/TestConfigDeployment/override/project/FpConfig.fpp index b33367ac03..1becb1a3f6 100644 --- a/cmake/test/data/TestConfigDeployment/override/project/FpConfig.fpp +++ b/cmake/test/data/TestConfigDeployment/override/project/FpConfig.fpp @@ -16,6 +16,8 @@ # This differs from stock-fprime defaults and thus may be tested to ensure that # the system has overridden this file. type FwChanIdType = U64 +constant SIZE_OF_FwChanIdType = 8 @< Size of FwChanIdType in bytes + # --- END OF THE ONLY DIFFERENCE --- #### @@ -44,6 +46,10 @@ type FwTaskPriorityType = PlatformTaskPriorityType @ The type of queue priorities used. type FwQueuePriorityType = PlatformQueuePriorityType +@ The id type. +type FwIdType = U32 +constant SIZE_OF_FwIdType = 4 @< Size of FwIdType in bytes + @ The type of task priorities used. type FwTaskIdType = PlatformTaskIdType @@ -52,9 +58,6 @@ type FwTaskIdType = PlatformTaskIdType # Used for the project to override types shared with GDSes and other remote systems. #### -@ The id type. -type FwIdType = U32 - @ The type of a data product identifier type FwDpIdType = FwIdType @@ -63,19 +66,19 @@ type FwDpPriorityType = U32 @ The type of an event identifier type FwEventIdType = FwIdType +constant SIZE_OF_FwEventIdType = SIZE_OF_FwIdType @< Size of FwEventIdType in bytes @ The type of a command opcode type FwOpcodeType = FwIdType +constant SIZE_OF_FwOpcodeType = SIZE_OF_FwIdType @< Size of FwOpcodeType in bytes @ The type of a parameter identifier type FwPrmIdType = FwIdType +constant SIZE_OF_FwPrmIdType = SIZE_OF_FwIdType @< Size of FwPrmIdType in bytes @ The type used to serialize a size value type FwSizeStoreType = U16 -@ The type used to serialize a time base value -type FwTimeBaseStoreType = U16 - @ The type used to serialize a time context value type FwTimeContextStoreType = U8 @@ -88,3 +91,14 @@ type FwTraceIdType = U32 @ The type used to serialize a C++ enumeration constant @ FPP enumerations are serialized according to their representation types type FwEnumStoreType = I32 + +@ The type used to serialize a time base value +type FwTimeBaseStoreType = U16 + +@ Define enumeration for Time base types +enum TimeBase : FwTimeBaseStoreType { + TB_NONE = 0 @< No time base has been established (Required) + TB_PROC_TIME = 1 @< Indicates time is processor cycle time. Not tied to external time + TB_WORKSTATION_TIME = 2 @< Time as reported on workstation where software is running. For testing. (Required) + TB_DONT_CARE = 0xFFFF @< Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed (Required) +} default TB_NONE; \ No newline at end of file diff --git a/default/config/CMakeLists.txt b/default/config/CMakeLists.txt index c2baaac3fa..066a44b75d 100644 --- a/default/config/CMakeLists.txt +++ b/default/config/CMakeLists.txt @@ -9,8 +9,10 @@ register_fprime_config( "${CMAKE_CURRENT_LIST_DIR}/DpCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/ComCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/FpConfig.fpp" + "${CMAKE_CURRENT_LIST_DIR}/FpConstants.fpp" "${CMAKE_CURRENT_LIST_DIR}/FpySequencerCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/MemoryAllocation.fpp" + "${CMAKE_CURRENT_LIST_DIR}/PlatformCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/PolyDbCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/VersionCfg.fpp" HEADERS diff --git a/default/config/ComCfg.fpp b/default/config/ComCfg.fpp index ff356b9a24..50d9ce219d 100644 --- a/default/config/ComCfg.fpp +++ b/default/config/ComCfg.fpp @@ -1,13 +1,10 @@ # ====================================================================== # FPP file for configuration of the communications stack -# -# The only reason to modify these definitions is if you are writing your own -# Framer/Deframer implementations and need more contextual data than what is -# defined # ====================================================================== @ The width of packet descriptors when they are serialized by the framework type FwPacketDescriptorType = U16 +constant SIZE_OF_FwPacketDescriptorType = 2 @< Size of FwPacketDescriptorType in bytes module ComCfg { diff --git a/default/config/FpConfig.fpp b/default/config/FpConfig.fpp index b857081eab..a1a4cac5e7 100644 --- a/default/config/FpConfig.fpp +++ b/default/config/FpConfig.fpp @@ -40,6 +40,7 @@ type FwQueuePriorityType = PlatformQueuePriorityType @ The id type. type FwIdType = U32 +constant SIZE_OF_FwIdType = 4 @< Size of FwIdType in bytes @ The type of task priorities used. type FwTaskIdType = PlatformTaskIdType @@ -51,6 +52,7 @@ type FwTaskIdType = PlatformTaskIdType @ The type of a telemetry channel identifier type FwChanIdType = FwIdType +constant SIZE_OF_FwChanIdType = SIZE_OF_FwIdType @< Size of FwChanIdType in bytes @ The type of a data product identifier type FwDpIdType = FwIdType @@ -60,17 +62,19 @@ type FwDpPriorityType = U32 @ The type of an event identifier type FwEventIdType = FwIdType +constant SIZE_OF_FwEventIdType = SIZE_OF_FwIdType @< Size of FwEventIdType in bytes @ The type of a command opcode type FwOpcodeType = FwIdType +constant SIZE_OF_FwOpcodeType = SIZE_OF_FwIdType @< Size of FwOpcodeType in bytes @ The type of a parameter identifier type FwPrmIdType = FwIdType +constant SIZE_OF_FwPrmIdType = SIZE_OF_FwIdType @< Size of FwPrmIdType in bytes @ The type used to serialize a size value type FwSizeStoreType = U16 - @ The type used to serialize a time context value type FwTimeContextStoreType = U8 @@ -84,7 +88,6 @@ type FwTraceIdType = U32 @ FPP enumerations are serialized according to their representation types type FwEnumStoreType = I32 - @ The type used to serialize a time base value type FwTimeBaseStoreType = U16 diff --git a/default/config/FpConfig.h b/default/config/FpConfig.h index 7c7119a7ed..6db0bcae58 100644 --- a/default/config/FpConfig.h +++ b/default/config/FpConfig.h @@ -17,24 +17,10 @@ extern "C" { #include #include -// ---------------------------------------------------------------------- -// Type aliases -// ---------------------------------------------------------------------- -#define FW_CONTEXT_DONT_CARE 0xFF //!< Don't care value for time contexts in sequences - // ---------------------------------------------------------------------- // Configuration switches // ---------------------------------------------------------------------- -// Boolean values for serialization -#ifndef FW_SERIALIZE_TRUE_VALUE -#define FW_SERIALIZE_TRUE_VALUE (0xFF) //!< Value encoded during serialization for boolean true -#endif - -#ifndef FW_SERIALIZE_FALSE_VALUE -#define FW_SERIALIZE_FALSE_VALUE (0x00) //!< Value encoded during serialization for boolean false -#endif - // Allow objects to have names. Allocates storage for each instance #ifndef FW_OBJECT_NAMES #define FW_OBJECT_NAMES \ @@ -135,56 +121,6 @@ extern "C" { #endif #endif -#if FW_OBJECT_REGISTRATION -// For the simple object registry provided with the framework, this specifies how many objects the registry will store. -#ifndef FW_OBJ_SIMPLE_REG_ENTRIES -#define FW_OBJ_SIMPLE_REG_ENTRIES 500 //!< Number of objects stored in simple object registry -#endif -// When dumping the contents of the registry, this specifies the size of the buffer used to store object names. Should -// be >= FW_OBJ_NAME_BUFFER_SIZE. -#ifndef FW_OBJ_SIMPLE_REG_BUFF_SIZE -#define FW_OBJ_SIMPLE_REG_BUFF_SIZE 255 //!< Size of object registry dump string -#endif -#endif - -#if FW_QUEUE_REGISTRATION -// For the simple queue registry provided with the framework, this specifies how many queues the registry will store. -#ifndef FW_QUEUE_SIMPLE_QUEUE_ENTRIES -#define FW_QUEUE_SIMPLE_QUEUE_ENTRIES 100 //!< Number of queues stored in simple queue registry -#endif -#endif - -// Specifies the size of the string holding the queue name for queues -#ifndef FW_QUEUE_NAME_BUFFER_SIZE -#define FW_QUEUE_NAME_BUFFER_SIZE 80 //!< Max size of message queue name -#endif - -// Specifies the size of the string holding the task name for active components and tasks -#ifndef FW_TASK_NAME_BUFFER_SIZE -#define FW_TASK_NAME_BUFFER_SIZE 80 //!< Max size of task name -#endif - -// Specifies the size of the buffer that contains a communications packet. -#ifndef FW_COM_BUFFER_MAX_SIZE -#define FW_COM_BUFFER_MAX_SIZE 512 -#endif - -// Specifies the size of the buffer attached to state machine signals. -#ifndef FW_SM_SIGNAL_BUFFER_MAX_SIZE -#define FW_SM_SIGNAL_BUFFER_MAX_SIZE 128 // Not to exceed max value of FwSizeType -#endif - -// Specifies the size of the buffer that contains the serialized command arguments. - -#ifndef FW_CMD_ARG_BUFFER_MAX_SIZE -#define FW_CMD_ARG_BUFFER_MAX_SIZE (FW_COM_BUFFER_MAX_SIZE - sizeof(FwOpcodeType) - sizeof(FwPacketDescriptorType)) -#endif - -// Specifies the maximum size of a string in a command argument -#ifndef FW_CMD_STRING_MAX_SIZE -#define FW_CMD_STRING_MAX_SIZE 40 //!< Max character size of command string arguments -#endif - // Normally when a command is deserialized, the handler checks to see if there are any leftover // bytes in the buffer. If there are, it assumes that the command was corrupted somehow since // the serialized size should match the serialized size of the argument list. In some cases, @@ -195,63 +131,12 @@ extern "C" { #define FW_CMD_CHECK_RESIDUAL 1 //!< Check for leftover command bytes #endif -// Specifies the size of the buffer that contains the serialized log arguments. -#ifndef FW_LOG_BUFFER_MAX_SIZE -#define FW_LOG_BUFFER_MAX_SIZE (FW_COM_BUFFER_MAX_SIZE - sizeof(FwEventIdType) - sizeof(FwPacketDescriptorType)) -#endif - -// Specifies the maximum size of a string in a log event -// Note: This constant truncates file names in assertion failure event reports -#ifndef FW_LOG_STRING_MAX_SIZE -#define FW_LOG_STRING_MAX_SIZE 200 //!< Max size of log string parameter type -#endif - -// Specifies the size of the buffer that contains the serialized telemetry value. -#ifndef FW_TLM_BUFFER_MAX_SIZE -#define FW_TLM_BUFFER_MAX_SIZE (FW_COM_BUFFER_MAX_SIZE - sizeof(FwChanIdType) - sizeof(FwPacketDescriptorType)) -#endif - -// Specifies the size of the buffer that contains statement args for the FpySequencer -#ifndef FW_STATEMENT_ARG_BUFFER_MAX_SIZE -#define FW_STATEMENT_ARG_BUFFER_MAX_SIZE (FW_CMD_ARG_BUFFER_MAX_SIZE) -#endif - -// Specifies the maximum size of a string in a telemetry channel -#ifndef FW_TLM_STRING_MAX_SIZE -#define FW_TLM_STRING_MAX_SIZE 40 //!< Max size of channelized telemetry string type -#endif - -// Specifies the size of the buffer that contains the serialized parameter value. -#ifndef FW_PARAM_BUFFER_MAX_SIZE -#define FW_PARAM_BUFFER_MAX_SIZE (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPrmIdType) - sizeof(FwPacketDescriptorType)) -#endif - -// Specifies the maximum size of a string in a parameter -#ifndef FW_PARAM_STRING_MAX_SIZE -#define FW_PARAM_STRING_MAX_SIZE 40 //!< Max size of parameter string type -#endif - -// Specifies the maximum size of a file downlink chunk -#ifndef FW_FILE_BUFFER_MAX_SIZE -#define FW_FILE_BUFFER_MAX_SIZE FW_COM_BUFFER_MAX_SIZE //!< Max size of file buffer (i.e. chunk of file) -#endif - -// Specifies the maximum size of a string in an interface call -#ifndef FW_INTERNAL_INTERFACE_STRING_MAX_SIZE -#define FW_INTERNAL_INTERFACE_STRING_MAX_SIZE 256 //!< Max size of interface string parameter type -#endif - // Enables text logging of events as well as data logging. Adds a second logging port for text output. // In order to set this to 0, FPRIME_ENABLE_TEXT_LOGGERS must be set to OFF. #ifndef FW_ENABLE_TEXT_LOGGING #define FW_ENABLE_TEXT_LOGGING 1 //!< Indicates whether text logging is turned on #endif -// Define the size of the text log string buffer. Should be large enough for format string and arguments -#ifndef FW_LOG_TEXT_BUFFER_SIZE -#define FW_LOG_TEXT_BUFFER_SIZE 256 //!< Max size of string for text log message -#endif - // Define if serializables have toString() method. Turning off will save code space and // string constants. Must be enabled if text logging enabled #ifndef FW_SERIALIZABLE_TO_STRING @@ -263,73 +148,6 @@ extern "C" { #define FW_AMPCS_COMPATIBLE 0 //!< Whether or not JPL AMPCS ground system support is enabled. #endif -// Configuration for Fw::String -#ifndef FW_FIXED_LENGTH_STRING_SIZE -#define FW_FIXED_LENGTH_STRING_SIZE 256 //!< Character array size for Fw::String -#endif - -// OS configuration -#ifndef FW_CONSOLE_HANDLE_MAX_SIZE -#define FW_CONSOLE_HANDLE_MAX_SIZE 24 //!< Maximum size of a handle for OS queues -#endif - -#ifndef FW_TASK_HANDLE_MAX_SIZE -#define FW_TASK_HANDLE_MAX_SIZE 24 //!< Maximum size of a handle for OS queues -#endif - -#ifndef FW_FILE_HANDLE_MAX_SIZE -#define FW_FILE_HANDLE_MAX_SIZE 16 //!< Maximum size of a handle for OS queues -#endif - -#ifndef FW_MUTEX_HANDLE_MAX_SIZE -#define FW_MUTEX_HANDLE_MAX_SIZE 72 //!< Maximum size of a handle for OS queues -#endif - -#ifndef FW_QUEUE_HANDLE_MAX_SIZE -#define FW_QUEUE_HANDLE_MAX_SIZE 352 //!< Maximum size of a handle for OS queues -#endif - -#ifndef FW_DIRECTORY_HANDLE_MAX_SIZE -#define FW_DIRECTORY_HANDLE_MAX_SIZE 16 //!< Maximum size of a handle for OS resources (files, queues, locks, etc.) -#endif - -#ifndef FW_FILESYSTEM_HANDLE_MAX_SIZE -#define FW_FILESYSTEM_HANDLE_MAX_SIZE 16 //!< Maximum size of a handle for OS resources (files, queues, locks, etc.) -#endif - -#ifndef FW_RAW_TIME_HANDLE_MAX_SIZE -#define FW_RAW_TIME_HANDLE_MAX_SIZE 56 //!< Maximum size of a handle for OS::RawTime objects -#endif - -#ifndef FW_RAW_TIME_SERIALIZATION_MAX_SIZE -#define FW_RAW_TIME_SERIALIZATION_MAX_SIZE 8 //!< Maximum allowed serialization size for Os::RawTime objects -#endif - -#ifndef FW_CONDITION_VARIABLE_HANDLE_MAX_SIZE -#define FW_CONDITION_VARIABLE_HANDLE_MAX_SIZE 56 //!< Maximum size of a handle for OS condition variables -#endif - -#ifndef FW_CPU_HANDLE_MAX_SIZE -#define FW_CPU_HANDLE_MAX_SIZE 16 //!< Maximum size of a handle for OS cpu -#endif - -#ifndef FW_MEMORY_HANDLE_MAX_SIZE -#define FW_MEMORY_HANDLE_MAX_SIZE 16 //!< Maximum size of a handle for OS memory -#endif - -#ifndef FW_HANDLE_ALIGNMENT -#define FW_HANDLE_ALIGNMENT 8 //!< Alignment of handle storage -#endif - -// Note: One buffer of this size will be stack-allocated during certain OSAL operations e.g. when copying a file -#ifndef FW_FILE_CHUNK_SIZE -#define FW_FILE_CHUNK_SIZE 512 //!< Chunk size for working with files in the OSAL layer -#endif - -#ifndef FW_ASSERT_COUNT_MAX -#define FW_ASSERT_COUNT_MAX 10 //!< Maximum number of cascading FW_ASSERT check failures before forcing a system assert -#endif - // *** NOTE configuration checks are in Fw/Cfg/ConfigCheck.cpp in order to have // the type definitions in Fw/Types/BasicTypes available. #ifdef __cplusplus diff --git a/default/config/FpConstants.fpp b/default/config/FpConstants.fpp new file mode 100644 index 0000000000..d304aec775 --- /dev/null +++ b/default/config/FpConstants.fpp @@ -0,0 +1,86 @@ +# ====================================================================== +# FPP file for configuration of various F Prime framework constants +# ====================================================================== + +# --------------------------------------------------------------------- +# Buffer sizes +# --------------------------------------------------------------------- + +@ When dumping the contents of the registry, this specifies the size of the buffer used to store object names. +@ Should be >= FW_OBJ_NAME_BUFFER_SIZE. +constant FW_OBJ_SIMPLE_REG_BUFF_SIZE = 255 + +@ Specifies the size of the string holding the queue name for queues +constant FW_QUEUE_NAME_BUFFER_SIZE = 80 + +@ Specifies the size of the string holding the task name for active components and tasks +constant FW_TASK_NAME_BUFFER_SIZE = 80 + +@ Specifies the size of the buffer that contains a communications packet +constant FW_COM_BUFFER_MAX_SIZE = 512 + +@ Specifies the size of the buffer attached to state machine signals +constant FW_SM_SIGNAL_BUFFER_MAX_SIZE = 128 + +@ Specifies the size of the buffer that contains the serialized command arguments +constant FW_CMD_ARG_BUFFER_MAX_SIZE = FW_COM_BUFFER_MAX_SIZE - SIZE_OF_FwOpcodeType - SIZE_OF_FwPacketDescriptorType + +@ Specifies the maximum size of a string in a command argument +constant FW_CMD_STRING_MAX_SIZE = 40 + +@ Specifies the size of the buffer that contains the serialized log arguments +constant FW_LOG_BUFFER_MAX_SIZE = FW_COM_BUFFER_MAX_SIZE - SIZE_OF_FwEventIdType - SIZE_OF_FwPacketDescriptorType + +@ Specifies the maximum size of a string in a log event +@ Note: This constant truncates file names in assertion failure event reports +constant FW_LOG_STRING_MAX_SIZE = 200 + +@ Specifies the size of the buffer that contains the serialized telemetry value +constant FW_TLM_BUFFER_MAX_SIZE = FW_COM_BUFFER_MAX_SIZE - SIZE_OF_FwChanIdType - SIZE_OF_FwPacketDescriptorType + +@ Specifies the size of the buffer that contains the serialized telemetry value +constant FW_STATEMENT_ARG_BUFFER_MAX_SIZE = FW_CMD_ARG_BUFFER_MAX_SIZE + +@ Specifies the maximum size of a string in a telemetry channel +constant FW_TLM_STRING_MAX_SIZE = 40 + +@ Specifies the size of the buffer that contains the serialized parameter value +constant FW_PARAM_BUFFER_MAX_SIZE = FW_COM_BUFFER_MAX_SIZE - SIZE_OF_FwPrmIdType - SIZE_OF_FwPacketDescriptorType + +@ Specifies the maximum size of a string in a parameter +constant FW_PARAM_STRING_MAX_SIZE = 40 + +@ Specifies the maximum size of a file downlink chunk +constant FW_FILE_BUFFER_MAX_SIZE = FW_COM_BUFFER_MAX_SIZE + +@ Specifies the maximum size of a string in an interface call +constant FW_INTERNAL_INTERFACE_STRING_MAX_SIZE = 256 + +@ Defines the size of the text log string buffer. Should be large enough for format string and arguments +constant FW_LOG_TEXT_BUFFER_SIZE = 256 + +@ Configuration for Fw::String +@ Note: FPrimeBasicTypes.hpp needs to be updated to sync enum +constant FW_FIXED_LENGTH_STRING_SIZE = 256 + +# --------------------------------------------------------------------- +# Other constants +# --------------------------------------------------------------------- + +@ For the simple object registry provided with the framework, this specifies how many objects the registry will store. +constant FW_OBJ_SIMPLE_REG_ENTRIES = 500 + +@ For the simple queue registry provided with the framework, this specifies how many queues the registry will store. +constant FW_QUEUE_SIMPLE_QUEUE_ENTRIES = 100 + +@ Maximum number of cascading FW_ASSERT check failures before forcing a system assert +constant FW_ASSERT_COUNT_MAX = 10 + +@ Don't care value for time contexts in sequences +constant FW_CONTEXT_DONT_CARE = 0xFF + +@ Value encoded during serialization for boolean true +constant FW_SERIALIZE_TRUE_VALUE = 0xFF + +@ Value encoded during serialization for boolean false +constant FW_SERIALIZE_FALSE_VALUE = 0x00 \ No newline at end of file diff --git a/default/config/PlatformCfg.fpp b/default/config/PlatformCfg.fpp new file mode 100644 index 0000000000..3aa26c630d --- /dev/null +++ b/default/config/PlatformCfg.fpp @@ -0,0 +1,45 @@ +# ======================================================================= +# FPP file for configuration of various F Prime Platform and Os constants +# ======================================================================= + +@ Maximum size of a handle for Os::Console +constant FW_CONSOLE_HANDLE_MAX_SIZE = 24 + +@ Maximum size of a handle for Os::Task +constant FW_TASK_HANDLE_MAX_SIZE = 24 + +@ Maximum size of a handle for Os::File +constant FW_FILE_HANDLE_MAX_SIZE = 16 + +@ Maximum size of a handle for Os::Mutex +constant FW_MUTEX_HANDLE_MAX_SIZE = 72 + +@ Maximum size of a handle for Os::Queue +constant FW_QUEUE_HANDLE_MAX_SIZE = 352 + +@ Maximum size of a handle for Os::Directory +constant FW_DIRECTORY_HANDLE_MAX_SIZE = 16 + +@ Maximum size of a handle for Os::FileSystem +constant FW_FILESYSTEM_HANDLE_MAX_SIZE = 16 + +@ Maximum size of a handle for Os::RawTime +constant FW_RAW_TIME_HANDLE_MAX_SIZE = 56 + +@ Maximum allowed serialization size for Os::RawTime objects +constant FW_RAW_TIME_SERIALIZATION_MAX_SIZE = 8 + +@ Maximum size of a handle for Os::ConditionVariable +constant FW_CONDITION_VARIABLE_HANDLE_MAX_SIZE = 56 + +@ Maximum size of a handle for Os::Cpu +constant FW_CPU_HANDLE_MAX_SIZE = 16 + +@ Maximum size of a handle for Os::Memory +constant FW_MEMORY_HANDLE_MAX_SIZE = 16 + +@ Alignment of handle storage +constant FW_HANDLE_ALIGNMENT = 8 + +@ Chunk size for working with files in the OSAL layer +constant FW_FILE_CHUNK_SIZE = 512 diff --git a/docs/reference/numerical-types.md b/docs/reference/numerical-types.md index a677157d70..5712fb491f 100644 --- a/docs/reference/numerical-types.md +++ b/docs/reference/numerical-types.md @@ -109,8 +109,8 @@ printf("Index %" PRI_PlatformIndexType ". Min %" PRI_PlatformIndexType, index, s ### Configurable Integer Types -Project may configure the framework types that the framework and components use for implementation through -`FpConfig.h`. The default configuration as supplied with F´ uses the above platform types where applicable. +Projects may configure the framework types that the framework and components use for implementation through +`FpConfig.[h|fpp]`. The default configuration as supplied with F´ uses the above platform types where applicable. | Framework Type | Logical Usage | Default | Format Specifier | Signed | Size | |------------------|------------------------------|------------------------|----------------------|--------|-----------------| diff --git a/docs/user-manual/framework/configuring-fprime.md b/docs/user-manual/framework/configuring-fprime.md index 479eb0ee38..ea26e8e4c1 100644 --- a/docs/user-manual/framework/configuring-fprime.md +++ b/docs/user-manual/framework/configuring-fprime.md @@ -27,12 +27,14 @@ This guide includes: All configurable files (top-level and component-specific) for F´ are available in the top-level `config` directory. By default, all deployments use the F´ provided default configuration options. -Projects can also take ownership of the `config` directory to provide their own `AcConstants.fpp` -and configuration `*.hpp` files. To do so, copy the `config` directory into your project and use the -`config_directory` options in the project's `settings.ini` file. -See the [settings.ini guide](../build-system/settings.md) for more details. +Projects can also take ownership of the `config` directory to provide their own HPP/FPP configuration to +override the framework defaults. To do so, copy the `config` directory into your project and use the +[`register_fprime_config()`](../../reference/api/cmake/API.md) CMake API to let the build system know +to use your configuration overrides. This is demonstrated in various F´ reference projects, such as the +[FprimeZephyrReference](https://github.com/fprime-community/fprime-zephyr-reference/tree/devel/FprimeZephyrReference). -The `FpConfig.h` file is a C header allowing the user to define global settings. +The `FpConfig.h` file is a C header allowing the user to define global settings. Other configuration options +can be found in `FpConfig.fpp` and `FpConstants.fpp` Where components allow specific configuration, a `Cfg.hpp` is available to be modified as well. ## AcConstants.fpp @@ -59,12 +61,12 @@ number of components. ## FpConfig.h Some configurations may be changed during compilation time. The F′ framework has a number of optional features that can -be enabled or disabled by editing the `config/FpConfig.h` file. These changes affect of the whole of the F´ +be enabled or disabled by editing one of the `config/FpConfig` files (H, HPP, or FPP). These changes affect of the whole of the F´ deployment. Users can change or override defined *C* macro values that activate or disable code by using compiler flags for different deployment settings. During flight software (FSW) execution, disabling unnecessary features saves memory and CPU cycles. -All of these settings should be set in `FpConfig.h` and for most projects, this whole file will be cloned and owned +All of these settings should be set in `FpConfig.fpp` and for most projects, this whole file will be cloned and owned for their specific settings. Typically, the user will define the setting to be 0 for off and 1 for on. e.g.