fsfw-example-linux-mcu/bsp_linux/main.cpp

74 lines
2.1 KiB
C++
Raw Normal View History

2021-06-11 12:50:14 +02:00
#include <bsp_hosted/core/InitMission.h>
#include <bsp_hosted/core/ObjectFactory.h>
#include <test/MutexExample.h>
#include <mission/utility/PusPacketCreator.h>
#include <common/utility/utility.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#if defined(RASPBERRY_PI)
static const char* COMPILE_PRINTOUT = "Raspberry Pi";
#elif defined(BEAGLE_BONE_BLACK)
static const char* COMPILE_PRINTOUT = "Beagle Bone Black";
#elif defined(LINUX)
static const char* COMPILE_PRINTOUT = "Host";
#else
static const char* COMPILE_PRINTOUT = "Unknown device";
#endif
#if FSFW_CPP_OSTREAM_ENABLED == 1
/* On Linux, no carriage return is added. */
ServiceInterfaceStream sif::debug("DEBUG");
ServiceInterfaceStream sif::info("INFO");
ServiceInterfaceStream sif::warning("WARNING");
ServiceInterfaceStream sif::error("ERROR", false, false, true);
#endif
ObjectManagerIF *objectManager = nullptr;
int main() {
utility::commonInitPrint("Linux", COMPILE_PRINTOUT);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Producing system objects.." << std::endl;
#else
sif::printInfo("Producing system objects..\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
ObjectManager* objManager = ObjectManager::instance();
objManager->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Objects created successfully.." << std::endl;
sif::info << "Initializing objects.." << std::endl;
#else
sif::printInfo("Objects created successfully..\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
objManager->initialize();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Creating tasks.." << std::endl;
#else
sif::printInfo("Creating tasks..\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
InitMission::createTasks();
MutexExample::example();
PusPacketCreator::createPusPacketAndPrint();
/* Permanent loop. */
for(;;) {
/* Sleep main thread, not needed anymore. */
TaskFactory::delayTask(5000);
}
return 0;
}