better missed deadline handling
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
@ -24,7 +24,7 @@ ServiceInterfaceStream sif::error("ERROR");
|
||||
|
||||
ObjectManagerIF *objectManager = nullptr;
|
||||
|
||||
void InitMission::initMission() {
|
||||
void initmission::initMission() {
|
||||
sif::info << "Building global objects.." << std::endl;
|
||||
/* Instantiate global object manager and also create all objects */
|
||||
objectManager = new ObjectManager(ObjectFactory::produce);
|
||||
@ -35,11 +35,21 @@ void InitMission::initMission() {
|
||||
initTasks();
|
||||
}
|
||||
|
||||
void InitMission::initTasks(){
|
||||
void initmission::initTasks() {
|
||||
TaskFactory* factory = TaskFactory::instance();
|
||||
if(factory == nullptr) {
|
||||
/* Should never happen ! */
|
||||
return;
|
||||
}
|
||||
#if OBSW_PRINT_MISSED_DEADLINES == 1
|
||||
void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline;
|
||||
#else
|
||||
void (*missedDeadlineFunc) (void) = nullptr;
|
||||
#endif
|
||||
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* tmTcDistributor = TaskFactory::instance()->
|
||||
createPeriodicTask("DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.100, nullptr);
|
||||
PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask(
|
||||
"DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||
ReturnValue_t result = tmTcDistributor->addComponent(
|
||||
objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
@ -55,95 +65,85 @@ void InitMission::initTasks(){
|
||||
}
|
||||
|
||||
/* UDP bridge */
|
||||
PeriodicTaskIF* udpBridgeTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.2, nullptr);
|
||||
PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||
result = udpBridgeTask->addComponent(objects::UDP_BRIDGE);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Add component UDP Unix Bridge failed" << std::endl;
|
||||
}
|
||||
PeriodicTaskIF* udpPollingTask = TaskFactory::instance()->
|
||||
createPeriodicTask("UDP_POLLING", 80,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, nullptr);
|
||||
PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask(
|
||||
"UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
||||
result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Add component UDP Polling failed" << std::endl;
|
||||
}
|
||||
|
||||
/* PUS Services */
|
||||
PeriodicTaskIF* pusVerification = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_VERIF", 40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
|
||||
PeriodicTaskIF* pusVerification = factory->createPeriodicTask(
|
||||
"PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
||||
result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "Object add component failed" << std::endl;
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusEvents = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_EVENTS", 60,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr);
|
||||
PeriodicTaskIF* pusEvents = factory->createPeriodicTask(
|
||||
"PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
||||
result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
InitMission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusHighPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_HIGH_PRIO", 50,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.200, nullptr);
|
||||
PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask(
|
||||
"PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc);
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS);
|
||||
}
|
||||
result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusMedPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_HIGH_PRIO", 40,
|
||||
PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
0.8, nullptr);
|
||||
PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask(
|
||||
"PUS_HIGH_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc);
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT);
|
||||
}
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT);
|
||||
}
|
||||
result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS);
|
||||
initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* pusLowPrio = TaskFactory::instance()->
|
||||
createPeriodicTask("PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
1.6, nullptr);
|
||||
PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask(
|
||||
"PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc);
|
||||
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST);
|
||||
initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* testTask = TaskFactory::instance()->
|
||||
createPeriodicTask("SPI_TEST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE,
|
||||
2.0, nullptr);
|
||||
PeriodicTaskIF* testTask = factory->createPeriodicTask(
|
||||
"TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
result = testTask->addComponent(objects::TEST_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
||||
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
||||
}
|
||||
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
||||
#if RPI_ADD_SPI_TEST == 1
|
||||
result = testTask->addComponent(objects::SPI_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
||||
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
||||
}
|
||||
#endif /* RPI_ADD_SPI_TEST == 1 */
|
||||
#if RPI_ADD_GPIO_TEST == 1
|
||||
result = testTask->addComponent(objects::LIBGPIOD_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
InitMission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST);
|
||||
initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST);
|
||||
}
|
||||
#endif /* RPI_ADD_GPIO_TEST == 1 */
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef BSP_LINUX_INITMISSION_H_
|
||||
#define BSP_LINUX_INITMISSION_H_
|
||||
|
||||
namespace InitMission {
|
||||
namespace initmission {
|
||||
void initMission();
|
||||
void initTasks();
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "ObjectFactory.h"
|
||||
#include <bsp_rpi/boardtest/SpiTest.h>
|
||||
#include <bsp_rpi/gpio/GPIORPi.h>
|
||||
|
||||
#include <objects/systemObjectList.h>
|
||||
@ -8,18 +7,21 @@
|
||||
#include <tmtc/apid.h>
|
||||
#include <tmtc/pusIds.h>
|
||||
|
||||
#include <linux/boardtest/LibgpiodTest.h>
|
||||
#include <linux/boardtest/SpiTestClass.h>
|
||||
#include <linux/gpio/GpioCookie.h>
|
||||
#include <linux/gpio/LinuxLibgpioIF.h>
|
||||
|
||||
#include <mission/core/GenericFactory.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
|
||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
#include <fsfw/osal/linux/TmTcUnixUdpBridge.h>
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/osal/linux/TcUnixUdpPollingTask.h>
|
||||
#include <linux/boardtest/LibgpiodTest.h>
|
||||
#include <linux/gpio/GpioCookie.h>
|
||||
#include <linux/gpio/LinuxLibgpioIF.h>
|
||||
|
||||
#include <mission/core/GenericFactory.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
|
||||
@ -52,7 +54,7 @@ void ObjectFactory::produce(){
|
||||
new LinuxLibgpioIF(objects::GPIO_IF);
|
||||
|
||||
#if RPI_ADD_SPI_TEST == 1
|
||||
new SpiTest(objects::SPI_TEST);
|
||||
new SpiTestClass(objects::SPI_TEST);
|
||||
#endif
|
||||
|
||||
#if RPI_LOOPBACK_TEST_GPIO == 1
|
||||
|
@ -1,5 +1,4 @@
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
SpiTest.cpp
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
#include "SpiTest.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
|
||||
|
||||
SpiTest::SpiTest(object_id_t objectId): SystemObject(objectId) {
|
||||
sif::info << "Setting up Raspberry Pi WiringPi library." << std::endl;
|
||||
// wiringPiSetupGpio();
|
||||
|
||||
// pinMode(SS_MGM_0_LIS3, OUTPUT);
|
||||
// pinMode(SS_MGM_1_RM, OUTPUT);
|
||||
// pinMode(SS_GYRO_0_ADIS, OUTPUT);
|
||||
// pinMode(SS_GYRO_1_L3G, OUTPUT);
|
||||
// pinMode(SS_GYRO_2_L3G, OUTPUT);
|
||||
// pinMode(SS_MGM_2_LIS3, OUTPUT);
|
||||
// pinMode(SS_MGM_3_RM, OUTPUT);
|
||||
//
|
||||
// digitalWrite(SS_MGM_0_LIS3, HIGH);
|
||||
// digitalWrite(SS_MGM_1_RM, HIGH);
|
||||
// digitalWrite(SS_GYRO_0_ADIS, HIGH);
|
||||
// digitalWrite(SS_GYRO_1_L3G, HIGH);
|
||||
// digitalWrite(SS_GYRO_2_L3G, HIGH);
|
||||
// digitalWrite(SS_MGM_2_LIS3, HIGH);
|
||||
// digitalWrite(SS_MGM_3_RM, HIGH);
|
||||
|
||||
int spiFd = open(spiDeviceName.c_str(), O_RDWR);
|
||||
if (spiFd < 0){
|
||||
sif::error << "Could not open SPI device!" << std::endl;
|
||||
}
|
||||
|
||||
spiMode = SPI_MODE_3;
|
||||
int ret = ioctl(spiFd, SPI_IOC_WR_MODE, &spiMode);
|
||||
if(ret < 0) {
|
||||
sif::error << "Could not set write mode!" << std::endl;
|
||||
}
|
||||
|
||||
/* Datenrate setzen */
|
||||
ret = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &spiSpeed);
|
||||
if(ret < 0) {
|
||||
sif::error << "Could not SPI speed!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SpiTest::performOperation(uint8_t opCode) {
|
||||
if(oneShot) {
|
||||
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiTest::initialize() {
|
||||
//transferHandle.rx_buf = reinterpret_cast<__u64>(receiveBuffer);
|
||||
//transferHandle.tx_buf = reinterpret_cast<__u64>(sendBuffer);
|
||||
//transferHandle.speed_hz = 976000;
|
||||
//transferHandle.len = 2;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
#ifndef BSP_LINUX_TEST_SPITEST_H_
|
||||
#define BSP_LINUX_TEST_SPITEST_H_
|
||||
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <string>
|
||||
|
||||
class SpiTest:
|
||||
public SystemObject,
|
||||
public ExecutableObjectIF {
|
||||
public:
|
||||
SpiTest(object_id_t objectId);
|
||||
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
ReturnValue_t initialize() override;
|
||||
private:
|
||||
// These chip selects (BCM number) will be pulled high if not used
|
||||
// ACS board specific.
|
||||
enum SpiChipSelects {
|
||||
SS_MGM_0_LIS3 = 0, //!< MGM 0, LIS3MDLTR, U6, A side
|
||||
SS_MGM_1_RM = 1, //!< MGM 1, RM3100, U7, A side
|
||||
SS_GYRO_0_ADIS = 2, //!< Gyro 0, ADIS16485, U3, A side
|
||||
SS_GYRO_1_L3G = 3, //!< Gyro 1, L3GD20H, U4, A side
|
||||
SS_GYRO_2_L3G = 4, //!< Gyro 2, L3GD20h, U5, B side
|
||||
SS_MGM_2_LIS3 = 17, //!< MGM 2, LIS3MDLTR, U8, B side
|
||||
SS_MGM_3_RM = 27, //!< MGM 3, RM3100, U9, B side
|
||||
};
|
||||
|
||||
const std::string spiDeviceName = "/dev/spidev0.0";
|
||||
int spiFd = 0;
|
||||
|
||||
uint8_t spiMode = SPI_MODE_3;
|
||||
uint32_t spiSpeed = 976000;
|
||||
|
||||
uint8_t sendBuffer[32];
|
||||
uint8_t receiveBuffer[32];
|
||||
struct spi_ioc_transfer transferHandle;
|
||||
|
||||
bool oneShot = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* BSP_LINUX_TEST_SPITEST_H_ */
|
@ -1,12 +1,10 @@
|
||||
#include "InitMission.h"
|
||||
|
||||
#include <OBSWVersion.h>
|
||||
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* @brief This is the main program for the target hardware.
|
||||
* @return
|
||||
@ -14,15 +12,15 @@
|
||||
int main(void)
|
||||
{
|
||||
std::cout << "-- EIVE OBSW --" << std::endl;
|
||||
std::cout << "-- Compiled for Linux " << " --" << std::endl;
|
||||
std::cout << "-- Compiled for Linux (Raspberry Pi) --" << std::endl;
|
||||
std::cout << "-- Software version " << SW_NAME << " v" << SW_VERSION << "."
|
||||
<< SW_SUBVERSION << "." << SW_SUBSUBVERSION << " -- " << std::endl;
|
||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
|
||||
InitMission::initMission();
|
||||
initmission::initMission();
|
||||
|
||||
for(;;) {
|
||||
// suspend main thread by sleeping it.
|
||||
/* suspend main thread by sleeping it. */
|
||||
TaskFactory::delayTask(5000);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user