refactor power code
This commit is contained in:
parent
b43e1ef4e9
commit
c9e16642c5
@ -26,6 +26,13 @@ will consitute of a breaking change warranting a new major release:
|
||||
- Limitation of RW speeds was done before converting them to the correct unit scale.
|
||||
- The Syrlinks task now has a proper name instead of `MAIN_SPI`.
|
||||
|
||||
## Changed
|
||||
|
||||
- Initialize switch states to a special `SWITCH_STATE_UNKNOWN` (2) variable. Return
|
||||
`returnvalue::FAILED` in switch state getter.
|
||||
- Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that
|
||||
the switch states were initialized.
|
||||
|
||||
# [v1.37.0] 2023-03-11
|
||||
|
||||
eive-tmtc: v2.18.1
|
||||
|
@ -32,8 +32,13 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP;
|
||||
xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY;
|
||||
|
||||
CoreController::CoreController(object_id_t objectId)
|
||||
: ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), cmdRepliesSizes(128),
|
||||
opDivider5(5), opDivider10(10), hkSet(this) {
|
||||
: ExtendedControllerBase(objectId, 5),
|
||||
cmdExecutor(4096),
|
||||
cmdReplyBuf(4096, true),
|
||||
cmdRepliesSizes(128),
|
||||
opDivider5(5),
|
||||
opDivider10(10),
|
||||
hkSet(this) {
|
||||
cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes);
|
||||
try {
|
||||
sdcMan = SdCardManager::instance();
|
||||
@ -318,7 +323,8 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
||||
}
|
||||
case (EXECUTE_SHELL_CMD): {
|
||||
std::string cmd = std::string(cmd, size);
|
||||
if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or shellCmdIsExecuting) {
|
||||
if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or
|
||||
shellCmdIsExecuting) {
|
||||
return HasActionsIF::IS_BUSY;
|
||||
}
|
||||
cmdExecutor.load(cmd, false, false);
|
||||
|
@ -74,6 +74,8 @@
|
||||
#include <mission/devices/GyrAdis1650XHandler.h>
|
||||
#include <mission/devices/ImtqHandler.h>
|
||||
#include <mission/devices/PcduHandler.h>
|
||||
#include <mission/devices/Pdu1Handler.h>
|
||||
#include <mission/devices/Pdu2Handler.h>
|
||||
#include <mission/devices/SyrlinksHandler.h>
|
||||
#include <mission/devices/devicedefinitions/rwHelpers.h>
|
||||
#include <mission/tmtc/VirtualChannelWithQueue.h>
|
||||
@ -102,8 +104,6 @@
|
||||
#include "mission/devices/HeaterHandler.h"
|
||||
#include "mission/devices/Max31865PT1000Handler.h"
|
||||
#include "mission/devices/P60DockHandler.h"
|
||||
#include "mission/devices/PDU1Handler.h"
|
||||
#include "mission/devices/PDU2Handler.h"
|
||||
#include "mission/devices/PayloadPcduHandler.h"
|
||||
#include "mission/devices/RadiationSensorHandler.h"
|
||||
#include "mission/devices/RwHandler.h"
|
||||
@ -193,12 +193,12 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI
|
||||
new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie, p60Fdir);
|
||||
|
||||
auto pdu1Fdir = new GomspacePowerFdir(objects::PDU1_HANDLER);
|
||||
PDU1Handler* pdu1handler =
|
||||
new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir);
|
||||
Pdu1Handler* pdu1handler =
|
||||
new Pdu1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir);
|
||||
|
||||
auto pdu2Fdir = new GomspacePowerFdir(objects::PDU2_HANDLER);
|
||||
PDU2Handler* pdu2handler =
|
||||
new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir);
|
||||
Pdu2Handler* pdu2handler =
|
||||
new Pdu2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir);
|
||||
|
||||
auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER);
|
||||
ACUHandler* acuhandler =
|
||||
|
@ -66,6 +66,8 @@ int obsw::obsw(int argc, char* argv[]) {
|
||||
|
||||
// Command the EIVE system to safe mode
|
||||
#if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1
|
||||
// This ensures that the PCDU switches were updated.
|
||||
TaskFactory::delayTask(1000);
|
||||
commandEiveSystemToSafe();
|
||||
#else
|
||||
announceAllModes();
|
||||
|
@ -19,6 +19,7 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize)
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
pwrLock = MutexFactory::instance()->createMutex();
|
||||
std::memset(switchStates, SWITCH_STATE_UNKNOWN, sizeof(switchStates));
|
||||
}
|
||||
|
||||
PCDUHandler::~PCDUHandler() {}
|
||||
@ -407,6 +408,9 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const {
|
||||
MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX);
|
||||
currentState = switchStates[switchNr];
|
||||
}
|
||||
if (currentState == SWITCH_STATE_UNKNOWN) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if (currentState == 1) {
|
||||
return PowerSwitchIF::SWITCH_ON;
|
||||
} else {
|
||||
|
@ -35,7 +35,11 @@ class PCDUHandler : public PowerSwitchIF,
|
||||
|
||||
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
|
||||
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
|
||||
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override;
|
||||
/**
|
||||
* @param switchNr
|
||||
* @return returnvalue::FAILED if the switch state has not been updated yet.
|
||||
*/
|
||||
ReturnValue_t getSwitchState(uint8_t switchNr) const override;
|
||||
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override;
|
||||
virtual uint32_t getSwitchDelayMs(void) const override;
|
||||
virtual object_id_t getObjectId() const override;
|
||||
@ -84,6 +88,7 @@ class PCDUHandler : public PowerSwitchIF,
|
||||
/** The timeStamp of the current pdu1HkTableDataset */
|
||||
CCSDSTime::CDS_short timeStampPdu1HkDataset;
|
||||
|
||||
uint8_t SWITCH_STATE_UNKNOWN = 2;
|
||||
uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES];
|
||||
/**
|
||||
* Pointer to the IPCStore.
|
||||
|
@ -1,11 +1,10 @@
|
||||
#include "PDU1Handler.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <mission/devices/Pdu1Handler.h>
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
|
||||
#include "devices/powerSwitcherList.h"
|
||||
|
||||
PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
Pdu1Handler::Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
FailureIsolationBase *customFdir)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
|
||||
coreHk(this),
|
||||
@ -13,23 +12,23 @@ PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC
|
||||
initPduConfigTable();
|
||||
}
|
||||
|
||||
PDU1Handler::~PDU1Handler() {}
|
||||
Pdu1Handler::~Pdu1Handler() {}
|
||||
|
||||
ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
ReturnValue_t Pdu1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
*id = GOMSPACE::REQUEST_HK_TABLE;
|
||||
return buildCommandFromCommand(*id, NULL, 0);
|
||||
}
|
||||
|
||||
void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
void Pdu1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
parseHkTableReply(packet);
|
||||
}
|
||||
|
||||
void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) {
|
||||
void Pdu1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) {
|
||||
this->channelSwitchHook = hook;
|
||||
this->hookArgs = args;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
ReturnValue_t Pdu1Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
bool afterExecution) {
|
||||
using namespace PDU1;
|
||||
GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1;
|
||||
@ -79,15 +78,15 @@ ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PDU1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
void Pdu1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id);
|
||||
}
|
||||
|
||||
void PDU1Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
void Pdu1Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet);
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
ReturnValue_t Pdu1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU1);
|
||||
poolManager.subscribeForDiagPeriodicPacket(
|
||||
@ -97,7 +96,7 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) {
|
||||
LocalPoolDataSetBase *Pdu1Handler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == coreHk.getSid()) {
|
||||
return &coreHk;
|
||||
} else if (sid == auxHk.getSid()) {
|
||||
@ -106,7 +105,7 @@ LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t Pdu1Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
switch (cmd) {
|
||||
case (GOMSPACE::PRINT_SWITCH_V_I): {
|
||||
@ -137,7 +136,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void PDU1Handler::printHkTableSwitchVI() {
|
||||
void Pdu1Handler::printHkTableSwitchVI() {
|
||||
using namespace PDU1;
|
||||
sif::info << "PDU1 Info: " << std::endl;
|
||||
sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right
|
||||
@ -163,7 +162,7 @@ void PDU1Handler::printHkTableSwitchVI() {
|
||||
printerHelper("Syrlinks", Channels::SYRLINKS);
|
||||
}
|
||||
|
||||
void PDU1Handler::printHkTableLatchups() {
|
||||
void Pdu1Handler::printHkTableLatchups() {
|
||||
using namespace PDU1;
|
||||
sif::info << "PDU1 Latchup Information" << std::endl;
|
||||
auto printerHelper = [&](std::string channelStr, Channels idx) {
|
@ -19,11 +19,11 @@
|
||||
* ACS 3.3V for Side A group, channel 7
|
||||
* Unoccupied, 5V, channel 8
|
||||
*/
|
||||
class PDU1Handler : public GomspaceDeviceHandler {
|
||||
class Pdu1Handler : public GomspaceDeviceHandler {
|
||||
public:
|
||||
PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
FailureIsolationBase* customFdir);
|
||||
virtual ~PDU1Handler();
|
||||
virtual ~Pdu1Handler();
|
||||
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
@ -1,11 +1,10 @@
|
||||
#include "PDU2Handler.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <mission/devices/Pdu2Handler.h>
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
|
||||
#include "devices/powerSwitcherList.h"
|
||||
|
||||
PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
Pdu2Handler::Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
FailureIsolationBase *customFdir)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir),
|
||||
coreHk(this),
|
||||
@ -13,27 +12,27 @@ PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC
|
||||
initPduConfigTable();
|
||||
}
|
||||
|
||||
PDU2Handler::~PDU2Handler() {}
|
||||
Pdu2Handler::~Pdu2Handler() {}
|
||||
|
||||
ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
ReturnValue_t Pdu2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) {
|
||||
*id = GOMSPACE::REQUEST_HK_TABLE;
|
||||
return buildCommandFromCommand(*id, NULL, 0);
|
||||
}
|
||||
|
||||
void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
void Pdu2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
parseHkTableReply(packet);
|
||||
}
|
||||
|
||||
void PDU2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
void Pdu2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) {
|
||||
handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id);
|
||||
}
|
||||
|
||||
void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) {
|
||||
void Pdu2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) {
|
||||
this->channelSwitchHook = hook;
|
||||
this->hookArgs = args;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) {
|
||||
LocalPoolDataSetBase *Pdu2Handler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == coreHk.getSid()) {
|
||||
return &coreHk;
|
||||
} else if (sid == auxHk.getSid()) {
|
||||
@ -42,11 +41,11 @@ LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PDU2Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
void Pdu2Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet);
|
||||
}
|
||||
|
||||
ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
ReturnValue_t Pdu2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
LocalDataPoolManager &poolManager) {
|
||||
initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU2);
|
||||
poolManager.subscribeForDiagPeriodicPacket(
|
||||
@ -56,7 +55,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDat
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t Pdu2Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
switch (cmd) {
|
||||
case (GOMSPACE::PRINT_SWITCH_V_I): {
|
||||
@ -87,7 +86,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void PDU2Handler::printHkTableSwitchVI() {
|
||||
void Pdu2Handler::printHkTableSwitchVI() {
|
||||
using namespace PDU2;
|
||||
sif::info << "PDU2 Info:" << std::endl;
|
||||
sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right
|
||||
@ -111,7 +110,7 @@ void PDU2Handler::printHkTableSwitchVI() {
|
||||
printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA);
|
||||
}
|
||||
|
||||
void PDU2Handler::printHkTableLatchups() {
|
||||
void Pdu2Handler::printHkTableLatchups() {
|
||||
using namespace PDU2;
|
||||
sif::info << "PDU2 Latchup Information" << std::endl;
|
||||
auto printerHelper = [&](std::string channelStr, Channels idx) {
|
||||
@ -129,7 +128,7 @@ void PDU2Handler::printHkTableLatchups() {
|
||||
printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA);
|
||||
}
|
||||
|
||||
ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
ReturnValue_t Pdu2Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
bool afterExecution) {
|
||||
using namespace PDU2;
|
||||
GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2;
|
@ -19,11 +19,11 @@
|
||||
* ACS Board (Gyro, MGMs, GPS), 3.3V channel 7
|
||||
* Payload Camera, 8V, channel 8
|
||||
*/
|
||||
class PDU2Handler : public GomspaceDeviceHandler {
|
||||
class Pdu2Handler : public GomspaceDeviceHandler {
|
||||
public:
|
||||
PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||
FailureIsolationBase* customFdir);
|
||||
virtual ~PDU2Handler();
|
||||
virtual ~Pdu2Handler();
|
||||
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override;
|
Loading…
Reference in New Issue
Block a user