bugfix for scex testcode
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Irini Kosmidou 2022-09-27 18:54:48 +02:00
parent a1cc5b0ca7
commit 308a855d8c
16 changed files with 56 additions and 55 deletions

View File

@ -82,9 +82,9 @@ void ObjectFactory::produce(void* args) {
#endif #endif
#endif #endif
auto* sdcMan = new RPiSdCardManager("/tmp");
#if OBSW_ADD_SCEX_DEVICE == 1 #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 #endif
#if OBSW_ADD_SUN_SENSORS == 1 #if OBSW_ADD_SUN_SENSORS == 1
@ -201,8 +201,7 @@ void ObjectFactory::createTestTasks() {
#endif #endif
#if OBSW_ADD_UART_TEST_CODE == 1 #if OBSW_ADD_UART_TEST_CODE == 1
auto scexReader = new ScexUartReader(objects::SCEX_UART_READER); new UartTestClass(objects::UART_TEST);
new UartTestClass(objects::UART_TEST, scexReader);
#else #else
new UartComIF(objects::UART_COM_IF); new UartComIF(objects::UART_COM_IF);
#endif #endif

View File

@ -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_STAR_TRACKER_DEV[] = "/dev/ul-str";
static constexpr char UART_SCEX_DEV[] = "/dev/ul-scex"; static constexpr char UART_SCEX_DEV[] = "/dev/ul-scex";
static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0";
static constexpr char UIO_PTME[] = "/dev/uio1"; static constexpr char UIO_PTME[] = "/dev/uio1";
static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2";

View File

@ -249,7 +249,6 @@ void initmission::initTasks() {
scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask); scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask);
#endif #endif
std::vector<PeriodicTaskIF*> pusTasks; std::vector<PeriodicTaskIF*> pusTasks;
createPusTasks(*factory, missedDeadlineFunc, pusTasks); createPusTasks(*factory, missedDeadlineFunc, pusTasks);
std::vector<PeriodicTaskIF*> pstTasks; std::vector<PeriodicTaskIF*> pstTasks;

View File

@ -1,5 +1,7 @@
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include <linux/devices/ScexUartReader.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/boardtest/Q7STestTask.h"
#include "bsp_q7s/callbacks/gnssCallback.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); new I2cTestClass(objects::I2C_TEST, q7s::I2C_DEFAULT_DEV);
#endif #endif
#if OBSW_ADD_UART_TEST_CODE == 1 #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 #endif
} }

View File

@ -1,4 +1,5 @@
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h> #include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/CoreController.h"
#include "bsp_q7s/core/ObjectFactory.h" #include "bsp_q7s/core/ObjectFactory.h"
@ -60,7 +61,7 @@ void ObjectFactory::produce(void* args) {
#if OBSW_ADD_SCEX_DEVICE == 1 #if OBSW_ADD_SCEX_DEVICE == 1
createScexComponents(q7s::UART_GNSS_DEV, pwrSwitcher, *SdCardManager::instance(), false, 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 #endif
/* Test Task */ /* Test Task */
#if OBSW_ADD_TEST_CODE == 1 #if OBSW_ADD_TEST_CODE == 1

View File

@ -7,7 +7,8 @@
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "ObjectFactory.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; using namespace initmission;
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
#if OBSW_PRINT_MISSED_DEADLINES == 1 #if OBSW_PRINT_MISSED_DEADLINES == 1

View File

@ -2,5 +2,6 @@
#include <fsfw/tasks/TaskFactory.h> #include <fsfw/tasks/TaskFactory.h>
namespace scheduling { namespace scheduling {
void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, PeriodicTaskIF*& scexReaderTask); void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler,
PeriodicTaskIF*& scexReaderTask);
} }

View File

@ -325,17 +325,17 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
SdCardMountedIF& mountedIF, bool onImmediately, SdCardMountedIF& mountedIF, bool onImmediately,
std::optional<power::Switch_t> switchId) { std::optional<power::Switch_t> switchId) {
// objekte anlegen // objekte anlegen
auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096);
auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER);
auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, mountedIF); auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, mountedIF);
if(onImmediately) { if (onImmediately) {
scexHandler->setStartUpImmediately(); scexHandler->setStartUpImmediately();
} }
if (switchId) { if (switchId) {
scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value()); scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value());
} }
} }

View File

@ -5,8 +5,8 @@
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h> #include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include <mission/memory/SdCardMountedIF.h> #include <mission/memory/SdCardMountedIF.h>
#include <string>
#include <optional> #include <optional>
#include <string>
class GpioIF; class GpioIF;
class SpiComIF; class SpiComIF;
@ -21,7 +21,7 @@ void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* p
void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
SdCardMountedIF& mountedIF, bool onImmediately, SdCardMountedIF& mountedIF, bool onImmediately,
std::optional<power::Switch_t> switchId); std::optional<power::Switch_t> switchId);
void gpioChecker(ReturnValue_t result, std::string output); void gpioChecker(ReturnValue_t result, std::string output);

View File

@ -27,12 +27,11 @@
using namespace returnvalue; using namespace returnvalue;
UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {
: TestTask(objectId), reader(reader) {
mode = TestModes::SCEX; mode = TestModes::SCEX;
scexMode = ScexModes::READER_TASK; scexMode = ScexModes::SIMPLE;
// No one-cell and all-cell support implemented yet // No one-cell and all-cell support implemented yet
currCmd = scex::Cmds::FRAM; currCmd = scex::Cmds::PING;
if (scexMode == ScexModes::SIMPLE) { if (scexMode == ScexModes::SIMPLE) {
auto encodingBuf = new std::array<uint8_t, 4096>; auto encodingBuf = new std::array<uint8_t, 4096>;
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; 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::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
decodingBufPair, &foundDlePacketHandler, this); decodingBufPair, &foundDlePacketHandler, this);
} else {
reader = new ScexUartReader(objects::SCEX_UART_READER);
} }
} }
@ -150,13 +151,13 @@ void UartTestClass::gpsPeriodic() {
} }
void UartTestClass::scexInit() { void UartTestClass::scexInit() {
if (reader == nullptr) {
sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl;
return;
}
if (scexMode == ScexModes::SIMPLE) { if (scexMode == ScexModes::SIMPLE) {
scexSimpleInit(); scexSimpleInit();
} else { } else {
if (reader == nullptr) {
sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl;
return;
}
#if defined(RASPBERRY_PI) #if defined(RASPBERRY_PI)
std::string devname = "/dev/serial0"; std::string devname = "/dev/serial0";
#else #else
@ -176,13 +177,13 @@ void UartTestClass::scexInit() {
void UartTestClass::scexPeriodic() { void UartTestClass::scexPeriodic() {
using namespace std; using namespace std;
using namespace scex; using namespace scex;
if (reader == nullptr) {
return;
}
if (scexMode == ScexModes::SIMPLE) { if (scexMode == ScexModes::SIMPLE) {
scexSimplePeriodic(); scexSimplePeriodic();
} else { } else {
if (reader == nullptr) {
return;
}
if (not cmdSent) { if (not cmdSent) {
size_t len = 0; size_t len = 0;
prepareScexCmd(currCmd, false, cmdBuf.data(), &len); 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); uint16_t crc = CRC::crc16ccitt(cmdBuf, 5);
cmdBuf[5] = (crc >> 8) & 0xff; cmdBuf[5] = (crc >> 8) & 0xff;
cmdBuf[6] = crc & 0xff; cmdBuf[6] = crc & 0xff;
*len = 7;
return 0; return 0;
} }

View File

@ -19,7 +19,7 @@ class ScexDleParser;
class UartTestClass : public TestTask { class UartTestClass : public TestTask {
public: public:
UartTestClass(object_id_t objectId, ScexUartReader* reader); UartTestClass(object_id_t objectId);
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
ReturnValue_t performOneShotAction() override; ReturnValue_t performOneShotAction() override;

View File

@ -166,23 +166,23 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
if (result != 0) { if (result != 0) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
} else if(req == GOMSPACE::SpecialRequestTypes::SAVE_TABLE) { } else if (req == GOMSPACE::SpecialRequestTypes::SAVE_TABLE) {
if(sendLen < 2) { if (sendLen < 2) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData); const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData);
int result = gs_rparam_save(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable, int result = gs_rparam_save(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable,
tableInfo->targetTable); tableInfo->targetTable);
if (result != 0) { if (result != 0) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
} else if(req == GOMSPACE::SpecialRequestTypes::LOAD_TABLE) { } else if (req == GOMSPACE::SpecialRequestTypes::LOAD_TABLE) {
if(sendLen < 2) { if (sendLen < 2) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData); const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData);
int result = gs_rparam_load(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable, int result = gs_rparam_load(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable,
tableInfo->targetTable); tableInfo->targetTable);
if (result != 0) { if (result != 0) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }

View File

@ -87,7 +87,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
} }
case (GOMSPACE::REQUEST_HK_TABLE): { case (GOMSPACE::REQUEST_HK_TABLE): {
DeviceType devType; DeviceType devType;
if(getDevType(devType) != returnvalue::OK) { if (getDevType(devType) != returnvalue::OK) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
result = result =
@ -99,11 +99,11 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
} }
case (GOMSPACE::REQUEST_CONFIG_TABLE): { case (GOMSPACE::REQUEST_CONFIG_TABLE): {
DeviceType devType; DeviceType devType;
if(getDevType(devType) != returnvalue::OK) { if (getDevType(devType) != returnvalue::OK) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
result = generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, result =
deviceCommand, cspCookie); generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, deviceCommand, cspCookie);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }

View File

@ -93,10 +93,9 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @param cspCookie * @param cspCookie
* @return * @return
*/ */
ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, uint16_t tableSize,
uint16_t tableSize, DeviceCommandId_t id, DeviceCommandId_t id, CspCookie *cspCookie);
CspCookie *cspCookie); ReturnValue_t getDevType(GOMSPACE::DeviceType &type) const;
ReturnValue_t getDevType(GOMSPACE::DeviceType& type) const;
/** /**
* This command handles printing the HK table to the console. This is useful for debugging * This command handles printing the HK table to the console. This is useful for debugging
* purposes * purposes

View File

@ -20,9 +20,7 @@ ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reade
ScexDeviceHandler::~ScexDeviceHandler() {} ScexDeviceHandler::~ScexDeviceHandler() {}
void ScexDeviceHandler::doStartUp() { void ScexDeviceHandler::doStartUp() { setMode(MODE_ON); }
setMode(MODE_ON);
}
void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } 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; } uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return OK; }
ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
if(switchId) { if (switchId) {
*numberOfSwitches = 1; *numberOfSwitches = 1;
*switches = &switchId.value(); *switches = &switchId.value();
} }
return OK; return OK;
} }
@ -348,8 +346,7 @@ std::string ScexDeviceHandler::date_time_string() {
void ScexDeviceHandler::modeChanged() {} void ScexDeviceHandler::modeChanged() {}
void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) {
{ DeviceHandlerBase::setPowerSwitcher(&powerSwitcher);
DeviceHandlerBase::setPowerSwitcher(&powerSwitcher); this->switchId = switchId;
this->switchId = switchId;
} }

View File

@ -1,13 +1,13 @@
#ifndef MISSION_DEVICES_SCEXDEVICEHANDLER_H_ #ifndef MISSION_DEVICES_SCEXDEVICEHANDLER_H_
#define MISSION_DEVICES_SCEXDEVICEHANDLER_H_ #define MISSION_DEVICES_SCEXDEVICEHANDLER_H_
#include <optional>
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <linux/devices/ScexHelper.h> #include <linux/devices/ScexHelper.h>
#include <linux/devices/ScexUartReader.h> #include <linux/devices/ScexUartReader.h>
#include "commonSubsystemIds.h" #include <optional>
#include "commonSubsystemIds.h"
class SdCardMountedIF; class SdCardMountedIF;
@ -15,7 +15,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
public: public:
ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie, ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie,
SdCardMountedIF &sdcMan); SdCardMountedIF &sdcMan);
void setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId); void setPowerSwitcher(PowerSwitchIF &powerSwitcher, power::Switch_t switchId);
virtual ~ScexDeviceHandler(); virtual ~ScexDeviceHandler();
private: private: