added mutex protection for power switches
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <devices/powerSwitcherList.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
|
||||
#include <fsfw/ipc/MutexFactory.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
|
||||
@ -15,6 +16,7 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize)
|
||||
cmdQueueSize(cmdQueueSize) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
pwrMutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
PCDUHandler::~PCDUHandler() {}
|
||||
@ -156,8 +158,9 @@ void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSet
|
||||
|
||||
void PCDUHandler::updatePdu2SwitchStates() {
|
||||
using namespace pcduSwitches;
|
||||
PoolReadGuard rf(&pdu2HkTableDataset);
|
||||
if (rf.getReadResult() == RETURN_OK) {
|
||||
PoolReadGuard rg(&pdu2HkTableDataset);
|
||||
if (rg.getReadResult() == RETURN_OK) {
|
||||
MutexGuard mg(pwrMutex);
|
||||
switchStates[Switches::PDU2_CH0_Q7S] = pdu2HkTableDataset.outEnabledQ7S.value;
|
||||
switchStates[Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8] =
|
||||
pdu2HkTableDataset.outEnabledPlPCDUCh1.value;
|
||||
@ -181,9 +184,10 @@ void PCDUHandler::updatePdu2SwitchStates() {
|
||||
}
|
||||
|
||||
void PCDUHandler::updatePdu1SwitchStates() {
|
||||
if (pdu1HkTableDataset.read() == RETURN_OK) {
|
||||
using namespace pcduSwitches;
|
||||
PoolReadGuard rf(&pdu1HkTableDataset);
|
||||
using namespace pcduSwitches;
|
||||
PoolReadGuard rg(&pdu1HkTableDataset);
|
||||
if (rg.getReadResult() == RETURN_OK) {
|
||||
MutexGuard mg(pwrMutex);
|
||||
switchStates[Switches::PDU1_CH0_TCS_BOARD_3V3] = pdu1HkTableDataset.outEnabledTCSBoard3V3.value;
|
||||
switchStates[Switches::PDU1_CH1_SYRLINKS_12V] = pdu1HkTableDataset.outEnabledSyrlinks.value;
|
||||
switchStates[Switches::PDU1_CH2_STAR_TRACKER_5V] =
|
||||
@ -352,7 +356,10 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const {
|
||||
sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
if (switchStates[switchNr] == 1) {
|
||||
pwrMutex->lockMutex();
|
||||
uint8_t currentState = switchStates[switchNr];
|
||||
pwrMutex->unlockMutex();
|
||||
if (currentState == 1) {
|
||||
return PowerSwitchIF::SWITCH_ON;
|
||||
} else {
|
||||
return PowerSwitchIF::SWITCH_OFF;
|
||||
|
Reference in New Issue
Block a user