linux working

This commit is contained in:
2020-09-16 16:22:36 +02:00
parent 6f6eceef6f
commit ffcb6e0213
47 changed files with 1926 additions and 6 deletions

168
bsp_linux/InitMission.cpp Normal file
View File

@ -0,0 +1,168 @@
#include <PollingSequenceFactory.h>
#include <dataPoolInit.h>
#include <Factory.h>
#include <systemObjectList.h>
#include <fsfw/datapool/DataPool.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/tasks/PeriodicTaskIF.h>
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <ostream>
/* Declare global object manager */
ObjectManagerIF* objectManager;
/* Initialize Data Pool */
DataPool dataPool(datapool::dataPoolInit);
/* Set up output streams */
namespace sif {
ServiceInterfaceStream debug("DEBUG");
ServiceInterfaceStream info("INFO");
ServiceInterfaceStream warning("WARNING");
ServiceInterfaceStream error("ERROR", false, true, true);
}
void initTask();
void initMission() {
sif::info << "Initiating mission specific code." << std::endl;
// Allocate object manager here, as global constructors might not be
// executed, depending on buildchain
sif::info << "Creating objects" << std::endl;
objectManager = new ObjectManager(Factory::produce);
objectManager -> initialize();
initTask();
}
void initTask() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
/* Packet Distributor Taks */
PeriodicTaskIF* PacketDistributorTask =
TaskFactory::instance()-> createPeriodicTask(
"PACKET_DIST_TASK", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PacketDistributorTask->
addComponent(objects::CCSDS_PACKET_DISTRIBUTOR);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Add component CCSDS Packet Distributor failed"
<< std::endl;
}
result = PacketDistributorTask->
addComponent(objects::PUS_PACKET_DISTRIBUTOR);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Add component PUS Packet Distributor failed"
<< std::endl;
}
result = PacketDistributorTask->addComponent(objects::PUS_FUNNEL);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Add component PUS Funnel failed" << std::endl;
}
/* UDP bridge */
PeriodicTaskIF* UdpBridgeTask = TaskFactory::instance()->createPeriodicTask(
"UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.2, nullptr);
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);
result = UdpPollingTask->addComponent(objects::UDP_POLLING_TASK);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component UDP Polling failed" << std::endl;
}
/* PUS Services */
PeriodicTaskIF* PusService1 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_1", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PusService1->addComponent(objects::PUS_SERVICE_1);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Verification Reporter failed" << std::endl;
}
PeriodicTaskIF* PusService2 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_2", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.2, nullptr);
result = PusService2->addComponent(objects::PUS_SERVICE_2);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Device Access failed" << std::endl;
}
PeriodicTaskIF* PusService5 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_5", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PusService5->addComponent(objects::PUS_SERVICE_5);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Event Service failed" << std::endl;
}
PeriodicTaskIF* PusService8 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_8", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PusService2->addComponent(objects::PUS_SERVICE_8);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Function MGMT failed" << std::endl;
}
PeriodicTaskIF* PusService17 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_17", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PusService17->addComponent(objects::PUS_SERVICE_17);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Test Service failed" << std::endl;
}
PeriodicTaskIF* PusService200 = TaskFactory::instance()->createPeriodicTask(
"PUS_SRV_200", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.4, nullptr);
result = PusService200->addComponent(objects::PUS_SERVICE_200);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Add component Mode MGMT failed" << std::endl;
}
/* Test Task */
// PeriodicTaskIF* TestTask = TaskFactory::instance()->
// createPeriodicTask("TEST_TASK", 80,
// PeriodicTaskIF::MINIMUM_STACK_SIZE, 5.0, nullptr);
// result = TestTask->addComponent(objects::TEST_TASK);
// if (result != HasReturnvaluesIF::RETURN_OK) {
// sif::error << "Add component Test Task failed" << std::endl;
// }
/* Polling Sequence Table Default */
// FixedTimeslotTaskIF * PollingSequenceTableTaskDefault =
// TaskFactory::instance()-> createFixedTimeslotTask(
// "PST_DEFAULT", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0,
// nullptr);
// result = pst::pollingSequenceInitDefault(PollingSequenceTableTaskDefault);
// if (result != HasReturnvaluesIF::RETURN_OK) {
// sif::error << "creating PST failed" << std::endl;
// }
//TestTask->startTask();
PacketDistributorTask->startTask();
//PollingSequenceTableTaskDefault->startTask();
UdpBridgeTask->startTask();
UdpPollingTask->startTask();
PusService1->startTask();
PusService2->startTask();
PusService5->startTask();
PusService8->startTask();
PusService17->startTask();
PusService200->startTask();
}

View File

@ -0,0 +1,38 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_PROFILE_H__
#define __ETL_PROFILE_H__
#define ETL_CHECK_PUSH_POP
#define ETL_CPP11_SUPPORTED 1
#define ETL_NO_NULLPTR_SUPPORT 0
#endif

View File

@ -0,0 +1,14 @@
#ifndef LINUX_GCOV_H_
#define LINUX_GCOV_H_
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#ifdef GCOV
extern "C" void __gcov_flush();
#else
void __gcov_flush() {
sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if "
"coverage information is desired.\n" << std::flush;
}
#endif
#endif /* LINUX_GCOV_H_ */

View File

@ -0,0 +1,14 @@
#include "print.h"
#include <stdio.h>
void printChar(const char* character, bool errStream) {
if(errStream) {
putc(*character, stderr);
return;
}
putc(*character, stdout);
}

View File

@ -0,0 +1,8 @@
#ifndef HOSTED_BOARDCONFIG_PRINT_H_
#define HOSTED_BOARDCONFIG_PRINT_H_
#include <stdbool.h>
void printChar(const char* character, bool errStream);
#endif /* HOSTED_BOARDCONFIG_PRINT_H_ */

View File

@ -0,0 +1,4 @@
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
CSRC += $(wildcard $(CURRENTPATH)/*.c)
CSRC += $(wildcard $(CURRENTPATH)/boardconfig/*.c)

39
bsp_linux/main.cpp Normal file
View File

@ -0,0 +1,39 @@
#if defined(GCOV)
#include <boardconfig/gcov.h>
#endif
#include <iostream>
#include <version.h>
#include <unistd.h>
// This will be the entry to the mission specific code
void initMission();
#ifndef SW_VERSION
#define SW_VERSION 0
#endif
#ifndef SW_SUBVERSION
#define SW_SUBVERSION 0
#endif
/**
* @brief This is the main program for the hosted build. It can be run for
* Linux and Windows.
* @return
*/
int main(void)
{
std::cout << "-- EIVE OBSW --" << std::endl;
std::cout << "-- Compiled for Linux " << " --" << std::endl;
std::cout << "-- Software version v" << SW_VERSION << "." << SW_SUBVERSION
<< " -- " << std::endl;
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
initMission();
for(;;) {
// suspend main thread by sleeping it.
sleep(5);
}
}