diff --git a/FprimeZephyrReference/project/config/CMakeLists.txt b/FprimeZephyrReference/project/config/CMakeLists.txt index cf115d7..25ae8d4 100644 --- a/FprimeZephyrReference/project/config/CMakeLists.txt +++ b/FprimeZephyrReference/project/config/CMakeLists.txt @@ -3,13 +3,24 @@ # # Sets a list of source files for cmake to process as part of autocoding. #### + +# Select ComCfg file based on build environment +# Use ComCfg.CI.fpp for CI builds, ComCfg.fpp for development +if(DEFINED ENV{CI}) + set(COM_CFG_FILE "${CMAKE_CURRENT_LIST_DIR}/ComCfg.CI.fpp") + message(STATUS "Using CI spacecraft ID configuration") +else() + set(COM_CFG_FILE "${CMAKE_CURRENT_LIST_DIR}/ComCfg.fpp") + message(STATUS "Using development spacecraft ID configuration") +endif() + register_fprime_config( CONFIGURATION_OVERRIDES "${CMAKE_CURRENT_LIST_DIR}/CdhCoreConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreTlmConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreFatalHandlerConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/ComCcsdsConfig.fpp" - "${CMAKE_CURRENT_LIST_DIR}/ComCfg.fpp" + "${COM_CFG_FILE}" "${CMAKE_CURRENT_LIST_DIR}/CommandDispatcherImplCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/LoRaCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/FpConfig.h" diff --git a/FprimeZephyrReference/project/config/ComCfg.CI.fpp b/FprimeZephyrReference/project/config/ComCfg.CI.fpp new file mode 100644 index 0000000..414d2f2 --- /dev/null +++ b/FprimeZephyrReference/project/config/ComCfg.CI.fpp @@ -0,0 +1,52 @@ +# ====================================================================== +# FPP file for configuration of the communications stack (CI Build) +# +# 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 + +module ComCfg { + + # Needed in dictionary: + # - spacecraftId + # - TmFrameFixedSize + # - potentially APID enum ? + constant SpacecraftId = 0x00C1 # Spacecraft ID (10 bits, range 0x0000-0x03FF) - CI build + constant TmFrameFixedSize = 248 # Needs to be at least COM_BUFFER_MAX_SIZE + (2 * SpacePacketHeaderSize) + 1 + constant AggregationSize = TmFrameFixedSize - 6 - 6 - 1 - 2 # 2 header (6) + 1 idle byte + 2 trailer bytes + + @ APIDs are 11 bits in the Space Packet protocol, so we use U16. Max value 7FF + enum Apid : FwPacketDescriptorType { + # APIDs prefixed with FW are reserved for F Prime and need to be present + # in the enumeration. Their values can be changed + FW_PACKET_COMMAND = 0x0000 @< Command packet type - incoming + FW_PACKET_TELEM = 0x0001 @< Telemetry packet type - outgoing + FW_PACKET_LOG = 0x0002 @< Log type - outgoing + FW_PACKET_FILE = 0x0003 @< File type - incoming and outgoing + FW_PACKET_PACKETIZED_TLM = 0x0004 @< Packetized telemetry packet type + FW_PACKET_DP = 0x0005 @< Data Product packet type + FW_PACKET_IDLE = 0x0006 @< F Prime idle + FW_PACKET_HAND = 0x00FE @< F Prime handshake + FW_PACKET_UNKNOWN = 0x00FF @< F Prime unknown packet + SPP_IDLE_PACKET = 0x07FF @< Per Space Packet Standard, all 1s (11bits) is reserved for Idle Packets + INVALID_UNINITIALIZED = 0x0800 @< Anything equal or higher value is invalid and should not be used + } default INVALID_UNINITIALIZED + + @ Type used to pass context info between components during framing/deframing + struct FrameContext { + comQueueIndex: FwIndexType @< Queue Index used by the ComQueue, other components shall not modify + apid: Apid @< 11 bits APID in CCSDS + sequenceCount: U16 @< 14 bit Sequence count - sequence count is incremented per APID + vcId: U8 @< 6 bit Virtual Channel ID - used for TC and TM + } default { + comQueueIndex = 0 + apid = Apid.FW_PACKET_UNKNOWN + sequenceCount = 0 + vcId = 1 + } + +} diff --git a/README.md b/README.md index 179facb..3fac938 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,17 @@ cd proves-core-reference make ``` +## Configuration + +### Spacecraft ID + +The spacecraft ID is used to identify different spacecraft/devices in the communication protocol. The project uses different spacecraft IDs for different build environments: + +- **Development builds**: `0x0044` (68 in decimal) - Uses `ComCfg.fpp` +- **CI builds**: `0x00C1` (193 in decimal) - Uses `ComCfg.CI.fpp` + +The build system automatically selects the appropriate configuration file based on the `CI` environment variable. CI builds (when `CI` environment variable is set) automatically use the CI spacecraft ID to prevent conflicts with development devices in shared lab environments. + ## Running the code Run generate from the `proves-core-reference` directory. This generates the build cache for FPrime. You only need to do generate if something in the core FPrime package has changed