added rest of necessary logic
This commit is contained in:
parent
213dba1e75
commit
dc1e51891e
@ -146,6 +146,7 @@ ReturnValue_t PdecHandler::polledOperation() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case State::PDEC_RESET: {
|
case State::PDEC_RESET: {
|
||||||
|
triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT);
|
||||||
ReturnValue_t result = pdecToReset();
|
ReturnValue_t result = pdecToReset();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
triggerEvent(PDEC_RESET_FAILED);
|
triggerEvent(PDEC_RESET_FAILED);
|
||||||
@ -194,11 +195,12 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case State::PDEC_RESET: {
|
case State::PDEC_RESET: {
|
||||||
|
triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT);
|
||||||
result = pdecToReset();
|
result = pdecToReset();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
triggerEvent(PDEC_RESET_FAILED);
|
triggerEvent(PDEC_RESET_FAILED);
|
||||||
}
|
}
|
||||||
usleep(10);
|
usleep(20);
|
||||||
state = State::INIT;
|
state = State::INIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -352,9 +354,7 @@ ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t c
|
|||||||
printPdecMon();
|
printPdecMon();
|
||||||
return EXECUTION_FINISHED;
|
return EXECUTION_FINISHED;
|
||||||
case RESET_PDEC_NO_REINIITALIZATION: {
|
case RESET_PDEC_NO_REINIITALIZATION: {
|
||||||
pdecToReset();
|
pdecResetNoInit();
|
||||||
usleep(20);
|
|
||||||
releasePdec();
|
|
||||||
return EXECUTION_FINISHED;
|
return EXECUTION_FINISHED;
|
||||||
}
|
}
|
||||||
case RESET_PDEC_WITH_REINIITALIZATION: {
|
case RESET_PDEC_WITH_REINIITALIZATION: {
|
||||||
@ -780,6 +780,13 @@ void PdecHandler::initFailedHandler(ReturnValue_t reason) {
|
|||||||
state = State::WAIT_FOR_RECOVERY;
|
state = State::WAIT_FOR_RECOVERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PdecHandler::pdecResetNoInit() {
|
||||||
|
triggerEvent(pdec::PDEC_TRYING_RESET_NO_INIT);
|
||||||
|
pdecToReset();
|
||||||
|
usleep(20);
|
||||||
|
releasePdec();
|
||||||
|
}
|
||||||
|
|
||||||
std::string PdecHandler::getMonStatusString(uint32_t status) {
|
std::string PdecHandler::getMonStatusString(uint32_t status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case TC_CHANNEL_INACTIVE:
|
case TC_CHANNEL_INACTIVE:
|
||||||
|
@ -363,6 +363,8 @@ class PdecHandler : public SystemObject,
|
|||||||
*/
|
*/
|
||||||
void printPdecMon();
|
void printPdecMon();
|
||||||
|
|
||||||
|
void pdecResetNoInit();
|
||||||
|
|
||||||
void initFailedHandler(ReturnValue_t reason);
|
void initFailedHandler(ReturnValue_t reason);
|
||||||
|
|
||||||
std::string getMonStatusString(uint32_t status);
|
std::string getMonStatusString(uint32_t status);
|
||||||
|
@ -29,13 +29,19 @@ static constexpr Event TOO_MANY_IRQS = MAKE_EVENT(7, severity::MEDIUM);
|
|||||||
static constexpr Event POLL_SYSCALL_ERROR_PDEC =
|
static constexpr Event POLL_SYSCALL_ERROR_PDEC =
|
||||||
event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
||||||
static constexpr Event WRITE_SYSCALL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 9, severity::HIGH);
|
static constexpr Event WRITE_SYSCALL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 9, severity::HIGH);
|
||||||
|
//! [EXPORT] : [COMMENT] Trying a PDEC reset with complete re-initialization
|
||||||
|
static constexpr Event PDEC_TRYING_RESET_WITH_INIT =
|
||||||
|
event::makeEvent(SUBSYSTEM_ID, 10, severity::LOW);
|
||||||
|
//! [EXPORT] : [COMMENT] Trying a PDEC reset without re-initialization.
|
||||||
|
static constexpr Event PDEC_TRYING_RESET_NO_INIT =
|
||||||
|
event::makeEvent(SUBSYSTEM_ID, 11, severity::LOW);
|
||||||
//! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low
|
//! [EXPORT] : [COMMENT] Failed to pull PDEC reset to low
|
||||||
static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 10, severity::HIGH);
|
static constexpr Event PDEC_RESET_FAILED = event::makeEvent(SUBSYSTEM_ID, 12, severity::HIGH);
|
||||||
//! [EXPORT] : [COMMENT] Failed to open the IRQ uio file
|
//! [EXPORT] : [COMMENT] Failed to open the IRQ uio file
|
||||||
static constexpr Event OPEN_IRQ_FILE_FAILED = event::makeEvent(SUBSYSTEM_ID, 11, severity::HIGH);
|
static constexpr Event OPEN_IRQ_FILE_FAILED = event::makeEvent(SUBSYSTEM_ID, 13, severity::HIGH);
|
||||||
//! [EXPORT] : [COMMENT] PDEC initialization failed. This might also be due to the persistent
|
//! [EXPORT] : [COMMENT] PDEC initialization failed. This might also be due to the persistent
|
||||||
//! confiuration never becoming available, for example due to SD card issues.
|
//! confiuration never becoming available, for example due to SD card issues.
|
||||||
static constexpr Event PDEC_INIT_FAILED = event::makeEvent(SUBSYSTEM_ID, 12, severity::HIGH);
|
static constexpr Event PDEC_INIT_FAILED = event::makeEvent(SUBSYSTEM_ID, 14, severity::HIGH);
|
||||||
|
|
||||||
// Action IDs
|
// Action IDs
|
||||||
static constexpr ActionId_t PRINT_CLCW = 0;
|
static constexpr ActionId_t PRINT_CLCW = 0;
|
||||||
|
@ -63,11 +63,8 @@ void EiveSystem::performChildOperation() {
|
|||||||
performSafeRecovery = false;
|
performSafeRecovery = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (frameDirtyCheckCd.hasTimedOut()) {
|
pdecRecoveryLogic();
|
||||||
if (frameDirtyErrorCounter >= 4) {
|
|
||||||
}
|
|
||||||
frameDirtyErrorCounter = 0;
|
|
||||||
}
|
|
||||||
i2cRecoveryLogic();
|
i2cRecoveryLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +89,12 @@ ReturnValue_t EiveSystem::initialize() {
|
|||||||
}
|
}
|
||||||
coreCtrlQueueId = coreCtrl->getCommandQueue();
|
coreCtrlQueueId = coreCtrl->getCommandQueue();
|
||||||
|
|
||||||
|
auto* pdecHandler = ObjectManager::instance()->get<HasActionsIF>(objects::PDEC_HANDLER);
|
||||||
|
if (pdecHandler == nullptr) {
|
||||||
|
return ObjectManager::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
pdecHandlerQueueId = pdecHandler->getCommandQueue();
|
||||||
|
|
||||||
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
@ -188,9 +191,8 @@ void EiveSystem::i2cRecoveryLogic() {
|
|||||||
} else {
|
} else {
|
||||||
// We already tried an I2C recovery but the bus is still broken.
|
// We already tried an I2C recovery but the bus is still broken.
|
||||||
// Send full reboot request to core controller.
|
// Send full reboot request to core controller.
|
||||||
CommandMessage msg;
|
sendFullRebootCommand();
|
||||||
ActionMessage::setCommand(&msg, core::REBOOT_OBC, store_address_t());
|
return;
|
||||||
result = commandQueue->sendMessage(coreCtrlQueueId, &msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,6 +271,33 @@ void EiveSystem::i2cRecoveryLogic() {
|
|||||||
|
|
||||||
void EiveSystem::commandSelfToSafe() { startTransition(satsystem::Mode::SAFE, 0); }
|
void EiveSystem::commandSelfToSafe() { startTransition(satsystem::Mode::SAFE, 0); }
|
||||||
|
|
||||||
|
ReturnValue_t EiveSystem::sendFullRebootCommand() {
|
||||||
|
CommandMessage msg;
|
||||||
|
ActionMessage::setCommand(&msg, core::REBOOT_OBC, store_address_t());
|
||||||
|
return commandQueue->sendMessage(coreCtrlQueueId, &msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EiveSystem::pdecRecoveryLogic() {
|
||||||
|
if (frameDirtyCheckCd.hasTimedOut()) {
|
||||||
|
if (frameDirtyErrorCounter >= 4) {
|
||||||
|
// If a PTME reset was already attempted and there is still an issue receiving TC frames,
|
||||||
|
// reboot the system.
|
||||||
|
if (ptmeResetWasAttemptedCd.isBusy()) {
|
||||||
|
// Send reboot command.
|
||||||
|
sendFullRebootCommand();
|
||||||
|
} else {
|
||||||
|
// Try one full PDEC reset.
|
||||||
|
CommandMessage msg;
|
||||||
|
store_address_t dummy{};
|
||||||
|
ActionMessage::setCommand(&msg, pdec::RESET_PDEC_WITH_REINIITALIZATION, dummy);
|
||||||
|
commandQueue->sendMessage(pdecHandlerQueueId, &msg);
|
||||||
|
ptmeResetWasAttemptedCd.resetTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
frameDirtyErrorCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EiveSystem::commonI2cRecoverySequenceFinish() {
|
void EiveSystem::commonI2cRecoverySequenceFinish() {
|
||||||
alreadyTriedI2cRecovery = true;
|
alreadyTriedI2cRecovery = true;
|
||||||
performI2cReboot = false;
|
performI2cReboot = false;
|
||||||
|
@ -37,11 +37,14 @@ class EiveSystem : public Subsystem, public HasActionsIF {
|
|||||||
|
|
||||||
uint8_t frameDirtyErrorCounter = 0;
|
uint8_t frameDirtyErrorCounter = 0;
|
||||||
Countdown frameDirtyCheckCd = Countdown(10000);
|
Countdown frameDirtyCheckCd = Countdown(10000);
|
||||||
|
Countdown ptmeResetWasAttemptedCd = Countdown(60000);
|
||||||
|
|
||||||
ActionHelper actionHelper;
|
ActionHelper actionHelper;
|
||||||
PowerSwitchIF* powerSwitcher = nullptr;
|
PowerSwitchIF* powerSwitcher = nullptr;
|
||||||
std::atomic_uint16_t& i2cErrors;
|
std::atomic_uint16_t& i2cErrors;
|
||||||
|
|
||||||
|
MessageQueueId_t pdecHandlerQueueId = MessageQueueIF::NO_QUEUE;
|
||||||
|
|
||||||
MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE;
|
||||||
MessageQueueId_t coreCtrlQueueId = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t coreCtrlQueueId = MessageQueueIF::NO_QUEUE;
|
||||||
MessageQueueId_t actionCommandedBy = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t actionCommandedBy = MessageQueueIF::NO_QUEUE;
|
||||||
@ -56,6 +59,10 @@ class EiveSystem : public Subsystem, public HasActionsIF {
|
|||||||
const uint8_t* data, size_t size) override;
|
const uint8_t* data, size_t size) override;
|
||||||
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||||
|
|
||||||
|
ReturnValue_t sendFullRebootCommand();
|
||||||
|
|
||||||
|
void pdecRecoveryLogic();
|
||||||
|
|
||||||
void i2cRecoveryLogic();
|
void i2cRecoveryLogic();
|
||||||
void handleEventMessages();
|
void handleEventMessages();
|
||||||
void commandSelfToSafe();
|
void commandSelfToSafe();
|
||||||
|
Loading…
Reference in New Issue
Block a user