cleaned up code a bit

This commit is contained in:
Robin Müller 2021-07-19 12:44:43 +02:00
parent 1348f7dafb
commit 7f0c6863d6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
21 changed files with 360 additions and 180 deletions

View File

@ -33,7 +33,7 @@ namespace pcduSwitches {
static const uint8_t INIT_STATE_Q7S = ON; static const uint8_t INIT_STATE_Q7S = ON;
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
static const uint8_t INIT_STATE_RW = OFF; static const uint8_t INIT_STATE_RW = OFF;
#if TE0720 == 1 #if BOARD_TE0720 == 1
/* Because the TE0720 is not connected to the PCDU, this switch is always on */ /* Because the TE0720 is not connected to the PCDU, this switch is always on */
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
#else #else

View File

@ -1,3 +1,5 @@
#include <bsp_q7s/memory/FileSystemHandler.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include "Q7STestTask.h" #include "Q7STestTask.h"
#include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/memory/SdCardManager.h"
@ -18,14 +20,15 @@ Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) {
} }
ReturnValue_t Q7STestTask::performOneShotAction() { ReturnValue_t Q7STestTask::performOneShotAction() {
//sdCardTests(); //testSdCard();
testScratchApi(); //testScratchApi();
//testJsonLibDirect(); //testJsonLibDirect();
//testDummyParams(); //testDummyParams();
testFileSystemHandlerDirect();
return TestTask::performOneShotAction(); return TestTask::performOneShotAction();
} }
void Q7STestTask::sdCardTests() { void Q7STestTask::testSdCard() {
using namespace std; using namespace std;
Stopwatch stopwatch; Stopwatch stopwatch;
int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); int result = std::system("q7hw sd info all > /tmp/sd_status.txt");
@ -126,3 +129,12 @@ void Q7STestTask::testDummyParams() {
sif::info << "Test value (3 expected): " << test << std::endl; sif::info << "Test value (3 expected): " << test << std::endl;
sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl;
} }
void Q7STestTask::testFileSystemHandlerDirect() {
auto fsHandler = ObjectManager::instance()->
get<FileSystemHandler>(objects::FILE_SYSTEM_HANDLER);
if(fsHandler == nullptr) {
sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.."
<< std::endl;
}
}

View File

@ -9,12 +9,13 @@ public:
private: private:
ReturnValue_t performOneShotAction() override; ReturnValue_t performOneShotAction() override;
void sdCardTests(); void testSdCard();
void fileTests(); void fileTests();
void testScratchApi(); void testScratchApi();
void testJsonLibDirect(); void testJsonLibDirect();
void testDummyParams(); void testDummyParams();
void testFileSystemHandlerDirect();
}; };

View File

@ -1,6 +1,8 @@
#include "CoreController.h" #include "CoreController.h"
#include "q7sConfig.h" #include "q7sConfig.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "../memory/scratchApi.h" #include "../memory/scratchApi.h"
#include "../memory/SdCardManager.h" #include "../memory/SdCardManager.h"
@ -25,7 +27,16 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) {
} }
ReturnValue_t CoreController::initialize() { ReturnValue_t CoreController::initialize() {
return sdCardInit(); ReturnValue_t result = sdCardInit();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: SD card init failed" << std::endl;
}
result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Setting up alloc failure "
"count failed" << std::endl;
}
return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode,
@ -162,3 +173,13 @@ ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan,
sdcMan->updateSdCardStateFile(); sdcMan->updateSdCardStateFile();
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t CoreController::incrementAllocationFailureCount() {
uint32_t count = 0;
ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
count++;
return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count);
}

View File

@ -4,14 +4,22 @@
#include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/controller/ExtendedControllerBase.h"
#include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/memory/SdCardManager.h"
#include "events/subsystemIdRanges.h"
class CoreController: public ExtendedControllerBase { class CoreController: public ExtendedControllerBase {
public: public:
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
CoreController(object_id_t objectId); CoreController(object_id_t objectId);
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
ReturnValue_t handleCommandMessage(CommandMessage *message) override; ReturnValue_t handleCommandMessage(CommandMessage *message) override;
void performControlOperation() override; void performControlOperation() override;
static ReturnValue_t incrementAllocationFailureCount();
private: private:
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override; LocalDataPoolManager& poolManager) override;

View File

@ -162,7 +162,7 @@ void initmission::initTasks() {
initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER);
} }
#if TE0720 == 0 #if BOARD_TE0720 == 0
//TODO: Add handling of missed deadlines //TODO: Add handling of missed deadlines
/* Polling Sequence Table Default */ /* Polling Sequence Table Default */
#if Q7S_ADD_SPI_TEST == 0 #if Q7S_ADD_SPI_TEST == 0
@ -201,7 +201,7 @@ void initmission::initTasks() {
sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl;
} }
#else /* TE7020 == 0 */ #else /* BOARD_TE7020 == 0 */
FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask( FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask(
"PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0,
missedDeadlineFunc); missedDeadlineFunc);
@ -209,7 +209,7 @@ void initmission::initTasks() {
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl;
} }
#endif /* TE7020 == 1 */ #endif /* BOARD_TE7020 == 1 */
#if OBSW_ADD_TEST_CODE == 1 #if OBSW_ADD_TEST_CODE == 1
PeriodicTaskIF* testTask = factory->createPeriodicTask( PeriodicTaskIF* testTask = factory->createPeriodicTask(
@ -226,7 +226,7 @@ void initmission::initTasks() {
} }
#endif #endif
#endif /* OBSW_ADD_TEST_CODE == 1 */ #endif /* OBSW_ADD_TEST_CODE == 1 */
#if TE0720 == 1 && TEST_LIBGPIOD == 1 #if BOARD_TE0720 == 1 && TEST_LIBGPIOD == 1
result = testTask->addComponent(objects::LIBGPIOD_TEST); result = testTask->addComponent(objects::LIBGPIOD_TEST);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST);
@ -239,7 +239,7 @@ void initmission::initTasks() {
udpPollingTask->startTask(); udpPollingTask->startTask();
coreController->startTask(); coreController->startTask();
#if TE0720 == 0 #if BOARD_TE0720 == 0
uartPst->startTask(); uartPst->startTask();
gpioPst->startTask(); gpioPst->startTask();
i2cPst->startTask(); i2cPst->startTask();
@ -248,7 +248,7 @@ void initmission::initTasks() {
spiPst->startTask(); spiPst->startTask();
#endif /* Q7S_ADD_SPI_TEST == 0 */ #endif /* Q7S_ADD_SPI_TEST == 0 */
#elif TE0720 == 1 && Q7S_ADD_SPI_TEST == 0 #elif BOARD_TE0720 == 1 && Q7S_ADD_SPI_TEST == 0
pollingSequenceTaskTE0720->startTask(); pollingSequenceTaskTE0720->startTask();
#endif #endif

View File

@ -1,4 +1,3 @@
#include <bsp_q7s/boardtest/Q7STestTask.h>
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "tmtc/apid.h" #include "tmtc/apid.h"
@ -11,62 +10,67 @@
#include "bsp_q7s/gpio/gpioCallbacks.h" #include "bsp_q7s/gpio/gpioCallbacks.h"
#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/CoreController.h"
#include "bsp_q7s/spiCallbacks/rwSpiCallback.h" #include "bsp_q7s/spiCallbacks/rwSpiCallback.h"
#include "bsp_q7s/boardtest/Q7STestTask.h"
#include <linux/devices/HeaterHandler.h> #include "linux/devices/HeaterHandler.h"
#include <linux/devices/SolarArrayDeploymentHandler.h> #include "linux/devices/SolarArrayDeploymentHandler.h"
#include <linux/devices/devicedefinitions/SusDefinitions.h> #include "linux/devices/devicedefinitions/SusDefinitions.h"
#include <linux/devices/SusHandler.h> #include "linux/devices/SusHandler.h"
#include <linux/csp/CspCookie.h> #include "linux/csp/CspCookie.h"
#include <linux/csp/CspComIF.h> #include "linux/csp/CspComIF.h"
#include <mission/core/GenericFactory.h> #include "mission/core/GenericFactory.h"
#include <mission/devices/PDU1Handler.h> #include "mission/devices/PDU1Handler.h"
#include <mission/devices/PDU2Handler.h> #include "mission/devices/PDU2Handler.h"
#include <mission/devices/ACUHandler.h> #include "mission/devices/ACUHandler.h"
#include <mission/devices/PCDUHandler.h> #include "mission/devices/PCDUHandler.h"
#include <mission/devices/P60DockHandler.h> #include "mission/devices/P60DockHandler.h"
#include <mission/devices/Tmp1075Handler.h> #include "mission/devices/Tmp1075Handler.h"
#include <mission/devices/Max31865PT1000Handler.h> #include "mission/devices/Max31865PT1000Handler.h"
#include <mission/devices/IMTQHandler.h> #include "mission/devices/IMTQHandler.h"
#include <mission/devices/SyrlinksHkHandler.h> #include "mission/devices/SyrlinksHkHandler.h"
#include <mission/devices/MGMHandlerLIS3MDL.h> #include "mission/devices/MGMHandlerLIS3MDL.h"
#include <mission/devices/MGMHandlerRM3100.h> #include "mission/devices/MGMHandlerRM3100.h"
#include <mission/devices/PlocHandler.h> #include "mission/devices/PlocHandler.h"
#include <mission/devices/RadiationSensorHandler.h> #include "mission/devices/RadiationSensorHandler.h"
#include <mission/devices/RwHandler.h> #include "mission/devices/RwHandler.h"
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h> #include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
#include <mission/devices/devicedefinitions/SyrlinksDefinitions.h> #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
#include <mission/devices/devicedefinitions/PlocDefinitions.h> #include "mission/devices/devicedefinitions/PlocDefinitions.h"
#include <mission/devices/devicedefinitions/RadSensorDefinitions.h> #include "mission/devices/devicedefinitions/RadSensorDefinitions.h"
#include <mission/devices/devicedefinitions/Max31865Definitions.h> #include "mission/devices/devicedefinitions/Max31865Definitions.h"
#include <mission/devices/devicedefinitions/RwDefinitions.h> #include "mission/devices/devicedefinitions/RwDefinitions.h"
#include <mission/utility/TmFunnel.h> #include "mission/utility/TmFunnel.h"
#include <linux/obc/CCSDSIPCoreBridge.h> #include "linux/obc/CCSDSIPCoreBridge.h"
#include "fsfw/hal/linux/uart/UartComIF.h" #include "fsfw/hal/linux/uart/UartComIF.h"
#include "fsfw/hal/linux/uart/UartCookie.h" #include "fsfw/hal/linux/uart/UartCookie.h"
#include "fsfw/hal/devicehandlers/GyroL3GD20Handler.h" #include "fsfw/hal/devicehandlers/GyroL3GD20Handler.h"
#include <fsfw/hal/linux/i2c/I2cCookie.h> #include "fsfw/hal/linux/i2c/I2cCookie.h"
#include <fsfw/hal/linux/i2c/I2cComIF.h> #include "fsfw/hal/linux/i2c/I2cComIF.h"
#include <fsfw/hal/linux/spi/SpiCookie.h> #include "fsfw/hal/linux/spi/SpiCookie.h"
#include <fsfw/hal/linux/spi/SpiComIF.h> #include "fsfw/hal/linux/spi/SpiComIF.h"
#include <fsfw/hal/linux/gpio/LinuxLibgpioIF.h> #include "fsfw/hal/linux/gpio/LinuxLibgpioIF.h"
#include <fsfw/hal/common/gpio/GpioCookie.h> #include "fsfw/hal/common/gpio/GpioCookie.h"
#include <fsfw/datapoollocal/LocalDataPoolManager.h> #include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include <fsfw/tmtcservices/CommandingServiceBase.h> #include "fsfw/tmtcservices/CommandingServiceBase.h"
#include <fsfw/tmtcservices/PusServiceBase.h> #include "fsfw/tmtcservices/PusServiceBase.h"
#include <fsfw/tmtcpacket/pus/tm.h> #include "fsfw/tmtcpacket/pus/tm.h"
/* UDP server includes */ /* UDP server includes */
#include <fsfw/osal/common/UdpTmTcBridge.h> #include "fsfw/osal/common/UdpTmTcBridge.h"
#include <fsfw/osal/common/UdpTcPollingTask.h> #include "fsfw/osal/common/UdpTcPollingTask.h"
#include <linux/boardtest/SpiTestClass.h> #include "linux/boardtest/SpiTestClass.h"
#if TEST_LIBGPIOD == 1 #if TEST_LIBGPIOD == 1
#include <linux/boardtest/LibgpiodTest.h> #include "linux/boardtest/LibgpiodTest.h"
#endif #endif
void ObjectFactory::setStatics() {
Factory::setStaticFrameworkObjectIds();
}
void Factory::setStaticFrameworkObjectIds() { void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL; PusServiceBase::packetDestination = objects::TM_FUNNEL;
@ -84,24 +88,54 @@ void Factory::setStaticFrameworkObjectIds() {
TmPacketBase::timeStamperId = objects::TIME_STAMPER; TmPacketBase::timeStamperId = objects::TIME_STAMPER;
} }
void ObjectFactory::produce(void* args){ void ObjectFactory::produce(void* args){
Factory::setStaticFrameworkObjectIds(); ObjectFactory::setStatics();
ObjectFactory::produceGenericObjects(); ObjectFactory::produceGenericObjects();
LinuxLibgpioIF* gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF);
/* Communication interfaces */
new CspComIF(objects::CSP_COM_IF);
new I2cComIF(objects::I2C_COM_IF);
new UartComIF(objects::UART_COM_IF);
#if Q7S_ADD_SPI_TEST == 0
new SpiComIF(objects::SPI_COM_IF, gpioComIF);
#endif /* Q7S_ADD_SPI_TEST == 0 */
new CoreController(objects::CORE_CONTROLLER); new CoreController(objects::CORE_CONTROLLER);
LinuxLibgpioIF* gpioComIF = nullptr;
createCommunicationInterfaces(&gpioComIF);
createTmpComponents();
#if BOARD_TE0720 == 0
#if TE0720 == 1 createPcduComponents();
createRadSensorComponent(gpioComIF);
createSunSensorComponents(gpioComIF);
#if OBSW_ADD_ACS_BOARD == 1
createAcsBoardComponents(gpioComIF);
#endif /* OBSW_ADD_ACS_BOARD == 1 */
createHeaterComponents();
createSolarArrayDeploymentComponents();
#if Q7S_ADD_SYRLINKS_HANDLER == 1
createSyrlinksComponents();
#endif /* Q7S_ADD_SYRLINKS_HANDLER == 1 */
#if Q7S_ADD_RTD_DEVICES == 1
createRtdComponents();
#endif /* Q7S_ADD_RTD_DEVICES == 1 */
I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE,
std::string("/dev/i2c-0"));
new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
UartCookie* plocUartCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"),
UartModes::NON_CANONICAL, 115200, PLOC::MAX_REPLY_SIZE);
new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie);
createReactionWheelComponents(gpioComIF);
#endif /* TE7020 != 0 */
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
/* Test Task */
#if OBSW_ADD_TEST_CODE == 1
createTestComponents();
#endif /* OBSW_ADD_TEST_CODE == 1 */
}
void ObjectFactory::createTmpComponents() {
#if BOARD_TE0720 == 1
I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1,
TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2,
@ -122,8 +156,27 @@ void ObjectFactory::produce(void* args){
objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, objects::TMP1075_HANDLER_2, objects::I2C_COM_IF,
i2cCookieTmp1075tcs2); i2cCookieTmp1075tcs2);
(void) tmp1075Handler_2; (void) tmp1075Handler_2;
}
#if TE0720 == 0 void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF) {
if(gpioComIF == nullptr) {
sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid GPIO ComIF"
<< std::endl;
}
*gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF);
/* Communication interfaces */
new CspComIF(objects::CSP_COM_IF);
new I2cComIF(objects::I2C_COM_IF);
new UartComIF(objects::UART_COM_IF);
#if Q7S_ADD_SPI_TEST == 0
new SpiComIF(objects::SPI_COM_IF, *gpioComIF);
#endif /* Q7S_ADD_SPI_TEST == 0 */
/* Adding gpios for chip select decoding to the gpioComIf */
gpioCallbacks::initSpiCsDecoder(*gpioComIF);
}
void ObjectFactory::createPcduComponents() {
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH,
addresses::P60DOCK); addresses::P60DOCK);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
@ -156,10 +209,9 @@ void ObjectFactory::produce(void* args){
(void) pdu1handler; (void) pdu1handler;
(void) pdu2handler; (void) pdu2handler;
(void) acuhandler; (void) acuhandler;
}
/* Adding gpios for chip select decoding to the gpioComIf */ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
gpioCallbacks::initSpiCsDecoder(gpioComIF);
GpioCookie* gpioCookieRadSensor = new GpioCookie; GpioCookie* gpioCookieRadSensor = new GpioCookie;
GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip5"), 19, GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip5"), 19,
std::string("Chip Select Radiation Sensor"), gpio::OUT, 1); std::string("Chip Select Radiation Sensor"), gpio::OUT, 1);
@ -170,6 +222,9 @@ void ObjectFactory::produce(void* args){
std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
spi::DEFAULT_MAX_1227_SPEED); spi::DEFAULT_MAX_1227_SPEED);
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor);
}
void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) {
GpioCookie* gpioCookieSus = new GpioCookie(); GpioCookie* gpioCookieSus = new GpioCookie();
GpioCallback* susgpio = new GpioCallback(std::string("Chip select SUS 1"), gpio::OUT, 1, GpioCallback* susgpio = new GpioCallback(std::string("Chip select SUS 1"), gpio::OUT, 1,
@ -254,21 +309,35 @@ void ObjectFactory::produce(void* args){
std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE,
SUS::MAX1227_SPI_FREQ); SUS::MAX1227_SPI_FREQ);
new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1); new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF,
new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2); gpioIds::CS_SUS_1);
new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3); new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF,
new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4); gpioIds::CS_SUS_2);
new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5); new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF,
new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6); gpioIds::CS_SUS_3);
new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7); new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF,
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8); gpioIds::CS_SUS_4);
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9); new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF,
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, gpioIds::CS_SUS_10); gpioIds::CS_SUS_5);
new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, gpioIds::CS_SUS_11); new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF,
new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, gpioIds::CS_SUS_12); gpioIds::CS_SUS_6);
new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, gpioIds::CS_SUS_13); new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF,
gpioIds::CS_SUS_7);
new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF,
gpioIds::CS_SUS_8);
new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF,
gpioIds::CS_SUS_9);
new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF,
gpioIds::CS_SUS_10);
new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF,
gpioIds::CS_SUS_11);
new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF,
gpioIds::CS_SUS_12);
new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF,
gpioIds::CS_SUS_13);
}
#if OBSW_ADD_ACS_BOARD == 1 void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF) {
GpioCookie* gpioCookieAcsBoard = new GpioCookie(); GpioCookie* gpioCookieAcsBoard = new GpioCookie();
GpiodRegular* gpio = nullptr; GpiodRegular* gpio = nullptr;
gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_0_ADIS"), gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_0_ADIS"),
@ -326,20 +395,23 @@ void ObjectFactory::produce(void* args){
//TODO: Adis Gyro (Gyro 0 Side A) //TODO: Adis Gyro (Gyro 0 Side A)
// Commented until ACS board V2 in in clean room again
/* Gyro 1 Side A */ /* Gyro 1 Side A */
spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, // spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev,
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); // L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, // auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF,
spiCookie); // spiCookie);
gyroL3gHandler->setStartUpImmediately(); // gyroL3gHandler->setStartUpImmediately();
//
// /* Gyro 2 Side B */
// spiCookie = new SpiCookie(addresses::GYRO_2_L3G, gpioIds::GYRO_2_L3G_CS, spiDev,
// L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
// gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_2_L3G_HANDLER, objects::SPI_COM_IF,
// spiCookie);
// gyroL3gHandler->setStartUpImmediately();
}
/* Gyro 2 Side B */ void ObjectFactory::createHeaterComponents() {
spiCookie = new SpiCookie(addresses::GYRO_2_L3G, gpioIds::GYRO_2_L3G_CS, spiDev,
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_2_L3G_HANDLER, objects::SPI_COM_IF,
spiCookie);
gyroL3gHandler->setStartUpImmediately();
#endif
GpioCookie* heaterGpiosCookie = new GpioCookie; GpioCookie* heaterGpiosCookie = new GpioCookie;
@ -380,7 +452,9 @@ void ObjectFactory::produce(void* args){
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie,
objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN);
}
void ObjectFactory::createSolarArrayDeploymentComponents() {
GpioCookie* solarArrayDeplCookie = new GpioCookie; GpioCookie* solarArrayDeplCookie = new GpioCookie;
GpiodRegular* gpioConfigDeplSA0 = new GpiodRegular(std::string("gpiochip7"), 4, GpiodRegular* gpioConfigDeplSA0 = new GpiodRegular(std::string("gpiochip7"), 4,
@ -394,8 +468,9 @@ void ObjectFactory::produce(void* args){
new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF,
solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM,
gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000);
}
#if Q7S_ADD_SYRLINKS_HANDLER == 1 void ObjectFactory::createSyrlinksComponents() {
UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER,
std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE);
syrlinksUartCookie->setParityEven(); syrlinksUartCookie->setParityEven();
@ -403,9 +478,9 @@ void ObjectFactory::produce(void* args){
SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER,
objects::UART_COM_IF, syrlinksUartCookie); objects::UART_COM_IF, syrlinksUartCookie);
syrlinksHkHandler->setModeNormal(); syrlinksHkHandler->setModeNormal();
#endif }
#if Q7S_ADD_RTD_DEVICES == 1 void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) {
GpioCookie* rtdGpioCookie = new GpioCookie; GpioCookie* rtdGpioCookie = new GpioCookie;
GpioCallback* gpioRtdIc3 = new GpioCallback(std::string("Chip select RTD IC3"), gpio::OUT, 1, GpioCallback* gpioRtdIc3 = new GpioCallback(std::string("Chip select RTD IC3"), gpio::OUT, 1,
@ -508,22 +583,38 @@ void ObjectFactory::produce(void* args){
std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE,
spi::SpiModes::MODE_1, 2000000); spi::SpiModes::MODE_1, 2000000);
Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3, objects::SPI_COM_IF, spiRtdIc3, 0); // 0 is switchId Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3,
Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC4, objects::SPI_COM_IF, spiRtdIc4, 0); objects::SPI_COM_IF, spiRtdIc3, 0); // 0 is switchId
Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC5, objects::SPI_COM_IF, spiRtdIc5, 0); Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC4,
Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC6, objects::SPI_COM_IF, spiRtdIc6, 0); objects::SPI_COM_IF, spiRtdIc4, 0);
Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC7, objects::SPI_COM_IF, spiRtdIc7, 0); Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC5,
Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC8, objects::SPI_COM_IF, spiRtdIc8, 0); objects::SPI_COM_IF, spiRtdIc5, 0);
Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC9, objects::SPI_COM_IF, spiRtdIc9, 0); Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC6,
Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC10, objects::SPI_COM_IF, spiRtdIc10, 0); objects::SPI_COM_IF, spiRtdIc6, 0);
Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC11, objects::SPI_COM_IF, spiRtdIc11, 0); Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC7,
Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC12, objects::SPI_COM_IF, spiRtdIc12, 0); objects::SPI_COM_IF, spiRtdIc7, 0);
Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC13, objects::SPI_COM_IF, spiRtdIc13, 0); Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC8,
Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC14, objects::SPI_COM_IF, spiRtdIc14, 0); objects::SPI_COM_IF, spiRtdIc8, 0);
Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC15, objects::SPI_COM_IF, spiRtdIc15, 0); Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC9,
Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16, objects::SPI_COM_IF, spiRtdIc16, 0); objects::SPI_COM_IF, spiRtdIc9, 0);
Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17, objects::SPI_COM_IF, spiRtdIc17, 0); Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC10,
Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, objects::SPI_COM_IF, spiRtdIc18, 0); objects::SPI_COM_IF, spiRtdIc10, 0);
Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC11,
objects::SPI_COM_IF, spiRtdIc11, 0);
Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC12,
objects::SPI_COM_IF, spiRtdIc12, 0);
Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC13,
objects::SPI_COM_IF, spiRtdIc13, 0);
Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC14,
objects::SPI_COM_IF, spiRtdIc14, 0);
Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC15,
objects::SPI_COM_IF, spiRtdIc15, 0);
Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16,
objects::SPI_COM_IF, spiRtdIc16, 0);
Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17,
objects::SPI_COM_IF, spiRtdIc17, 0);
Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18,
objects::SPI_COM_IF, spiRtdIc18, 0);
(void) rtdIc3; (void) rtdIc3;
(void) rtdIc4; (void) rtdIc4;
@ -541,17 +632,9 @@ void ObjectFactory::produce(void* args){
(void) rtdIc16; (void) rtdIc16;
(void) rtdIc17; (void) rtdIc17;
(void) rtdIc18; (void) rtdIc18;
}
#endif /* Q7S_ADD_RTD_DEVICES == 1 */ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) {
I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE,
std::string("/dev/i2c-0"));
new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
UartCookie* plocUartCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"),
UartModes::NON_CANONICAL, 115200, PLOC::MAX_REPLY_SIZE);
new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie);
GpioCookie* gpioCookieRw = new GpioCookie; GpioCookie* gpioCookieRw = new GpioCookie;
GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT,
1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF);
@ -618,18 +701,12 @@ void ObjectFactory::produce(void* args){
auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF,
gpioIds::EN_RW4); gpioIds::EN_RW4);
rw4SpiCookie->setCallbackArgs(rwHandler4); rw4SpiCookie->setCallbackArgs(rwHandler4);
}
#endif /* TE0720 == 0 */ void ObjectFactory::createTestComponents() {
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
/* Test Task */
#if OBSW_ADD_TEST_CODE == 1
new Q7STestTask(objects::TEST_TASK); new Q7STestTask(objects::TEST_TASK);
#endif
#if TE0720 == 1 && TEST_LIBGPIOD == 1 #if BOARD_TE0720 == 1 && TEST_LIBGPIOD == 1
/* Configure MIO0 as input */ /* Configure MIO0 as input */
GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0, GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0,
std::string("MIO0"), gpio::IN, 0); std::string("MIO0"), gpio::IN, 0);
@ -638,7 +715,7 @@ void ObjectFactory::produce(void* args){
new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie);
#endif #endif
#if TE0720 == 1 && TEST_SUS_HANDLER == 1 #if BOARD_TE0720 == 1 && TEST_SUS_HANDLER == 1
GpioCookie* gpioCookieSus = new GpioCookie; GpioCookie* gpioCookieSus = new GpioCookie;
GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9,
std::string("Chip Select Sus Sensor"), gpio::OUT, 1); std::string("Chip Select Sus Sensor"), gpio::OUT, 1);
@ -652,7 +729,7 @@ void ObjectFactory::produce(void* args){
gpioIds::CS_SUS_1); gpioIds::CS_SUS_1);
#endif #endif
#if TE0720 == 1 && TEST_CCSDS_BRIDGE == 1 #if BOARD_TE0720 == 1 && TEST_CCSDS_BRIDGE == 1
GpioCookie* gpioCookieCcsdsIp = new GpioCookie; GpioCookie* gpioCookieCcsdsIp = new GpioCookie;
GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N")); GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N"));
gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN);
@ -666,7 +743,7 @@ void ObjectFactory::produce(void* args){
gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY);
#endif #endif
#if TE0720 == 1 && TEST_RADIATION_SENSOR_HANDLER == 1 #if BOARD_TE0720 == 1 && TEST_RADIATION_SENSOR_HANDLER == 1
GpioCookie* gpioCookieRadSensor = new GpioCookie; GpioCookie* gpioCookieRadSensor = new GpioCookie;
GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0,
std::string("Chip select radiation sensor"), gpio::OUT, 1); std::string("Chip select radiation sensor"), gpio::OUT, 1);
@ -682,7 +759,7 @@ void ObjectFactory::produce(void* args){
radSensor->setStartUpImmediately(); radSensor->setStartUpImmediately();
#endif #endif
#if TE0720 == 1 && TEST_PLOC_HANDLER == 1 #if BOARD_TE0720 == 1 && TEST_PLOC_HANDLER == 1
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200,
PLOC::MAX_REPLY_SIZE); PLOC::MAX_REPLY_SIZE);
/* Testing PlocHandler on TE0720-03-1CFA */ /* Testing PlocHandler on TE0720-03-1CFA */
@ -691,7 +768,7 @@ void ObjectFactory::produce(void* args){
plocHandler->setStartUpImmediately(); plocHandler->setStartUpImmediately();
#endif #endif
#if TE0720 == 1 && TE0720_HEATER_TEST == 1 #if BOARD_TE0720 == 1 && TE0720_HEATER_TEST == 1
/* Configuration for MIO0 on TE0720-03-1CFA */ /* Configuration for MIO0 on TE0720-03-1CFA */
GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0);
GpioCookie* gpioCookie = new GpioCookie; GpioCookie* gpioCookie = new GpioCookie;

View File

@ -1,9 +1,26 @@
#ifndef BSP_Q7S_OBJECTFACTORY_H_ #ifndef BSP_Q7S_OBJECTFACTORY_H_
#define BSP_Q7S_OBJECTFACTORY_H_ #define BSP_Q7S_OBJECTFACTORY_H_
class LinuxLibgpioIF;
namespace ObjectFactory { namespace ObjectFactory {
void setStatics(); void setStatics();
void produce(void* args); void produce(void* args);
void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF);
void createTmpComponents();
void createPcduComponents();
void createRadSensorComponent(LinuxLibgpioIF* gpioComIF);
void createSunSensorComponents(LinuxLibgpioIF* gpioComIF);
void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF);
void createHeaterComponents();
void createSolarArrayDeploymentComponents();
void createSyrlinksComponents();
void createRtdComponents(LinuxLibgpioIF* gpioComIF);
void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF);
void createTestComponents();
}; };
#endif /* BSP_Q7S_OBJECTFACTORY_H_ */ #endif /* BSP_Q7S_OBJECTFACTORY_H_ */

View File

@ -6,7 +6,7 @@
int obsw::obsw() { int obsw::obsw() {
std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- EIVE OBSW --" << std::endl;
#if TE0720 == 0 #if BOARD_TE0720 == 0
std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl;
#else #else
std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; std::cout << "-- Compiled for Linux (TE0720) --" << std::endl;

View File

@ -1,9 +1,12 @@
#include "FileSystemHandler.h" #include "FileSystemHandler.h"
#include "bsp_q7s/core/CoreController.h"
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/memory/GenericFileSystemMessage.h" #include "fsfw/memory/GenericFileSystemMessage.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include <fstream>
#include <filesystem> #include <filesystem>
FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler):
@ -24,9 +27,9 @@ ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) {
// Restart OBSW, hints at a memory leak // Restart OBSW, hints at a memory leak
sif::error << "Allocation error in FileSystemHandler::performOperation" sif::error << "Allocation error in FileSystemHandler::performOperation"
<< e.what() << std::endl; << e.what() << std::endl;
// TODO: If we trigger an event, it might not get sent because were restarting // Set up an error file or a special flag in the scratch buffer for these cases
// Set up an error file or a special flag in the scratch buffer. triggerEvent(CoreController::ALLOC_FAILURE, 0 , 0);
// TODO: CoreController: Implement function to restart OBC CoreController::incrementAllocationFailureCount();
} }
} }
} }
@ -94,8 +97,8 @@ void FileSystemHandler::fileSystemCheckup() {
ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
// Oh no. // Oh no.
// TODO: Trigger medium severity event triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0);
sif::error << "Fix failed" << std::endl; sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl;
} }
} }
} }
@ -125,6 +128,14 @@ ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const
// A double slash between repo and filename should not be an issue, so add it in any case // A double slash between repo and filename should not be an issue, so add it in any case
std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" +
std::string(filename); std::string(filename);
if(not std::filesystem::exists(fullPath)) {
return FILE_DOES_NOT_EXIST;
}
std::ofstream file(fullPath, std::ios_base::app|std::ios_base::out);
file.write(reinterpret_cast<const char*>(data), size);
if(not file.good()) {
return GENERIC_FILE_ERROR;
}
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -133,6 +144,14 @@ ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const ch
// A double slash between repo and filename should not be an issue, so add it in any case // A double slash between repo and filename should not be an issue, so add it in any case
std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" +
std::string(filename); std::string(filename);
if(std::filesystem::exists(fullPath)) {
return FILE_ALREADY_EXISTS;
}
std::ofstream file(fullPath);
file.write(reinterpret_cast<const char*>(data), size);
if(not file.good()) {
return GENERIC_FILE_ERROR;
}
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -141,6 +160,14 @@ ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const ch
// A double slash between repo and filename should not be an issue, so add it in any case // A double slash between repo and filename should not be an issue, so add it in any case
std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" +
std::string(filename); std::string(filename);
if(not std::filesystem::exists(fullPath)) {
return FILE_DOES_NOT_EXIST;
}
int result = std::remove(fullPath.c_str());
if(result != 0) {
sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl;
return GENERIC_FILE_ERROR;
}
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -169,14 +196,20 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath,
} }
else { else {
// Check error code. Most probably denied permissions because folder is not empty // Check error code. Most probably denied permissions because folder is not empty
sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with "
"err" << err << std::endl;
return GENERIC_FILE_ERROR;
} }
} }
else { else {
if(std::filesystem::remove_all(fullPath, err)) { if(std::filesystem::remove_all(fullPath, err)) {
sif::warning << "FileSystemHandler::removeDirectory: Deleting directory recursively "
"failed with err" << err << std::endl;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else { else {
// Check error code // Check error code
return GENERIC_FILE_ERROR;
} }
} }

View File

@ -32,6 +32,7 @@ private:
MessageQueueIF* mq = nullptr; MessageQueueIF* mq = nullptr;
std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE;
SdCardManager* sdcMan = nullptr; SdCardManager* sdcMan = nullptr;
uint8_t opCounter = 0; uint8_t opCounter = 0;

View File

@ -3,7 +3,9 @@
#include "definitions.h" #include "definitions.h"
#include "returnvalues/classIds.h" #include "returnvalues/classIds.h"
#include "events/subsystemIdRanges.h"
#include "fsfw/events/Event.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <cstdint> #include <cstdint>
@ -41,6 +43,10 @@ public:
static constexpr ReturnValue_t SYSTEM_CALL_ERROR = static constexpr ReturnValue_t SYSTEM_CALL_ERROR =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14);
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM;
static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
// C++17 does not support constexpr std::string yet // C++17 does not support constexpr std::string yet
static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1";
static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1";

View File

@ -18,6 +18,7 @@
namespace scratch { namespace scratch {
static constexpr char PREFERED_SDC_KEY[] = "PREFSD"; static constexpr char PREFERED_SDC_KEY[] = "PREFSD";
static constexpr char ALLOC_FAILURE_COUNT[] = "ALLOCERR";
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SCRATCH_BUFFER; static constexpr uint8_t INTERFACE_ID = CLASS_ID::SCRATCH_BUFFER;
static constexpr ReturnValue_t KEY_NOT_FOUND = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); static constexpr ReturnValue_t KEY_NOT_FOUND = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0);

View File

@ -10,6 +10,7 @@ enum commonObjects: uint32_t {
PUS_PACKET_DISTRIBUTOR = 0x50000200, PUS_PACKET_DISTRIBUTOR = 0x50000200,
UDP_BRIDGE = 0x50000300, UDP_BRIDGE = 0x50000300,
UDP_POLLING_TASK = 0x50000400, UDP_POLLING_TASK = 0x50000400,
FILE_SYSTEM_HANDLER = 0x50000500,
/* 0x43 ('C') for Controllers */ /* 0x43 ('C') for Controllers */
THERMAL_CONTROLLER = 0x43400001, THERMAL_CONTROLLER = 0x43400001,

View File

@ -14,6 +14,7 @@ enum: uint8_t {
PLOC_HANDLER = 111, PLOC_HANDLER = 111,
IMTQ_HANDLER = 112, IMTQ_HANDLER = 112,
RW_HANDLER = 113, RW_HANDLER = 113,
FILE_SYSTEM = 114,
COMMON_SUBSYSTEM_ID_END COMMON_SUBSYSTEM_ID_END
}; };
} }

View File

@ -29,7 +29,7 @@ debugging. */
#define TEST_CCSDS_BRIDGE 0 #define TEST_CCSDS_BRIDGE 0
#define PERFORM_PTME_TEST 0 #define PERFORM_PTME_TEST 0
#define TE0720 0 #define BOARD_TE0720 0
#define TE0720_HEATER_TEST 0 #define TE0720_HEATER_TEST 0
#define P60DOCK_DEBUG 0 #define P60DOCK_DEBUG 0

View File

@ -33,7 +33,7 @@ namespace pcduSwitches {
static const uint8_t INIT_STATE_Q7S = ON; static const uint8_t INIT_STATE_Q7S = ON;
static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF;
static const uint8_t INIT_STATE_RW = OFF; static const uint8_t INIT_STATE_RW = OFF;
#if TE0720 == 1 #if BOARD_TE0720 == 1
/* Because the TE0720 is not connected to the PCDU, this switch is always on */ /* Because the TE0720 is not connected to the PCDU, this switch is always on */
static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON;
#else #else

View File

@ -12,7 +12,8 @@
*/ */
namespace SUBSYSTEM_ID { namespace SUBSYSTEM_ID {
enum: uint8_t { enum: uint8_t {
SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END,
CORE = 116,
}; };
} }

View File

@ -680,7 +680,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if TE7020 == 1 #if BOARD_TE7020 == 1
ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs(); uint32_t length = thisSequence->getPeriodMs();
@ -729,4 +729,4 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#endif /* TE7020 == 1 */ #endif /* BOARD_TE7020 == 1 */

View File

@ -329,7 +329,7 @@ ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDat
pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 })); pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( { localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( {
pcduSwitches::INIT_STATE_RW })); pcduSwitches::INIT_STATE_RW }));
#if TE0720 == 1 #if BOARD_TE0720 == 1
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
#else #else
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN}));

View File

@ -265,7 +265,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>( { 0 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>( { 0 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( { 0 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry<uint8_t>( { 0 }));
#if TE0720 == 1 #if BOARD_TE0720 == 1
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 1 }));
#else #else
localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 0 })); localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry<uint8_t>( { 0 }));