From 308a855d8c6716a893e9fd523e9e4e2b67b24c39 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 27 Sep 2022 18:54:48 +0200 Subject: [PATCH] bugfix for scex testcode --- bsp_linux_board/ObjectFactory.cpp | 7 +++---- bsp_q7s/boardconfig/busConf.h | 1 - bsp_q7s/core/InitMission.cpp | 1 - bsp_q7s/core/ObjectFactory.cpp | 5 ++++- bsp_q7s/fmObjectFactory.cpp | 3 ++- linux/InitMission.cpp | 3 ++- linux/InitMission.h | 3 ++- linux/ObjectFactory.cpp | 8 ++++---- linux/ObjectFactory.h | 4 ++-- linux/boardtest/UartTestClass.cpp | 24 ++++++++++++----------- linux/boardtest/UartTestClass.h | 2 +- linux/csp/CspComIF.cpp | 12 ++++++------ mission/devices/GomspaceDeviceHandler.cpp | 8 ++++---- mission/devices/GomspaceDeviceHandler.h | 7 +++---- mission/devices/ScexDeviceHandler.cpp | 17 +++++++--------- mission/devices/ScexDeviceHandler.h | 6 +++--- 16 files changed, 56 insertions(+), 55 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 950ae3ce..075d1af6 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -82,9 +82,9 @@ void ObjectFactory::produce(void* args) { #endif #endif - auto* sdcMan = new RPiSdCardManager("/tmp"); #if OBSW_ADD_SCEX_DEVICE == 1 - createScexComponents(uart::DEV, pwrSwitcher, *sdcMan, true); + auto* sdcMan = new RPiSdCardManager("/tmp"); + createScexComponents(uart::DEV, pwrSwitcher, *sdcMan, true, std::nullopt); #endif #if OBSW_ADD_SUN_SENSORS == 1 @@ -201,8 +201,7 @@ void ObjectFactory::createTestTasks() { #endif #if OBSW_ADD_UART_TEST_CODE == 1 - auto scexReader = new ScexUartReader(objects::SCEX_UART_READER); - new UartTestClass(objects::UART_TEST, scexReader); + new UartTestClass(objects::UART_TEST); #else new UartComIF(objects::UART_COM_IF); #endif diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 3bccf249..3fb8d801 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,7 +17,6 @@ static constexpr char UART_SYRLINKS_DEV[] = "/dev/ul-syrlinks"; static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ul-str"; static constexpr char UART_SCEX_DEV[] = "/dev/ul-scex"; - static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PTME[] = "/dev/uio1"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index e3cef398..725252a5 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -249,7 +249,6 @@ void initmission::initTasks() { scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask); #endif - std::vector pusTasks; createPusTasks(*factory, missedDeadlineFunc, pusTasks); std::vector pstTasks; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6627d90d..29b42906 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,5 +1,7 @@ #include "ObjectFactory.h" +#include + #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -865,7 +867,8 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { new I2cTestClass(objects::I2C_TEST, q7s::I2C_DEFAULT_DEV); #endif #if OBSW_ADD_UART_TEST_CODE == 1 - new UartTestClass(objects::UART_TEST); + // auto* reader= new ScexUartReader(objects::SCEX_UART_READER); + new UartTestClass(objects::UART_TEST, nullptr); #endif } diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 43b8d255..86fb8bd9 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -1,4 +1,5 @@ #include + #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/ObjectFactory.h" @@ -60,7 +61,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_SCEX_DEVICE == 1 createScexComponents(q7s::UART_GNSS_DEV, pwrSwitcher, *SdCardManager::instance(), false, - pcdu::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); + pcdu::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 diff --git a/linux/InitMission.cpp b/linux/InitMission.cpp index 7388c974..eb8f677a 100644 --- a/linux/InitMission.cpp +++ b/linux/InitMission.cpp @@ -7,7 +7,8 @@ #include "OBSWConfig.h" #include "ObjectFactory.h" -void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, PeriodicTaskIF*& scexReaderTask) { +void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, + PeriodicTaskIF*& scexReaderTask) { using namespace initmission; ReturnValue_t result = returnvalue::OK; #if OBSW_PRINT_MISSED_DEADLINES == 1 diff --git a/linux/InitMission.h b/linux/InitMission.h index cc507265..e5a3afff 100644 --- a/linux/InitMission.h +++ b/linux/InitMission.h @@ -2,5 +2,6 @@ #include namespace scheduling { -void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, PeriodicTaskIF*& scexReaderTask); +void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, + PeriodicTaskIF*& scexReaderTask); } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 84d62162..43e4109a 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -325,17 +325,17 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, SdCardMountedIF& mountedIF, bool onImmediately, - std::optional switchId) { + std::optional switchId) { // objekte anlegen auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, mountedIF); - if(onImmediately) { - scexHandler->setStartUpImmediately(); + if (onImmediately) { + scexHandler->setStartUpImmediately(); } if (switchId) { - scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value()); + scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value()); } } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 8142df7e..f4ecc6e3 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -5,8 +5,8 @@ #include #include -#include #include +#include class GpioIF; class SpiComIF; @@ -21,7 +21,7 @@ void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* p void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, SdCardMountedIF& mountedIF, bool onImmediately, - std::optional switchId); + std::optional switchId); void gpioChecker(ReturnValue_t result, std::string output); diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 9843baa5..7f18957a 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -27,12 +27,11 @@ using namespace returnvalue; -UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) - : TestTask(objectId), reader(reader) { +UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) { mode = TestModes::SCEX; - scexMode = ScexModes::READER_TASK; + scexMode = ScexModes::SIMPLE; // No one-cell and all-cell support implemented yet - currCmd = scex::Cmds::FRAM; + currCmd = scex::Cmds::PING; if (scexMode == ScexModes::SIMPLE) { auto encodingBuf = new std::array; DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; @@ -40,6 +39,8 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()}; dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, decodingBufPair, &foundDlePacketHandler, this); + } else { + reader = new ScexUartReader(objects::SCEX_UART_READER); } } @@ -150,13 +151,13 @@ void UartTestClass::gpsPeriodic() { } void UartTestClass::scexInit() { - if (reader == nullptr) { - sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; - return; - } if (scexMode == ScexModes::SIMPLE) { scexSimpleInit(); } else { + if (reader == nullptr) { + sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; + return; + } #if defined(RASPBERRY_PI) std::string devname = "/dev/serial0"; #else @@ -176,13 +177,13 @@ void UartTestClass::scexInit() { void UartTestClass::scexPeriodic() { using namespace std; using namespace scex; - if (reader == nullptr) { - return; - } if (scexMode == ScexModes::SIMPLE) { scexSimplePeriodic(); } else { + if (reader == nullptr) { + return; + } if (not cmdSent) { size_t len = 0; prepareScexCmd(currCmd, false, cmdBuf.data(), &len); @@ -375,6 +376,7 @@ int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBu uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); cmdBuf[5] = (crc >> 8) & 0xff; cmdBuf[6] = crc & 0xff; + *len = 7; return 0; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 1c1b9988..14d74322 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -19,7 +19,7 @@ class ScexDleParser; class UartTestClass : public TestTask { public: - UartTestClass(object_id_t objectId, ScexUartReader* reader); + UartTestClass(object_id_t objectId); ReturnValue_t initialize() override; ReturnValue_t performOneShotAction() override; diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index 5d8c3fd6..ea508a31 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -166,23 +166,23 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s if (result != 0) { return returnvalue::FAILED; } - } else if(req == GOMSPACE::SpecialRequestTypes::SAVE_TABLE) { - if(sendLen < 2) { + } else if (req == GOMSPACE::SpecialRequestTypes::SAVE_TABLE) { + if (sendLen < 2) { return returnvalue::FAILED; } const TableInfo* tableInfo = reinterpret_cast(sendData); int result = gs_rparam_save(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable, - tableInfo->targetTable); + tableInfo->targetTable); if (result != 0) { return returnvalue::FAILED; } - } else if(req == GOMSPACE::SpecialRequestTypes::LOAD_TABLE) { - if(sendLen < 2) { + } else if (req == GOMSPACE::SpecialRequestTypes::LOAD_TABLE) { + if (sendLen < 2) { return returnvalue::FAILED; } const TableInfo* tableInfo = reinterpret_cast(sendData); int result = gs_rparam_load(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable, - tableInfo->targetTable); + tableInfo->targetTable); if (result != 0) { return returnvalue::FAILED; } diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index ebfcf2a9..412f2e46 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -87,7 +87,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d } case (GOMSPACE::REQUEST_HK_TABLE): { DeviceType devType; - if(getDevType(devType) != returnvalue::OK) { + if (getDevType(devType) != returnvalue::OK) { return returnvalue::FAILED; } result = @@ -99,11 +99,11 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d } case (GOMSPACE::REQUEST_CONFIG_TABLE): { DeviceType devType; - if(getDevType(devType) != returnvalue::OK) { + if (getDevType(devType) != returnvalue::OK) { return returnvalue::FAILED; } - result = generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, - deviceCommand, cspCookie); + result = + generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, deviceCommand, cspCookie); if (result != returnvalue::OK) { return result; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 528cd2dd..af9d3411 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -93,10 +93,9 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { * @param cspCookie * @return */ - ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, - uint16_t tableSize, DeviceCommandId_t id, - CspCookie *cspCookie); - ReturnValue_t getDevType(GOMSPACE::DeviceType& type) const; + ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, uint16_t tableSize, + DeviceCommandId_t id, CspCookie *cspCookie); + ReturnValue_t getDevType(GOMSPACE::DeviceType &type) const; /** * This command handles printing the HK table to the console. This is useful for debugging * purposes diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 8add8d6b..5dddec3e 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -20,9 +20,7 @@ ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reade ScexDeviceHandler::~ScexDeviceHandler() {} -void ScexDeviceHandler::doStartUp() { - setMode(MODE_ON); -} +void ScexDeviceHandler::doStartUp() { setMode(MODE_ON); } void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } @@ -305,9 +303,9 @@ void ScexDeviceHandler::performOperationHook() { uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return OK; } ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { - if(switchId) { - *numberOfSwitches = 1; - *switches = &switchId.value(); + if (switchId) { + *numberOfSwitches = 1; + *switches = &switchId.value(); } return OK; } @@ -348,8 +346,7 @@ std::string ScexDeviceHandler::date_time_string() { void ScexDeviceHandler::modeChanged() {} -void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) -{ - DeviceHandlerBase::setPowerSwitcher(&powerSwitcher); - this->switchId = switchId; +void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) { + DeviceHandlerBase::setPowerSwitcher(&powerSwitcher); + this->switchId = switchId; } diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index 19ce2e52..6cf2492b 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -1,13 +1,13 @@ #ifndef MISSION_DEVICES_SCEXDEVICEHANDLER_H_ #define MISSION_DEVICES_SCEXDEVICEHANDLER_H_ -#include #include #include #include -#include "commonSubsystemIds.h" +#include +#include "commonSubsystemIds.h" class SdCardMountedIF; @@ -15,7 +15,7 @@ class ScexDeviceHandler : public DeviceHandlerBase { public: ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie, SdCardMountedIF &sdcMan); - void setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId); + void setPowerSwitcher(PowerSwitchIF &powerSwitcher, power::Switch_t switchId); virtual ~ScexDeviceHandler(); private: