diff --git a/FSFWVersion.h b/FSFWVersion.h new file mode 100644 index 00000000..dcb592dc --- /dev/null +++ b/FSFWVersion.h @@ -0,0 +1,11 @@ +#ifndef FSFW_DEFAULTCFG_VERSION_H_ +#define FSFW_DEFAULTCFG_VERSION_H_ + +const char* const FSFW_VERSION_NAME = "fsfw"; + +#define FSFW_VERSION 0 +#define FSFW_SUBVERSION 0 + + + +#endif /* FSFW_DEFAULTCFG_VERSION_H_ */ diff --git a/README.md b/README.md new file mode 100644 index 00000000..fc86fca7 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Flight Software Framework (FSFW) +====== + +I want to be written! diff --git a/defaultcfg/README.md b/defaultcfg/README.md new file mode 100644 index 00000000..8446cda4 --- /dev/null +++ b/defaultcfg/README.md @@ -0,0 +1,6 @@ +# How to setup configuration folder for FSFW + +It is recommended to copy the content of the defaultcfg folder +into a config folder which is in the same directory as the Flight +Software Framework submodule. After that, the config.mk folder should be +included by the primary Makefile with CURRENTPATH set correctly. diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h new file mode 100644 index 00000000..ea86152c --- /dev/null +++ b/defaultcfg/config/FSFWConfig.h @@ -0,0 +1,54 @@ +#ifndef CONFIG_FSFWCONFIG_H_ +#define CONFIG_FSFWCONFIG_H_ + +#include +#include + +//! Used to determine whether C++ ostreams are used +//! Those can lead to code bloat. +#define FSFW_CPP_OSTREAM_ENABLED 1 + +//! Reduced printout to further decrese code size +//! Be careful, this also turns off most diagnostic prinouts! +#define FSFW_REDUCED_PRINTOUT 0 + +//! Can be used to enable debugging printouts for developing the FSFW +#define FSFW_DEBUGGING 0 + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +#define FSFW_CSB_FIFO_DEPTH 6 + +//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, +//! additional output which requires the translation files translateObjects +//! and translateEvents (and their compiled source files) +#define FSFW_OBJ_EVENT_TRANSLATION 0 + +#if FSFW_OBJ_EVENT_TRANSLATION == 1 +#define FSFW_DEBUG_OUTPUT 1 +//! Specify whether info events are printed too. +#define FSFW_DEBUG_INFO 1 +#include +#include +#else +#define FSFW_DEBUG_OUTPUT 0 +#endif + +//! When using the newlib nano library, C99 support for stdio facilities +//! will not be provided. This define should be set to 1 if this is the case. +#define FSFW_NO_C99_IO 1 + +namespace fsfwconfig { +//! Default timestamp size. The default timestamp will be an eight byte CDC +//! short timestamp. +static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; + +//! Configure the allocated pool sizes for the event manager. +static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; +static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; +static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; +} + +#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/defaultcfg/config/OBSWConfig.h b/defaultcfg/config/OBSWConfig.h new file mode 100644 index 00000000..a9f57638 --- /dev/null +++ b/defaultcfg/config/OBSWConfig.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_OBSWCONFIG_H_ +#define CONFIG_OBSWCONFIG_H_ + +#include "OBSWVersion.h" + +#ifdef __cplusplus +namespace config { +#endif + +/* Add mission configuration flags here */ + +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_OBSWCONFIG_H_ */ diff --git a/defaultcfg/config/OBSWVersion.h b/defaultcfg/config/OBSWVersion.h new file mode 100644 index 00000000..3c60317c --- /dev/null +++ b/defaultcfg/config/OBSWVersion.h @@ -0,0 +1,9 @@ +#ifndef CONFIG_VERSION_H_ +#define CONFIG_VERSION_H_ + +/* OBSW versioning can be specified in this file */ + +#define OBSW_VERSION 0 +#define OBSW_SUBVERSION 0 + +#endif /* CONFIG_VERSION_H_ */ diff --git a/defaultcfg/config/config.mk b/defaultcfg/config/config.mk new file mode 100644 index 00000000..51543eba --- /dev/null +++ b/defaultcfg/config/config.mk @@ -0,0 +1,15 @@ +CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/tmtc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/devices/*.cpp) + +INCLUDES += $(CURRENTPATH) +INCLUDES += $(CURRENTPATH)/objects +INCLUDES += $(CURRENTPATH)/returnvalues +INCLUDES += $(CURRENTPATH)/tmtc +INCLUDES += $(CURRENTPATH)/events +INCLUDES += $(CURRENTPATH)/devices +INCLUDES += $(CURRENTPATH)/pollingsequence +INCLUDES += $(CURRENTPATH)/ipc diff --git a/defaultcfg/config/devices/logicalAddresses.cpp b/defaultcfg/config/devices/logicalAddresses.cpp new file mode 100644 index 00000000..c7ce314d --- /dev/null +++ b/defaultcfg/config/devices/logicalAddresses.cpp @@ -0,0 +1,5 @@ +#include "logicalAddresses.h" + + + + diff --git a/defaultcfg/config/devices/logicalAddresses.h b/defaultcfg/config/devices/logicalAddresses.h new file mode 100644 index 00000000..174fa788 --- /dev/null +++ b/defaultcfg/config/devices/logicalAddresses.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ +#define CONFIG_DEVICES_LOGICALADDRESSES_H_ + +#include +#include +#include + +/** + * Can be used for addresses for physical devices like I2C adresses. + */ +namespace addresses { + /* Logical addresses have uint32_t datatype */ + enum logicalAddresses: address_t { + }; +} + + +#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/defaultcfg/config/devices/powerSwitcherList.cpp b/defaultcfg/config/devices/powerSwitcherList.cpp new file mode 100644 index 00000000..343f78d0 --- /dev/null +++ b/defaultcfg/config/devices/powerSwitcherList.cpp @@ -0,0 +1,4 @@ +#include "powerSwitcherList.h" + + + diff --git a/defaultcfg/config/devices/powerSwitcherList.h b/defaultcfg/config/devices/powerSwitcherList.h new file mode 100644 index 00000000..86ddea57 --- /dev/null +++ b/defaultcfg/config/devices/powerSwitcherList.h @@ -0,0 +1,12 @@ +#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ + +namespace switches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum switcherList { + }; + +} + + +#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/defaultcfg/config/events/subsystemIdRanges.h b/defaultcfg/config/events/subsystemIdRanges.h new file mode 100644 index 00000000..24eee819 --- /dev/null +++ b/defaultcfg/config/events/subsystemIdRanges.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ + +#include +#include + +/** + * @brief Custom subsystem IDs can be added here + * @details + * Subsystem IDs are used to create unique events. + */ +namespace SUBSYSTEM_ID { +enum: uint8_t { + SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, +}; +} + +#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/defaultcfg/config/ipc/missionMessageTypes.cpp b/defaultcfg/config/ipc/missionMessageTypes.cpp new file mode 100644 index 00000000..e2edbf9c --- /dev/null +++ b/defaultcfg/config/ipc/missionMessageTypes.cpp @@ -0,0 +1,11 @@ +#include +#include + +void messagetypes::clearMissionMessage(CommandMessage* message) { + switch(message->getMessageType()) { + default: + break; + } +} + + diff --git a/defaultcfg/config/ipc/missionMessageTypes.h b/defaultcfg/config/ipc/missionMessageTypes.h new file mode 100644 index 00000000..8b2e2fcc --- /dev/null +++ b/defaultcfg/config/ipc/missionMessageTypes.h @@ -0,0 +1,21 @@ +#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ +#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ + +#include +#include + +/** + * Custom command messages are specified here. + * Most messages needed to use FSFW are already located in + * + * @param message Generic Command Message + */ +namespace messagetypes { +enum CustomMessageTypes { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT +}; + +void clearMissionMessage(CommandMessage* message); +} + +#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/defaultcfg/config/objects/Factory.cpp b/defaultcfg/config/objects/Factory.cpp new file mode 100644 index 00000000..51dd6130 --- /dev/null +++ b/defaultcfg/config/objects/Factory.cpp @@ -0,0 +1,54 @@ +#include "Factory.h" +#include "../tmtc/apid.h" +#include "../tmtc/pusIds.h" +#include "../objects/systemObjectList.h" +#include "../devices/logicalAddresses.h" +#include "../devices/powerSwitcherList.h" + +#include +#include +#include +#include +#include +#include + +#include + +/** + * This class should be used to create all system objects required for + * the on-board software, using the object ID list from the configuration + * folder. + * + * The objects are registered in the internal object manager automatically. + * This is used later to add objects to tasks. + * + * This file also sets static framework IDs. + * + * Framework objects are created first. + * @ingroup init + */ +void Factory::produce(void) { + setStaticFrameworkObjectIds(); + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + //new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); +} + +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; + + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; + + DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; + + TmPacketStored::timeStamperId = objects::PUS_TIME; + //TmFunnel::downlinkDestination = objects::NO_OBJECT; +} + diff --git a/defaultcfg/config/objects/Factory.h b/defaultcfg/config/objects/Factory.h new file mode 100644 index 00000000..fe55deff --- /dev/null +++ b/defaultcfg/config/objects/Factory.h @@ -0,0 +1,17 @@ +#ifndef FACTORY_H_ +#define FACTORY_H_ + +#include +#include + +namespace Factory { + /** + * @brief Creates all SystemObject elements which are persistent + * during execution. + */ + void produce(); + void setStaticFrameworkObjectIds(); +} + + +#endif /* FACTORY_H_ */ diff --git a/defaultcfg/config/objects/systemObjectList.h b/defaultcfg/config/objects/systemObjectList.h new file mode 100644 index 00000000..f4292f6d --- /dev/null +++ b/defaultcfg/config/objects/systemObjectList.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include +#include + +// The objects will be instantiated in the ID order +namespace objects { + enum sourceObjects: uint32_t { + /* All addresses between start and end are reserved for the FSFW */ + FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, + FSFW_CONFIG_RESERVED_END = TM_STORE + }; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp b/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp new file mode 100644 index 00000000..f836a746 --- /dev/null +++ b/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp @@ -0,0 +1,23 @@ +#include "PollingSequenceFactory.h" + +#include +#include +#include + +ReturnValue_t pst::pollingSequenceInitDefault( + FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + + /* Add polling sequence table here */ + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + else { + sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } +} + diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.h b/defaultcfg/config/pollingsequence/PollingSequenceFactory.h new file mode 100644 index 00000000..c5d41b7d --- /dev/null +++ b/defaultcfg/config/pollingsequence/PollingSequenceFactory.h @@ -0,0 +1,32 @@ +#ifndef POLLINGSEQUENCEFACTORY_H_ +#define POLLINGSEQUENCEFACTORY_H_ + +#include + +class FixedTimeslotTaskIF; + +/** + * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) + * to satisfy stricter timing requirements of device communication, + * A device handler has four different communication steps: + * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface + * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write + * 3. DeviceHandlerIF::SEND_READ -> Send read request + * 4. DeviceHandlerIF::GET_READ -> Read from interface + * The PST specifies precisely when the respective ComIF functions are called + * during the communication cycle time. + * The task is created using the FixedTimeslotTaskIF, + * which utilises the underlying Operating System Abstraction Layer (OSAL) + * + * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST + * @return + */ +namespace pst { + +/* Default PST */ +ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); + + +} + +#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/defaultcfg/config/returnvalues/classIds.h b/defaultcfg/config/returnvalues/classIds.h new file mode 100644 index 00000000..606cc60b --- /dev/null +++ b/defaultcfg/config/returnvalues/classIds.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ +#define CONFIG_RETURNVALUES_CLASSIDS_H_ + +#include + +/** + * @brief CLASS_ID defintions which are required for custom returnvalues. + */ +namespace CLASS_ID { +enum { + MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, +}; +} + + +#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/defaultcfg/config/tmtc/apid.h b/defaultcfg/config/tmtc/apid.h new file mode 100644 index 00000000..c0231bca --- /dev/null +++ b/defaultcfg/config/tmtc/apid.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_TMTC_APID_H_ +#define CONFIG_TMTC_APID_H_ + +#include + +/** + * Application Process Definition: entity, uniquely identified by an + * application process ID (APID), capable of generating telemetry source + * packets and receiving telecommand packets. + * + * Chose APID(s) for mission and define it here. + */ +namespace apid { + static const uint16_t DEFAULT_APID = 0x00; +} + + +#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/defaultcfg/config/tmtc/pusIds.h b/defaultcfg/config/tmtc/pusIds.h new file mode 100644 index 00000000..cc0db9f0 --- /dev/null +++ b/defaultcfg/config/tmtc/pusIds.h @@ -0,0 +1,23 @@ +#ifndef CONFIG_TMTC_PUSIDS_HPP_ +#define CONFIG_TMTC_PUSIDS_HPP_ + +namespace pus { +enum Ids: uint8_t { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_11 = 11, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, +}; +}; + +#endif /* CONFIG_TMTC_PUSIDS_HPP_ */ diff --git a/events/EventManager.cpp b/events/EventManager.cpp index e71951e3..f60a8a66 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -1,5 +1,7 @@ #include "EventManager.h" #include "EventMessage.h" +#include + #include "../serviceinterface/ServiceInterfaceStream.h" #include "../ipc/QueueFactory.h" #include "../ipc/MutexFactory.h" @@ -12,8 +14,10 @@ const uint16_t EventManager::POOL_SIZES[N_POOLS] = { // objects registering for certain events. // Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher. // So a good guess is 75 to a max of 100 pools required for each, which fits well. -// SHOULDDO: Shouldn't this be in the config folder and passed via ctor? -const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 }; +const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { + fsfwconfig::FSFW_EVENTMGMR_MATCHTREE_NODES , + fsfwconfig::FSFW_EVENTMGMT_EVENTIDMATCHERS, + fsfwconfig::FSFW_EVENTMGMR_RANGEMATCHERS }; EventManager::EventManager(object_id_t setObjectId) : SystemObject(setObjectId), diff --git a/unittest/README.md b/unittest/README.md index e628d43e..8a787c07 100644 --- a/unittest/README.md +++ b/unittest/README.md @@ -7,6 +7,16 @@ The makefile with default settings creates the unit test binary which can be run in the terminal or in eclipse. ### Instructions + +To run the fsfw unittests in the project, perform following steps: + +1. Copy the testcfg folder the project root (folder containing the FSFW). +2. There is a makefile inside the testcfg folder which can be used to have + a starting point to compile the unit tests. Copy that Makefile to the project + root +3. Create a folder named catch2 (can have other name which requires Makefile + adaption) and copy the Catch2 header files there (NOTE: CMake support + not enabled yet!) ### Eclipse CDT settings diff --git a/unittest/testcfg/Makefile-FSFW-Tests b/unittest/testcfg/Makefile-FSFW-Tests index d43a6edc..2017d2bd 100644 --- a/unittest/testcfg/Makefile-FSFW-Tests +++ b/unittest/testcfg/Makefile-FSFW-Tests @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------- -# Makefile for FSFW Test +# Makefile for FSFW Test #------------------------------------------------------------------------------- # User-modifiable options #------------------------------------------------------------------------------- diff --git a/unittest/testcfg/cdatapool/dataPoolInit.h b/unittest/testcfg/cdatapool/dataPoolInit.h index 23a3d01f..9425d767 100644 --- a/unittest/testcfg/cdatapool/dataPoolInit.h +++ b/unittest/testcfg/cdatapool/dataPoolInit.h @@ -1,7 +1,7 @@ #ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_ #define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_ -#include +#include #include #include #include