add optional printout mode for PLOC SUPV

This commit is contained in:
Robin Müller 2023-10-26 13:41:52 +02:00
parent 534ddde9e8
commit 27d6760322
Signed by: muellerr
GPG Key ID: FCE0B2BD2195142F
2 changed files with 68 additions and 26 deletions

View File

@ -517,10 +517,8 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
tmReader.setData(start, remainingSize);
uint16_t apid = tmReader.getModuleApid();
if(DEBUG_PLOC_SUPV) {
sif::debug << "PlocSupervisorHandler: RECV PACKET Size " << tmReader.getFullPacketLen() << " APID " << tmReader.getApid()
<< " Module APID: " << tmReader.getModuleApid() << std::endl;
arrayprinter::print(start, remainingSize);
if (DEBUG_PLOC_SUPV) {
handlePacketPrint();
}
switch (apid) {
@ -575,6 +573,42 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
return INVALID_DATA;
}
void PlocSupervisorHandler::handlePacketPrint() {
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) or
(tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK))) {
AcknowledgmentReport ack(tmReader);
const char* printStr = "???";
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) {
printStr = "ACK";
} else if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
printStr = "NAK";
}
sif::debug << "PlocSupervisorHandler: RECV " << printStr << " for APID Module ID "
<< (int)ack.getRefModuleApid() << " Service ID " << (int)ack.getRefServiceId()
<< " Seq Count " << ack.getRefSequenceCount() << std::endl;
return;
} else if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) or
(tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK))) {
ExecutionReport exe(tmReader);
const char* printStr = "???";
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) {
printStr = "ACK EXE";
} else if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
printStr = "NAK EXE";
}
sif::debug << "PlocSupervisorHandler: RECV " << printStr << " for APID Module ID "
<< (int)exe.getRefModuleApid() << " Service ID " << (int)exe.getRefServiceId()
<< " Seq Count " << exe.getRefSequenceCount() << std::endl;
return;
}
}
sif::debug << "PlocSupervisorHandler: RECV PACKET Size " << tmReader.getFullPacketLen()
<< " Module APID " << (int)tmReader.getModuleApid() << " Service ID "
<< (int)tmReader.getServiceId() << std::endl;
}
ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) {
using namespace supv;
@ -1203,7 +1237,7 @@ ReturnValue_t PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid, uint8_t serv
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1214,7 +1248,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* comma
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1231,7 +1265,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1241,7 +1275,7 @@ ReturnValue_t PlocSupervisorHandler::prepareDisableHk() {
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1253,7 +1287,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* com
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1264,7 +1298,7 @@ ReturnValue_t PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* comma
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1282,7 +1316,7 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
break;
}
case (supv::DISABLE_LATCHUP_ALERT): {
@ -1291,7 +1325,7 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
break;
}
default: {
@ -1318,7 +1352,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1329,7 +1363,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1343,7 +1377,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1355,7 +1389,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* co
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1369,7 +1403,7 @@ ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* command
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1382,7 +1416,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandDat
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1394,7 +1428,7 @@ ReturnValue_t PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandDa
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1408,14 +1442,18 @@ ReturnValue_t PlocSupervisorHandler::prepareFactoryResetCmd(const uint8_t* comma
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(resetCmd.getFullPacketLen());
finishTcPrep(resetCmd);
return returnvalue::OK;
}
void PlocSupervisorHandler::finishTcPrep(size_t packetLen) {
void PlocSupervisorHandler::finishTcPrep(TcBase& tc) {
nextReplyId = supv::ACK_REPORT;
rawPacket = commandBuffer;
rawPacketLen = packetLen;
rawPacketLen = tc.getFullPacketLen();
if (DEBUG_PLOC_SUPV) {
sif::debug << "PLOC SUPV: SEND PACKET Size " << tc.getFullPacketLen() << " Module APID "
<< (int)tc.getModuleApid() << " Service ID " << (int)tc.getServiceId() << std::endl;
}
}
ReturnValue_t PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandData) {
@ -1434,7 +1472,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t*
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}
@ -1651,7 +1689,7 @@ ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandDa
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
finishTcPrep(packet);
return returnvalue::OK;
}

View File

@ -18,8 +18,10 @@
#endif
using supv::ExecutionReport;
using supv::TcBase;
static constexpr bool DEBUG_PLOC_SUPV = true;
static constexpr bool DEBUG_PLOC_SUPV = false;
/**
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
* Thales.
@ -175,6 +177,8 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
*/
void setExecutionTimeout(DeviceCommandId_t command);
void handlePacketPrint();
/**
* @brief Handles event messages received from the supervisor helper
*/
@ -303,7 +307,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
/**
* @brief Copies the content of a space packet to the command buffer.
*/
void finishTcPrep(size_t packetLen);
void finishTcPrep(TcBase& tc);
/**
* @brief In case an acknowledgment failure reply has been received this function disables