Merge remote-tracking branch 'origin/develop' into irini
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
add_subdirectory(csp)
|
||||
add_subdirectory(utility)
|
||||
add_subdirectory(callbacks)
|
||||
add_subdirectory(boardtest)
|
||||
add_subdirectory(devices)
|
||||
add_subdirectory(fsfwconfig)
|
||||
add_subdirectory(obc)
|
||||
add_subdirectory(obc)
|
||||
|
||||
target_sources(${OBSW_NAME} PUBLIC
|
||||
ObjectFactory.cpp
|
||||
)
|
286
linux/ObjectFactory.cpp
Normal file
286
linux/ObjectFactory.cpp
Normal file
@ -0,0 +1,286 @@
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/linux/spi/SpiComIF.h>
|
||||
#include <fsfw_hal/linux/spi/SpiCookie.h>
|
||||
#include <linux/callbacks/gpioCallbacks.h>
|
||||
#include <mission/devices/Max31865PT1000Handler.h>
|
||||
#include <mission/devices/SusHandler.h>
|
||||
#include <mission/system/RtdFdir.h>
|
||||
#include <mission/system/SusAssembly.h>
|
||||
#include <mission/system/SusFdir.h>
|
||||
#include <mission/system/TcsBoardAssembly.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "devConf.h"
|
||||
#include "devices/addresses.h"
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF,
|
||||
PowerSwitchIF* pwrSwitcher, std::string spiDev) {
|
||||
using namespace gpio;
|
||||
GpioCookie* gpioCookieSus = new GpioCookie();
|
||||
GpioCallback* susgpio = nullptr;
|
||||
|
||||
susgpio = new GpioCallback("Chip select SUS 0", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_0, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 1", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 2", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 3", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 4", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 5", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 6", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 7", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 8", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 9", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 10", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 11", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio);
|
||||
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
#if OBSW_ADD_SUN_SENSORS == 1
|
||||
SusFdir* fdir = nullptr;
|
||||
std::array<SusHandler*, 12> susHandlers = {};
|
||||
SpiCookie* spiCookie =
|
||||
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[0] = new SusHandler(objects::SUS_0, 0, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_0);
|
||||
susHandlers[0]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[0]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[1] = new SusHandler(objects::SUS_1, 1, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_1);
|
||||
susHandlers[1]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[1]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[2] = new SusHandler(objects::SUS_2, 2, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_2);
|
||||
susHandlers[2]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[2]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[3] = new SusHandler(objects::SUS_3, 3, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_3);
|
||||
susHandlers[3]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[3]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[4] = new SusHandler(objects::SUS_4, 4, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_4);
|
||||
susHandlers[4]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[4]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[5] = new SusHandler(objects::SUS_5, 5, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_5);
|
||||
susHandlers[5]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[5]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[6] = new SusHandler(objects::SUS_6, 6, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_6);
|
||||
susHandlers[6]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[6]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[7] = new SusHandler(objects::SUS_7, 7, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_7);
|
||||
susHandlers[7]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[7]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[8] = new SusHandler(objects::SUS_8, 8, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_8);
|
||||
susHandlers[8]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[8]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[9] = new SusHandler(objects::SUS_9, 9, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_9);
|
||||
susHandlers[9]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[9]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[10] = new SusHandler(objects::SUS_10, 10, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_10);
|
||||
susHandlers[10]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[10]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[11] = new SusHandler(objects::SUS_11, 11, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_11);
|
||||
susHandlers[11]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[11]->setCustomFdir(fdir);
|
||||
|
||||
for (auto& sus : susHandlers) {
|
||||
if (sus != nullptr) {
|
||||
#if OBSW_TEST_SUS == 1
|
||||
sus->setStartUpImmediately();
|
||||
sus->setToGoToNormalMode(true);
|
||||
#endif
|
||||
#if OBSW_DEBUG_SUS == 1
|
||||
sus->enablePeriodicPrintout(true, 3);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
std::array<object_id_t, 12> susIds = {objects::SUS_0, objects::SUS_1, objects::SUS_2,
|
||||
objects::SUS_3, objects::SUS_4, objects::SUS_5,
|
||||
objects::SUS_6, objects::SUS_7, objects::SUS_8,
|
||||
objects::SUS_9, objects::SUS_10, objects::SUS_11};
|
||||
SusAssHelper susAssHelper = SusAssHelper(susIds);
|
||||
auto susAss =
|
||||
new SusAssembly(objects::SUS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher, susAssHelper);
|
||||
static_cast<void>(susAss);
|
||||
#endif /* OBSW_ADD_SUN_SENSORS == 1 */
|
||||
}
|
||||
|
||||
void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
|
||||
PowerSwitchIF* pwrSwitcher) {
|
||||
using namespace gpio;
|
||||
GpioCookie* rtdGpioCookie = new GpioCookie;
|
||||
|
||||
GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0);
|
||||
GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1);
|
||||
GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2);
|
||||
GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3);
|
||||
GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4);
|
||||
GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5);
|
||||
GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6);
|
||||
GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7);
|
||||
GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8);
|
||||
GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9);
|
||||
GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10);
|
||||
GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11);
|
||||
GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12);
|
||||
GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13);
|
||||
GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14);
|
||||
GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15);
|
||||
|
||||
gpioComIF->addGpios(rtdGpioCookie);
|
||||
|
||||
#if OBSW_ADD_RTD_DEVICES == 1
|
||||
static constexpr uint8_t NUMBER_RTDS = 16;
|
||||
std::array<std::pair<address_t, gpioId_t>, NUMBER_RTDS> cookieArgs = {{
|
||||
{addresses::RTD_IC_3, gpioIds::RTD_IC_3},
|
||||
{addresses::RTD_IC_4, gpioIds::RTD_IC_4},
|
||||
{addresses::RTD_IC_5, gpioIds::RTD_IC_5},
|
||||
{addresses::RTD_IC_6, gpioIds::RTD_IC_6},
|
||||
{addresses::RTD_IC_7, gpioIds::RTD_IC_7},
|
||||
{addresses::RTD_IC_8, gpioIds::RTD_IC_8},
|
||||
{addresses::RTD_IC_9, gpioIds::RTD_IC_9},
|
||||
{addresses::RTD_IC_10, gpioIds::RTD_IC_10},
|
||||
{addresses::RTD_IC_11, gpioIds::RTD_IC_11},
|
||||
{addresses::RTD_IC_12, gpioIds::RTD_IC_12},
|
||||
{addresses::RTD_IC_13, gpioIds::RTD_IC_13},
|
||||
{addresses::RTD_IC_14, gpioIds::RTD_IC_14},
|
||||
{addresses::RTD_IC_15, gpioIds::RTD_IC_15},
|
||||
{addresses::RTD_IC_16, gpioIds::RTD_IC_16},
|
||||
{addresses::RTD_IC_17, gpioIds::RTD_IC_17},
|
||||
{addresses::RTD_IC_18, gpioIds::RTD_IC_18},
|
||||
}};
|
||||
std::array<object_id_t, NUMBER_RTDS> rtdIds = {
|
||||
objects::RTD_IC_3, objects::RTD_IC_4, objects::RTD_IC_5, objects::RTD_IC_6,
|
||||
objects::RTD_IC_7, objects::RTD_IC_8, objects::RTD_IC_9, objects::RTD_IC_10,
|
||||
objects::RTD_IC_11, objects::RTD_IC_12, objects::RTD_IC_13, objects::RTD_IC_14,
|
||||
objects::RTD_IC_15, objects::RTD_IC_16, objects::RTD_IC_17, objects::RTD_IC_18};
|
||||
std::array<SpiCookie*, NUMBER_RTDS> rtdCookies = {};
|
||||
std::array<Max31865PT1000Handler*, NUMBER_RTDS> rtds = {};
|
||||
RtdFdir* rtdFdir = nullptr;
|
||||
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
|
||||
rtdCookies[idx] =
|
||||
new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second, spiDev,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
rtds[idx] = new Max31865PT1000Handler(rtdIds[idx], objects::SPI_COM_IF, rtdCookies[idx]);
|
||||
rtds[idx]->setParent(objects::TCS_BOARD_ASS);
|
||||
rtdFdir = new RtdFdir(rtdIds[idx]);
|
||||
rtds[idx]->setCustomFdir(rtdFdir);
|
||||
rtds[idx]->setDeviceIdx(idx + 3);
|
||||
}
|
||||
|
||||
#if OBSW_TEST_RTD == 1
|
||||
for (auto& rtd : rtds) {
|
||||
if (rtd != nullptr) {
|
||||
rtd->setStartUpImmediately();
|
||||
rtd->setInstantNormal(true);
|
||||
}
|
||||
}
|
||||
#endif // OBSW_TEST_RTD == 1
|
||||
TcsBoardHelper helper(rtdIds);
|
||||
TcsBoardAssembly* tcsBoardAss =
|
||||
new TcsBoardAssembly(objects::TCS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher,
|
||||
pcduSwitches::Switches::PDU1_CH0_TCS_BOARD_3V3, helper);
|
||||
static_cast<void>(tcsBoardAss);
|
||||
#endif // OBSW_ADD_RTD_DEVICES == 1
|
||||
}
|
15
linux/ObjectFactory.h
Normal file
15
linux/ObjectFactory.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class GpioIF;
|
||||
class SpiComIF;
|
||||
class PowerSwitchIF;
|
||||
|
||||
namespace ObjectFactory {
|
||||
|
||||
void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher,
|
||||
std::string spiDev);
|
||||
void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher);
|
||||
|
||||
} // namespace ObjectFactory
|
@ -339,6 +339,8 @@ void SpiTestClass::performMax1227Test() {
|
||||
std::string deviceName = "";
|
||||
#elif defined(EGSE)
|
||||
std::string deviceName = "";
|
||||
#elif defined(TE0720_1CFA)
|
||||
std::string deviceName = "";
|
||||
#endif
|
||||
int fd = 0;
|
||||
UnixFileGuard fileHelper(deviceName, &fd, O_RDWR, "SpiComIF::initializeInterface");
|
||||
|
@ -3,9 +3,14 @@
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#if defined(XIPHOS_Q7S)
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "busConf.h"
|
||||
#endif
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
#include <bsp_linux_board/definitions.h>
|
||||
#endif
|
||||
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
#include <fsfw_hal/linux/spi/SpiCookie.h>
|
||||
#include <test/testtasks/TestTask.h>
|
||||
|
3
linux/callbacks/CMakeLists.txt
Normal file
3
linux/callbacks/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${OBSW_NAME} PRIVATE
|
||||
gpioCallbacks.cpp
|
||||
)
|
431
linux/callbacks/gpioCallbacks.cpp
Normal file
431
linux/callbacks/gpioCallbacks.cpp
Normal file
@ -0,0 +1,431 @@
|
||||
#include "gpioCallbacks.h"
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
|
||||
void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp,
|
||||
gpio::Levels value, void* args) {
|
||||
GpioIF* gpioIF = reinterpret_cast<GpioIF*>(args);
|
||||
if (gpioIF == nullptr) {
|
||||
sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder "
|
||||
<< "to specify gpioComIF" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reading is not supported by the callback function */
|
||||
if (gpioOp == gpio::GpioOperation::READ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == gpio::Levels::HIGH) {
|
||||
switch (gpioId) {
|
||||
case (gpioIds::RTD_IC_3): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_4): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_5): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_6): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_7): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_8): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_9): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_10): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_11): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_12): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_13): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_14): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_15): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_16): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_17): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_18): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_0): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_1): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_2): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_3): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_4): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_10): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_11): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW1): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW2): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW3): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW4): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
} else if (value == gpio::Levels::LOW) {
|
||||
switch (gpioId) {
|
||||
case (gpioIds::RTD_IC_3): {
|
||||
selectY7(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_4): {
|
||||
selectY6(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_5): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_6): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_7): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_8): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_9): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_10): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_11): {
|
||||
selectY7(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_12): {
|
||||
selectY6(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_13): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_14): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_15): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_16): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_17): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_18): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_0): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_1): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_2): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_3): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_4): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_10): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_11): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW1): {
|
||||
selectY0(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW2): {
|
||||
selectY1(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW3): {
|
||||
selectY2(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW4): {
|
||||
selectY3(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
} else {
|
||||
sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderTcsIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderTcsIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderInterfaceBoardIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderInterfaceBoardIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderTcsIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderTcsIc2(GpioIF* gpioIF) {
|
||||
// DO NOT CHANGE THE ORDER HERE
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderInterfaceBoardIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderInterfaceBoardIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableRwDecoder(GpioIF* gpioIF) { gpioIF->pullHigh(gpioIds::EN_RW_CS); }
|
||||
|
||||
void gpioCallbacks::disableRwDecoder(GpioIF* gpioIF) { gpioIF->pullLow(gpioIds::EN_RW_CS); }
|
||||
|
||||
void gpioCallbacks::selectY0(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY2(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY3(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY4(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY5(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY6(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY7(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableAllDecoder(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::EN_RW_CS);
|
||||
}
|
66
linux/callbacks/gpioCallbacks.h
Normal file
66
linux/callbacks/gpioCallbacks.h
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
|
||||
class GpioIF;
|
||||
|
||||
namespace gpioCallbacks {
|
||||
|
||||
/**
|
||||
* @brief This function implements the decoding to multiply gpios by using the decoder
|
||||
* chips SN74LVC138APWR on the TCS board and the interface board.
|
||||
*/
|
||||
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value,
|
||||
void* args);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the TCS board which is named to IC1 in the schematic.
|
||||
*/
|
||||
void enableDecoderTcsIc1(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the TCS board which is named to IC2 in the schematic.
|
||||
*/
|
||||
void enableDecoderTcsIc2(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC21 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc1(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC22 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc2(GpioIF* gpioIF);
|
||||
|
||||
void disableDecoderTcsIc1(GpioIF* gpioIF);
|
||||
void disableDecoderTcsIc2(GpioIF* gpioIF);
|
||||
void disableDecoderInterfaceBoardIc1(GpioIF* gpioIF);
|
||||
void disableDecoderInterfaceBoardIc2(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief Enables the reaction wheel chip select decoder (IC3).
|
||||
*/
|
||||
void enableRwDecoder(GpioIF* gpioIF);
|
||||
void disableRwDecoder(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function disables all decoder.
|
||||
*/
|
||||
void disableAllDecoder(GpioIF* gpioIF);
|
||||
|
||||
/** The following functions enable the appropriate channel of the currently enabled decoder */
|
||||
void selectY0(GpioIF* gpioIF);
|
||||
void selectY1(GpioIF* gpioIF);
|
||||
void selectY2(GpioIF* gpioIF);
|
||||
void selectY3(GpioIF* gpioIF);
|
||||
void selectY4(GpioIF* gpioIF);
|
||||
void selectY5(GpioIF* gpioIF);
|
||||
void selectY6(GpioIF* gpioIF);
|
||||
void selectY7(GpioIF* gpioIF);
|
||||
|
||||
} // namespace gpioCallbacks
|
@ -4,7 +4,11 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER)
|
||||
)
|
||||
endif()
|
||||
|
||||
<<<<<<< HEAD
|
||||
target_sources(${OBSW_NAME} PRIVATE
|
||||
ScexUartReader.cpp
|
||||
)
|
||||
=======
|
||||
add_subdirectory(ploc)
|
||||
>>>>>>> origin/develop
|
||||
add_subdirectory(startracker)
|
||||
|
@ -3,19 +3,24 @@
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
#include "linux/utility/utility.h"
|
||||
#include "mission/utility/compileTime.h"
|
||||
|
||||
#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps)
|
||||
: ExtendedControllerBase(objectId, objects::NO_OBJECT),
|
||||
gpsSet(this),
|
||||
myGpsmm(GPSD_SHARED_MEMORY, nullptr),
|
||||
debugHyperionGps(debugHyperionGps) {}
|
||||
debugHyperionGps(debugHyperionGps) {
|
||||
timeUpdateCd.resetTimer();
|
||||
}
|
||||
|
||||
GPSHyperionLinuxController::~GPSHyperionLinuxController() {}
|
||||
|
||||
@ -76,9 +81,7 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
|
||||
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
|
||||
localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>());
|
||||
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
|
||||
#if OBSW_ENABLE_PERIODIC_HK == 1
|
||||
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false);
|
||||
#endif
|
||||
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 30.0, false);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -124,8 +127,17 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
return;
|
||||
}
|
||||
|
||||
bool validFix = false;
|
||||
static_cast<void>(validFix);
|
||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
||||
gpsSet.fixMode.value = gps->fix.mode;
|
||||
int newFixMode = gps->fix.mode;
|
||||
if (newFixMode == 2 or newFixMode == 3) {
|
||||
validFix = true;
|
||||
}
|
||||
if (gpsSet.fixMode.value != newFixMode) {
|
||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
||||
}
|
||||
gpsSet.fixMode.value = newFixMode;
|
||||
if (gps->fix.mode == 0 or gps->fix.mode == 1) {
|
||||
if (modeCommanded and maxTimeToReachFix.hasTimedOut()) {
|
||||
// We are supposed to be on and functioning, but not fix was found
|
||||
@ -172,6 +184,34 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
timeval time = {};
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
time.tv_usec = gps->fix.time.tv_nsec / 1000;
|
||||
std::time_t t = std::time(nullptr);
|
||||
if (time.tv_sec == t) {
|
||||
timeIsConstantCounter++;
|
||||
} else {
|
||||
timeIsConstantCounter = 0;
|
||||
}
|
||||
if (timeInit and validFix) {
|
||||
if (not utility::timeSanityCheck()) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
time_t timeRaw = time.tv_sec;
|
||||
std::tm *timeTm = std::gmtime(&timeRaw);
|
||||
sif::info << "Setting invalid system time from GPS data directly: "
|
||||
<< std::put_time(timeTm, "%c %Z") << std::endl;
|
||||
#endif
|
||||
// For some reason, the clock needs to be somewhat correct for NTP to work. Really dumb..
|
||||
Clock::setClock(&time);
|
||||
}
|
||||
timeInit = false;
|
||||
}
|
||||
// If the received time does not change anymore for whatever reason, do not set it here
|
||||
// to avoid stale times. Also, don't do it too often often to avoid jumping times
|
||||
if (timeIsConstantCounter < 20 and timeUpdateCd.hasTimedOut()) {
|
||||
// Update the system time here for now. NTP seems to be unable to do so for whatever reason.
|
||||
// Further tests have shown that the time seems to be set by NTPD after some time..
|
||||
// Clock::setClock(&time);
|
||||
timeUpdateCd.resetTimer();
|
||||
}
|
||||
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
@ -192,6 +232,9 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
|
||||
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
|
||||
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
|
||||
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::gmtime(&t);
|
||||
std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_
|
||||
#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_
|
||||
|
||||
#include "commonSubsystemIds.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/controller/ExtendedControllerBase.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
@ -22,6 +23,7 @@
|
||||
class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
public:
|
||||
static constexpr uint32_t MAX_SECONDS_TO_REACH_FIX = 60 * 60 * 5;
|
||||
|
||||
GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId,
|
||||
bool debugHyperionGps = false);
|
||||
virtual ~GPSHyperionLinuxController();
|
||||
@ -49,8 +51,11 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
|
||||
GpsPrimaryDataset gpsSet;
|
||||
Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000);
|
||||
bool modeCommanded = true;
|
||||
bool timeInit = true;
|
||||
gpsmm myGpsmm;
|
||||
bool debugHyperionGps = false;
|
||||
uint32_t timeIsConstantCounter = 0;
|
||||
Countdown timeUpdateCd = Countdown(60);
|
||||
|
||||
void readGpsDataFromGpsd();
|
||||
};
|
||||
|
32
linux/devices/devicedefinitions/MPSoCReturnValuesIF.h
Normal file
32
linux/devices/devicedefinitions/MPSoCReturnValuesIF.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef MPSOC_RETURN_VALUES_IF_H_
|
||||
#define MPSOC_RETURN_VALUES_IF_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class MPSoCReturnValuesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
|
||||
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
|
||||
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
|
||||
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
|
||||
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
|
||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
|
||||
//! [EXPORT] : [COMMENT] Filename of file in OBC filesystem is too long
|
||||
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
|
||||
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
|
||||
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
|
||||
//! [EXPORT] : [COMMENT] Filename of MPSoC file is to long (max. 256 bytes)
|
||||
static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7);
|
||||
//! [EXPORT] : [COMMENT] Command has invalid parameter
|
||||
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8);
|
||||
//! [EXPORT] : [COMMENT] Received command has file string with invalid length
|
||||
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA9);
|
||||
};
|
||||
|
||||
#endif /* MPSOC_RETURN_VALUES_IF_H_ */
|
620
linux/devices/devicedefinitions/PlocMPSoCDefinitions.h
Normal file
620
linux/devices/devicedefinitions/PlocMPSoCDefinitions.h
Normal file
@ -0,0 +1,620 @@
|
||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
||||
|
||||
#include "MPSoCReturnValuesIF.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "eive/definitions.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
|
||||
namespace mpsoc {
|
||||
|
||||
static const DeviceCommandId_t NONE = 0;
|
||||
static const DeviceCommandId_t TC_MEM_WRITE = 1;
|
||||
static const DeviceCommandId_t TC_MEM_READ = 2;
|
||||
static const DeviceCommandId_t ACK_REPORT = 3;
|
||||
static const DeviceCommandId_t EXE_REPORT = 5;
|
||||
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6;
|
||||
static const DeviceCommandId_t TC_FLASHFOPEN = 7;
|
||||
static const DeviceCommandId_t TC_FLASHFCLOSE = 8;
|
||||
static const DeviceCommandId_t TC_FLASHWRITE = 9;
|
||||
static const DeviceCommandId_t TC_FLASHDELETE = 10;
|
||||
static const DeviceCommandId_t TC_REPLAY_START = 11;
|
||||
static const DeviceCommandId_t TC_REPLAY_STOP = 12;
|
||||
static const DeviceCommandId_t TC_REPLAY_WRITE_SEQUENCE = 13;
|
||||
static const DeviceCommandId_t TC_DOWNLINK_PWR_ON = 14;
|
||||
static const DeviceCommandId_t TC_DOWNLINK_PWR_OFF = 15;
|
||||
static const DeviceCommandId_t TC_MODE_REPLAY = 16;
|
||||
|
||||
// Will reset the sequence count of the OBSW
|
||||
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
|
||||
|
||||
static const uint16_t SIZE_ACK_REPORT = 14;
|
||||
static const uint16_t SIZE_EXE_REPORT = 14;
|
||||
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
|
||||
|
||||
/**
|
||||
* SpacePacket apids of PLOC telecommands and telemetry.
|
||||
*/
|
||||
namespace apid {
|
||||
static const uint16_t TC_REPLAY_START = 0x110;
|
||||
static const uint16_t TC_REPLAY_STOP = 0x111;
|
||||
static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112;
|
||||
static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
|
||||
static const uint16_t TC_MEM_WRITE = 0x114;
|
||||
static const uint16_t TC_MEM_READ = 0x115;
|
||||
static const uint16_t TC_FLASHWRITE = 0x117;
|
||||
static const uint16_t TC_FLASHFOPEN = 0x119;
|
||||
static const uint16_t TC_FLASHFCLOSE = 0x11A;
|
||||
static const uint16_t TC_FLASHDELETE = 0x11C;
|
||||
static const uint16_t TC_MODE_REPLAY = 0x11F;
|
||||
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
|
||||
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
|
||||
static const uint16_t ACK_SUCCESS = 0x400;
|
||||
static const uint16_t ACK_FAILURE = 0x401;
|
||||
static const uint16_t EXE_SUCCESS = 0x402;
|
||||
static const uint16_t EXE_FAILURE = 0x403;
|
||||
} // namespace apid
|
||||
|
||||
/** Offset from first byte in space packet to first byte of data field */
|
||||
static const uint8_t DATA_FIELD_OFFSET = 6;
|
||||
static const size_t MEM_READ_RPT_LEN_OFFSET = 10;
|
||||
static const char NULL_TERMINATOR = '\0';
|
||||
|
||||
/**
|
||||
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
|
||||
* 8.
|
||||
*/
|
||||
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
|
||||
|
||||
static const size_t MAX_FILENAME_SIZE = 256;
|
||||
|
||||
/**
|
||||
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
|
||||
* field. For the length field in the space packet this size will be substracted by one.
|
||||
*/
|
||||
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
|
||||
static const uint16_t LENGTH_TC_MEM_READ = 8;
|
||||
|
||||
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
|
||||
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
|
||||
static const size_t MAX_DATA_SIZE = 1016;
|
||||
|
||||
/**
|
||||
* The replay write sequence command has a maximum delay for the execution report which amounts to
|
||||
* 30 seconds. (80 cycles * 0.5 seconds = 40 seconds).
|
||||
*/
|
||||
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80;
|
||||
// Requires approx. 2 seconds for execution. 8 => 4 seconds
|
||||
static const uint16_t TC_DOWNLINK_PWR_ON_EXECUTION_DELAY = 8;
|
||||
|
||||
/**
|
||||
* @brief Abstract base class for TC space packet of MPSoC.
|
||||
*/
|
||||
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
public:
|
||||
// Initial length field of space packet. Will always be updated when packet is created.
|
||||
static const uint16_t INIT_LENGTH = 1;
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param sequenceCount Sequence count of space packet which will be incremented with each
|
||||
* sent and received packets.
|
||||
*/
|
||||
TcBase(uint16_t apid, uint16_t sequenceCount)
|
||||
: SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {}
|
||||
|
||||
/**
|
||||
* @brief Function to initialize the space packet
|
||||
*
|
||||
* @param commandData Pointer to command specific data
|
||||
* @param commandDataLen Length of command data
|
||||
*
|
||||
* @return RETURN_OK if packet creation was successful, otherwise error return value
|
||||
*/
|
||||
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = initPacket(commandData, commandDataLen);
|
||||
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Must be overwritten by the child class to define the command specific parameters
|
||||
*
|
||||
* @param commandData Pointer to received command data
|
||||
* @param commandDataLen Length of received command data
|
||||
*/
|
||||
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the CRC
|
||||
*/
|
||||
ReturnValue_t addCrc() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t serializedSize = 0;
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
result = SerializeAdapter::serialize<uint16_t>(
|
||||
&crc, this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class for handling tm replies of the PLOC MPSoC.
|
||||
*/
|
||||
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
|
||||
*/
|
||||
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {}
|
||||
|
||||
ReturnValue_t checkCrc() {
|
||||
uint8_t* crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
|
||||
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
|
||||
uint16_t recalculatedCrc =
|
||||
CRC::crc16ccitt(this->localData.byteStream, this->getFullSize() - CRC_SIZE);
|
||||
if (recalculatedCrc != receivedCrc) {
|
||||
return CRC_FAILURE;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to build the memory read command for the PLOC.
|
||||
*/
|
||||
class TcMemRead : public TcBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcMemRead(uint16_t sequenceCount) : TcBase(apid::TC_MEM_READ, sequenceCount) {
|
||||
this->setPacketDataLength(PACKET_LENGTH);
|
||||
}
|
||||
|
||||
uint16_t getMemLen() const { return memLen; }
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
||||
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE,
|
||||
MEM_LEN_SIZE);
|
||||
size_t size = sizeof(memLen);
|
||||
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
|
||||
result =
|
||||
SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static const size_t COMMAND_LENGTH = 6;
|
||||
static const size_t MEM_ADDRESS_SIZE = 4;
|
||||
static const size_t MEM_LEN_SIZE = 2;
|
||||
static const uint16_t PACKET_LENGTH = 7;
|
||||
|
||||
uint16_t memLen = 0;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen != COMMAND_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to generate the space packet to write data to a memory address within
|
||||
* the PLOC.
|
||||
*/
|
||||
class TcMemWrite : public TcBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
uint16_t memLen =
|
||||
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
|
||||
static const size_t MIN_COMMAND_DATA_LENGTH = 10;
|
||||
static const size_t MEM_ADDRESS_SIZE = 4;
|
||||
static const size_t FIX_LENGTH = 8;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
||||
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to help creation of flash fopen command.
|
||||
*/
|
||||
class FlashFopen : public TcBase {
|
||||
public:
|
||||
FlashFopen(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
|
||||
static const char APPEND = 'a';
|
||||
static const char WRITE = 'w';
|
||||
static const char READ = 'r';
|
||||
|
||||
ReturnValue_t createPacket(std::string filename, char accessMode_) {
|
||||
accessMode = accessMode_;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
std::memcpy(this->getPacketData() + nameSize + sizeof(NULL_TERMINATOR), &accessMode,
|
||||
sizeof(accessMode));
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE -
|
||||
1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
char accessMode = APPEND;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to help creation of flash fclose command.
|
||||
*/
|
||||
class FlashFclose : public TcBase {
|
||||
public:
|
||||
FlashFclose(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build flash write space packet.
|
||||
*/
|
||||
class TcFlashWrite : public TcBase {
|
||||
public:
|
||||
TcFlashWrite(uint16_t sequenceCount) : TcBase(apid::TC_FLASHWRITE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(const uint8_t* writeData, uint32_t writeLen_) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
writeLen = writeLen_;
|
||||
if (writeLen > MAX_DATA_SIZE) {
|
||||
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
size_t serializedSize = 0;
|
||||
result =
|
||||
SerializeAdapter::serialize<uint32_t>(&writeLen, this->getPacketData(), &serializedSize,
|
||||
sizeof(writeLen), SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
|
||||
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t writeLen = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to help creation of flash delete command.
|
||||
*/
|
||||
class TcFlashDelete : public TcBase {
|
||||
public:
|
||||
TcFlashDelete(uint16_t sequenceCount) : TcBase(apid::TC_FLASHDELETE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
size_t nameSize = filename.size();
|
||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build replay stop space packet.
|
||||
*/
|
||||
class TcReplayStop : public TcBase {
|
||||
public:
|
||||
TcReplayStop(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_STOP, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to build the replay start command.
|
||||
*/
|
||||
class TcReplayStart : public TcBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = checkData(*commandData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static const size_t COMMAND_DATA_LENGTH = 1;
|
||||
static const uint8_t REPEATING = 0;
|
||||
static const uint8_t ONCE = 1;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen != COMMAND_DATA_LENGTH) {
|
||||
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t checkData(uint8_t replay) {
|
||||
if (replay != REPEATING && replay != ONCE) {
|
||||
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
|
||||
return INVALID_PARAMETER;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to build downlink power on command.
|
||||
*/
|
||||
class TcDownlinkPwrOn : public TcBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = modeCheck(*commandData);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = laneRateCheck(*(commandData + 1));
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
|
||||
sizeof(MAX_AMPLITUDE));
|
||||
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DWLPWRON_CMD;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Received command has invalid JESD mode (valid modes are 0 - 5)
|
||||
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0xE0);
|
||||
//! [EXPORT] : [COMMENT] Received command has invalid lane rate (valid lane rate are 0 - 9)
|
||||
static const ReturnValue_t INVALID_LANE_RATE = MAKE_RETURN_CODE(0xE1);
|
||||
|
||||
static const size_t COMMAND_DATA_LENGTH = 2;
|
||||
static const uint8_t MAX_MODE = 5;
|
||||
static const uint8_t MAX_LANE_RATE = 9;
|
||||
static const uint16_t MAX_AMPLITUDE = 0;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen != COMMAND_DATA_LENGTH) {
|
||||
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t modeCheck(uint8_t mode) {
|
||||
if (mode > MAX_MODE) {
|
||||
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
|
||||
return INVALID_MODE;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t laneRateCheck(uint8_t laneRate) {
|
||||
if (laneRate > MAX_LANE_RATE) {
|
||||
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
|
||||
return INVALID_LANE_RATE;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build replay stop space packet.
|
||||
*/
|
||||
class TcDownlinkPwrOff : public TcBase {
|
||||
public:
|
||||
TcDownlinkPwrOff(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to build the replay start command.
|
||||
*/
|
||||
class TcReplayWriteSeq : public TcBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcReplayWriteSeq(uint16_t sequenceCount)
|
||||
: TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
*(this->localData.fields.buffer + commandDataLen) = NULL_TERMINATOR;
|
||||
this->setPacketDataLength(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static const size_t USE_DECODING_LENGTH = 1;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE) {
|
||||
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
|
||||
<< std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
||||
public:
|
||||
FlashWritePusCmd(){};
|
||||
|
||||
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
obcFile = std::string(reinterpret_cast<const char*>(commandData));
|
||||
if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR));
|
||||
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
|
||||
return MPSOC_FILENAME_TOO_LONG;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
std::string getObcFile() { return obcFile; }
|
||||
|
||||
std::string getMPSoCFile() { return mpsocFile; }
|
||||
|
||||
private:
|
||||
static const size_t SIZE_NULL_TERMINATOR = 1;
|
||||
std::string obcFile = "";
|
||||
std::string mpsocFile = "";
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build replay stop space packet.
|
||||
*/
|
||||
class TcModeReplay : public TcBase {
|
||||
public:
|
||||
TcModeReplay(uint16_t sequenceCount) : TcBase(apid::TC_MODE_REPLAY, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = addCrc();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mpsoc
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|
28
linux/devices/devicedefinitions/PlocMemDumpDefinitions.h
Normal file
28
linux/devices/devicedefinitions/PlocMemDumpDefinitions.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_
|
||||
#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_
|
||||
|
||||
#include <fsfw/src/fsfw/serialize/SerialLinkedListAdapter.h>
|
||||
|
||||
class MemoryParams : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param startAddress Start of address range to dump
|
||||
* @param endAddress End of address range to dump
|
||||
*/
|
||||
MemoryParams(uint32_t startAddress, uint32_t endAddress)
|
||||
: startAddress(startAddress), endAddress(endAddress) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&startAddress);
|
||||
startAddress.setNext(&endAddress);
|
||||
}
|
||||
|
||||
SerializeElement<uint32_t> startAddress;
|
||||
SerializeElement<uint32_t> endAddress;
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */
|
1546
linux/devices/devicedefinitions/PlocSupervisorDefinitions.h
Normal file
1546
linux/devices/devicedefinitions/PlocSupervisorDefinitions.h
Normal file
File diff suppressed because it is too large
Load Diff
7
linux/devices/ploc/CMakeLists.txt
Normal file
7
linux/devices/ploc/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
target_sources(${OBSW_NAME} PRIVATE
|
||||
PlocSupervisorHandler.cpp
|
||||
PlocUpdater.cpp
|
||||
PlocMemoryDumper.cpp
|
||||
PlocMPSoCHandler.cpp
|
||||
PlocMPSoCHelper.cpp
|
||||
)
|
881
linux/devices/ploc/PlocMPSoCHandler.cpp
Normal file
881
linux/devices/ploc/PlocMPSoCHandler.cpp
Normal file
@ -0,0 +1,881 @@
|
||||
#include "PlocMPSoCHandler.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
|
||||
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
|
||||
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
||||
plocMPSoCHelper(plocMPSoCHelper),
|
||||
uartIsolatorSwitch(uartIsolatorSwitch),
|
||||
supervisorHandler(supervisorHandler),
|
||||
commandActionHelper(this) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
|
||||
}
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
commandActionHelperQueue =
|
||||
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
}
|
||||
|
||||
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = DeviceHandlerBase::initialize();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uartComIf = dynamic_cast<UartComIF*>(communicationInterface);
|
||||
if (uartComIf == nullptr) {
|
||||
sif::warning << "PlocMPSoCHandler::initialize: Invalid uart com if" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PlocMPSoCHandler::initialize: Invalid event manager" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
;
|
||||
}
|
||||
result = manager->registerListener(eventQueue->getId());
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = manager->subscribeToEventRange(
|
||||
eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED),
|
||||
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
|
||||
" ploc mpsoc helper"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
result = plocMPSoCHelper->setComIF(communicationInterface);
|
||||
if (result != RETURN_OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
plocMPSoCHelper->setComCookie(comCookie);
|
||||
plocMPSoCHelper->setSequenceCount(&sequenceCount);
|
||||
result = commandActionHelper.initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::performOperationHook() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
switch (event.getMessageId()) {
|
||||
case EventMessage::EVENT_MESSAGE:
|
||||
handleEvent(&event);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::performOperationHook: Did not subscribe to this event"
|
||||
<< " message" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CommandMessage message;
|
||||
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message);
|
||||
result == RETURN_OK; result = commandActionHelperQueue->receiveMessage(&message)) {
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
if (plocMPSoCHelperExecuting) {
|
||||
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
case mpsoc::TC_FLASHWRITE: {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsoc::FlashWritePusCmd flashWritePusCmd;
|
||||
result = flashWritePusCmd.extractFields(data, size);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
|
||||
flashWritePusCmd.getMPSoCFile());
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
plocMPSoCHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (mpsoc::OBSW_RESET_SEQ_COUNT): {
|
||||
sequenceCount = 0;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doStartUp() {
|
||||
switch (powerState) {
|
||||
case PowerState::OFF:
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
|
||||
powerState = PowerState::BOOTING;
|
||||
break;
|
||||
case PowerState::ON:
|
||||
setMode(_MODE_TO_ON);
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doShutDown() {
|
||||
switch (powerState) {
|
||||
case PowerState::ON:
|
||||
uartIsolatorSwitch.pullLow();
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
powerState = PowerState::SHUTDOWN;
|
||||
break;
|
||||
case PowerState::OFF:
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
switch (deviceCommand) {
|
||||
case (mpsoc::TC_MEM_WRITE): {
|
||||
result = prepareTcMemWrite(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_MEM_READ): {
|
||||
result = prepareTcMemRead(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_FLASHDELETE): {
|
||||
result = prepareTcFlashDelete(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_REPLAY_START): {
|
||||
result = prepareTcReplayStart(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_REPLAY_STOP): {
|
||||
result = prepareTcReplayStop();
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_DOWNLINK_PWR_ON): {
|
||||
result = prepareTcDownlinkPwrOn(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_DOWNLINK_PWR_OFF): {
|
||||
result = prepareTcDownlinkPwrOff();
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_REPLAY_WRITE_SEQUENCE): {
|
||||
result = prepareTcReplayWriteSequence(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_MODE_REPLAY): {
|
||||
result = prepareTcModeReplay();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
|
||||
<< std::endl;
|
||||
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == RETURN_OK) {
|
||||
/**
|
||||
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
|
||||
*/
|
||||
uartComIf->flushUartRxBuffer(comCookie);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
|
||||
this->insertInCommandMap(mpsoc::TC_MEM_READ);
|
||||
this->insertInCommandMap(mpsoc::TC_FLASHDELETE);
|
||||
this->insertInCommandMap(mpsoc::TC_REPLAY_START);
|
||||
this->insertInCommandMap(mpsoc::TC_REPLAY_STOP);
|
||||
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_ON);
|
||||
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_OFF);
|
||||
this->insertInCommandMap(mpsoc::TC_REPLAY_WRITE_SEQUENCE);
|
||||
this->insertInCommandMap(mpsoc::TC_MODE_REPLAY);
|
||||
this->insertInReplyMap(mpsoc::ACK_REPORT, 1, nullptr, mpsoc::SIZE_ACK_REPORT);
|
||||
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
|
||||
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
|
||||
|
||||
switch (apid) {
|
||||
case (mpsoc::apid::ACK_SUCCESS):
|
||||
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||
*foundId = mpsoc::ACK_REPORT;
|
||||
break;
|
||||
case (mpsoc::apid::ACK_FAILURE):
|
||||
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||
*foundId = mpsoc::ACK_REPORT;
|
||||
break;
|
||||
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
|
||||
*foundLen = tmMemReadReport.rememberRequestedSize;
|
||||
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||
break;
|
||||
case (mpsoc::apid::EXE_SUCCESS):
|
||||
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||
*foundId = mpsoc::EXE_REPORT;
|
||||
break;
|
||||
case (mpsoc::apid::EXE_FAILURE):
|
||||
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||
*foundId = mpsoc::EXE_REPORT;
|
||||
break;
|
||||
default: {
|
||||
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
|
||||
*foundLen = remainingSize;
|
||||
return MPSoCReturnValuesIF::INVALID_APID;
|
||||
}
|
||||
}
|
||||
sequenceCount++;
|
||||
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
if (recvSeqCnt != sequenceCount) {
|
||||
triggerEvent(MPSOC_HANDLER_SEQ_CNT_MISMATCH, sequenceCount, recvSeqCnt);
|
||||
sequenceCount = recvSeqCnt;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
switch (id) {
|
||||
case mpsoc::ACK_REPORT: {
|
||||
result = handleAckReport(packet);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TM_MEMORY_READ_REPORT): {
|
||||
result = handleMemoryReadReport(packet);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::EXE_REPORT): {
|
||||
result = handleExecutionReport(packet);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
|
||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; }
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
||||
object_id_t objectId = eventMessage->getReporter();
|
||||
switch (objectId) {
|
||||
case objects::PLOC_MPSOC_HELPER: {
|
||||
plocMPSoCHelperExecuting = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcMemWrite tcMemWrite(sequenceCount);
|
||||
result = tcMemWrite.createPacket(commandData, commandDataLen);
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcMemWrite);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcMemRead tcMemRead(sequenceCount);
|
||||
result = tcMemRead.createPacket(commandData, commandDataLen);
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcMemRead);
|
||||
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return MPSoCReturnValuesIF::NAME_TOO_LONG;
|
||||
}
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcFlashDelete tcFlashDelete(sequenceCount);
|
||||
result = tcFlashDelete.createPacket(
|
||||
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcFlashDelete);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
|
||||
result = tcReplayStart.createPacket(commandData, commandDataLen);
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcReplayStart);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcReplayStop tcReplayStop(sequenceCount);
|
||||
result = tcReplayStop.createPacket();
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcReplayStop);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
|
||||
result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcDownlinkPwrOn);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(sequenceCount);
|
||||
result = tcDownlinkPwrOff.createPacket();
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcDownlinkPwrOff);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(sequenceCount);
|
||||
result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
copyToCommandBuffer(&tcReplayWriteSeq);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
mpsoc::TcModeReplay tcModeReplay(sequenceCount);
|
||||
result = tcModeReplay.createPacket();
|
||||
if (result != RETURN_OK) {
|
||||
sequenceCount--;
|
||||
return result;
|
||||
}
|
||||
memcpy(commandBuffer, tcModeReplay.getWholeData(), tcModeReplay.getFullSize());
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = tcModeReplay.getFullSize();
|
||||
nextReplyId = mpsoc::ACK_REPORT;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
|
||||
if (tc == nullptr) {
|
||||
sif::debug << "PlocMPSoCHandler::copyToCommandBuffer: Invalid TC" << std::endl;
|
||||
}
|
||||
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = tc->getFullSize();
|
||||
nextReplyId = mpsoc::ACK_REPORT;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
||||
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
||||
if (receivedCrc != recalculatedCrc) {
|
||||
return MPSoCReturnValuesIF::CRC_FAILURE;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
||||
nextReplyId = mpsoc::NONE;
|
||||
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
||||
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
||||
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
|
||||
disableAllReplies();
|
||||
return IGNORE_REPLY_DATA;
|
||||
}
|
||||
|
||||
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||
|
||||
switch (apid) {
|
||||
case mpsoc::apid::ACK_FAILURE: {
|
||||
// TODO: Interpretation of status field in acknowledgment report
|
||||
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
uint16_t status = getStatus(data);
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(ACK_FAILURE, commandId, status);
|
||||
}
|
||||
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::RECEIVED_ACK_FAILURE);
|
||||
disableAllReplies();
|
||||
nextReplyId = mpsoc::NONE;
|
||||
result = IGNORE_REPLY_DATA;
|
||||
break;
|
||||
}
|
||||
case mpsoc::apid::ACK_SUCCESS: {
|
||||
setNextReplyId();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
|
||||
result = RETURN_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
|
||||
nextReplyId = mpsoc::NONE;
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||
|
||||
switch (apid) {
|
||||
case (mpsoc::apid::EXE_SUCCESS): {
|
||||
break;
|
||||
}
|
||||
case (mpsoc::apid::EXE_FAILURE): {
|
||||
// TODO: Interpretation of status field in execution report
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
|
||||
<< std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
uint16_t status = getStatus(data);
|
||||
triggerEvent(EXE_FAILURE, commandId, status);
|
||||
} else {
|
||||
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
||||
}
|
||||
printStatus(data);
|
||||
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
disableExeReportReply();
|
||||
result = IGNORE_REPLY_DATA;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
|
||||
result = RETURN_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextReplyId = mpsoc::NONE;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
|
||||
<< std::endl;
|
||||
}
|
||||
uint16_t memLen =
|
||||
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
|
||||
/** Send data to commanding queue */
|
||||
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
|
||||
mpsoc::TM_MEMORY_READ_REPORT);
|
||||
nextReplyId = mpsoc::EXE_REPORT;
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies, bool useAlternateId,
|
||||
DeviceCommandId_t alternateReplyID) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
uint8_t enabledReplies = 0;
|
||||
|
||||
switch (command->first) {
|
||||
case mpsoc::TC_MEM_WRITE:
|
||||
case mpsoc::TC_FLASHDELETE:
|
||||
case mpsoc::TC_REPLAY_START:
|
||||
case mpsoc::TC_REPLAY_STOP:
|
||||
case mpsoc::TC_DOWNLINK_PWR_ON:
|
||||
case mpsoc::TC_DOWNLINK_PWR_OFF:
|
||||
case mpsoc::TC_REPLAY_WRITE_SEQUENCE:
|
||||
case mpsoc::TC_MODE_REPLAY:
|
||||
enabledReplies = 2;
|
||||
break;
|
||||
case mpsoc::TC_MEM_READ: {
|
||||
enabledReplies = 3;
|
||||
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
||||
mpsoc::TM_MEMORY_READ_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case mpsoc::OBSW_RESET_SEQ_COUNT:
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every command causes at least one acknowledgment and one execution report. Therefore both
|
||||
* replies will be enabled here.
|
||||
*/
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::ACK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
|
||||
<< " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::EXE_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
|
||||
<< " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
switch (command->first) {
|
||||
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||
// Overwrite delay cycles because replay write sequence command can required up to
|
||||
// 30 seconds for execution
|
||||
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
|
||||
break;
|
||||
}
|
||||
case mpsoc::TC_DOWNLINK_PWR_ON: {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||
//
|
||||
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::setNextReplyId() {
|
||||
switch (getPendingCommand()) {
|
||||
case mpsoc::TC_MEM_READ:
|
||||
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||
break;
|
||||
default:
|
||||
/* If no telemetry is expected the next reply is always the execution report */
|
||||
nextReplyId = mpsoc::EXE_REPORT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
size_t replyLen = 0;
|
||||
|
||||
if (nextReplyId == mpsoc::NONE) {
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
|
||||
|
||||
if (iter != deviceReplyMap.end()) {
|
||||
if (iter->second.delayCycles == 0) {
|
||||
/* Reply inactive */
|
||||
return replyLen;
|
||||
}
|
||||
switch (nextReplyId) {
|
||||
case mpsoc::TM_MEMORY_READ_REPORT: {
|
||||
replyLen = tmMemReadReport.rememberRequestedSize;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
replyLen = iter->second.replyLen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
|
||||
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
|
||||
}
|
||||
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||
|
||||
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
||||
|
||||
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
switch (actionId) {
|
||||
case supv::START_MPSOC:
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
case supv::SHUTDOWN_MPSOC:
|
||||
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl;
|
||||
// TODO: Setting state to on or off here?
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
if (actionId != supv::EXE_REPORT) {
|
||||
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
||||
<< "ID" << std::endl;
|
||||
return;
|
||||
}
|
||||
switch (powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
case PowerState::SHUTDOWN: {
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
DeviceCommandId_t replyId) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
if (wiretappingMode == RAW) {
|
||||
/* Data already sent in doGetRead() */
|
||||
return;
|
||||
}
|
||||
|
||||
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl;
|
||||
return;
|
||||
}
|
||||
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
||||
|
||||
if (queueId == NO_COMMANDER) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = actionHelper.reportData(queueId, replyId, data, dataSize);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::disableAllReplies() {
|
||||
DeviceReplyMap::iterator iter;
|
||||
|
||||
/* Disable ack reply */
|
||||
iter = deviceReplyMap.find(mpsoc::ACK_REPORT);
|
||||
DeviceReplyInfo* info = &(iter->second);
|
||||
info->delayCycles = 0;
|
||||
info->command = deviceCommandMap.end();
|
||||
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
|
||||
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
|
||||
switch (commandId) {
|
||||
case mpsoc::TC_MEM_WRITE:
|
||||
break;
|
||||
case mpsoc::TC_MEM_READ: {
|
||||
iter = deviceReplyMap.find(mpsoc::TM_MEMORY_READ_REPORT);
|
||||
info = &(iter->second);
|
||||
info->delayCycles = 0;
|
||||
info->command = deviceCommandMap.end();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* We always need to disable the execution report reply here */
|
||||
disableExeReportReply();
|
||||
nextReplyId = mpsoc::NONE;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(replyId);
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
|
||||
return;
|
||||
}
|
||||
DeviceCommandInfo* info = &(iter->second.command->second);
|
||||
if (info == nullptr) {
|
||||
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl;
|
||||
return;
|
||||
}
|
||||
if (info->sendReplyTo != NO_COMMANDER) {
|
||||
actionHelper.finish(false, info->sendReplyTo, iter->first, status);
|
||||
}
|
||||
info->isExecuting = false;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::disableExeReportReply() {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||
DeviceReplyInfo* info = &(iter->second);
|
||||
info->delayCycles = 0;
|
||||
info->command = deviceCommandMap.end();
|
||||
/* Expected replies is set to one here. The value will be set to 0 in replyToReply() */
|
||||
info->command->second.expectedReplies = 0;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::printStatus(const uint8_t* data) {
|
||||
uint16_t status = *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
|
||||
sif::info << "Verification report status: 0x" << std::hex << status << std::endl;
|
||||
}
|
||||
|
||||
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
|
||||
return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
switch (actionId) {
|
||||
case supv::ACK_REPORT:
|
||||
case supv::EXE_REPORT:
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID "
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
switch (powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
}
|
||||
case PowerState::SHUTDOWN: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
246
linux/devices/ploc/PlocMPSoCHandler.h
Normal file
246
linux/devices/ploc/PlocMPSoCHandler.h
Normal file
@ -0,0 +1,246 @@
|
||||
#ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
|
||||
#define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "PlocMPSoCHelper.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/CommandsActionsIF.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||
#include "fsfw_hal/linux/gpio/Gpio.h"
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
|
||||
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the MPSoC of the payload computer.
|
||||
*
|
||||
* @details The PLOC uses the space packet protocol for communication. Each command will be
|
||||
* answered with at least one acknowledgment and one execution report.
|
||||
* Flight manual:
|
||||
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_MPSoC ICD:
|
||||
* https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_TAS-ILH-IRS/ICD-PLOC/ILH&fileid=1030263
|
||||
*
|
||||
* @note The sequence count in the space packets must be incremented with each received and sent
|
||||
* packet otherwise the MPSoC will reply with an acknowledgment failure report.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param ojectId Object ID of the MPSoC handler
|
||||
* @param uartcomIFid Object ID of the UART communication interface
|
||||
* @param comCookie UART communication cookie
|
||||
* @param plocMPSoCHelper Pointer to MPSoC helper object
|
||||
* @param uartIsolatorSwitch Gpio object representing the GPIO connected to the UART isolator
|
||||
* module in the programmable logic
|
||||
* @param supervisorHandler Object ID of the supervisor handler
|
||||
*/
|
||||
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
|
||||
PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch,
|
||||
object_id_t supervisorHandler);
|
||||
virtual ~PlocMPSoCHandler();
|
||||
virtual ReturnValue_t initialize() override;
|
||||
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) override;
|
||||
void performOperationHook() override;
|
||||
MessageQueueIF* getCommandQueuePtr() override;
|
||||
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
|
||||
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
|
||||
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
||||
void completionSuccessfulReceived(ActionId_t actionId) override;
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
|
||||
protected:
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||
size_t* foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies = 1, bool useAlternateId = false,
|
||||
DeviceCommandId_t alternateReplyID = 0) override;
|
||||
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
|
||||
|
||||
private:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] PLOC crc failure in telemetry packet
|
||||
static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC receive acknowledgment failure report
|
||||
//! P1: Command Id which leads the acknowledgment failure report
|
||||
//! P2: The status field inserted by the MPSoC into the data field
|
||||
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC receive execution failure report
|
||||
//! P1: Command Id which leads the execution failure report
|
||||
//! P2: The status field inserted by the MPSoC into the data field
|
||||
static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC reply has invalid crc
|
||||
static const Event MPSOC_HANDLER_CRC_FAILURE = MAKE_EVENT(4, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Packet sequence count in received space packet does not match expected
|
||||
//! count P1: Expected sequence count P2: Received sequence count
|
||||
static const Event MPSOC_HANDLER_SEQ_CNT_MISMATCH = MAKE_EVENT(5, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and
|
||||
//! thus also to shutdown the supervisor.
|
||||
static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH);
|
||||
|
||||
static const uint16_t APID_MASK = 0x7FF;
|
||||
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
|
||||
static const uint8_t STATUS_OFFSET = 10;
|
||||
|
||||
MessageQueueIF* eventQueue = nullptr;
|
||||
MessageQueueIF* commandActionHelperQueue = nullptr;
|
||||
|
||||
SourceSequenceCounter sequenceCount;
|
||||
|
||||
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
|
||||
|
||||
/**
|
||||
* This variable is used to store the id of the next reply to receive. This is necessary
|
||||
* because the PLOC sends as reply to each command at least one acknowledgment and execution
|
||||
* report.
|
||||
*/
|
||||
DeviceCommandId_t nextReplyId = mpsoc::NONE;
|
||||
|
||||
UartComIF* uartComIf = nullptr;
|
||||
|
||||
PlocMPSoCHelper* plocMPSoCHelper = nullptr;
|
||||
Gpio uartIsolatorSwitch;
|
||||
object_id_t supervisorHandler = 0;
|
||||
CommandActionHelper commandActionHelper;
|
||||
|
||||
// Used to block incoming commands when MPSoC helper class is currently executing a command
|
||||
bool plocMPSoCHelperExecuting = false;
|
||||
|
||||
class TmMemReadReport {
|
||||
public:
|
||||
static const uint8_t FIX_SIZE = 14;
|
||||
size_t rememberRequestedSize = 0;
|
||||
};
|
||||
|
||||
TmMemReadReport tmMemReadReport;
|
||||
|
||||
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
|
||||
|
||||
PowerState powerState = PowerState::OFF;
|
||||
|
||||
/**
|
||||
* @brief Handles events received from the PLOC MPSoC helper
|
||||
*/
|
||||
void handleEvent(EventMessage* eventMessage);
|
||||
|
||||
ReturnValue_t prepareTcMemWrite(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcMemRead(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcFlashDelete(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcReplayStart(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcReplayStop();
|
||||
ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcDownlinkPwrOff();
|
||||
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief Copies space packet into command buffer
|
||||
*/
|
||||
void copyToCommandBuffer(mpsoc::TcBase* tc);
|
||||
|
||||
/**
|
||||
* @brief This function checks the crc of the received PLOC reply.
|
||||
*
|
||||
* @param start Pointer to the first byte of the reply.
|
||||
* @param foundLen Pointer to the length of the whole packet.
|
||||
*
|
||||
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
|
||||
*/
|
||||
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
|
||||
|
||||
/**
|
||||
* @brief This function handles the acknowledgment report.
|
||||
*
|
||||
* @param data Pointer to the data holding the acknowledgment report.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleAckReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief This function handles the data of a execution report.
|
||||
*
|
||||
* @param data Pointer to the received data packet.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleExecutionReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief This function handles the memory read report.
|
||||
*
|
||||
* @param data Pointer to the data buffer holding the memory read report.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleMemoryReadReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief Depending on the current active command, this function sets the reply id of the
|
||||
* next reply after a successful acknowledgment report has been received. This is
|
||||
* required by the function getNextReplyLength() to identify the length of the next
|
||||
* reply to read.
|
||||
*/
|
||||
void setNextReplyId();
|
||||
|
||||
/**
|
||||
* @brief This function handles action message replies in case the telemetry has been
|
||||
* requested by another object.
|
||||
*
|
||||
* @param data Pointer to the telemetry data.
|
||||
* @param dataSize Size of telemetry in bytes.
|
||||
* @param replyId Id of the reply. This will be added to the ActionMessage.
|
||||
*/
|
||||
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
|
||||
|
||||
/**
|
||||
* @brief In case an acknowledgment failure reply has been received this function disables
|
||||
* all previously enabled commands and resets the exepected replies variable of an
|
||||
* active command.
|
||||
*/
|
||||
void disableAllReplies();
|
||||
|
||||
/**
|
||||
* @brief This function sends a failure report if the active action was commanded by an other
|
||||
* object.
|
||||
*
|
||||
* @param replyId The id of the reply which signals a failure.
|
||||
* @param status A status byte which gives information about the failure type.
|
||||
*/
|
||||
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
|
||||
|
||||
/**
|
||||
* @brief This function disables the execution report reply. Within this function also the
|
||||
* the variable expectedReplies of an active command will be set to 0.
|
||||
*/
|
||||
void disableExeReportReply();
|
||||
|
||||
void printStatus(const uint8_t* data);
|
||||
|
||||
ReturnValue_t prepareTcModeReplay();
|
||||
|
||||
uint16_t getStatus(const uint8_t* data);
|
||||
|
||||
void handleActionCommandFailure(ActionId_t actionId);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */
|
321
linux/devices/ploc/PlocMPSoCHelper.cpp
Normal file
321
linux/devices/ploc/PlocMPSoCHelper.cpp
Normal file
@ -0,0 +1,321 @@
|
||||
#include "PlocMPSoCHelper.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "bsp_q7s/memory/FilesystemHelper.h"
|
||||
#endif
|
||||
|
||||
#include "mission/utility/Timestamp.h"
|
||||
|
||||
PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) {}
|
||||
|
||||
PlocMPSoCHelper::~PlocMPSoCHelper() {}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::initialize() {
|
||||
#ifdef XIPHOS_Q7S
|
||||
sdcMan = SdCardManager::instance();
|
||||
if (sdcMan == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid SD Card Manager" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
#endif
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
semaphore.acquire();
|
||||
while (true) {
|
||||
switch (internalState) {
|
||||
case InternalState::IDLE: {
|
||||
semaphore.acquire();
|
||||
break;
|
||||
}
|
||||
case InternalState::FLASH_WRITE: {
|
||||
result = performFlashWrite();
|
||||
if (result == RETURN_OK) {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL);
|
||||
} else {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHelper::performOperation: Invalid state" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInterface_) {
|
||||
uartComIF = dynamic_cast<UartComIF*>(communicationInterface_);
|
||||
if (uartComIF == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
|
||||
void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||
sequenceCount = sequenceCount_;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
#ifdef XIPHOS_Q7S
|
||||
result = FilesystemHelper::checkPath(obcFile);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = FilesystemHelper::fileExists(mpsocFile);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#ifdef TE0720_1CFA
|
||||
if (not std::filesystem::exists(obcFile)) {
|
||||
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
|
||||
<< std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
#endif
|
||||
|
||||
flashWrite.obcFile = obcFile;
|
||||
flashWrite.mpsocFile = mpsocFile;
|
||||
internalState = InternalState::FLASH_WRITE;
|
||||
result = resetHelper();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::resetHelper() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
semaphore.release();
|
||||
terminate = false;
|
||||
result = uartComIF->flushUartRxBuffer(comCookie);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::stopProcess() { terminate = true; }
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = flashfopen();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
||||
std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
|
||||
// Set position of next character to end of file input stream
|
||||
file.seekg(0, file.end);
|
||||
// tellg returns position of character in input stream
|
||||
size_t remainingSize = file.tellg();
|
||||
size_t dataLength = 0;
|
||||
size_t bytesRead = 0;
|
||||
while (remainingSize > 0) {
|
||||
if (terminate) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
if (remainingSize > mpsoc::MAX_DATA_SIZE) {
|
||||
dataLength = mpsoc::MAX_DATA_SIZE;
|
||||
} else {
|
||||
dataLength = remainingSize;
|
||||
}
|
||||
if (file.is_open()) {
|
||||
file.seekg(bytesRead, file.beg);
|
||||
file.read(reinterpret_cast<char*>(tempData), dataLength);
|
||||
bytesRead += dataLength;
|
||||
remainingSize -= dataLength;
|
||||
} else {
|
||||
return FILE_CLOSED_ACCIDENTALLY;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
mpsoc::TcFlashWrite tc(*sequenceCount);
|
||||
tc.createPacket(tempData, dataLength);
|
||||
result = handlePacketTransmission(tc);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result = flashfclose();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFopen flashFopen(*sequenceCount);
|
||||
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(flashFopen);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFclose flashFclose(*sequenceCount);
|
||||
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(flashFclose);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(mpsoc::TcBase& tc) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = sendCommand(tc);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleAck();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleExe();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::sendCommand(mpsoc::TcBase& tc) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = uartComIF->sendMessage(comCookie, tc.getWholeData(), tc.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
|
||||
triggerEvent(SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleAck() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
mpsoc::TmPacket tmPacket;
|
||||
result = handleTmReception(&tmPacket, mpsoc::SIZE_ACK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getAPID();
|
||||
if (apid != mpsoc::apid::ACK_SUCCESS) {
|
||||
handleAckApidFailure(apid);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
|
||||
if (apid == mpsoc::apid::ACK_FAILURE) {
|
||||
triggerEvent(ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure "
|
||||
<< "report" << std::endl;
|
||||
} else {
|
||||
triggerEvent(ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleExe() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
mpsoc::TmPacket tmPacket;
|
||||
result = handleTmReception(&tmPacket, mpsoc::SIZE_EXE_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getAPID();
|
||||
if (apid != mpsoc::apid::EXE_SUCCESS) {
|
||||
handleExeApidFailure(apid);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) {
|
||||
if (apid == mpsoc::apid::EXE_FAILURE) {
|
||||
triggerEvent(EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure "
|
||||
<< "report" << std::endl;
|
||||
} else {
|
||||
triggerEvent(EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
size_t readBytes = 0;
|
||||
size_t currentBytes = 0;
|
||||
for (int retries = 0; retries < RETRIES; retries++) {
|
||||
result = receive(tmPacket->getWholeData() + readBytes, ¤tBytes, remainingBytes);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
readBytes += currentBytes;
|
||||
remainingBytes = remainingBytes - currentBytes;
|
||||
if (remainingBytes == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (remainingBytes != 0) {
|
||||
sif::warning << "PlocMPSoCHelper::handleTmReception: Failed to receive reply" << std::endl;
|
||||
triggerEvent(MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
result = tmPacket->checkCrc();
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl;
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
uint16_t recvSeqCnt = tmPacket->getPacketSequenceCount();
|
||||
if (recvSeqCnt != *sequenceCount) {
|
||||
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
|
||||
*sequenceCount = recvSeqCnt;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint8_t* buffer = nullptr;
|
||||
result = uartComIF->requestReceiveMessage(comCookie, requestBytes);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to request reply" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_REQUESTING_REPLY_FAILED, result,
|
||||
static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
result = uartComIF->readReceivedMessage(comCookie, &buffer, readBytes);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to read received message" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_READING_REPLY_FAILED, result, static_cast<uint32_t>(internalState));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
if (*readBytes > 0) {
|
||||
std::memcpy(data, buffer, *readBytes);
|
||||
}
|
||||
return result;
|
||||
}
|
153
linux/devices/ploc/PlocMPSoCHelper.h
Normal file
153
linux/devices/ploc/PlocMPSoCHelper.h
Normal file
@ -0,0 +1,153 @@
|
||||
#ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
|
||||
#define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/devicehandlers/CookieIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/osal/linux/BinarySemaphore.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Helper class for MPSoC of PLOC intended to accelerate large data transfers between
|
||||
* MPSoC and OBC.
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Flash write fails
|
||||
static const Event MPSOC_FLASH_WRITE_FAILED = MAKE_EVENT(0, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Flash write successful
|
||||
static const Event MPSOC_FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command
|
||||
//! ot the PLOC
|
||||
//! P1: Return value returned by the communication interface sendMessage function
|
||||
//! P2: Internal state of MPSoC helper
|
||||
static const Event SENDING_COMMAND_FAILED = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Request receive message of communication interface failed
|
||||
//! P1: Return value returned by the communication interface requestReceiveMessage function
|
||||
//! P2: Internal state of MPSoC helper
|
||||
static const Event MPSOC_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(3, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Reading receive message of communication interface failed
|
||||
//! P1: Return value returned by the communication interface readingReceivedMessage function
|
||||
//! P2: Internal state of MPSoC helper
|
||||
static const Event MPSOC_HELPER_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Did not receive acknowledgement report
|
||||
//! P1: Number of bytes missing
|
||||
//! P2: Internal state of MPSoC helper
|
||||
static const Event MISSING_ACK = MAKE_EVENT(5, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Did not receive execution report
|
||||
//! P1: Number of bytes missing
|
||||
//! P2: Internal state of MPSoC helper
|
||||
static const Event MISSING_EXE = MAKE_EVENT(6, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Received acknowledgement failure report
|
||||
//! P1: Internal state of MPSoC
|
||||
static const Event ACK_FAILURE_REPORT = MAKE_EVENT(7, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Received execution failure report
|
||||
//! P1: Internal state of MPSoC
|
||||
static const Event EXE_FAILURE_REPORT = MAKE_EVENT(8, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Expected acknowledgement report but received space packet with other apid
|
||||
//! P1: Apid of received space packet
|
||||
//! P2: Internal state of MPSoC
|
||||
static const Event ACK_INVALID_APID = MAKE_EVENT(9, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Expected execution report but received space packet with other apid
|
||||
//! P1: Apid of received space packet
|
||||
//! P2: Internal state of MPSoC
|
||||
static const Event EXE_INVALID_APID = MAKE_EVENT(10, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Received sequence count does not match expected sequence count
|
||||
//! P1: Expected sequence count
|
||||
//! P2: Received sequence count
|
||||
static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW);
|
||||
|
||||
PlocMPSoCHelper(object_id_t objectId);
|
||||
virtual ~PlocMPSoCHelper();
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_);
|
||||
void setComCookie(CookieIF* comCookie_);
|
||||
|
||||
/**
|
||||
* @brief Starts flash write sequence
|
||||
*
|
||||
* @param obcFile File where to read from the data
|
||||
* @param mpsocFile The file of the MPSoC where should be written to
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise error return value
|
||||
*/
|
||||
ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile);
|
||||
|
||||
/**
|
||||
* @brief Can be used to interrupt a running data transfer.
|
||||
*/
|
||||
void stopProcess();
|
||||
|
||||
/**
|
||||
* @brief Sets the sequence count object responsible for the sequence count handling
|
||||
*/
|
||||
void setSequenceCount(SourceSequenceCounter* sequenceCount_);
|
||||
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] File accidentally close
|
||||
static const ReturnValue_t FILE_CLOSED_ACCIDENTALLY = MAKE_RETURN_CODE(0xA0);
|
||||
|
||||
// Maximum number of times the communication interface retries polling data from the reply
|
||||
// buffer
|
||||
static const int RETRIES = 10000;
|
||||
|
||||
struct FlashWrite {
|
||||
std::string obcFile;
|
||||
std::string mpsocFile;
|
||||
};
|
||||
|
||||
struct FlashWrite flashWrite;
|
||||
|
||||
enum class InternalState { IDLE, FLASH_WRITE, FLASH_READ };
|
||||
|
||||
InternalState internalState = InternalState::IDLE;
|
||||
|
||||
BinarySemaphore semaphore;
|
||||
#ifdef XIPHOS_Q7S
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
#endif
|
||||
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
|
||||
|
||||
bool terminate = false;
|
||||
|
||||
/**
|
||||
* Communication interface of MPSoC responsible for low level access. Must be set by the
|
||||
* MPSoC Handler.
|
||||
*/
|
||||
UartComIF* uartComIF = nullptr;
|
||||
// Communication cookie. Must be set by the MPSoC Handler
|
||||
CookieIF* comCookie = nullptr;
|
||||
// Sequence count, must be set by Ploc MPSoC Handler
|
||||
SourceSequenceCounter* sequenceCount;
|
||||
|
||||
ReturnValue_t resetHelper();
|
||||
ReturnValue_t performFlashWrite();
|
||||
ReturnValue_t flashfopen();
|
||||
ReturnValue_t flashfclose();
|
||||
ReturnValue_t handlePacketTransmission(mpsoc::TcBase& tc);
|
||||
ReturnValue_t sendCommand(mpsoc::TcBase& tc);
|
||||
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
|
||||
ReturnValue_t handleAck();
|
||||
ReturnValue_t handleExe();
|
||||
void handleAckApidFailure(uint16_t apid);
|
||||
void handleExeApidFailure(uint16_t apid);
|
||||
ReturnValue_t handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */
|
194
linux/devices/ploc/PlocMemoryDumper.cpp
Normal file
194
linux/devices/ploc/PlocMemoryDumper.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
#include "PlocMemoryDumper.h"
|
||||
|
||||
#include <fsfw/src/fsfw/serialize/SerializeAdapter.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId)
|
||||
: SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
auto mqArgs = MqArgs(this->getObjectId());
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
}
|
||||
|
||||
PlocMemoryDumper::~PlocMemoryDumper() {}
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = commandActionHelper.initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = actionHelper.initialize(commandQueue);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) {
|
||||
readCommandQueue();
|
||||
doStateMachine();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
if (state != State::IDLE) {
|
||||
return IS_BUSY;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
case DUMP_MRAM: {
|
||||
size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress);
|
||||
SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (mram.endAddress > MAX_MRAM_ADDRESS) {
|
||||
return MRAM_ADDRESS_TOO_HIGH;
|
||||
}
|
||||
if (mram.endAddress <= mram.startAddress) {
|
||||
return MRAM_INVALID_ADDRESS_COMBINATION;
|
||||
}
|
||||
state = State::COMMAND_FIRST_MRAM_DUMP;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id"
|
||||
<< std::endl;
|
||||
return INVALID_ACTION_ID;
|
||||
}
|
||||
}
|
||||
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { return commandQueue->getId(); }
|
||||
|
||||
MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { return commandQueue; }
|
||||
|
||||
void PlocMemoryDumper::readCommandQueue() {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result;
|
||||
|
||||
for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&message)) {
|
||||
if (result != RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
result = actionHelper.handleActionMessage(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::doStateMachine() {
|
||||
switch (state) {
|
||||
case State::IDLE:
|
||||
break;
|
||||
case State::COMMAND_FIRST_MRAM_DUMP:
|
||||
commandNextMramDump(supv::FIRST_MRAM_DUMP);
|
||||
break;
|
||||
case State::COMMAND_CONSECUTIVE_MRAM_DUMP:
|
||||
commandNextMramDump(supv::CONSECUTIVE_MRAM_DUMP);
|
||||
break;
|
||||
case State::EXECUTING_MRAM_DUMP:
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
|
||||
|
||||
void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {}
|
||||
|
||||
void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {}
|
||||
|
||||
void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch (pendingCommand) {
|
||||
case (supv::FIRST_MRAM_DUMP):
|
||||
case (supv::CONSECUTIVE_MRAM_DUMP):
|
||||
if (mram.endAddress == mram.startAddress) {
|
||||
triggerEvent(MRAM_DUMP_FINISHED);
|
||||
state = State::IDLE;
|
||||
} else {
|
||||
state = State::COMMAND_CONSECUTIVE_MRAM_DUMP;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command"
|
||||
<< std::endl;
|
||||
state = State::IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
switch (pendingCommand) {
|
||||
case (supv::FIRST_MRAM_DUMP):
|
||||
case (supv::CONSECUTIVE_MRAM_DUMP):
|
||||
triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command "
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
state = State::IDLE;
|
||||
}
|
||||
|
||||
void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
uint32_t tempStartAddress = 0;
|
||||
uint32_t tempEndAddress = 0;
|
||||
|
||||
if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) {
|
||||
tempStartAddress = mram.startAddress;
|
||||
tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE;
|
||||
mram.startAddress += MAX_MRAM_DUMP_SIZE;
|
||||
mram.lastStartAddress = tempStartAddress;
|
||||
} else {
|
||||
tempStartAddress = mram.startAddress;
|
||||
tempEndAddress = mram.endAddress;
|
||||
mram.startAddress = mram.endAddress;
|
||||
}
|
||||
|
||||
MemoryParams params(tempStartAddress, tempEndAddress);
|
||||
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, dumpCommand, ¶ms);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command "
|
||||
<< "with start address " << tempStartAddress << " and end address "
|
||||
<< tempEndAddress << std::endl;
|
||||
triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress);
|
||||
state = State::IDLE;
|
||||
pendingCommand = NONE;
|
||||
return;
|
||||
}
|
||||
state = State::EXECUTING_MRAM_DUMP;
|
||||
pendingCommand = dumpCommand;
|
||||
return;
|
||||
}
|
114
linux/devices/ploc/PlocMemoryDumper.h
Normal file
114
linux/devices/ploc/PlocMemoryDumper.h
Normal file
@ -0,0 +1,114 @@
|
||||
#ifndef MISSION_DEVICES_PLOCMEMORYDUMPER_H_
|
||||
#define MISSION_DEVICES_PLOCMEMORYDUMPER_H_
|
||||
|
||||
#include <linux/devices/devicedefinitions/PlocMemDumpDefinitions.h>
|
||||
#include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "fsfw/action/ActionHelper.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/CommandsActionsIF.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
|
||||
/**
|
||||
* @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is
|
||||
* created to perform large dumps of PLOC memories.
|
||||
*
|
||||
* @details Currently the PLOC supervisor only implements the functionality to dump the MRAM.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocMemoryDumper : public SystemObject,
|
||||
public HasActionsIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasReturnvaluesIF,
|
||||
public CommandsActionsIF {
|
||||
public:
|
||||
static const ActionId_t NONE = 0;
|
||||
static const ActionId_t DUMP_MRAM = 1;
|
||||
|
||||
PlocMemoryDumper(object_id_t objectId);
|
||||
virtual ~PlocMemoryDumper();
|
||||
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size);
|
||||
MessageQueueId_t getCommandQueue() const;
|
||||
ReturnValue_t initialize() override;
|
||||
MessageQueueIF* getCommandQueuePtr() override;
|
||||
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
|
||||
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
|
||||
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
||||
void completionSuccessfulReceived(ActionId_t actionId) override;
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
|
||||
private:
|
||||
static const uint32_t QUEUE_SIZE = 10;
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must
|
||||
//! not be higher than 0x7d000.
|
||||
static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] The specified end address is lower than the start address
|
||||
static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1);
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler
|
||||
//! P1: Return value of commandAction function
|
||||
//! P2: Start address of MRAM to dump with this command
|
||||
static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler
|
||||
//! P1: MRAM start address of failing dump command
|
||||
static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] MRAM dump finished successfully
|
||||
static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW);
|
||||
|
||||
// Maximum size of mram dump which can be retrieved with one command
|
||||
static const uint32_t MAX_MRAM_DUMP_SIZE = 100000;
|
||||
static const uint32_t MAX_MRAM_ADDRESS = 0x7d000;
|
||||
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
|
||||
CommandActionHelper commandActionHelper;
|
||||
|
||||
ActionHelper actionHelper;
|
||||
|
||||
enum class State : uint8_t {
|
||||
IDLE,
|
||||
COMMAND_FIRST_MRAM_DUMP,
|
||||
COMMAND_CONSECUTIVE_MRAM_DUMP,
|
||||
EXECUTING_MRAM_DUMP
|
||||
};
|
||||
|
||||
State state = State::IDLE;
|
||||
|
||||
ActionId_t pendingCommand = NONE;
|
||||
|
||||
typedef struct MemoryInfo {
|
||||
// Stores the start address of the next memory range to dump
|
||||
uint32_t startAddress;
|
||||
uint32_t endAddress;
|
||||
// Stores the start address of the last sent dump command
|
||||
uint32_t lastStartAddress;
|
||||
} MemoryInfo_t;
|
||||
|
||||
MemoryInfo_t mram = {0, 0, 0};
|
||||
|
||||
void readCommandQueue();
|
||||
void doStateMachine();
|
||||
|
||||
/**
|
||||
* @brief Sends the next mram dump command to the PLOC supervisor handler.
|
||||
*/
|
||||
void commandNextMramDump(ActionId_t dumpCommand);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */
|
1518
linux/devices/ploc/PlocSupervisorHandler.cpp
Normal file
1518
linux/devices/ploc/PlocSupervisorHandler.cpp
Normal file
File diff suppressed because it is too large
Load Diff
353
linux/devices/ploc/PlocSupervisorHandler.h
Normal file
353
linux/devices/ploc/PlocSupervisorHandler.h
Normal file
@ -0,0 +1,353 @@
|
||||
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw_hal/linux/gpio/Gpio.h"
|
||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
|
||||
* Thales.
|
||||
*
|
||||
* @details The PLOC uses the space packet protocol for communication. To each command the PLOC
|
||||
* answers with at least one acknowledgment and one execution report.
|
||||
* Flight manual:
|
||||
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_Commands
|
||||
* ILH ICD: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/
|
||||
* Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocSupervisorHandler : public DeviceHandlerBase {
|
||||
public:
|
||||
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
|
||||
Gpio uartIsolatorSwitch, power::Switch_t powerSwitch);
|
||||
virtual ~PlocSupervisorHandler();
|
||||
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
||||
void fillCommandAndReplyMap() override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
|
||||
size_t* foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
||||
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies = 1, bool useAlternateId = false,
|
||||
DeviceCommandId_t alternateReplyID = 0) override;
|
||||
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
|
||||
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC
|
||||
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor
|
||||
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor
|
||||
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
|
||||
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor
|
||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
||||
//! [EXPORT] : [COMMENT] Failed to read current system time
|
||||
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0
|
||||
//! for PS, 1 for PL and 2 for INT
|
||||
static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA5);
|
||||
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid
|
||||
//! timeouts must be in the range between 1000 and 360000 ms.
|
||||
static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA6);
|
||||
//! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID
|
||||
static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA7);
|
||||
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be
|
||||
//! larger than 21.
|
||||
static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA8);
|
||||
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1
|
||||
//! and 2.
|
||||
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xA9);
|
||||
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
|
||||
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAA);
|
||||
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe
|
||||
//! commands are invalid (e.g. start address bigger than stop address)
|
||||
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAB);
|
||||
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with
|
||||
//! other apid.
|
||||
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAC);
|
||||
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
|
||||
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAD);
|
||||
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have
|
||||
//! been created with the reception of the first dump packet.
|
||||
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAE);
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet
|
||||
static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report
|
||||
static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC received execution failure report
|
||||
static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc
|
||||
static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW);
|
||||
|
||||
static const uint16_t APID_MASK = 0x7FF;
|
||||
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
|
||||
|
||||
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
|
||||
|
||||
/**
|
||||
* This variable is used to store the id of the next reply to receive. This is necessary
|
||||
* because the PLOC sends as reply to each command at least one acknowledgment and execution
|
||||
* report.
|
||||
*/
|
||||
DeviceCommandId_t nextReplyId = supv::NONE;
|
||||
|
||||
UartComIF* uartComIf = nullptr;
|
||||
LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
Gpio uartIsolatorSwitch;
|
||||
|
||||
supv::HkSet hkset;
|
||||
supv::BootStatusReport bootStatusReport;
|
||||
supv::LatchupStatusReport latchupStatusReport;
|
||||
|
||||
const power::Switch_t powerSwitch = power::NO_SWITCH;
|
||||
|
||||
/** Number of expected replies following the MRAM dump command */
|
||||
uint32_t expectedMramDumpPackets = 0;
|
||||
uint32_t receivedMramDumpPackets = 0;
|
||||
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
|
||||
bool packetInBuffer = false;
|
||||
/** Points to the next free position in the space packet buffer */
|
||||
uint16_t bufferTop = 0;
|
||||
|
||||
/** This buffer is used to concatenate space packets received in two different read steps */
|
||||
uint8_t spacePacketBuffer[supv::MAX_PACKET_SIZE];
|
||||
|
||||
#ifdef TE0720_1CFA
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
#endif /* BOARD_TE0720 == 0 */
|
||||
|
||||
/** Path to PLOC specific files on SD card */
|
||||
std::string plocFilePath = "ploc";
|
||||
std::string activeMramFile;
|
||||
|
||||
/** Setting this variable to true will enable direct downlink of MRAM packets */
|
||||
bool downlinkMramDump = false;
|
||||
|
||||
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches);
|
||||
|
||||
/**
|
||||
* @brief This function checks the crc of the received PLOC reply.
|
||||
*
|
||||
* @param start Pointer to the first byte of the reply.
|
||||
* @param foundLen Pointer to the length of the whole packet.
|
||||
*
|
||||
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
|
||||
*/
|
||||
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
|
||||
|
||||
/**
|
||||
* @brief This function handles the acknowledgment report.
|
||||
*
|
||||
* @param data Pointer to the data holding the acknowledgment report.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleAckReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief This function handles the data of a execution report.
|
||||
*
|
||||
* @param data Pointer to the received data packet.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleExecutionReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief This function handles the housekeeping report. This means verifying the CRC of the
|
||||
* reply and filling the appropriate dataset.
|
||||
*
|
||||
* @param data Pointer to the data buffer holding the housekeeping read report.
|
||||
*
|
||||
* @return RETURN_OK if successful, otherwise an error code.
|
||||
*/
|
||||
ReturnValue_t handleHkReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief This function calls the function to check the CRC of the received boot status report
|
||||
* and fills the associated dataset with the boot status information.
|
||||
*/
|
||||
ReturnValue_t handleBootStatusReport(const uint8_t* data);
|
||||
|
||||
ReturnValue_t handleLatchupStatusReport(const uint8_t* data);
|
||||
|
||||
/**
|
||||
* @brief Depending on the current active command, this function sets the reply id of the
|
||||
* next reply after a successful acknowledgment report has been received. This is
|
||||
* required by the function getNextReplyLength() to identify the length of the next
|
||||
* reply to read.
|
||||
*/
|
||||
void setNextReplyId();
|
||||
|
||||
/**
|
||||
* @brief This function handles action message replies in case the telemetry has been
|
||||
* requested by another object.
|
||||
*
|
||||
* @param data Pointer to the telemetry data.
|
||||
* @param dataSize Size of telemetry in bytes.
|
||||
* @param replyId Id of the reply. This will be added to the ActionMessage.
|
||||
*/
|
||||
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
|
||||
|
||||
/**
|
||||
* @brief This function prepares a space packet which does not transport any data in the
|
||||
* packet data field apart from the crc.
|
||||
*/
|
||||
void prepareEmptyCmd(uint16_t apid);
|
||||
|
||||
/**
|
||||
* @brief This function initializes the space packet to select the boot image of the MPSoC.
|
||||
*/
|
||||
void prepareSelBootImageCmd(const uint8_t* commandData);
|
||||
|
||||
void prepareDisableHk();
|
||||
|
||||
/**
|
||||
* @brief This function fills the commandBuffer with the data to update the time of the
|
||||
* PLOC supervisor.
|
||||
*/
|
||||
ReturnValue_t prepareSetTimeRefCmd();
|
||||
|
||||
/**
|
||||
* @brief This function fills the commandBuffer with the data to change the boot timeout
|
||||
* value in the PLOC supervisor.
|
||||
*/
|
||||
void prepareSetBootTimeoutCmd(const uint8_t* commandData);
|
||||
|
||||
void prepareRestartTriesCmd(const uint8_t* commandData);
|
||||
|
||||
/**
|
||||
* @brief This function fills the command buffer with the packet to enable or disable the
|
||||
* watchdogs on the PLOC.
|
||||
*/
|
||||
void prepareWatchdogsEnableCmd(const uint8_t* commandData);
|
||||
|
||||
/**
|
||||
* @brief This function fills the command buffer with the packet to set the watchdog timer
|
||||
* of one of the three watchdogs (PS, PL, INT).
|
||||
*/
|
||||
ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData);
|
||||
|
||||
ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData,
|
||||
DeviceCommandId_t deviceCommand);
|
||||
ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData);
|
||||
ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData);
|
||||
ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData);
|
||||
ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData);
|
||||
void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
|
||||
void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
|
||||
void prepareSetAdcThresholdCmd(const uint8_t* commandData);
|
||||
void prepareEnableNvmsCmd(const uint8_t* commandData);
|
||||
void prepareSelectNvmCmd(const uint8_t* commandData);
|
||||
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
|
||||
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
|
||||
ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData);
|
||||
void preparePrintCpuStatsCmd(const uint8_t* commandData);
|
||||
void prepareSetDbgVerbosityCmd(const uint8_t* commandData);
|
||||
void prepareSetGpioCmd(const uint8_t* commandData);
|
||||
void prepareReadGpioCmd(const uint8_t* commandData);
|
||||
|
||||
/**
|
||||
* @brief Copies the content of a space packet to the command buffer.
|
||||
*/
|
||||
void packetToOutBuffer(uint8_t* packetData, size_t fullSize);
|
||||
|
||||
/**
|
||||
* @brief In case an acknowledgment failure reply has been received this function disables
|
||||
* all previously enabled commands and resets the exepected replies variable of an
|
||||
* active command.
|
||||
*/
|
||||
void disableAllReplies();
|
||||
|
||||
/**
|
||||
* @brief This function sends a failure report if the active action was commanded by an other
|
||||
* object.
|
||||
*
|
||||
* @param replyId The id of the reply which signals a failure.
|
||||
* @param status A status byte which gives information about the failure type.
|
||||
*/
|
||||
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
|
||||
|
||||
/**
|
||||
* @brief This function disables the execution report reply. Within this function also the
|
||||
* the variable expectedReplies of an active command will be set to 0.
|
||||
*/
|
||||
void disableExeReportReply();
|
||||
|
||||
/**
|
||||
* @brief Function is called in scanForReply and fills the spacePacketBuffer with the read
|
||||
* data until a full packet has been received.
|
||||
*/
|
||||
ReturnValue_t parseMramPackets(const uint8_t* packet, size_t remainingSize, size_t* foundlen);
|
||||
|
||||
/**
|
||||
* @brief This function generates the Service 8 packets for the MRAM dump data.
|
||||
*/
|
||||
ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id);
|
||||
|
||||
/**
|
||||
* @brief With this function the number of expected replies following an MRAM dump command
|
||||
* will be increased. This is necessary to release the command in case not all replies
|
||||
* have been received.
|
||||
*/
|
||||
void increaseExpectedMramReplies(DeviceCommandId_t id);
|
||||
|
||||
/**
|
||||
* @brief Function checks if the packet written to the space packet buffer is really a
|
||||
* MRAM dump packet.
|
||||
*/
|
||||
ReturnValue_t checkMramPacketApid();
|
||||
|
||||
/**
|
||||
* @brief Writes the data of the MRAM dump to a file. The file will be created when receiving
|
||||
* the first packet.
|
||||
*/
|
||||
ReturnValue_t handleMramDumpFile(DeviceCommandId_t id);
|
||||
|
||||
/**
|
||||
* @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer.
|
||||
*
|
||||
* @param spacePacket Pointer to the buffer holding the space packet.
|
||||
*
|
||||
* @return The value stored in the length field of the data field.
|
||||
*/
|
||||
uint16_t readSpacePacketLength(uint8_t* spacePacket);
|
||||
|
||||
/**
|
||||
* @brief Extracts the sequence flags from a space packet referenced by the spacePacket
|
||||
* pointer.
|
||||
*
|
||||
* @param spacePacket Pointer to the buffer holding the space packet.
|
||||
*
|
||||
* @return uint8_t where the two least significant bits hold the sequence flags.
|
||||
*/
|
||||
uint8_t readSequenceFlags(uint8_t* spacePacket);
|
||||
|
||||
ReturnValue_t createMramDumpFile();
|
||||
ReturnValue_t getTimeStampString(std::string& timeStamp);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */
|
385
linux/devices/ploc/PlocUpdater.cpp
Normal file
385
linux/devices/ploc/PlocUpdater.cpp
Normal file
@ -0,0 +1,385 @@
|
||||
#include "PlocUpdater.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
PlocUpdater::PlocUpdater(object_id_t objectId)
|
||||
: SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
||||
auto mqArgs = MqArgs(this->getObjectId());
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
}
|
||||
|
||||
PlocUpdater::~PlocUpdater() {}
|
||||
|
||||
ReturnValue_t PlocUpdater::initialize() {
|
||||
#ifdef XIPHOS_Q7S
|
||||
sdcMan = SdCardManager::instance();
|
||||
#endif
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = commandActionHelper.initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = actionHelper.initialize(commandQueue);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) {
|
||||
readCommandQueue();
|
||||
doStateMachine();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
|
||||
if (state != State::IDLE) {
|
||||
return IS_BUSY;
|
||||
}
|
||||
|
||||
if (size > MAX_PLOC_UPDATE_PATH) {
|
||||
return NAME_TOO_LONG;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
case UPDATE_A_UBOOT:
|
||||
image = Image::A;
|
||||
partition = Partition::UBOOT;
|
||||
break;
|
||||
case UPDATE_A_BITSTREAM:
|
||||
image = Image::A;
|
||||
partition = Partition::BITSTREAM;
|
||||
break;
|
||||
case UPDATE_A_LINUX:
|
||||
image = Image::A;
|
||||
partition = Partition::LINUX_OS;
|
||||
break;
|
||||
case UPDATE_A_APP_SW:
|
||||
image = Image::A;
|
||||
partition = Partition::APP_SW;
|
||||
break;
|
||||
case UPDATE_B_UBOOT:
|
||||
image = Image::B;
|
||||
partition = Partition::UBOOT;
|
||||
break;
|
||||
case UPDATE_B_BITSTREAM:
|
||||
image = Image::B;
|
||||
partition = Partition::BITSTREAM;
|
||||
break;
|
||||
case UPDATE_B_LINUX:
|
||||
image = Image::B;
|
||||
partition = Partition::LINUX_OS;
|
||||
break;
|
||||
case UPDATE_B_APP_SW:
|
||||
image = Image::B;
|
||||
partition = Partition::APP_SW;
|
||||
break;
|
||||
default:
|
||||
return INVALID_ACTION_ID;
|
||||
}
|
||||
|
||||
result = getImageLocation(data, size);
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
state = State::UPDATE_AVAILABLE;
|
||||
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue->getId(); }
|
||||
|
||||
MessageQueueIF* PlocUpdater::getCommandQueuePtr() { return commandQueue; }
|
||||
|
||||
void PlocUpdater::readCommandQueue() {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result;
|
||||
|
||||
for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&message)) {
|
||||
if (result != RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
result = actionHelper.handleActionMessage(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlocUpdater::doStateMachine() {
|
||||
switch (state) {
|
||||
case State::IDLE:
|
||||
break;
|
||||
case State::UPDATE_AVAILABLE:
|
||||
commandUpdateAvailable();
|
||||
break;
|
||||
case State::UPDATE_TRANSFER:
|
||||
commandUpdatePacket();
|
||||
break;
|
||||
case State::UPDATE_VERIFY:
|
||||
commandUpdateVerify();
|
||||
break;
|
||||
case State::COMMAND_EXECUTING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::checkNameLength(size_t size) {
|
||||
if (size > MAX_PLOC_UPDATE_PATH) {
|
||||
return NAME_TOO_LONG;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = checkNameLength(size);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef XIPHOS_Q7S
|
||||
// Check if file is stored on SD card and if associated SD card is mounted
|
||||
if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) ==
|
||||
std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
} else if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) ==
|
||||
std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
} else {
|
||||
// update image not stored on SD card
|
||||
}
|
||||
#endif /* BOARD_TE0720 == 0 */
|
||||
|
||||
updateFile = std::string(reinterpret_cast<const char*>(data), size);
|
||||
|
||||
// Check if file exists
|
||||
if (not std::filesystem::exists(updateFile)) {
|
||||
return FILE_NOT_EXISTS;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {}
|
||||
|
||||
void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) {}
|
||||
|
||||
void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {}
|
||||
|
||||
void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch (pendingCommand) {
|
||||
case (supv::UPDATE_AVAILABLE):
|
||||
state = State::UPDATE_TRANSFER;
|
||||
break;
|
||||
case (supv::UPDATE_IMAGE_DATA):
|
||||
if (remainingPackets == 0) {
|
||||
packetsSent = 0; // Reset packets sent variable for next update sequence
|
||||
state = State::UPDATE_VERIFY;
|
||||
} else {
|
||||
state = State::UPDATE_TRANSFER;
|
||||
}
|
||||
break;
|
||||
case (supv::UPDATE_VERIFY):
|
||||
triggerEvent(UPDATE_FINISHED);
|
||||
state = State::IDLE;
|
||||
pendingCommand = supv::NONE;
|
||||
break;
|
||||
default:
|
||||
state = State::IDLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
switch (pendingCommand) {
|
||||
case (supv::UPDATE_AVAILABLE): {
|
||||
triggerEvent(UPDATE_AVAILABLE_FAILED);
|
||||
break;
|
||||
}
|
||||
case (supv::UPDATE_IMAGE_DATA): {
|
||||
triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent);
|
||||
break;
|
||||
}
|
||||
case (supv::UPDATE_VERIFY): {
|
||||
triggerEvent(UPDATE_VERIFY_FAILED);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
state = State::IDLE;
|
||||
}
|
||||
|
||||
void PlocUpdater::commandUpdateAvailable() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
if (not std::filesystem::exists(updateFile)) {
|
||||
triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast<uint8_t>(state));
|
||||
state = State::IDLE;
|
||||
return;
|
||||
}
|
||||
|
||||
std::ifstream file(updateFile, std::ifstream::binary);
|
||||
file.seekg(0, file.end);
|
||||
imageSize = static_cast<size_t>(file.tellg());
|
||||
file.close();
|
||||
|
||||
numOfUpdatePackets = imageSize / MAX_SP_DATA;
|
||||
if (imageSize % MAX_SP_DATA) {
|
||||
numOfUpdatePackets++;
|
||||
}
|
||||
|
||||
remainingPackets = numOfUpdatePackets;
|
||||
packetsSent = 0;
|
||||
|
||||
calcImageCrc();
|
||||
|
||||
supv::UpdateInfo packet(supv::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_AVAILABLE,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_AVAILABLE);
|
||||
state = State::IDLE;
|
||||
pendingCommand = supv::NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
pendingCommand = supv::UPDATE_AVAILABLE;
|
||||
state = State::COMMAND_EXECUTING;
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocUpdater::commandUpdatePacket() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint16_t payloadLength = 0;
|
||||
|
||||
if (not std::filesystem::exists(updateFile)) {
|
||||
triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast<uint8_t>(state), packetsSent);
|
||||
state = State::IDLE;
|
||||
return;
|
||||
}
|
||||
|
||||
std::ifstream file(updateFile, std::ifstream::binary);
|
||||
file.seekg(packetsSent * MAX_SP_DATA, file.beg);
|
||||
|
||||
if (remainingPackets == 1) {
|
||||
payloadLength = imageSize - static_cast<uint16_t>(file.tellg());
|
||||
} else {
|
||||
payloadLength = MAX_SP_DATA;
|
||||
}
|
||||
|
||||
supv::UpdatePacket packet(payloadLength);
|
||||
file.read(reinterpret_cast<char*>(packet.getDataFieldPointer()), payloadLength);
|
||||
file.close();
|
||||
// sequence count of first packet is 1
|
||||
packet.setPacketSequenceCount((packetsSent + 1) & supv::SEQUENCE_COUNT_MASK);
|
||||
if (numOfUpdatePackets > 1) {
|
||||
adjustSequenceFlags(packet);
|
||||
}
|
||||
packet.makeCrc();
|
||||
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_IMAGE_DATA,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_IMAGE_DATA);
|
||||
state = State::IDLE;
|
||||
pendingCommand = supv::NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
remainingPackets--;
|
||||
packetsSent++;
|
||||
|
||||
pendingCommand = supv::UPDATE_IMAGE_DATA;
|
||||
state = State::COMMAND_EXECUTING;
|
||||
}
|
||||
|
||||
void PlocUpdater::commandUpdateVerify() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
supv::UpdateInfo packet(supv::APID_UPDATE_VERIFY, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_VERIFY);
|
||||
state = State::IDLE;
|
||||
pendingCommand = supv::NONE;
|
||||
return;
|
||||
}
|
||||
state = State::COMMAND_EXECUTING;
|
||||
pendingCommand = supv::UPDATE_VERIFY;
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocUpdater::calcImageCrc() {
|
||||
std::ifstream file(updateFile, std::ifstream::binary);
|
||||
file.seekg(0, file.end);
|
||||
uint32_t count;
|
||||
uint32_t bit;
|
||||
uint32_t remainder = INITIAL_REMAINDER_32;
|
||||
char input;
|
||||
for (count = 0; count < imageSize; count++) {
|
||||
file.seekg(count, file.beg);
|
||||
file.read(&input, 1);
|
||||
remainder ^= (input << 16);
|
||||
for (bit = 8; bit > 0; --bit) {
|
||||
if (remainder & TOPBIT_32) {
|
||||
remainder = (remainder << 1) ^ POLYNOMIAL_32;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
imageCrc = (remainder ^ FINAL_XOR_VALUE_32);
|
||||
}
|
||||
|
||||
void PlocUpdater::adjustSequenceFlags(supv::UpdatePacket& packet) {
|
||||
if (packetsSent == 0) {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::FIRST_PKT));
|
||||
} else if (remainingPackets == 1) {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::LAST_PKT));
|
||||
} else {
|
||||
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::CONTINUED_PKT));
|
||||
}
|
||||
}
|
174
linux/devices/ploc/PlocUpdater.h
Normal file
174
linux/devices/ploc/PlocUpdater.h
Normal file
@ -0,0 +1,174 @@
|
||||
#ifndef MISSION_DEVICES_PLOCUPDATER_H_
|
||||
#define MISSION_DEVICES_PLOCUPDATER_H_
|
||||
|
||||
#include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "eive/definitions.h"
|
||||
#include "fsfw/action/ActionHelper.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/action/CommandsActionsIF.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacket.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
#include "linux/fsfwconfig/objects/systemObjectList.h"
|
||||
|
||||
/**
|
||||
* @brief An object of this class can be used to perform the software updates of the PLOC. The
|
||||
* software update will be read from one of the SD cards, split into multiple space
|
||||
* packets and sent to the PlocSupervisorHandler.
|
||||
*
|
||||
* @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition
|
||||
* A and Partition B)
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocUpdater : public SystemObject,
|
||||
public HasActionsIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasReturnvaluesIF,
|
||||
public CommandsActionsIF {
|
||||
public:
|
||||
static const ActionId_t UPDATE_A_UBOOT = 0;
|
||||
static const ActionId_t UPDATE_A_BITSTREAM = 1;
|
||||
static const ActionId_t UPDATE_A_LINUX = 2;
|
||||
static const ActionId_t UPDATE_A_APP_SW = 3;
|
||||
static const ActionId_t UPDATE_B_UBOOT = 4;
|
||||
static const ActionId_t UPDATE_B_BITSTREAM = 5;
|
||||
static const ActionId_t UPDATE_B_LINUX = 6;
|
||||
static const ActionId_t UPDATE_B_APP_SW = 7;
|
||||
|
||||
PlocUpdater(object_id_t objectId);
|
||||
virtual ~PlocUpdater();
|
||||
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size);
|
||||
MessageQueueId_t getCommandQueue() const;
|
||||
ReturnValue_t initialize() override;
|
||||
MessageQueueIF* getCommandQueuePtr() override;
|
||||
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
|
||||
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
|
||||
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
||||
void completionSuccessfulReceived(ActionId_t actionId) override;
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Updater is already performing an update
|
||||
static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] Received update command with invalid path string (too long).
|
||||
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1);
|
||||
//! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not
|
||||
//! mounted.
|
||||
static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2);
|
||||
//! [EXPORT] : [COMMENT] Update file received with update command does not exist.
|
||||
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3);
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Try to read update file but the file does not exist.
|
||||
//! P1: Indicates in which state the file read fails
|
||||
//! P2: During the update transfer the second parameter gives information about the number of
|
||||
//! already sent packets
|
||||
static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Failed to send command to supervisor handler
|
||||
//! P1: Return value of CommandActionHelper::commandAction
|
||||
//! P2: Action ID of command to send
|
||||
static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution
|
||||
//! failure of the update available command
|
||||
static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet.
|
||||
//! P1: Parameter holds the number of update packets already sent (inclusive the failed packet)
|
||||
static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command.
|
||||
static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] MPSoC update successful completed
|
||||
static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO);
|
||||
|
||||
static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE;
|
||||
static const size_t MAX_PLOC_UPDATE_PATH = 50;
|
||||
static const size_t SD_PREFIX_LENGTH = 8;
|
||||
// Maximum size of update payload data per space packet (max size of space packet is 1024 bytes)
|
||||
static const size_t MAX_SP_DATA = 1016;
|
||||
|
||||
static const uint32_t TOPBIT_32 = (1 << 31);
|
||||
static const uint32_t POLYNOMIAL_32 = 0x04C11DB7;
|
||||
static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF;
|
||||
static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF;
|
||||
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
|
||||
#ifdef XIPHOS_Q7S
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
#endif
|
||||
CommandActionHelper commandActionHelper;
|
||||
|
||||
ActionHelper actionHelper;
|
||||
|
||||
enum class State : uint8_t {
|
||||
IDLE,
|
||||
UPDATE_AVAILABLE,
|
||||
UPDATE_TRANSFER,
|
||||
UPDATE_VERIFY,
|
||||
COMMAND_EXECUTING
|
||||
};
|
||||
|
||||
State state = State::IDLE;
|
||||
|
||||
ActionId_t pendingCommand = supv::NONE;
|
||||
|
||||
enum class Image : uint8_t { NONE, A, B };
|
||||
|
||||
Image image = Image::NONE;
|
||||
|
||||
enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW };
|
||||
|
||||
Partition partition = Partition::NONE;
|
||||
|
||||
uint32_t packetsSent = 0;
|
||||
uint32_t remainingPackets = 0;
|
||||
// Number of packets required to transfer the update image
|
||||
uint32_t numOfUpdatePackets = 0;
|
||||
|
||||
std::string updateFile;
|
||||
uint32_t imageSize = 0;
|
||||
uint32_t imageCrc = 0;
|
||||
|
||||
void readCommandQueue();
|
||||
void doStateMachine();
|
||||
|
||||
/**
|
||||
* @brief Extracts the path and name of the update image from the service 8 command data.
|
||||
*/
|
||||
ReturnValue_t getImageLocation(const uint8_t* data, size_t size);
|
||||
|
||||
ReturnValue_t checkNameLength(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Prepares and sends update available command to PLOC supervisor handler.
|
||||
*/
|
||||
void commandUpdateAvailable();
|
||||
|
||||
/**
|
||||
* @brief Prepares and sends and update packet to the PLOC supervisor handler.
|
||||
*/
|
||||
void commandUpdatePacket();
|
||||
|
||||
/**
|
||||
* @brief Prepares and sends the update verification packet to the PLOC supervisor handler.
|
||||
*/
|
||||
void commandUpdateVerify();
|
||||
|
||||
void calcImageCrc();
|
||||
|
||||
void adjustSequenceFlags(supv::UpdatePacket& packet);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_PLOCUPDATER_H_ */
|
@ -15,7 +15,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
StrHelper* strHelper)
|
||||
StrHelper* strHelper, power::Switch_t powerSwitch)
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||
temperatureSet(this),
|
||||
versionSet(this),
|
||||
@ -39,7 +39,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
||||
subscriptionSet(this),
|
||||
logSubscriptionSet(this),
|
||||
debugCameraSet(this),
|
||||
strHelper(strHelper) {
|
||||
strHelper(strHelper),
|
||||
powerSwitch(powerSwitch) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
@ -1223,6 +1224,15 @@ ReturnValue_t StarTrackerHandler::doSendReadHook() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
|
||||
if (powerSwitch == power::NO_SWITCH) {
|
||||
return DeviceHandlerBase::NO_SWITCH;
|
||||
}
|
||||
*numberOfSwitches = 1;
|
||||
*switches = &powerSwitch;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) {
|
||||
switch (actionId) {
|
||||
case startracker::UPLOAD_IMAGE:
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "StrHelper.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/src/fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/timemanager/Countdown.h"
|
||||
@ -34,7 +35,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
* to high to enable the device.
|
||||
*/
|
||||
StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
StrHelper* strHelper);
|
||||
StrHelper* strHelper, power::Switch_t powerSwitch);
|
||||
virtual ~StarTrackerHandler();
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
@ -75,6 +76,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
*/
|
||||
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
|
||||
virtual ReturnValue_t doSendReadHook() override;
|
||||
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override;
|
||||
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
||||
|
||||
private:
|
||||
@ -161,14 +163,12 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
static const uint32_t BOOT_TIMEOUT = 1000;
|
||||
static const uint32_t DEFAULT_TRANSITION_DELAY = 15000;
|
||||
|
||||
class FlashReadCmd {
|
||||
public:
|
||||
struct FlashReadCmd {
|
||||
// Minimum length of a read command (region, length and filename)
|
||||
static const size_t MIN_LENGTH = 7;
|
||||
};
|
||||
|
||||
class ChecksumCmd {
|
||||
public:
|
||||
struct ChecksumCmd {
|
||||
static const uint8_t ADDRESS_OFFSET = 1;
|
||||
static const uint8_t LENGTH_OFFSET = 5;
|
||||
// Length of checksum command
|
||||
@ -268,6 +268,8 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
|
||||
bool strHelperExecuting = false;
|
||||
|
||||
const power::Switch_t powerSwitch = power::NO_SWITCH;
|
||||
|
||||
/**
|
||||
* @brief Handles internal state
|
||||
*/
|
||||
|
@ -10,21 +10,16 @@
|
||||
#cmakedefine XIPHOS_Q7S
|
||||
#cmakedefine BEAGLEBONEBLACK
|
||||
#cmakedefine EGSE
|
||||
#cmakedefine TE0720_1CFA
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
#include "rpiConfig.h"
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
#include "q7sConfig.h"
|
||||
#endif
|
||||
#include "commonConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
|
||||
/* These defines should be disabled for mission code but are useful for
|
||||
debugging. */
|
||||
#define OBSW_VERBOSE_LEVEL 1
|
||||
|
||||
//! Board defines
|
||||
#define BOARD_TE0720 0
|
||||
|
||||
#define Q7S_EM 0
|
||||
|
||||
/*******************************************************************/
|
||||
/** All of the following flags should be enabled for mission code */
|
||||
@ -45,21 +40,23 @@ debugging. */
|
||||
#define OBSW_ENABLE_TIMERS 1
|
||||
#define OBSW_ADD_MGT 1
|
||||
#define OBSW_ADD_BPX_BATTERY_HANDLER 1
|
||||
#define OBSW_ADD_STAR_TRACKER 0
|
||||
#define OBSW_ADD_STAR_TRACKER @OBSW_ADD_STAR_TRACKER@
|
||||
#define OBSW_ADD_PLOC_SUPERVISOR 0
|
||||
#define OBSW_ADD_PLOC_MPSOC 0
|
||||
#define OBSW_ADD_SUN_SENSORS 1
|
||||
#define OBSW_ADD_SUS_BOARD_ASS 1
|
||||
#define OBSW_ADD_ACS_BOARD 1
|
||||
#define OBSW_ADD_ACS_HANDLERS 1
|
||||
#define OBSW_ADD_RW 0
|
||||
#define OBSW_ADD_RTD_DEVICES 1
|
||||
#define OBSW_ADD_TMP_DEVICES 0
|
||||
#define OBSW_ADD_RAD_SENSORS 1
|
||||
#define OBSW_ADD_PL_PCDU 0
|
||||
#define OBSW_ADD_PL_PCDU 1
|
||||
#define OBSW_ADD_SYRLINKS 0
|
||||
#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0
|
||||
#define OBSW_STAR_TRACKER_GROUND_CONFIG 1
|
||||
#define OBSW_ENABLE_PERIODIC_HK 0
|
||||
|
||||
#endif // XIPHOS_Q7S
|
||||
|
||||
// This is a really tricky switch.. It initializes the PCDU switches to their default states
|
||||
// at powerup. I think it would be better
|
||||
@ -67,11 +64,37 @@ debugging. */
|
||||
// something the operators might want to do by giving the software too much intelligence
|
||||
// at the wrong place. The system component might command all the Switches accordingly anyway
|
||||
#define OBSW_INITIALIZE_SWITCHES 0
|
||||
#define OBSW_ENABLE_PERIODIC_HK 0
|
||||
|
||||
#endif
|
||||
#ifdef TE0720_1CFA
|
||||
|
||||
#define OBSW_USE_CCSDS_IP_CORE 0
|
||||
// Set to 1 if all telemetry should be sent to the PTME IP Core
|
||||
#define OBSW_TM_TO_PTME 0
|
||||
// Set to 1 if telecommands are received via the PDEC IP Core
|
||||
#define OBSW_TC_FROM_PDEC 0
|
||||
#define OBSW_ENABLE_TIMERS 1
|
||||
#define OBSW_ADD_MGT 0
|
||||
#define OBSW_ADD_BPX_BATTERY_HANDLER 0
|
||||
#define OBSW_ADD_STAR_TRACKER 0
|
||||
#define OBSW_ADD_PLOC_SUPERVISOR 0
|
||||
#define OBSW_ADD_PLOC_MPSOC 1
|
||||
#define OBSW_ADD_SUN_SENSORS 0
|
||||
#define OBSW_ADD_ACS_BOARD 1
|
||||
#define OBSW_ADD_ACS_HANDLERS 0
|
||||
#define OBSW_ADD_RW 0
|
||||
#define OBSW_ADD_RTD_DEVICES 0
|
||||
#define OBSW_ADD_TMP_DEVICES 0
|
||||
#define OBSW_ADD_RAD_SENSORS 0
|
||||
#define OBSW_ADD_PL_PCDU 0
|
||||
#define OBSW_ADD_SYRLINKS 0
|
||||
#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0
|
||||
#define OBSW_SYRLINKS_SIMULATED 1
|
||||
#define OBSW_STAR_TRACKER_GROUND_CONFIG 1
|
||||
#define OBSW_ENABLE_PERIODIC_HK 0
|
||||
#define OBSW_PRINT_CORE_HK 0
|
||||
#define OBSW_INITIALIZE_SWITCHES 0
|
||||
|
||||
#ifdef EGSE
|
||||
#define OBSW_ADD_STAR_TRACKER 1
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
@ -93,7 +116,6 @@ debugging. */
|
||||
#define OBSW_ADD_UART_TEST_CODE 0
|
||||
|
||||
#define OBSW_TEST_ACS 0
|
||||
#define OBSW_TEST_ACS_BOARD_ASS 0
|
||||
#define OBSW_DEBUG_ACS 0
|
||||
#define OBSW_TEST_SUS 0
|
||||
#define OBSW_DEBUG_SUS 0
|
||||
@ -123,10 +145,16 @@ debugging. */
|
||||
#define OBSW_DEBUG_SYRLINKS 0
|
||||
#define OBSW_DEBUG_IMTQ 0
|
||||
#define OBSW_DEBUG_RW 0
|
||||
#define OBSW_DEBUG_PLOC_MPSOC 0
|
||||
#define OBSW_DEBUG_PLOC_SUPERVISOR 0
|
||||
#define OBSW_DEBUG_PDEC_HANDLER 0
|
||||
|
||||
#ifdef TE0720_1CFA
|
||||
#define OBSW_DEBUG_PLOC_SUPERVISOR 1
|
||||
#define OBSW_DEBUG_PLOC_MPSOC 1
|
||||
#else
|
||||
#define OBSW_DEBUG_PLOC_SUPERVISOR 0
|
||||
#define OBSW_DEBUG_PLOC_MPSOC 0
|
||||
#endif
|
||||
|
||||
#ifdef EGSE
|
||||
#define OBSW_DEBUG_STARTRACKER 1
|
||||
#else
|
||||
@ -140,23 +168,34 @@ debugging. */
|
||||
#define OBSW_ADD_PLOC_SUPERVISOR 0
|
||||
#define OBSW_ADD_PLOC_MPSOC 0
|
||||
#define OBSW_ADD_SUN_SENSORS 0
|
||||
#define OBSW_ADD_MGT 0
|
||||
#define OBSW_ADD_ACS_BOARD 0
|
||||
#define OBSW_ADD_ACS_HANDLERS 0
|
||||
#define OBSW_ADD_GPS_0 0
|
||||
#define OBSW_ADD_GPS_1 0
|
||||
#define OBSW_ADD_RW 0
|
||||
#define OBSW_ADD_BPX_BATTERY_HANDLER 0
|
||||
#define OBSW_ADD_RTD_DEVICES 0
|
||||
#define OBSW_ADD_PL_PCDU 0
|
||||
#define OBSW_ADD_TMP_DEVICES 0
|
||||
#define OBSW_ADD_RAD_SENSORS 0
|
||||
#define OBSW_ADD_SYRLINKS 0
|
||||
#define OBSW_STAR_TRACKER_GROUND_CONFIG 1
|
||||
|
||||
#endif
|
||||
#endif // RASPBERRY_PI
|
||||
|
||||
#define TCP_SERVER_WIRETAPPING 0
|
||||
|
||||
/*******************************************************************/
|
||||
/** CMake Defines */
|
||||
/*******************************************************************/
|
||||
#cmakedefine EIVE_BUILD_GPSD_GPS_HANDLER
|
||||
|
||||
#include "OBSWVersion.h"
|
||||
#ifdef RASPBERRY_PI
|
||||
#include "rpiConfig.h"
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
#include "q7sConfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -164,18 +203,6 @@ debugging. */
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
|
||||
namespace config {
|
||||
#endif
|
||||
|
||||
/* Add mission configuration flags here */
|
||||
static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50;
|
||||
static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50;
|
||||
static constexpr uint32_t STR_IMG_HELPER_QUEUE_SIZE = 50;
|
||||
|
||||
static constexpr uint8_t LIVE_TM = 0;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FSFWCONFIG_OBSWCONFIG_H_ */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 168 translations.
|
||||
* @brief Auto-generated event translation file. Contains 183 translations.
|
||||
* @details
|
||||
* Generated on: 2022-03-22 20:43:04
|
||||
* Generated on: 2022-04-08 11:21:58
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
@ -100,7 +100,9 @@ const char *DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING = "DEPL_SA2_GPIO_SWTICH_ON_FAI
|
||||
const char *MEMORY_READ_RPT_CRC_FAILURE_STRING = "MEMORY_READ_RPT_CRC_FAILURE";
|
||||
const char *ACK_FAILURE_STRING = "ACK_FAILURE";
|
||||
const char *EXE_FAILURE_STRING = "EXE_FAILURE";
|
||||
const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT";
|
||||
const char *MPSOC_HANDLER_CRC_FAILURE_STRING = "MPSOC_HANDLER_CRC_FAILURE";
|
||||
const char *MPSOC_HANDLER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQ_CNT_MISMATCH";
|
||||
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
|
||||
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
|
||||
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
|
||||
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
|
||||
@ -148,6 +150,18 @@ const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH";
|
||||
const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS";
|
||||
const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED";
|
||||
const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED";
|
||||
const char *MPSOC_FLASH_WRITE_FAILED_STRING = "MPSOC_FLASH_WRITE_FAILED";
|
||||
const char *MPSOC_FLASH_WRITE_SUCCESSFUL_STRING = "MPSOC_FLASH_WRITE_SUCCESSFUL";
|
||||
const char *SENDING_COMMAND_FAILED_STRING = "SENDING_COMMAND_FAILED";
|
||||
const char *MPSOC_HELPER_REQUESTING_REPLY_FAILED_STRING = "MPSOC_HELPER_REQUESTING_REPLY_FAILED";
|
||||
const char *MPSOC_HELPER_READING_REPLY_FAILED_STRING = "MPSOC_HELPER_READING_REPLY_FAILED";
|
||||
const char *MISSING_ACK_STRING = "MISSING_ACK";
|
||||
const char *MISSING_EXE_STRING = "MISSING_EXE";
|
||||
const char *ACK_FAILURE_REPORT_STRING = "ACK_FAILURE_REPORT";
|
||||
const char *EXE_FAILURE_REPORT_STRING = "EXE_FAILURE_REPORT";
|
||||
const char *ACK_INVALID_APID_STRING = "ACK_INVALID_APID";
|
||||
const char *EXE_INVALID_APID_STRING = "EXE_INVALID_APID";
|
||||
const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH";
|
||||
const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF";
|
||||
const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS";
|
||||
const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS";
|
||||
@ -165,6 +179,7 @@ const char *NOT_ENOUGH_DEVICES_DUAL_MODE_STRING = "NOT_ENOUGH_DEVICES_DUAL_MODE"
|
||||
const char *POWER_STATE_MACHINE_TIMEOUT_STRING = "POWER_STATE_MACHINE_TIMEOUT";
|
||||
const char *SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING = "SIDE_SWITCH_TRANSITION_NOT_ALLOWED";
|
||||
const char *CHILDREN_LOST_MODE_STRING = "CHILDREN_LOST_MODE";
|
||||
const char *GPS_FIX_CHANGE_STRING = "GPS_FIX_CHANGE";
|
||||
const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE";
|
||||
const char *REBOOT_SW_STRING = "REBOOT_SW";
|
||||
const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED";
|
||||
@ -330,168 +345,198 @@ const char *translateEvents(Event event) {
|
||||
return TEST_STRING;
|
||||
case (10600):
|
||||
return CHANGE_OF_SETUP_PARAMETER_STRING;
|
||||
case (10800):
|
||||
case (11300):
|
||||
return SWITCH_CMD_SENT_STRING;
|
||||
case (10801):
|
||||
return SWITCH_HAS_CHANGED_STRING;
|
||||
case (10802):
|
||||
return SWITCHING_Q7S_DENIED_STRING;
|
||||
case (10900):
|
||||
return GPIO_PULL_HIGH_FAILED_STRING;
|
||||
case (10901):
|
||||
return GPIO_PULL_LOW_FAILED_STRING;
|
||||
case (10902):
|
||||
return SWITCH_ALREADY_ON_STRING;
|
||||
case (10903):
|
||||
return SWITCH_ALREADY_OFF_STRING;
|
||||
case (10904):
|
||||
return MAIN_SWITCH_TIMEOUT_STRING;
|
||||
case (11000):
|
||||
return MAIN_SWITCH_ON_TIMEOUT_STRING;
|
||||
case (11001):
|
||||
return MAIN_SWITCH_OFF_TIMEOUT_STRING;
|
||||
case (11002):
|
||||
return DEPLOYMENT_FAILED_STRING;
|
||||
case (11003):
|
||||
return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING;
|
||||
case (11004):
|
||||
return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING;
|
||||
case (11101):
|
||||
return MEMORY_READ_RPT_CRC_FAILURE_STRING;
|
||||
case (11102):
|
||||
return ACK_FAILURE_STRING;
|
||||
case (11103):
|
||||
return EXE_FAILURE_STRING;
|
||||
case (11104):
|
||||
return CRC_FAILURE_EVENT_STRING;
|
||||
case (11201):
|
||||
return SELF_TEST_I2C_FAILURE_STRING;
|
||||
case (11202):
|
||||
return SELF_TEST_SPI_FAILURE_STRING;
|
||||
case (11203):
|
||||
return SELF_TEST_ADC_FAILURE_STRING;
|
||||
case (11204):
|
||||
return SELF_TEST_PWM_FAILURE_STRING;
|
||||
case (11205):
|
||||
return SELF_TEST_TC_FAILURE_STRING;
|
||||
case (11206):
|
||||
return SELF_TEST_MTM_RANGE_FAILURE_STRING;
|
||||
case (11207):
|
||||
return SELF_TEST_COIL_CURRENT_FAILURE_STRING;
|
||||
case (11208):
|
||||
return INVALID_ERROR_BYTE_STRING;
|
||||
case (11301):
|
||||
return ERROR_STATE_STRING;
|
||||
return SWITCH_HAS_CHANGED_STRING;
|
||||
case (11302):
|
||||
return SWITCHING_Q7S_DENIED_STRING;
|
||||
case (11400):
|
||||
return GPIO_PULL_HIGH_FAILED_STRING;
|
||||
case (11401):
|
||||
return BOOTING_FIRMWARE_FAILED_STRING;
|
||||
return GPIO_PULL_LOW_FAILED_STRING;
|
||||
case (11402):
|
||||
return BOOTING_BOOTLOADER_FAILED_STRING;
|
||||
return SWITCH_ALREADY_ON_STRING;
|
||||
case (11403):
|
||||
return SWITCH_ALREADY_OFF_STRING;
|
||||
case (11404):
|
||||
return MAIN_SWITCH_TIMEOUT_STRING;
|
||||
case (11500):
|
||||
return MAIN_SWITCH_ON_TIMEOUT_STRING;
|
||||
case (11501):
|
||||
return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING;
|
||||
return MAIN_SWITCH_OFF_TIMEOUT_STRING;
|
||||
case (11502):
|
||||
return SUPV_ACK_FAILURE_STRING;
|
||||
return DEPLOYMENT_FAILED_STRING;
|
||||
case (11503):
|
||||
return SUPV_EXE_FAILURE_STRING;
|
||||
return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING;
|
||||
case (11504):
|
||||
return SUPV_CRC_FAILURE_EVENT_STRING;
|
||||
case (11600):
|
||||
return SANITIZATION_FAILED_STRING;
|
||||
return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING;
|
||||
case (11601):
|
||||
return MOUNTED_SD_CARD_STRING;
|
||||
case (11700):
|
||||
return UPDATE_FILE_NOT_EXISTS_STRING;
|
||||
return MEMORY_READ_RPT_CRC_FAILURE_STRING;
|
||||
case (11602):
|
||||
return ACK_FAILURE_STRING;
|
||||
case (11603):
|
||||
return EXE_FAILURE_STRING;
|
||||
case (11604):
|
||||
return MPSOC_HANDLER_CRC_FAILURE_STRING;
|
||||
case (11605):
|
||||
return MPSOC_HANDLER_SEQ_CNT_MISMATCH_STRING;
|
||||
case (11606):
|
||||
return MPSOC_SHUTDOWN_FAILED_STRING;
|
||||
case (11701):
|
||||
return ACTION_COMMANDING_FAILED_STRING;
|
||||
return SELF_TEST_I2C_FAILURE_STRING;
|
||||
case (11702):
|
||||
return UPDATE_AVAILABLE_FAILED_STRING;
|
||||
return SELF_TEST_SPI_FAILURE_STRING;
|
||||
case (11703):
|
||||
return UPDATE_TRANSFER_FAILED_STRING;
|
||||
return SELF_TEST_ADC_FAILURE_STRING;
|
||||
case (11704):
|
||||
return UPDATE_VERIFY_FAILED_STRING;
|
||||
return SELF_TEST_PWM_FAILURE_STRING;
|
||||
case (11705):
|
||||
return UPDATE_FINISHED_STRING;
|
||||
case (11800):
|
||||
return SEND_MRAM_DUMP_FAILED_STRING;
|
||||
return SELF_TEST_TC_FAILURE_STRING;
|
||||
case (11706):
|
||||
return SELF_TEST_MTM_RANGE_FAILURE_STRING;
|
||||
case (11707):
|
||||
return SELF_TEST_COIL_CURRENT_FAILURE_STRING;
|
||||
case (11708):
|
||||
return INVALID_ERROR_BYTE_STRING;
|
||||
case (11801):
|
||||
return MRAM_DUMP_FAILED_STRING;
|
||||
case (11802):
|
||||
return MRAM_DUMP_FINISHED_STRING;
|
||||
return ERROR_STATE_STRING;
|
||||
case (11901):
|
||||
return INVALID_TC_FRAME_STRING;
|
||||
return BOOTING_FIRMWARE_FAILED_STRING;
|
||||
case (11902):
|
||||
return INVALID_FAR_STRING;
|
||||
case (11903):
|
||||
return CARRIER_LOCK_STRING;
|
||||
case (11904):
|
||||
return BIT_LOCK_PDEC_STRING;
|
||||
case (12000):
|
||||
return IMAGE_UPLOAD_FAILED_STRING;
|
||||
return BOOTING_BOOTLOADER_FAILED_STRING;
|
||||
case (12001):
|
||||
return IMAGE_DOWNLOAD_FAILED_STRING;
|
||||
return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING;
|
||||
case (12002):
|
||||
return IMAGE_UPLOAD_SUCCESSFUL_STRING;
|
||||
return SUPV_ACK_FAILURE_STRING;
|
||||
case (12003):
|
||||
return IMAGE_DOWNLOAD_SUCCESSFUL_STRING;
|
||||
return SUPV_EXE_FAILURE_STRING;
|
||||
case (12004):
|
||||
return FLASH_WRITE_SUCCESSFUL_STRING;
|
||||
case (12005):
|
||||
return FLASH_READ_SUCCESSFUL_STRING;
|
||||
case (12006):
|
||||
return FLASH_READ_FAILED_STRING;
|
||||
case (12007):
|
||||
return FIRMWARE_UPDATE_SUCCESSFUL_STRING;
|
||||
case (12008):
|
||||
return FIRMWARE_UPDATE_FAILED_STRING;
|
||||
case (12009):
|
||||
return STR_HELPER_READING_REPLY_FAILED_STRING;
|
||||
case (12010):
|
||||
return STR_HELPER_COM_ERROR_STRING;
|
||||
case (12011):
|
||||
return STR_HELPER_NO_REPLY_STRING;
|
||||
case (12012):
|
||||
return STR_HELPER_DEC_ERROR_STRING;
|
||||
case (12013):
|
||||
return POSITION_MISMATCH_STRING;
|
||||
case (12014):
|
||||
return STR_HELPER_FILE_NOT_EXISTS_STRING;
|
||||
case (12015):
|
||||
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
|
||||
case (12016):
|
||||
return STR_HELPER_REQUESTING_MSG_FAILED_STRING;
|
||||
return SUPV_CRC_FAILURE_EVENT_STRING;
|
||||
case (12100):
|
||||
return TRANSITION_BACK_TO_OFF_STRING;
|
||||
return SANITIZATION_FAILED_STRING;
|
||||
case (12101):
|
||||
return NEG_V_OUT_OF_BOUNDS_STRING;
|
||||
case (12102):
|
||||
return U_DRO_OUT_OF_BOUNDS_STRING;
|
||||
case (12103):
|
||||
return I_DRO_OUT_OF_BOUNDS_STRING;
|
||||
case (12104):
|
||||
return U_X8_OUT_OF_BOUNDS_STRING;
|
||||
case (12105):
|
||||
return I_X8_OUT_OF_BOUNDS_STRING;
|
||||
case (12106):
|
||||
return U_TX_OUT_OF_BOUNDS_STRING;
|
||||
case (12107):
|
||||
return I_TX_OUT_OF_BOUNDS_STRING;
|
||||
case (12108):
|
||||
return U_MPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12109):
|
||||
return I_MPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12110):
|
||||
return U_HPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12111):
|
||||
return I_HPA_OUT_OF_BOUNDS_STRING;
|
||||
return MOUNTED_SD_CARD_STRING;
|
||||
case (12200):
|
||||
return TRANSITION_OTHER_SIDE_FAILED_STRING;
|
||||
return UPDATE_FILE_NOT_EXISTS_STRING;
|
||||
case (12201):
|
||||
return NOT_ENOUGH_DEVICES_DUAL_MODE_STRING;
|
||||
return ACTION_COMMANDING_FAILED_STRING;
|
||||
case (12202):
|
||||
return POWER_STATE_MACHINE_TIMEOUT_STRING;
|
||||
return UPDATE_AVAILABLE_FAILED_STRING;
|
||||
case (12203):
|
||||
return UPDATE_TRANSFER_FAILED_STRING;
|
||||
case (12204):
|
||||
return UPDATE_VERIFY_FAILED_STRING;
|
||||
case (12205):
|
||||
return UPDATE_FINISHED_STRING;
|
||||
case (12300):
|
||||
return SEND_MRAM_DUMP_FAILED_STRING;
|
||||
case (12301):
|
||||
return MRAM_DUMP_FAILED_STRING;
|
||||
case (12302):
|
||||
return MRAM_DUMP_FINISHED_STRING;
|
||||
case (12401):
|
||||
return INVALID_TC_FRAME_STRING;
|
||||
case (12402):
|
||||
return INVALID_FAR_STRING;
|
||||
case (12403):
|
||||
return CARRIER_LOCK_STRING;
|
||||
case (12404):
|
||||
return BIT_LOCK_PDEC_STRING;
|
||||
case (12500):
|
||||
return IMAGE_UPLOAD_FAILED_STRING;
|
||||
case (12501):
|
||||
return IMAGE_DOWNLOAD_FAILED_STRING;
|
||||
case (12502):
|
||||
return IMAGE_UPLOAD_SUCCESSFUL_STRING;
|
||||
case (12503):
|
||||
return IMAGE_DOWNLOAD_SUCCESSFUL_STRING;
|
||||
case (12504):
|
||||
return FLASH_WRITE_SUCCESSFUL_STRING;
|
||||
case (12505):
|
||||
return FLASH_READ_SUCCESSFUL_STRING;
|
||||
case (12506):
|
||||
return FLASH_READ_FAILED_STRING;
|
||||
case (12507):
|
||||
return FIRMWARE_UPDATE_SUCCESSFUL_STRING;
|
||||
case (12508):
|
||||
return FIRMWARE_UPDATE_FAILED_STRING;
|
||||
case (12509):
|
||||
return STR_HELPER_READING_REPLY_FAILED_STRING;
|
||||
case (12510):
|
||||
return STR_HELPER_COM_ERROR_STRING;
|
||||
case (12511):
|
||||
return STR_HELPER_NO_REPLY_STRING;
|
||||
case (12512):
|
||||
return STR_HELPER_DEC_ERROR_STRING;
|
||||
case (12513):
|
||||
return POSITION_MISMATCH_STRING;
|
||||
case (12514):
|
||||
return STR_HELPER_FILE_NOT_EXISTS_STRING;
|
||||
case (12515):
|
||||
return STR_HELPER_SENDING_PACKET_FAILED_STRING;
|
||||
case (12516):
|
||||
return STR_HELPER_REQUESTING_MSG_FAILED_STRING;
|
||||
case (12600):
|
||||
return MPSOC_FLASH_WRITE_FAILED_STRING;
|
||||
case (12601):
|
||||
return MPSOC_FLASH_WRITE_SUCCESSFUL_STRING;
|
||||
case (12602):
|
||||
return SENDING_COMMAND_FAILED_STRING;
|
||||
case (12603):
|
||||
return MPSOC_HELPER_REQUESTING_REPLY_FAILED_STRING;
|
||||
case (12604):
|
||||
return MPSOC_HELPER_READING_REPLY_FAILED_STRING;
|
||||
case (12605):
|
||||
return MISSING_ACK_STRING;
|
||||
case (12606):
|
||||
return MISSING_EXE_STRING;
|
||||
case (12607):
|
||||
return ACK_FAILURE_REPORT_STRING;
|
||||
case (12608):
|
||||
return EXE_FAILURE_REPORT_STRING;
|
||||
case (12609):
|
||||
return ACK_INVALID_APID_STRING;
|
||||
case (12610):
|
||||
return EXE_INVALID_APID_STRING;
|
||||
case (12611):
|
||||
return MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING;
|
||||
case (12700):
|
||||
return TRANSITION_BACK_TO_OFF_STRING;
|
||||
case (12701):
|
||||
return NEG_V_OUT_OF_BOUNDS_STRING;
|
||||
case (12702):
|
||||
return U_DRO_OUT_OF_BOUNDS_STRING;
|
||||
case (12703):
|
||||
return I_DRO_OUT_OF_BOUNDS_STRING;
|
||||
case (12704):
|
||||
return U_X8_OUT_OF_BOUNDS_STRING;
|
||||
case (12705):
|
||||
return I_X8_OUT_OF_BOUNDS_STRING;
|
||||
case (12706):
|
||||
return U_TX_OUT_OF_BOUNDS_STRING;
|
||||
case (12707):
|
||||
return I_TX_OUT_OF_BOUNDS_STRING;
|
||||
case (12708):
|
||||
return U_MPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12709):
|
||||
return I_MPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12710):
|
||||
return U_HPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12711):
|
||||
return I_HPA_OUT_OF_BOUNDS_STRING;
|
||||
case (12800):
|
||||
return TRANSITION_OTHER_SIDE_FAILED_STRING;
|
||||
case (12801):
|
||||
return NOT_ENOUGH_DEVICES_DUAL_MODE_STRING;
|
||||
case (12802):
|
||||
return POWER_STATE_MACHINE_TIMEOUT_STRING;
|
||||
case (12803):
|
||||
return SIDE_SWITCH_TRANSITION_NOT_ALLOWED_STRING;
|
||||
case (12400):
|
||||
case (13000):
|
||||
return CHILDREN_LOST_MODE_STRING;
|
||||
case (13100):
|
||||
return GPS_FIX_CHANGE_STRING;
|
||||
case (13600):
|
||||
return ALLOC_FAILURE_STRING;
|
||||
case (13601):
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @brief Auto-generated object translation file.
|
||||
* @details
|
||||
* Contains 115 translations.
|
||||
* Generated on: 2022-03-22 20:43:04
|
||||
* Contains 117 translations.
|
||||
* Generated on: 2022-04-08 11:21:58
|
||||
*/
|
||||
#include "translateObjects.h"
|
||||
|
||||
@ -48,8 +48,10 @@ const char *RAD_SENSOR_STRING = "RAD_SENSOR";
|
||||
const char *PLOC_UPDATER_STRING = "PLOC_UPDATER";
|
||||
const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER";
|
||||
const char *STR_HELPER_STRING = "STR_HELPER";
|
||||
const char *PLOC_MPSOC_HELPER_STRING = "PLOC_MPSOC_HELPER";
|
||||
const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER";
|
||||
const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER";
|
||||
const char *PLOC_SUPERVISOR_HELPER_STRING = "PLOC_SUPERVISOR_HELPER";
|
||||
const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER";
|
||||
const char *HEATER_HANDLER_STRING = "HEATER_HANDLER";
|
||||
const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1";
|
||||
@ -208,10 +210,14 @@ const char *translateObject(object_id_t object) {
|
||||
return PLOC_MEMORY_DUMPER_STRING;
|
||||
case 0x44330002:
|
||||
return STR_HELPER_STRING;
|
||||
case 0x44330003:
|
||||
return PLOC_MPSOC_HELPER_STRING;
|
||||
case 0x44330015:
|
||||
return PLOC_MPSOC_HANDLER_STRING;
|
||||
case 0x44330016:
|
||||
return PLOC_SUPERVISOR_HANDLER_STRING;
|
||||
case 0x44330017:
|
||||
return PLOC_SUPERVISOR_HELPER_STRING;
|
||||
case 0x444100A2:
|
||||
return SOLAR_ARRAY_DEPL_HANDLER_STRING;
|
||||
case 0x444100A4:
|
||||
|
@ -177,14 +177,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
bool addSus9 = true;
|
||||
bool addSus10 = true;
|
||||
bool addSus11 = true;
|
||||
/**
|
||||
* The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all
|
||||
* requests to a sun sensor must be performed consecutively. Another reason for calling multiple
|
||||
* device handler cycles is that the ADC conversions take some time. Thus first the ADC
|
||||
* conversions are initiated and in a next step the results can be read from the internal FIFO.
|
||||
* One sun sensor communication sequence also blocks the SPI bus. So other devices can not be
|
||||
* inserted between the device handler cycles of one SUS.
|
||||
*/
|
||||
|
||||
if (addSus0) {
|
||||
/* Write setup */
|
||||
thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
@ -517,6 +510,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
|
||||
|
||||
ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
#ifndef TE0720_1CFA
|
||||
#if Q7S_EM != 1
|
||||
// PCDU handlers receives two messages and both must be handled
|
||||
thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
@ -551,6 +545,7 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
#endif /* Q7S_EM == 0 */
|
||||
#endif
|
||||
static_cast<void>(length);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -590,69 +585,3 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) {
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#if BOARD_TE0720 == 1
|
||||
ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
|
||||
#if TEST_PLOC_MPSOC_HANDLER == 1
|
||||
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
#if OBSW_TEST_RAD_SENSOR == 1
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
#if OBSW_TEST_SUS == 1
|
||||
/* Write setup */
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ);
|
||||
|
||||
/* Start conversion*/
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ);
|
||||
|
||||
/* Read conversions */
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_PLOC_SUPERVISOR == 1
|
||||
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2,
|
||||
DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0,
|
||||
DeviceHandlerIF::PERFORM_OPERATION);
|
||||
|
||||
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Initialization of TE0720 PST failed" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
#endif /* BOARD_TE0720 == 1 */
|
||||
|
@ -54,14 +54,6 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence);
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence);
|
||||
|
||||
#if BOARD_TE0720 == 1
|
||||
/**
|
||||
* @brief This polling sequence will be created when the software is compiled for the TE0720.
|
||||
*/
|
||||
ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence);
|
||||
#endif
|
||||
|
||||
} // namespace pst
|
||||
|
||||
#endif /* POLLINGSEQUENCEINIT_H_ */
|
||||
|
@ -37,6 +37,8 @@ class AxiPtmeConfig : public SystemObject {
|
||||
* The default implementation of the PTME generates a clock where the high level is
|
||||
* only one bit clock period long. This might be too short to match the setup and hold
|
||||
* times of the S-and transceiver.
|
||||
* Default: Enables TX clock manipulator
|
||||
*
|
||||
*/
|
||||
ReturnValue_t enableTxclockManipulator();
|
||||
ReturnValue_t disableTxclockManipulator();
|
||||
@ -47,6 +49,7 @@ class AxiPtmeConfig : public SystemObject {
|
||||
* Enable inversion will update data on falling edge (not the configuration required by the
|
||||
* syrlinks)
|
||||
* Disable clock inversion. Data updated on rising edge.
|
||||
* Default: Inversion is disabled
|
||||
*/
|
||||
ReturnValue_t enableTxclockInversion();
|
||||
ReturnValue_t disableTxclockInversion();
|
||||
@ -54,7 +57,7 @@ class AxiPtmeConfig : public SystemObject {
|
||||
private:
|
||||
// Address of register storing the bitrate configuration parameter
|
||||
static const uint32_t CADU_BITRATE_REG = 0x0;
|
||||
// Address to register storing common configuration parameters
|
||||
// Address of register storing common configuration parameters
|
||||
static const uint32_t COMMON_CONFIG_REG = 0x4;
|
||||
static const uint32_t ADRESS_DIVIDER = 4;
|
||||
|
||||
|
@ -326,6 +326,7 @@ void PdecHandler::handleNewTc() {
|
||||
printTC(tcLength);
|
||||
#endif /* OBSW_DEBUG_PDEC_HANDLER */
|
||||
|
||||
#if OBSW_TC_FROM_PDEC == 1
|
||||
store_address_t storeId;
|
||||
result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1);
|
||||
if (result != RETURN_OK) {
|
||||
@ -343,6 +344,7 @@ void PdecHandler::handleNewTc() {
|
||||
tcStore->deleteData(storeId);
|
||||
return;
|
||||
}
|
||||
#endif /* OBSW_TC_FROM_PDEC == 1 */
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class PdecHandler : public SystemObject,
|
||||
static const uint32_t PDEC_SLEN_OFFSET = 0xA26;
|
||||
static const uint32_t PDEC_MON_OFFSET = 0xA27;
|
||||
|
||||
#if BOARD_TE0720 == 1
|
||||
#ifdef TE0720_1CFA
|
||||
static const int CONFIG_MEMORY_MAP_SIZE = 0x400;
|
||||
static const int RAM_MAP_SIZE = 0x4000;
|
||||
static const int REGISTER_MAP_SIZE = 0x10000;
|
||||
@ -169,7 +169,7 @@ class PdecHandler : public SystemObject,
|
||||
static const size_t MAX_TC_SEGMENT_SIZE = 1017;
|
||||
static const uint8_t MAP_ID_MASK = 0x3F;
|
||||
|
||||
#if BOARD_TE0720 == 1
|
||||
#ifdef TE0720_1CFA
|
||||
static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000;
|
||||
#else
|
||||
static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
#include "utility.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -5,6 +6,7 @@
|
||||
#include "FSFWConfig.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
void utility::handleSystemError(int retcode, std::string function) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
@ -12,3 +14,14 @@ void utility::handleSystemError(int retcode, std::string function) {
|
||||
<< strerror(retcode) << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool utility::timeSanityCheck() {
|
||||
timeval currentTime = {};
|
||||
Clock::getUptime(¤tTime);
|
||||
Clock::TimeOfDay_t currTimeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(¤tTime, &currTimeOfDay);
|
||||
if (currTimeOfDay.year == 2000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ namespace utility {
|
||||
|
||||
void handleSystemError(int retcode, std::string function);
|
||||
|
||||
}
|
||||
bool timeSanityCheck();
|
||||
|
||||
} // namespace utility
|
||||
|
||||
#endif /* LINUX_UTILITY_UTILITY_H_ */
|
||||
|
Reference in New Issue
Block a user