added local parameter handler to PdecConfig to store persistent parameters
This commit is contained in:
parent
28f3b07c5c
commit
3b17af9d07
@ -22,7 +22,7 @@ ReturnValue_t FilesystemHelper::checkPath(std::string path) {
|
|||||||
}
|
}
|
||||||
} else if (path.substr(0, sizeof(config::SD_1_MOUNT_POINT)) ==
|
} else if (path.substr(0, sizeof(config::SD_1_MOUNT_POINT)) ==
|
||||||
std::string(config::SD_1_MOUNT_POINT)) {
|
std::string(config::SD_1_MOUNT_POINT)) {
|
||||||
if (!sdcMan->isSdCardUsable(sd::SLOT_0)) {
|
if (!sdcMan->isSdCardUsable(sd::SLOT_1)) {
|
||||||
sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
|
sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
|
||||||
return SD_NOT_MOUNTED;
|
return SD_NOT_MOUNTED;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,14 @@ LocalParameterHandler::~LocalParameterHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LocalParameterHandler::initialize() {
|
ReturnValue_t LocalParameterHandler::initialize() {
|
||||||
std::string mountPrefix = sdcMan->getCurrentMountPrefix();
|
std::string mountPrefix;
|
||||||
|
auto activeSd = sdcMan->getActiveSdCard();
|
||||||
|
if (activeSd and sdcMan->isSdCardUsable(activeSd.value())) {
|
||||||
|
mountPrefix = sdcMan->getCurrentMountPrefix();
|
||||||
|
} else {
|
||||||
|
return SD_NOT_READY;
|
||||||
|
}
|
||||||
|
mountPrefix = sdcMan->getCurrentMountPrefix();
|
||||||
std::string fullname = mountPrefix + "/" + sdRelativeName;
|
std::string fullname = mountPrefix + "/" + sdRelativeName;
|
||||||
setFullName(fullname);
|
setFullName(fullname);
|
||||||
ReturnValue_t result = readJsonFile();
|
ReturnValue_t result = readJsonFile();
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
*/
|
*/
|
||||||
class LocalParameterHandler : public NVMParameterBase {
|
class LocalParameterHandler : public NVMParameterBase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::LOCAL_PARAM_HANDLER;
|
||||||
|
|
||||||
|
static constexpr ReturnValue_t SD_NOT_READY = returnvalue::makeCode(INTERFACE_ID, 0);
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
|
@ -15,6 +15,7 @@ enum {
|
|||||||
CLASS_ID_START = COMMON_CLASS_ID_END,
|
CLASS_ID_START = COMMON_CLASS_ID_END,
|
||||||
SD_CARD_MANAGER, // SDMA
|
SD_CARD_MANAGER, // SDMA
|
||||||
SCRATCH_BUFFER, // SCBU
|
SCRATCH_BUFFER, // SCBU
|
||||||
|
LOCAL_PARAM_HANDLER, // LPH
|
||||||
CLASS_ID_END // [EXPORT] : [END]
|
CLASS_ID_END // [EXPORT] : [END]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "pdecconfigdefs.h"
|
#include "pdecconfigdefs.h"
|
||||||
|
|
||||||
PdecConfig::PdecConfig() : localParameterHandler("conf/pdecconfig", SdCardManager::instance()) {}
|
PdecConfig::PdecConfig() : localParameterHandler("conf/pdecconfig.json", SdCardManager::instance()) {}
|
||||||
|
|
||||||
PdecConfig::~PdecConfig() {}
|
PdecConfig::~PdecConfig() {}
|
||||||
|
|
||||||
@ -35,15 +35,13 @@ ReturnValue_t PdecConfig::write() {
|
|||||||
|
|
||||||
ReturnValue_t PdecConfig::initializePersistentParameters() {
|
ReturnValue_t PdecConfig::initializePersistentParameters() {
|
||||||
ReturnValue_t result = localParameterHandler.initialize();
|
ReturnValue_t result = localParameterHandler.initialize();
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
if (result == HasFileSystemIF::FILE_DOES_NOT_EXIST) {
|
if (result == HasFileSystemIF::FILE_DOES_NOT_EXIST) {
|
||||||
result = createPersistentConfig();
|
result = createPersistentConfig();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return result;
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PdecConfig::createPersistentConfig() {
|
ReturnValue_t PdecConfig::createPersistentConfig() {
|
||||||
|
@ -77,15 +77,28 @@ ReturnValue_t PdecHandler::initialize() {
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = pdecConfig.write();
|
result = actionHelper.initialize(commandQueue);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
sif::error << "PdecHandler::initialize: Failed to write PDEC config" << std::endl;
|
return result;
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
}
|
||||||
|
|
||||||
|
return returnvalue::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PdecHandler::firstLoop() {
|
||||||
|
ReturnValue_t result = pdecConfig.write();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
if (result == LocalParameterHandler::SD_NOT_READY) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
sif::error << "PdecHandler::firstLoop: Failed to write PDEC config" << std::endl;
|
||||||
|
}
|
||||||
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = releasePdec();
|
result = releasePdec();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This configuration must be done while the PDEC is not held in reset.
|
// This configuration must be done while the PDEC is not held in reset.
|
||||||
@ -93,11 +106,12 @@ ReturnValue_t PdecHandler::initialize() {
|
|||||||
// Configure interrupt mask register to enable interrupts
|
// Configure interrupt mask register to enable interrupts
|
||||||
*(registerBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg();
|
*(registerBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg();
|
||||||
}
|
}
|
||||||
result = actionHelper.initialize(commandQueue);
|
result = resetFarStatFlag();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
|
// Requires reconfiguration and reinitialization of PDEC
|
||||||
|
triggerEvent(INVALID_FAR);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,19 +125,11 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PdecHandler::polledOperation() {
|
ReturnValue_t PdecHandler::polledOperation() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
readCommandQueue();
|
readCommandQueue();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case State::INIT:
|
case State::INIT:
|
||||||
resetFarStatFlag();
|
handleInitState();
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
// Requires reconfiguration and reinitialization of PDEC
|
|
||||||
triggerEvent(INVALID_FAR);
|
|
||||||
state = State::WAIT_FOR_RECOVERY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
state = State::RUNNING;
|
|
||||||
break;
|
break;
|
||||||
case State::RUNNING:
|
case State::RUNNING:
|
||||||
if (newTcReceived()) {
|
if (newTcReceived()) {
|
||||||
@ -143,7 +149,6 @@ ReturnValue_t PdecHandler::polledOperation() {
|
|||||||
|
|
||||||
// See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information.
|
// See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information.
|
||||||
ReturnValue_t PdecHandler::irqOperation() {
|
ReturnValue_t PdecHandler::irqOperation() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
int fd = open(uioNames.irq, O_RDWR);
|
int fd = open(uioNames.irq, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
sif::error << "PdecHandler::irqOperation: Opening UIO IRQ file" << uioNames.irq << " failed"
|
sif::error << "PdecHandler::irqOperation: Opening UIO IRQ file" << uioNames.irq << " failed"
|
||||||
@ -166,14 +171,7 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
readCommandQueue();
|
readCommandQueue();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case State::INIT:
|
case State::INIT:
|
||||||
result = resetFarStatFlag();
|
handleInitState();
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
// Requires reconfiguration and reinitialization of PDEC
|
|
||||||
triggerEvent(INVALID_FAR);
|
|
||||||
state = State::WAIT_FOR_RECOVERY;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
state = State::RUNNING;
|
|
||||||
break;
|
break;
|
||||||
case State::RUNNING: {
|
case State::RUNNING: {
|
||||||
checkAndHandleIrqs(fd, info);
|
checkAndHandleIrqs(fd, info);
|
||||||
@ -194,6 +192,27 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PdecHandler::handleInitState() {
|
||||||
|
ReturnValue_t result = firstLoop();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
if (result == LocalParameterHandler::SD_NOT_READY) {
|
||||||
|
TaskFactory::delayTask(400);
|
||||||
|
if (initTries == MAX_INIT_TRIES) {
|
||||||
|
sif::error << "PdecHandler::handleInitState: SD card never "
|
||||||
|
"becomes ready"
|
||||||
|
<< std::endl;
|
||||||
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
state = State::INIT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
|
}
|
||||||
|
state = State::RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) {
|
ReturnValue_t PdecHandler::checkAndHandleIrqs(int fd, uint32_t& info) {
|
||||||
ssize_t nb = write(fd, &info, sizeof(info));
|
ssize_t nb = write(fd, &info, sizeof(info));
|
||||||
if (nb != static_cast<ssize_t>(sizeof(info))) {
|
if (nb != static_cast<ssize_t>(sizeof(info))) {
|
||||||
|
@ -169,6 +169,8 @@ class PdecHandler : public SystemObject,
|
|||||||
static const uint32_t NO_RF_MASK = 0x8000;
|
static const uint32_t NO_RF_MASK = 0x8000;
|
||||||
static const uint32_t NO_BITLOCK_MASK = 0x4000;
|
static const uint32_t NO_BITLOCK_MASK = 0x4000;
|
||||||
|
|
||||||
|
static const uint32_t MAX_INIT_TRIES = 20;
|
||||||
|
|
||||||
class ParameterId {
|
class ParameterId {
|
||||||
public:
|
public:
|
||||||
// ID of the parameter to update the positive window of AD frames
|
// ID of the parameter to update the positive window of AD frames
|
||||||
@ -258,6 +260,16 @@ class PdecHandler : public SystemObject,
|
|||||||
|
|
||||||
PdecConfig pdecConfig;
|
PdecConfig pdecConfig;
|
||||||
|
|
||||||
|
uint32_t initTries = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Performs initialization stuff which must be performed in first
|
||||||
|
* loop of running task
|
||||||
|
*
|
||||||
|
* @return OK if successful, otherwise FAILED
|
||||||
|
*/
|
||||||
|
ReturnValue_t firstLoop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reads and handles messages stored in the commandQueue
|
* @brief Reads and handles messages stored in the commandQueue
|
||||||
*/
|
*/
|
||||||
@ -265,6 +277,7 @@ class PdecHandler : public SystemObject,
|
|||||||
|
|
||||||
ReturnValue_t polledOperation();
|
ReturnValue_t polledOperation();
|
||||||
ReturnValue_t irqOperation();
|
ReturnValue_t irqOperation();
|
||||||
|
void handleInitState();
|
||||||
ReturnValue_t checkAndHandleIrqs(int fd, uint32_t& info);
|
ReturnValue_t checkAndHandleIrqs(int fd, uint32_t& info);
|
||||||
|
|
||||||
uint32_t readFar();
|
uint32_t readFar();
|
||||||
|
@ -664,7 +664,7 @@ ReturnValue_t PayloadPcduHandler::getParameter(uint8_t domainId, uint8_t uniqueI
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PayloadPcduHandler::handleFailureInjection(std::string output, Event event) {
|
void PayloadPcduHandler::handleFailureInjection(std::string output, Event event) {
|
||||||
sif::info << "PayloadPcduHandler::checkAdcValues: " << output
|
sif::info << "PayloadPcduHandler::handleFailureInjection: " << output
|
||||||
<< " failure injection. "
|
<< " failure injection. "
|
||||||
"Transitioning back to off"
|
"Transitioning back to off"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user