added common folder
This commit is contained in:
parent
56e93b5fd7
commit
51475efaab
3
common/CMakeLists.txt
Normal file
3
common/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(utility)
|
||||
|
7
common/config/CMakeLists.txt
Normal file
7
common/config/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
commonPollingSequenceFactory.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
8
common/config/OBSWVersion.h
Normal file
8
common/config/OBSWVersion.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef COMMON_OBSWVERSION_H_
|
||||
#define COMMON_OBSWVERSION_H_
|
||||
|
||||
#define FSFW_EXAMPLE_VERSION 1
|
||||
#define FSFW_EXAMPLE_SUBVERSION 1
|
||||
#define FSFW_EXAMPLE_REVISION 0
|
||||
|
||||
#endif /* COMMON_OBSWVERSION_H_ */
|
14
common/config/commonClassIds.h
Normal file
14
common/config/commonClassIds.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef COMMON_CONFIG_COMMONCLASSIDS_H_
|
||||
#define COMMON_CONFIG_COMMONCLASSIDS_H_
|
||||
|
||||
#include "fsfw/returnvalues/FwClassIds.h"
|
||||
|
||||
namespace CLASS_ID {
|
||||
enum commonClassIds: uint8_t {
|
||||
COMMON_CLASS_ID_START = FW_CLASS_ID_COUNT,
|
||||
DUMMY_HANDLER, //DDH
|
||||
COMMON_CLASS_ID_END // [EXPORT] : [END]
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* COMMON_CONFIG_COMMONCLASSIDS_H_ */
|
64
common/config/commonConfig.h.in
Normal file
64
common/config/commonConfig.h.in
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @brief This file will contain configuration constants which are used across all BSPs
|
||||
*/
|
||||
#ifndef COMMON_COMMONCONFIG_H_
|
||||
#define COMMON_COMMONCONFIG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//! Specify the debug output verbose level
|
||||
#define OBSW_VERBOSE_LEVEL 1
|
||||
|
||||
#define OBSW_PRINT_MISSED_DEADLINES 0
|
||||
|
||||
//! Add core components for the FSFW and for TMTC communication
|
||||
#define OBSW_ADD_CORE_COMPONENTS 1
|
||||
|
||||
//! Add the PUS service stack
|
||||
#define OBSW_ADD_PUS_STACK 1
|
||||
#define OBSW_PUS_PRINTOUT 0
|
||||
|
||||
//! Add the task examples
|
||||
#define OBSW_ADD_TASK_EXAMPLE 1
|
||||
#define OBSW_TASK_EXAMPLE_PRINTOUT 0
|
||||
|
||||
//! Add the demo device handler object
|
||||
#define OBSW_ADD_DEVICE_HANDLER_DEMO 1
|
||||
#define OBSW_DEVICE_HANDLER_PRINTOUT 1
|
||||
|
||||
//! Add the demo controller object
|
||||
#define OBSW_ADD_CONTROLLER_DEMO 1
|
||||
#define OBSW_CONTROLLER_PRINTOUT 1
|
||||
|
||||
/**
|
||||
* The APID is a 14 bit identifier which can be used to distinguish processes and applications
|
||||
* on a spacecraft. For more details, see the related ECSS/CCSDS standards.
|
||||
* For this example, we are going to use a constant APID
|
||||
*/
|
||||
static const uint16_t COMMON_APID = 0xEF;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <fsfw/events/fwSubsystemIdRanges.h>
|
||||
#include <fsfw/returnvalues/FwClassIds.h>
|
||||
|
||||
/**
|
||||
* Enumerations for used PUS service IDs.
|
||||
*/
|
||||
namespace pus {
|
||||
enum ServiceIds: uint8_t {
|
||||
PUS_SERVICE_1 = 1,
|
||||
PUS_SERVICE_2 = 2,
|
||||
PUS_SERVICE_3 = 3,
|
||||
PUS_SERVICE_5 = 5,
|
||||
PUS_SERVICE_8 = 8,
|
||||
PUS_SERVICE_9 = 9,
|
||||
PUS_SERVICE_17 = 17,
|
||||
PUS_SERVICE_20 = 20,
|
||||
PUS_SERVICE_200 = 200
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* COMMON_COMMONCONFIG_H_ */
|
81
common/config/commonPollingSequenceFactory.cpp
Normal file
81
common/config/commonPollingSequenceFactory.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <pollingsequence/pollingSequenceFactory.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <test/FsfwExampleTask.h>
|
||||
|
||||
ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF* thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0,
|
||||
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0,
|
||||
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0,
|
||||
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.2,
|
||||
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.2,
|
||||
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.2,
|
||||
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.5,
|
||||
FsfwExampleTask::OpCodes::DELAY_SHORT);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.5,
|
||||
FsfwExampleTask::OpCodes::DELAY_SHORT);
|
||||
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.5,
|
||||
FsfwExampleTask::OpCodes::DELAY_SHORT);
|
||||
|
||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
|
||||
#else
|
||||
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.3, DeviceHandlerIF::SEND_WRITE);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.45 * length,
|
||||
DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.45 * length,
|
||||
DeviceHandlerIF::GET_WRITE);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
||||
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.8 * length, DeviceHandlerIF::GET_READ);
|
||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.8 * length, DeviceHandlerIF::GET_READ);
|
||||
|
||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!" << std::endl;
|
||||
#else
|
||||
sif::printError("pst::pollingSequenceTestFunction: Initialization errors!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
17
common/config/commonSubsystemIds.h
Normal file
17
common/config/commonSubsystemIds.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef COMMON_CONFIG_COMMONSUBSYSTEMIDS_H_
|
||||
#define COMMON_CONFIG_COMMONSUBSYSTEMIDS_H_
|
||||
|
||||
#include "fsfw/events/fwSubsystemIdRanges.h"
|
||||
|
||||
/**
|
||||
* The subsystem IDs will be part of the event IDs used throughout the FSFW.
|
||||
*/
|
||||
namespace SUBSYSTEM_ID {
|
||||
enum commonSubsystemId: uint8_t {
|
||||
COMMON_SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE,
|
||||
COMMON_SUBSYSTEM_ID_END
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* COMMON_CONFIG_COMMONSUBSYSTEMIDS_H_ */
|
40
common/config/commonSystemObjects.h
Normal file
40
common/config/commonSystemObjects.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef COMMON_COMMONSYSTEMOBJECTS_H_
|
||||
#define COMMON_COMMONSYSTEMOBJECTS_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||
|
||||
namespace objects {
|
||||
enum commonObjects: object_id_t {
|
||||
|
||||
/* 0x41 ('A') for Assemblies */
|
||||
TEST_ASSEMBLY = 0x4100CAFE,
|
||||
|
||||
/* 0x43 ('C') for Controllers */
|
||||
TEST_CONTROLLER = 0x4301CAFE,
|
||||
|
||||
/* 0x44 ('D') for Device Handlers */
|
||||
TEST_DEVICE_HANDLER_0 = 0x4401AFFE,
|
||||
TEST_DEVICE_HANDLER_1 = 0x4402AFFE,
|
||||
|
||||
/* 0x49 ('I') for Communication Interfaces */
|
||||
TEST_ECHO_COM_IF = 0x4900AFFE,
|
||||
|
||||
/* 0x63 ('C') for core objects */
|
||||
CCSDS_DISTRIBUTOR = 0x63000000,
|
||||
PUS_DISTRIBUTOR = 0x63000001,
|
||||
TM_FUNNEL = 0x63000002,
|
||||
|
||||
/* 0x74 ('t') for test and example objects */
|
||||
TEST_TASK = 0x7400CAFE,
|
||||
TEST_DUMMY_1 = 0x74000001,
|
||||
TEST_DUMMY_2 = 0x74000002,
|
||||
TEST_DUMMY_3= 0x74000003,
|
||||
TEST_DUMMY_4 = 0x74000004,
|
||||
TEST_DUMMY_5 = 0x74000005,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* COMMON_COMMONSYSTEMOBJECTS_H_ */
|
3
common/utility/CMakeLists.txt
Normal file
3
common/utility/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
utility.cpp
|
||||
)
|
22
common/utility/utility.cpp
Normal file
22
common/utility/utility.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "utility.h"
|
||||
#include <FSFWConfig.h>
|
||||
#include <OBSWVersion.h>
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
|
||||
void utility::commonInitPrint(const char *const os, const char* const board) {
|
||||
if(os == nullptr or board == nullptr) {
|
||||
return;
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
std::cout << "-- FSFW Example (" << os<< ") v" << FSFW_EXAMPLE_VERSION << "." <<
|
||||
FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
|
||||
std::cout << "-- Compiled for " << board << " --" << std::endl;
|
||||
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
#else
|
||||
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
|
||||
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);
|
||||
printf("-- Compiled for %s --\n", board);
|
||||
printf("-- Compiled on %s %s --\n", __DATE__, __TIME__);
|
||||
#endif
|
||||
}
|
11
common/utility/utility.h
Normal file
11
common/utility/utility.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef COMMON_UTILITY_UTILITY_H_
|
||||
#define COMMON_UTILITY_UTILITY_H_
|
||||
|
||||
namespace utility {
|
||||
|
||||
void commonInitPrint(const char *const os, const char* const board);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* COMMON_UTILITY_UTILITY_H_ */
|
Loading…
Reference in New Issue
Block a user