this should work better

This commit is contained in:
2023-11-15 14:17:43 +01:00
parent 03a6a06e48
commit 0e6d2dc79b
3 changed files with 29 additions and 5 deletions

@ -8,6 +8,7 @@
#include "eive/definitions.h"
#include "eive/objects.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
@ -70,7 +71,9 @@ void FreshSupvHandler::performDeviceOperation(uint8_t opCode) {
handleTransitionToOff();
}
} else {
if (mode == MODE_NORMAL) {
// I think the SUPV is not able to process multiple commands consecutively, so only send
// normal command if no other command is pending.
if (mode == MODE_NORMAL and not isCommandPending()) {
auto cmdIter = activeActionCmds.find(
buildActiveCmdKey(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT)));
if (cmdIter == activeActionCmds.end() or not cmdIter->second.isPending) {
@ -525,6 +528,9 @@ void FreshSupvHandler::handleTransitionToOff() {
ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& tc,
bool replyExpected, uint32_t cmdCountdownMs) {
if (interCmdCd.isBusy()) {
TaskFactory::delayTask(interCmdCd.getRemainingMillis());
}
if (supv::DEBUG_PLOC_SUPV) {
if (not(supv::REDUCE_NORMAL_MODE_PRINTOUT and mode == MODE_NORMAL and
commandId == supv::GET_HK_REPORT)) {
@ -552,7 +558,10 @@ ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase&
activeCmdIter->second.cmdCountdown.setTimeout(cmdCountdownMs);
activeCmdIter->second.cmdCountdown.resetTimer();
}
return uartManager->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
ReturnValue_t result =
uartManager->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
interCmdCd.resetTimer();
return result;
}
ReturnValue_t FreshSupvHandler::initialize() {
@ -824,13 +833,15 @@ ReturnValue_t FreshSupvHandler::parseTmPackets() {
}
tmReader.setReadOnlyData(receivedData, receivedSize);
if (tmReader.checkCrc() != returnvalue::OK) {
sif::warning << "PlocSupervisorHandler::parseTmPackets: CRC failure" << std::endl;
sif::warning << "PlocSupervisorHandler::parseTmPackets: CRC failure for packet with size "
<< receivedSize << std::endl;
arrayprinter::print(receivedData, receivedSize);
continue;
}
uint16_t apid = tmReader.getModuleApid();
if (supv::DEBUG_PLOC_SUPV) {
handlePacketPrint();
}
uint16_t apid = tmReader.getModuleApid();
switch (apid) {
case (Apid::TMTC_MAN): {
switch (tmReader.getServiceId()) {
@ -952,7 +963,7 @@ void FreshSupvHandler::handlePacketPrint() {
sif::warning << "PlocSupervisorHandler: Parsing EXE failed" << std::endl;
}
const char* printStr = "???";
if (supv::REDUCE_NORMAL_MODE_PRINTOUT and
if (mode == MODE_NORMAL and supv::REDUCE_NORMAL_MODE_PRINTOUT and
exe.getRefModuleApid() == (uint8_t)supv::Apid::HK and
exe.getRefServiceId() == (uint8_t)supv::tc::HkId::GET_REPORT) {
return;
@ -1539,3 +1550,12 @@ ReturnValue_t FreshSupvHandler::genericHandleTm(const char* contextString, const
confirmReplyPacketReceived(apid, serviceId);
return result;
}
bool FreshSupvHandler::isCommandPending() const {
for (const auto& info : activeActionCmds) {
if (info.second.isPending) {
return true;
}
}
return false;
}