added rest of necessary logic
This commit is contained in:
parent
213dba1e75
commit
dc1e51891e
@ -146,6 +146,7 @@ ReturnValue_t PdecHandler::polledOperation() {
|
||||
break;
|
||||
}
|
||||
case State::PDEC_RESET: {
|
||||
triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT);
|
||||
ReturnValue_t result = pdecToReset();
|
||||
if (result != returnvalue::OK) {
|
||||
triggerEvent(PDEC_RESET_FAILED);
|
||||
@ -194,11 +195,12 @@ ReturnValue_t PdecHandler::irqOperation() {
|
||||
break;
|
||||
}
|
||||
case State::PDEC_RESET: {
|
||||
triggerEvent(pdec::PDEC_TRYING_RESET_WITH_INIT);
|
||||
result = pdecToReset();
|
||||
if (result != returnvalue::OK) {
|
||||
triggerEvent(PDEC_RESET_FAILED);
|
||||
}
|
||||
usleep(10);
|
||||
usleep(20);
|
||||
state = State::INIT;
|
||||
break;
|
||||
}
|
||||
@ -352,9 +354,7 @@ ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t c
|
||||
printPdecMon();
|
||||
return EXECUTION_FINISHED;
|
||||
case RESET_PDEC_NO_REINIITALIZATION: {
|
||||
pdecToReset();
|
||||
usleep(20);
|
||||
releasePdec();
|
||||
pdecResetNoInit();
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case RESET_PDEC_WITH_REINIITALIZATION: {
|
||||
@ -780,6 +780,13 @@ void PdecHandler::initFailedHandler(ReturnValue_t reason) {
|
||||
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) {
|
||||
switch (status) {
|
||||
case TC_CHANNEL_INACTIVE:
|
||||
|
@ -363,6 +363,8 @@ class PdecHandler : public SystemObject,
|
||||
*/
|
||||
void printPdecMon();
|
||||
|
||||
void pdecResetNoInit();
|
||||
|
||||
void initFailedHandler(ReturnValue_t reason);
|
||||
|
||||
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 =
|
||||
event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
||||
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
|
||||
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
|
||||
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
|
||||
//! 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
|
||||
static constexpr ActionId_t PRINT_CLCW = 0;
|
||||
|
@ -63,11 +63,8 @@ void EiveSystem::performChildOperation() {
|
||||
performSafeRecovery = false;
|
||||
return;
|
||||
}
|
||||
if (frameDirtyCheckCd.hasTimedOut()) {
|
||||
if (frameDirtyErrorCounter >= 4) {
|
||||
}
|
||||
frameDirtyErrorCounter = 0;
|
||||
}
|
||||
pdecRecoveryLogic();
|
||||
|
||||
i2cRecoveryLogic();
|
||||
}
|
||||
|
||||
@ -92,6 +89,12 @@ ReturnValue_t EiveSystem::initialize() {
|
||||
}
|
||||
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);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -188,9 +191,8 @@ void EiveSystem::i2cRecoveryLogic() {
|
||||
} else {
|
||||
// We already tried an I2C recovery but the bus is still broken.
|
||||
// Send full reboot request to core controller.
|
||||
CommandMessage msg;
|
||||
ActionMessage::setCommand(&msg, core::REBOOT_OBC, store_address_t());
|
||||
result = commandQueue->sendMessage(coreCtrlQueueId, &msg);
|
||||
sendFullRebootCommand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,6 +271,33 @@ void EiveSystem::i2cRecoveryLogic() {
|
||||
|
||||
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() {
|
||||
alreadyTriedI2cRecovery = true;
|
||||
performI2cReboot = false;
|
||||
|
@ -37,11 +37,14 @@ class EiveSystem : public Subsystem, public HasActionsIF {
|
||||
|
||||
uint8_t frameDirtyErrorCounter = 0;
|
||||
Countdown frameDirtyCheckCd = Countdown(10000);
|
||||
Countdown ptmeResetWasAttemptedCd = Countdown(60000);
|
||||
|
||||
ActionHelper actionHelper;
|
||||
PowerSwitchIF* powerSwitcher = nullptr;
|
||||
std::atomic_uint16_t& i2cErrors;
|
||||
|
||||
MessageQueueId_t pdecHandlerQueueId = MessageQueueIF::NO_QUEUE;
|
||||
|
||||
MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE;
|
||||
MessageQueueId_t coreCtrlQueueId = 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;
|
||||
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||
|
||||
ReturnValue_t sendFullRebootCommand();
|
||||
|
||||
void pdecRecoveryLogic();
|
||||
|
||||
void i2cRecoveryLogic();
|
||||
void handleEventMessages();
|
||||
void commandSelfToSafe();
|
||||
|
Loading…
Reference in New Issue
Block a user