Merge branch 'develop' into eggert/acs
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Marius Eggert 2023-01-09 09:30:37 +01:00
commit 00d4a7602a
15 changed files with 82 additions and 72 deletions

View File

@ -10,10 +10,16 @@ list yields a list of all related PRs for each release.
# [unreleased]
## Fixed
- PLOC SUPV: Minor adaptions and important bugfix for UART manager
## Added
- First version of ACS controller
PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/329
- Allow commanding the 5V stack internally in software
PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/334
# [v1.18.0] 01.12.2022

View File

@ -1323,7 +1323,7 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
#endif
rebootFile.enabled = true;
rebootFile.enabled = false;
rebootFile.img00Cnt = 0;
rebootFile.img01Cnt = 0;
rebootFile.img10Cnt = 0;

View File

@ -33,8 +33,12 @@ void ObjectFactory::produce(void* args) {
new CoreController(objects::CORE_CONTROLLER);
createPcduComponents(gpioComIF, &pwrSwitcher);
#if OBSW_ADD_RAD_SENSORS == 1
createRadSensorComponent(gpioComIF);
#endif
#if OBSW_ADD_SUN_SENSORS == 1
createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV);
#endif
#if OBSW_ADD_ACS_BOARD == 1
createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher);

View File

@ -152,7 +152,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
* sent and received packets.
*/
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid, sequenceCount) {
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
spParams.setFullPayloadLen(INIT_LENGTH);
}

View File

@ -730,17 +730,13 @@ class FactoryReset : public TcBase {
: TcBase(params, Apid::DATA_LOGGER,
static_cast<uint8_t>(tc::DataLoggerServiceId::FACTORY_RESET), 0) {}
ReturnValue_t buildPacket(std::optional<uint8_t> op) {
if (op) {
ReturnValue_t buildPacket(uint8_t op) {
setLenFromPayloadLen(1);
}
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
if (op) {
payloadStart[0] = op.value();
}
payloadStart[0] = op;
return calcAndSetCrc();
}

View File

@ -184,12 +184,14 @@ void PlocMPSoCHandler::doShutDown() {
powerState = PowerState::SHUTDOWN;
break;
case PowerState::OFF:
sequenceCount = 0;
setMode(_MODE_POWER_DOWN);
break;
default:
break;
}
#else
sequenceCount = 0;
uartIsolatorSwitch.pullLow();
setMode(_MODE_POWER_DOWN);
powerState = PowerState::OFF;
@ -340,7 +342,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
}
}
sequenceCount++;
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
if (recvSeqCnt != sequenceCount) {
triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt);
@ -403,11 +404,9 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
result = tcMemWrite.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcMemWrite.getFullPacketLen());
@ -417,11 +416,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
result = tcMemRead.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcMemRead.getFullPacketLen());
@ -435,12 +432,10 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
return MPSoCReturnValuesIF::NAME_TOO_LONG;
}
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
result = tcFlashDelete.buildPacket(
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcFlashDelete.getFullPacketLen());
@ -450,11 +445,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
result = tcReplayStart.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcReplayStart.getFullPacketLen());
@ -463,11 +456,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
result = tcReplayStop.buildPacket();
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcReplayStop.getFullPacketLen());
@ -477,11 +468,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcDownlinkPwrOn.getFullPacketLen());
@ -490,11 +479,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
result = tcDownlinkPwrOff.buildPacket();
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcDownlinkPwrOff.getFullPacketLen());
@ -504,11 +491,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcReplayWriteSeq.getFullPacketLen());
@ -517,11 +502,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
result = tcModeReplay.buildPacket();
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcModeReplay.getFullPacketLen());
@ -530,11 +513,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
result = tcModeIdle.buildPacket();
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcModeIdle.getFullPacketLen());
@ -544,11 +525,9 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
sequenceCount++;
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
result = tcCamCmdSend.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
sequenceCount--;
return result;
}
finishTcPrep(tcCamCmdSend.getFullPacketLen());
@ -560,6 +539,7 @@ void PlocMPSoCHandler::finishTcPrep(size_t packetLen) {
nextReplyId = mpsoc::ACK_REPORT;
rawPacket = commandBuffer;
rawPacketLen = packetLen;
sequenceCount++;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {

View File

@ -107,10 +107,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandActionHelperQueue = nullptr;
// Initiate the sequence count with the maximum value. It is incremented before
// a packet is sent, so the first value will be 0 accordingly using
// the wrap around of the counter.
SourceSequenceCounter sequenceCount = SourceSequenceCounter(ccsds::LIMIT_SEQUENCE_COUNT - 1);
SourceSequenceCounter sequenceCount = SourceSequenceCounter(0);
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
SpacePacketCreator creator;

View File

@ -136,7 +136,6 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
}
void PlocSupervisorHandler::doStartUp() {
if (setTimeDuringStartup) {
if (startupState == StartupState::OFF) {
bootTimeout.resetTimer();
startupState = StartupState::BOOTING;
@ -145,20 +144,26 @@ void PlocSupervisorHandler::doStartUp() {
if (bootTimeout.hasTimedOut()) {
uartIsolatorSwitch.pullHigh();
uartManager.start();
if (SET_TIME_DURING_BOOT) {
startupState = StartupState::SET_TIME;
} else {
startupState = StartupState::ON;
}
}
}
if (startupState == StartupState::SET_TIME_EXECUTING) {
startupState = StartupState::ON;
}
if (startupState == StartupState::ON) {
setMode(_MODE_TO_ON);
}
} else {
uartIsolatorSwitch.pullHigh();
setMode(_MODE_TO_ON);
}
}
void PlocSupervisorHandler::doShutDown() {
setMode(_MODE_POWER_DOWN);
shutdownCmdSent = false;
packetInBuffer = false;
nextReplyId = supv::NONE;
uartManager.stop();
uartIsolatorSwitch.pullLow();
startupState = StartupState::OFF;
@ -1467,11 +1472,10 @@ ReturnValue_t PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandDa
ReturnValue_t PlocSupervisorHandler::prepareFactoryResetCmd(const uint8_t* commandData,
size_t len) {
FactoryReset resetCmd(spParams);
std::optional<uint8_t> op;
if (len > 0) {
op = commandData[0];
if (len < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
ReturnValue_t result = resetCmd.buildPacket(op);
ReturnValue_t result = resetCmd.buildPacket(commandData[0]);
if (result != returnvalue::OK) {
return result;
}
@ -1897,9 +1901,8 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionSuccessReport(ExecutionRepor
break;
}
case supv::SET_TIME_REF: {
if (startupState == StartupState::SET_TIME_EXECUTING) {
startupState = StartupState::ON;
}
// We could only allow proper bootup when the time was set successfully, but
// this makes debugging difficult.
break;
}
default:

View File

@ -97,11 +97,11 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
static const uint32_t COPY_ADC_TO_MRAM_TIMEOUT = 70000;
// 60 s
static const uint32_t MRAM_DUMP_TIMEOUT = 60000;
// 2 s
static const uint32_t BOOT_TIMEOUT = 2000;
// 4 s
static const uint32_t BOOT_TIMEOUT = 4000;
enum class StartupState : uint8_t { OFF, BOOTING, SET_TIME, SET_TIME_EXECUTING, ON };
bool setTimeDuringStartup = true;
static constexpr bool SET_TIME_DURING_BOOT = true;
StartupState startupState = StartupState::OFF;
@ -138,8 +138,6 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint32_t receivedMramDumpPackets = 0;
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
bool packetInBuffer = false;
/** Points to the next free position in the space packet buffer */
uint16_t bufferTop = 0;
/** This buffer is used to concatenate space packets received in two different read steps */
uint8_t spacePacketBuffer[supv::MAX_PACKET_SIZE];

View File

@ -100,6 +100,7 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
state = InternalState::SLEEPING;
lock->unlockMutex();
semaphore->acquire();
putTaskToSleep = false;
while (true) {
if (putTaskToSleep) {
performUartShutdown();
@ -295,11 +296,14 @@ void PlocSupvUartManager::stop() {
}
void PlocSupvUartManager::start() {
{
MutexGuard mg(lock);
if (state != InternalState::SLEEPING and state != InternalState::GO_TO_SLEEP) {
return;
}
state = InternalState::DEFAULT;
}
semaphore->release();
}

View File

@ -216,10 +216,9 @@ void AcsController::performDetumble() {
{
PoolReadGuard pg(&actuatorCmdData);
if (pg.getReadResult() == returnvalue::OK) {
int32_t zeroVec[4] = {0, 0, 0, 0};
std::memcpy(actuatorCmdData.rwTargetTorque.value, zeroVec, 4 * sizeof(double));
std::memset(actuatorCmdData.rwTargetTorque.value, 0, 4 * sizeof(double));
actuatorCmdData.rwTargetTorque.setValid(false);
std::memcpy(actuatorCmdData.rwTargetSpeed.value, zeroVec, 4 * sizeof(int32_t));
std::memset(actuatorCmdData.rwTargetSpeed.value, 0, 4 * sizeof(int32_t));
actuatorCmdData.rwTargetSpeed.setValid(false);
std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolUnitsInt, 3 * sizeof(int16_t));
actuatorCmdData.mtqTargetDipole.setValid(true);
@ -495,7 +494,7 @@ void AcsController::copyMgmData() {
PoolReadGuard pg(&sensorValues.mgm3Rm3100Set);
if (pg.getReadResult() == returnvalue::OK) {
std::memcpy(mgmDataRaw.mgm3Rm3100.value, sensorValues.mgm3Rm3100Set.fieldStrengths.value,
3 + sizeof(float));
3 * sizeof(float));
mgmDataRaw.mgm3Rm3100.setValid(sensorValues.mgm3Rm3100Set.fieldStrengths.isValid());
}
}

View File

@ -321,6 +321,11 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::PDU2_HANDLER);
break;
}
case pcdu::P60_DOCK_5V_STACK: {
memoryAddress = P60Dock::CONFIG_ADDRESS_OUT_EN_5V_STACK;
pdu = ObjectManager::instance()->get<GomspaceDeviceHandler>(objects::P60DOCK_HANDLER);
break;
}
default: {
sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl;

View File

@ -69,6 +69,16 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if (getMode() == _MODE_TO_NORMAL) {
stateMachineToNormal(modeFrom, subModeFrom);
return;
} else if (getMode() == _MODE_TO_ON and modeFrom == MODE_NORMAL) {
gpioIF->pullLow(gpioIds::PLPCDU_ENB_HPA);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_MPA);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_TX);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_X8);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_DRO);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_TX);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_VBAT0);
gpioIF->pullLow(gpioIds::PLPCDU_ENB_VBAT1);
state = States::POWER_CHANNELS_ON;
}
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
}
@ -144,6 +154,10 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
}
};
// sif::debug << "DIFF MASK: " << (int)diffMask << std::endl;
// No handling for the SSRs: If those are pulled low, the ADC is off
// and normal mode does not really make sense anyway
switchHandler(DRO_ON, gpioIds::PLPCDU_ENB_DRO, "DRO");
switchHandler(X8_ON, gpioIds::PLPCDU_ENB_X8, "X8");
switchHandler(TX_ON, gpioIds::PLPCDU_ENB_TX, "TX");

View File

@ -108,6 +108,8 @@ enum class SetIds : uint32_t { CORE = 1, AUX = 2, CONFIG = 3 };
namespace P60Dock {
static const uint16_t CONFIG_ADDRESS_OUT_EN_5V_STACK = 0x72;
namespace pool {
enum Ids : lp_id_t {
@ -733,7 +735,9 @@ enum Switches : power::Switch_t {
PDU2_CH5_DEPLOYMENT_MECHANISM_8V,
PDU2_CH6_PL_PCDU_BATT_1_14V8,
PDU2_CH7_ACS_BOARD_SIDE_B_3V3,
PDU2_CH8_PAYLOAD_CAMERA
PDU2_CH8_PAYLOAD_CAMERA,
P60_DOCK_5V_STACK
};
static constexpr uint8_t NUMBER_OF_SWITCHES = 18;

2
tmtc

@ -1 +1 @@
Subproject commit 96e27e716349bf01cac11c7e7b0b497a36149e87
Subproject commit 5c675560eadadfbb5e674d9be87c206df09d1771