this is what device handler writing should have been
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
134073fd84
commit
8714948788
@ -774,12 +774,139 @@ ReturnValue_t FreshSupvHandler::parseTmPackets() {
|
|||||||
if (receivedSize == 0) {
|
if (receivedSize == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// TODO: Implement TM packet parsing and call corresponding handler functions or verify
|
tmReader.setData(receivedData, receivedSize);
|
||||||
// sent commands.
|
uint16_t apid = tmReader.getModuleApid();
|
||||||
|
if (DEBUG_PLOC_SUPV) {
|
||||||
|
handlePacketPrint();
|
||||||
|
}
|
||||||
|
switch (apid) {
|
||||||
|
case (Apid::TMTC_MAN): {
|
||||||
|
switch (tmReader.getServiceId()) {
|
||||||
|
case (static_cast<uint8_t>(supv::tm::TmtcId::ACK)):
|
||||||
|
case (static_cast<uint8_t>(supv::tm::TmtcId::NAK)): {
|
||||||
|
// TODO: Handle ACK report.
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
case (static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)):
|
||||||
|
case (static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)): {
|
||||||
|
// TODO: Hnadle Exe report.
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Apid::HK): {
|
||||||
|
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::HkId::REPORT)) {
|
||||||
|
// TODO: Handle HK report.
|
||||||
|
return OK;
|
||||||
|
} else if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::HkId::HARDFAULTS)) {
|
||||||
|
handleBadApidServiceCombination(SUPV_UNINIMPLEMENTED_TM, apid, tmReader.getServiceId());
|
||||||
|
return INVALID_DATA;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Apid::BOOT_MAN): {
|
||||||
|
if (tmReader.getServiceId() ==
|
||||||
|
static_cast<uint8_t>(supv::tm::BootManId::BOOT_STATUS_REPORT)) {
|
||||||
|
// TODO: Handle boot status report.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Apid::ADC_MON): {
|
||||||
|
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::AdcMonId::ADC_REPORT)) {
|
||||||
|
// TODO: Handle ADC report.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Apid::MEM_MAN): {
|
||||||
|
if (tmReader.getServiceId() ==
|
||||||
|
static_cast<uint8_t>(supv::tm::MemManId::UPDATE_STATUS_REPORT)) {
|
||||||
|
// TODO: Handle update status report.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Apid::DATA_LOGGER): {
|
||||||
|
if (tmReader.getServiceId() ==
|
||||||
|
static_cast<uint8_t>(supv::tm::DataLoggerId::COUNTERS_REPORT)) {
|
||||||
|
// TODO: Handle counters report.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleBadApidServiceCombination(SUPV_UNKNOWN_TM, apid, tmReader.getServiceId());
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreshSupvHandler::handleBadApidServiceCombination(Event event, unsigned int apid,
|
||||||
|
unsigned int serviceId) {
|
||||||
|
const char* printString = "";
|
||||||
|
if (event == SUPV_UNKNOWN_TM) {
|
||||||
|
printString = "PlocSupervisorHandler: Unknown";
|
||||||
|
} else if (event == SUPV_UNINIMPLEMENTED_TM) {
|
||||||
|
printString = "PlocSupervisorHandler: Unimplemented";
|
||||||
|
}
|
||||||
|
triggerEvent(event, apid, tmReader.getServiceId());
|
||||||
|
sif::warning << printString << " APID service combination 0x" << std::setw(2) << std::setfill('0')
|
||||||
|
<< std::hex << apid << ", 0x" << std::setw(2) << serviceId << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreshSupvHandler::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);
|
||||||
|
ReturnValue_t result = ack.parse();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
sif::warning << "PlocSupervisorHandler: Parsing ACK failed" << std::endl;
|
||||||
|
}
|
||||||
|
if (REDUCE_NORMAL_MODE_PRINTOUT and ack.getRefModuleApid() == (uint8_t)supv::Apid::HK and
|
||||||
|
ack.getRefServiceId() == (uint8_t)supv::tc::HkId::GET_REPORT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
ReturnValue_t result = exe.parse();
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
sif::warning << "PlocSupervisorHandler: Parsing EXE failed" << std::endl;
|
||||||
|
}
|
||||||
|
const char* printStr = "???";
|
||||||
|
if (REDUCE_NORMAL_MODE_PRINTOUT and exe.getRefModuleApid() == (uint8_t)supv::Apid::HK and
|
||||||
|
exe.getRefServiceId() == (uint8_t)supv::tc::HkId::GET_REPORT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
bool FreshSupvHandler::isCommandAlreadyActive(ActionId_t actionId) const {
|
bool FreshSupvHandler::isCommandAlreadyActive(ActionId_t actionId) const {
|
||||||
auto iter = activeActionCmds.find(actionId);
|
auto iter = activeActionCmds.find(actionId);
|
||||||
if (iter == activeActionCmds.end()) {
|
if (iter == activeActionCmds.end()) {
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
using supv::TcBase;
|
using supv::TcBase;
|
||||||
|
|
||||||
static constexpr bool DEBUG_PLOC_SUPV = false;
|
static constexpr bool DEBUG_PLOC_SUPV = true;
|
||||||
|
static constexpr bool REDUCE_NORMAL_MODE_PRINTOUT = true;
|
||||||
|
|
||||||
class FreshSupvHandler : public FreshDeviceHandlerBase {
|
class FreshSupvHandler : public FreshDeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
@ -76,6 +77,7 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
|
|||||||
|
|
||||||
StartupState startupState = StartupState::IDLE;
|
StartupState startupState = StartupState::IDLE;
|
||||||
MessageQueueIF* eventQueue = nullptr;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
|
supv::TmBase tmReader;
|
||||||
|
|
||||||
enum class ShutdownState : uint8_t { IDLE, POWER_SWITCHING };
|
enum class ShutdownState : uint8_t { IDLE, POWER_SWITCHING };
|
||||||
ShutdownState shutdownState = ShutdownState::IDLE;
|
ShutdownState shutdownState = ShutdownState::IDLE;
|
||||||
@ -155,7 +157,10 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
|
|||||||
ReturnValue_t extractBaseParams(const uint8_t** commandData, size_t& remSize,
|
ReturnValue_t extractBaseParams(const uint8_t** commandData, size_t& remSize,
|
||||||
supv::UpdateParams& params);
|
supv::UpdateParams& params);
|
||||||
void handleEvent(EventMessage* eventMessage);
|
void handleEvent(EventMessage* eventMessage);
|
||||||
|
|
||||||
|
void handleBadApidServiceCombination(Event event, unsigned int apid, unsigned int serviceId);
|
||||||
ReturnValue_t eventSubscription();
|
ReturnValue_t eventSubscription();
|
||||||
|
void handlePacketPrint();
|
||||||
bool isCommandAlreadyActive(ActionId_t actionId) const;
|
bool isCommandAlreadyActive(ActionId_t actionId) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user