#ifndef BSP_Q7S_CORE_CORECONTROLLER_H_ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include #include "fsfw/controller/ExtendedControllerBase.h" #include "bsp_q7s/memory/SdCardManager.h" #include "events/subsystemIdRanges.h" class Timer; class SdCardManager; class CoreController: public ExtendedControllerBase { public: enum Chip: uint8_t { CHIP_0, CHIP_1, NO_CHIP }; enum Copy: uint8_t { COPY_0, COPY_1, NO_COPY }; static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; static constexpr ActionId_t REBOOT_OBC = 32; static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); CoreController(object_id_t objectId); virtual~ CoreController(); ReturnValue_t initialize() override; ReturnValue_t initializeAfterTaskCreation() override; ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; ReturnValue_t handleCommandMessage(CommandMessage *message) override; void performControlOperation() override; static ReturnValue_t incrementAllocationFailureCount(); static void getCurrentBootCopy(Chip& chip, Copy& copy); private: static Chip currentChip; static Copy currentCopy; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); // States for non-blocking setup enum class SdStates { NONE, START, GET_INFO, SET_STATE, MOUNT, UPDATE_INFO, DONE }; static constexpr bool BLOCKING_SD_INIT = true; SdCardManager* sdcMan = nullptr; uint16_t sdcInitCycleCount = 0; ReturnValue_t initSdCardBlocking(); ReturnValue_t initSdCardNonBlocking(); sd::SdCard preferredSdCard = sd::SdCard::NONE; SdStates state = SdStates::START; SdCardManager::SdStatusPair statusPair; bool commandExecuted = true; bool sdInitFinished = false; ReturnValue_t sdCardSetup(SdCardManager::SdStatusPair& statusPair, sd::SdCard sdCard, std::string sdString); ReturnValue_t sdCardColdRedundantInit(SdCardManager* sdcMan, SdCardManager::SdStatusPair& statusPair, SdStates step = SdStates::NONE); void determinePreferredSdCard(); ReturnValue_t initVersionFile(); ReturnValue_t initBootCopy(); ReturnValue_t initWatchdogFifo(); ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size); ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); void initPrint(); // Designated value for rechecking FIFO open static constexpr int RETRY_FIFO_OPEN = -2; int watchdogFifoFd = 0; PeriodicOperationDivider opDivider; void performWatchdogControlOperation(); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */