added tm service IDs
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-11-08 11:08:21 +01:00
parent 4bf22f689a
commit 4515703efa
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 329 additions and 263 deletions

2
fsfw

@ -1 +1 @@
Subproject commit 672fca5169b017387e58e2ff864913d932c59aa1
Subproject commit 0e8f5ddd26d586dd40e69f52aef1a63c0d5a9da6

View File

@ -17,6 +17,12 @@ using namespace returnvalue;
namespace supv {
static const uint8_t CLASS_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER;
static constexpr ReturnValue_t CRC_MISSMATCH = makeCode(CLASS_ID, 1);
static constexpr ReturnValue_t APID_MISSMATCH = makeCode(CLASS_ID, 2);
static constexpr ReturnValue_t BUF_TOO_SMALL = makeCode(CLASS_ID, 3);
typedef struct {
// The most significant bit of msec value is set to 0x80 to indicate that full
// time and data information is transmitted, when the time has been synced with
@ -135,14 +141,16 @@ enum Apids {
WDOG_MAN = 0x07
};
enum class HkServiceIds : uint8_t {
namespace tc {
enum class HkId : uint8_t {
ENABLE = 0x01,
SET_PERIOD = 0x02,
GET_REPORT = 0x03,
GET_HARDFAULTS_REPORT = 0x04,
};
enum class TmtcServiceIds : uint8_t {
enum class TmtcId : uint8_t {
TIME_REF = 0x03,
GET_SUPV_VERSION = 0x05,
RUN_AUTO_EM_TEST = 0x08,
@ -151,7 +159,7 @@ enum class TmtcServiceIds : uint8_t {
GET_MPSOC_POWER_INFO = 0x10
};
enum class BootManServiceIds : uint8_t {
enum class BootManId : uint8_t {
START_MPSOC = 0x01,
SHUTDOWN_MPSOC = 0x02,
SELECT_IMAGE = 0x03,
@ -165,7 +173,7 @@ enum class BootManServiceIds : uint8_t {
FACTORY_FLASH = 0x0C
};
enum class LatchupMonServiceIds : uint8_t {
enum class LatchupMonId : uint8_t {
ENABLE = 0x01,
DISABLE = 0x02,
SET_ALERT_LIMIT = 0x04,
@ -174,7 +182,7 @@ enum class LatchupMonServiceIds : uint8_t {
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
enum class AdcMonServiceIds : uint8_t {
enum class AdcMonId : uint8_t {
SET_SWEEP_PERIOD = 0x01,
SET_ENABLED_CHANNELS = 0x02,
SET_WINDOW_STRIDE = 0x03,
@ -182,9 +190,9 @@ enum class AdcMonServiceIds : uint8_t {
COPY_ADC_DATA_TO_MRAM = 0x05
};
enum class MemManServiceIds : uint8_t { ERASE = 0x01, WRITE = 0x02, CHECK = 0x03 };
enum class MemManId : uint8_t { ERASE = 0x01, WRITE = 0x02, CHECK = 0x03 };
enum class DataLoggerServiceIds : uint8_t {
enum class DataLoggerServiceId : uint8_t {
WIPE_MRAM = 0x05,
DUMP_MRAM = 0x06,
FACTORY_RESET = 0x07
@ -192,7 +200,23 @@ enum class DataLoggerServiceIds : uint8_t {
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
enum class WdogManServiceIds : uint8_t {};
enum class WdogManServiceId : uint8_t {};
} // namespace tc
namespace tm {
enum class TmtcId : uint8_t { ACK = 0x01, NAK = 0x02, EXEC_ACK = 0x03, EXEC_NAK = 0x04 };
enum class HkId : uint8_t { REPORT = 0x01, HARDFAULTS = 0x02 };
enum class BootManId : uint8_t { BOOT_STATUS_REPORT = 0x01 };
enum class MemManId : uint8_t { UPDATE_STATUS_REPORT = 0x01 };
enum class LatchupMonId : uint8_t { LATCHUP_STATUS_REPORT = 0x01 };
} // namespace tm
static const uint16_t APID_MASK = 0x3FF;
static const uint16_t SEQUENCE_COUNT_MASK = 0xFFF;
@ -209,11 +233,11 @@ static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
static const uint32_t LOGGING_RPT_ID = LOGGING_REPORT;
static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT;
namespace recv_timeout {
namespace timeout {
// Erase memory can require up to 60 seconds for execution
static const uint32_t ERASE_MEMORY = 60000;
static const uint32_t UPDATE_STATUS_REPORT = 70000;
} // namespace recv_timeout
} // namespace timeout
static constexpr size_t TIMESTAMP_LEN = 7;
static constexpr size_t SECONDARY_HEADER_LEN = TIMESTAMP_LEN + 1;
@ -386,23 +410,29 @@ class TcBase : public ploc::SpTcBase {
}
};
class TmBase: public ploc::SpTmReader {
public:
TmBase(const uint8_t* data, size_t maxSize): ploc::SpTmReader(data, maxSize) {
if(maxSize < MIN_TMTC_LEN) {
class TmBase : public ploc::SpTmReader {
public:
TmBase(const uint8_t* data, size_t maxSize) : ploc::SpTmReader(data, maxSize) {
if (maxSize < MIN_TMTC_LEN) {
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
}
}
uint8_t getServiceId() {
return getPacketData()[TIMESTAMP_LEN];
bool verifyCrc() {
if (checkCrc() == returnvalue::OK) {
crcOk = true;
}
return crcOk;
}
const uint8_t* getPayloadStart() {
return getPacketData() + SECONDARY_HEADER_LEN;
}
private:
bool crcIsOk() const { return crcOk; }
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
const uint8_t* getPayloadStart() const { return getPacketData() + SECONDARY_HEADER_LEN; }
private:
bool crcOk = false;
};
class NoPayloadPacket : public TcBase {
@ -444,7 +474,7 @@ class MPSoCBootSelect : public TcBase {
* @note Selection of partitions is currently not supported.
*/
MPSoCBootSelect(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SELECT_IMAGE), 4) {}
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SELECT_IMAGE), 4) {}
ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
auto res = checkSizeAndSerializeHeader();
@ -471,7 +501,7 @@ class SetTimeRef : public TcBase {
public:
static constexpr size_t PAYLOAD_LEN = 8;
SetTimeRef(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(TmtcServiceIds::TIME_REF), 8) {}
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::TIME_REF), 8) {}
ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) {
auto res = checkSizeAndSerializeHeader();
@ -546,7 +576,7 @@ class SetBootTimeout : public TcBase {
* @param timeout The boot timeout in milliseconds.
*/
SetBootTimeout(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SET_BOOT_TIMEOUT),
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_BOOT_TIMEOUT),
PAYLOAD_LEN) {}
ReturnValue_t buildPacket(uint32_t timeout) {
@ -578,8 +608,8 @@ class SetRestartTries : public TcBase {
* @param restartTries Maximum restart tries to set.
*/
SetRestartTries(TcParams params)
: TcBase(params, Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::SET_MAX_REBOOT_TRIES), 1) {}
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_MAX_REBOOT_TRIES),
1) {}
ReturnValue_t buildPacket(uint8_t restartTries) {
auto res = checkSizeAndSerializeHeader();
@ -607,7 +637,7 @@ class DisablePeriodicHkTransmission : public TcBase {
* @brief Constructor
*/
DisablePeriodicHkTransmission(TcParams params)
: TcBase(params, Apids::HK, static_cast<uint8_t>(HkServiceIds::ENABLE), 1) {}
: TcBase(params, Apids::HK, static_cast<uint8_t>(tc::HkId::ENABLE), 1) {}
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
@ -640,9 +670,9 @@ class LatchupAlert : public TcBase {
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
if (state) {
setServiceId(static_cast<uint8_t>(LatchupMonServiceIds::ENABLE));
setServiceId(static_cast<uint8_t>(tc::LatchupMonId::ENABLE));
} else {
setServiceId(static_cast<uint8_t>(LatchupMonServiceIds::DISABLE));
setServiceId(static_cast<uint8_t>(tc::LatchupMonId::DISABLE));
}
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
@ -668,8 +698,8 @@ class SetAlertlimit : public TcBase {
* @param dutycycle
*/
SetAlertlimit(TcParams params)
: TcBase(params, Apids::LATCHUP_MON,
static_cast<uint8_t>(LatchupMonServiceIds::SET_ALERT_LIMIT), 5) {}
: TcBase(params, Apids::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::SET_ALERT_LIMIT),
5) {}
ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) {
auto res = checkSizeAndSerializeHeader();
@ -708,8 +738,7 @@ class SetAdcWindowAndStride : public TcBase {
* @param stridingStepSize
*/
SetAdcWindowAndStride(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(AdcMonServiceIds::SET_WINDOW_STRIDE),
4) {}
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_WINDOW_STRIDE), 4) {}
ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) {
auto res = checkSizeAndSerializeHeader();
@ -742,8 +771,7 @@ class SetAdcThreshold : public TcBase {
* @param threshold
*/
SetAdcThreshold(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(AdcMonServiceIds::SET_ADC_THRESHOLD),
4) {}
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ADC_THRESHOLD), 4) {}
ReturnValue_t buildPacket(uint32_t threshold) {
auto res = checkSizeAndSerializeHeader();
@ -773,8 +801,7 @@ class RunAutoEmTests : public TcBase {
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
*/
RunAutoEmTests(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(TmtcServiceIds::RUN_AUTO_EM_TEST), 1) {
}
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::RUN_AUTO_EM_TEST), 1) {}
ReturnValue_t buildPacket(uint8_t test) {
auto res = checkSizeAndSerializeHeader();
@ -805,7 +832,7 @@ class SetGpio : public TcBase {
* @param val
*/
SetGpio(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(TmtcServiceIds::SET_GPIO), 3) {}
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::SET_GPIO), 3) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin, uint8_t val) {
auto res = checkSizeAndSerializeHeader();
@ -841,7 +868,7 @@ class ReadGpio : public TcBase {
* @param pin
*/
ReadGpio(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(TmtcServiceIds::READ_GPIO), 2) {}
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::READ_GPIO), 2) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin) {
auto res = checkSizeAndSerializeHeader();
@ -865,8 +892,7 @@ class ReadGpio : public TcBase {
class SetShutdownTimeout : public TcBase {
public:
SetShutdownTimeout(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SHUTDOWN_TIMEOUT),
4) {}
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_TIMEOUT), 4) {}
ReturnValue_t buildPacket(uint32_t timeout) {
auto res = checkSizeAndSerializeHeader();
@ -898,7 +924,7 @@ class CheckMemory : public TcBase {
* @param length Length in bytes of memory region
*/
CheckMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(MemManServiceIds::CHECK), 10) {}
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::CHECK), 10) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
@ -938,7 +964,7 @@ class WriteMemory : public TcBase {
* @param updateData Pointer to buffer containing update data
*/
WriteMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(MemManServiceIds::WRITE), 1) {}
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::WRITE), 1) {}
ReturnValue_t buildPacket(ccsds::SequenceFlags seqFlags, uint16_t sequenceCount, uint8_t memoryId,
uint32_t startAddress, uint16_t length, uint8_t* updateData) {
@ -1001,8 +1027,7 @@ class WriteMemory : public TcBase {
class EraseMemory : public TcBase {
public:
EraseMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(MemManServiceIds::ERASE),
PAYLOAD_LENGTH) {}
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::ERASE), PAYLOAD_LENGTH) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
@ -1032,61 +1057,95 @@ class EraseMemory : public TcBase {
}
};
class VerificationReport : public ploc::SpTmReader {
class VerificationReport {
public:
VerificationReport(const uint8_t* buf, size_t maxSize) : ploc::SpTmReader(buf, maxSize) {}
VerificationReport(TmBase& readerBase) : readerBase(readerBase) {}
virtual ~VerificationReport() = default;
virtual ReturnValue_t parse() {
if (not readerBase.crcIsOk()) {
return CRC_MISSMATCH;
}
if (readerBase.getApid() != Apids::TMTC_MAN) {
return APID_MISSMATCH;
}
if (readerBase.getBufSize() < MIN_PAYLOAD_LEN + 8) {
sif::error << "VerificationReport: Invalid verification report, payload too small"
<< std::endl;
return BUF_TOO_SMALL;
}
const uint8_t* payloadStart = readerBase.getPayloadStart();
size_t remLen = PAYLOAD_LEN;
ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference APID field" << std::endl;
return result;
}
result = SerializeAdapter::deSerialize(&refServiceId, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference Service ID field"
<< std::endl;
return result;
}
result = SerializeAdapter::deSerialize(&refSeqCount, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference sequence count field"
<< std::endl;
return result;
}
result = SerializeAdapter::deSerialize(&statusCode, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize status code field" << std::endl;
return result;
}
return returnvalue::OK;
}
/**
* @brief Gets the APID of command which caused the transmission of this verification report.
*/
uint16_t getRefApid() {
uint16_t refApid = 0;
size_t size = 0;
const uint8_t* refApidPtr = this->getPacketData();
ReturnValue_t result =
SerializeAdapter::deSerialize(&refApid, refApidPtr, &size, SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "ExecutionReport: Failed to deserialize reference APID field" << std::endl;
return result;
}
return refApid;
}
uint8_t getRefApid() const { return refApid; }
uint16_t getStatusCode() {
uint16_t statusCode = 0;
size_t size = 0;
const uint8_t* statusCodePtr = this->getPacketData() + OFFSET_STATUS_CODE;
ReturnValue_t result = SerializeAdapter::deSerialize(&statusCode, statusCodePtr, &size,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "ExecutionReport: Failed to deserialize status code field" << std::endl;
return result;
}
return statusCode;
}
uint8_t getRefServiceId() const { return refServiceId; }
uint16_t getRefSequenceCount() const { return refSeqCount; }
uint32_t getStatusCode() const { return statusCode; }
virtual ReturnValue_t checkApid() { return returnvalue::FAILED; }
private:
static const uint8_t OFFSET_STATUS_CODE = 4;
TmBase& readerBase;
uint8_t refApid = 0;
uint8_t refServiceId = 0;
uint16_t refSeqCount = 0;
uint32_t statusCode = 0;
static const size_t PAYLOAD_LEN = 8;
};
class AcknowledgmentReport : public VerificationReport {
public:
AcknowledgmentReport(const uint8_t* buf, size_t maxSize) : VerificationReport(buf, maxSize) {}
AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {}
ReturnValue_t checkApid() {
uint16_t apid = this->getApid();
if (apid == APID_ACK_SUCCESS) {
return returnvalue::OK;
} else if (apid == APID_ACK_FAILURE) {
printStatusInformation();
return SupvReturnValuesIF::RECEIVED_ACK_FAILURE;
} else {
sif::warning << "AcknowledgmentReport::checkApid: Invalid apid: 0x" << std::hex << apid
<< std::endl;
return SupvReturnValuesIF::INVALID_APID;
}
virtual ReturnValue_t parse() override {
// if (readerBase.getServiceId() != )
// uint16_t apid = this->getApid();
// if (apid == APID_ACK_SUCCESS) {
// return returnvalue::OK;
// } else if (apid == APID_ACK_FAILURE) {
// printStatusInformation();
// return SupvReturnValuesIF::RECEIVED_ACK_FAILURE;
// } else {
// sif::warning << "AcknowledgmentReport::checkApid: Invalid apid: 0x" << std::hex << apid
// << std::endl;
// return SupvReturnValuesIF::INVALID_APID;
// }
return OK;
}
void printStatusInformation() {
@ -1147,20 +1206,21 @@ class AcknowledgmentReport : public VerificationReport {
class ExecutionReport : public VerificationReport {
public:
ExecutionReport(const uint8_t* buf, size_t maxSize) : VerificationReport(buf, maxSize) {}
ExecutionReport(TmBase& readerBase) : VerificationReport(readerBase) {}
ReturnValue_t checkApid() {
uint16_t apid = this->getApid();
if (apid == APID_EXE_SUCCESS) {
return returnvalue::OK;
} else if (apid == APID_EXE_FAILURE) {
printStatusInformation();
return SupvReturnValuesIF::RECEIVED_EXE_FAILURE;
} else {
sif::warning << "ExecutionReport::checkApid: Invalid apid: 0x" << std::hex << apid
<< std::endl;
return SupvReturnValuesIF::INVALID_APID;
}
ReturnValue_t parse() override {
/* uint16_t apid = this->getApid();
if (apid == APID_EXE_SUCCESS) {
return returnvalue::OK;
} else if (apid == APID_EXE_FAILURE) {
printStatusInformation();
return SupvReturnValuesIF::RECEIVED_EXE_FAILURE;
} else {
sif::warning << "ExecutionReport::checkApid: Invalid apid: 0x" << std::hex << apid
<< std::endl;
return SupvReturnValuesIF::INVALID_APID;
}*/
return OK;
}
private:
@ -1808,9 +1868,9 @@ class MramCmd : public TcBase {
ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) {
if (action == MramAction::WIPE) {
setServiceId(static_cast<uint8_t>(DataLoggerServiceIds::WIPE_MRAM));
setServiceId(static_cast<uint8_t>(tc::DataLoggerServiceId::WIPE_MRAM));
} else if (action == MramAction::DUMP) {
setServiceId(static_cast<uint8_t>(DataLoggerServiceIds::DUMP_MRAM));
setServiceId(static_cast<uint8_t>(tc::DataLoggerServiceId::DUMP_MRAM));
} else {
sif::debug << "WipeMram: Invalid action specified";
}
@ -1899,7 +1959,7 @@ class SetAdcEnabledChannels : public TcBase {
* @param ch Defines channels to be enabled or disabled.
*/
SetAdcEnabledChannels(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(AdcMonServiceIds::SET_ENABLED_CHANNELS),
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ENABLED_CHANNELS),
2) {}
ReturnValue_t buildPacket(uint16_t ch) {

View File

@ -221,17 +221,17 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
spParams.buf = commandBuffer;
switch (deviceCommand) {
case GET_HK_REPORT: {
prepareEmptyCmd(Apids::HK, static_cast<uint8_t>(HkServiceIds::GET_REPORT));
prepareEmptyCmd(Apids::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT));
result = returnvalue::OK;
break;
}
case START_MPSOC: {
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::START_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC));
result = returnvalue::OK;
break;
}
case SHUTDOWN_MPSOC: {
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SHUTDOWN_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC));
result = returnvalue::OK;
break;
}
@ -241,7 +241,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case RESET_MPSOC: {
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_MPSOC));
result = returnvalue::OK;
break;
}
@ -265,8 +265,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case GET_BOOT_STATUS_REPORT: {
prepareEmptyCmd(Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::GET_BOOT_STATUS_REPORT));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::GET_BOOT_STATUS_REPORT));
result = returnvalue::OK;
break;
}
@ -299,7 +298,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
// }
case GET_LATCHUP_STATUS_REPORT: {
prepareEmptyCmd(Apids::LATCHUP_MON,
static_cast<uint8_t>(LatchupMonServiceIds::GET_STATUS_REPORT));
static_cast<uint8_t>(tc::LatchupMonId::GET_STATUS_REPORT));
result = returnvalue::OK;
break;
}
@ -380,7 +379,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case FACTORY_FLASH: {
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::FACTORY_FLASH));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::FACTORY_FLASH));
result = returnvalue::OK;
break;
}
@ -434,7 +433,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
// break;
// }
case RESET_PL: {
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_PL));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_PL));
result = returnvalue::OK;
break;
}
@ -930,56 +929,57 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
using namespace supv;
ReturnValue_t result = returnvalue::OK;
AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
result = ack.checkSize();
if (result != returnvalue::OK) {
return result;
}
result = ack.checkCrc();
if (result != returnvalue::OK) {
sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
nextReplyId = supv::NONE;
replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT);
triggerEvent(SUPV_CRC_FAILURE_EVENT);
sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::CRC_FAILURE);
disableAllReplies();
return returnvalue::OK;
}
result = ack.checkApid();
switch (result) {
case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(SUPV_ACK_FAILURE, commandId, static_cast<uint32_t>(ack.getStatusCode()));
}
printAckFailureInfo(ack.getStatusCode(), commandId);
sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::RECEIVED_ACK_FAILURE);
disableAllReplies();
nextReplyId = supv::NONE;
result = IGNORE_REPLY_DATA;
break;
}
case returnvalue::OK: {
setNextReplyId();
break;
}
case SupvReturnValuesIF::INVALID_APID:
sif::warning << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report"
<< std::endl;
sendFailureReport(supv::ACK_REPORT, result);
disableAllReplies();
nextReplyId = supv::NONE;
result = IGNORE_REPLY_DATA;
break;
default: {
sif::error << "PlocSupervisorHandler::handleAckReport: APID parsing failed" << std::endl;
result = returnvalue::FAILED;
break;
}
}
// TODO: Fix
// AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
// result = ack.checkSize();
// if (result != returnvalue::OK) {
// return result;
// }
//
// result = ack.checkCrc();
// if (result != returnvalue::OK) {
// sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
// nextReplyId = supv::NONE;
// replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT);
// triggerEvent(SUPV_CRC_FAILURE_EVENT);
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::CRC_FAILURE);
// disableAllReplies();
// return returnvalue::OK;
// }
//
// result = ack.checkApid();
//
// switch (result) {
// case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
// DeviceCommandId_t commandId = getPendingCommand();
// if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
// triggerEvent(SUPV_ACK_FAILURE, commandId, static_cast<uint32_t>(ack.getStatusCode()));
// }
// printAckFailureInfo(ack.getStatusCode(), commandId);
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::RECEIVED_ACK_FAILURE);
// disableAllReplies();
// nextReplyId = supv::NONE;
// result = IGNORE_REPLY_DATA;
// break;
// }
// case returnvalue::OK: {
// setNextReplyId();
// break;
// }
// case SupvReturnValuesIF::INVALID_APID:
// sif::warning << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report"
// << std::endl;
// sendFailureReport(supv::ACK_REPORT, result);
// disableAllReplies();
// nextReplyId = supv::NONE;
// result = IGNORE_REPLY_DATA;
// break;
// default: {
// sif::error << "PlocSupervisorHandler::handleAckReport: APID parsing failed" << std::endl;
// result = returnvalue::FAILED;
// break;
// }
// }
return result;
}
@ -987,38 +987,39 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
using namespace supv;
ReturnValue_t result = returnvalue::OK;
ExecutionReport exe(data, SIZE_EXE_REPORT);
result = exe.checkSize();
if (result != returnvalue::OK) {
return result;
}
result = exe.checkCrc();
if (result != returnvalue::OK) {
sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl;
nextReplyId = supv::NONE;
return result;
}
result = exe.checkApid();
switch (result) {
case (returnvalue::OK): {
handleExecutionSuccessReport(data);
break;
}
case (SupvReturnValuesIF::RECEIVED_EXE_FAILURE): {
handleExecutionFailureReport(exe.getStatusCode());
result = returnvalue::OK;
break;
}
default: {
sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl;
result = returnvalue::FAILED;
break;
}
}
nextReplyId = supv::NONE;
// TODO: Fix
// ExecutionReport exe(data, SIZE_EXE_REPORT);
// result = exe.checkSize();
// if (result != returnvalue::OK) {
// return result;
// }
//
// result = exe.checkCrc();
// if (result != returnvalue::OK) {
// sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl;
// nextReplyId = supv::NONE;
// return result;
// }
//
// result = exe.checkApid();
//
// switch (result) {
// case (returnvalue::OK): {
// handleExecutionSuccessReport(data);
// break;
// }
// case (SupvReturnValuesIF::RECEIVED_EXE_FAILURE): {
// handleExecutionFailureReport(exe.getStatusCode());
// result = returnvalue::OK;
// break;
// }
// default: {
// sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl;
// result = returnvalue::FAILED;
// break;
// }
// }
// nextReplyId = supv::NONE;
return result;
}
@ -2107,33 +2108,36 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t*
DeviceCommandId_t commandId = getPendingCommand();
switch (commandId) {
case supv::READ_GPIO: {
supv::ExecutionReport exe(data, supv::SIZE_EXE_REPORT);
if (exe.isNull()) {
return returnvalue::FAILED;
}
ReturnValue_t result = exe.checkSize();
if (result != returnvalue::OK) {
return result;
}
uint16_t gpioState = exe.getStatusCode();
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::info << "PlocSupervisorHandler: Read GPIO TM, State: " << gpioState << std::endl;
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
DeviceCommandMap::iterator iter = deviceCommandMap.find(commandId);
if (iter->second.sendReplyTo == NO_COMMAND_ID) {
return returnvalue::OK;
}
uint8_t data[sizeof(gpioState)];
size_t size = 0;
result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState),
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl;
}
result = actionHelper.reportData(iter->second.sendReplyTo, commandId, data, sizeof(data));
if (result != returnvalue::OK) {
sif::warning << "PlocSupervisorHandler: Read GPIO, failed to report data" << std::endl;
}
// TODO: Fix
// supv::ExecutionReport exe(data, supv::SIZE_EXE_REPORT);
// if (exe.isNull()) {
// return returnvalue::FAILED;
// }
// ReturnValue_t result = exe.checkSize();
// if (result != returnvalue::OK) {
// return result;
// }
// uint16_t gpioState = exe.getStatusCode();
//#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
// sif::info << "PlocSupervisorHandler: Read GPIO TM, State: " << gpioState << std::endl;
//#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
// DeviceCommandMap::iterator iter = deviceCommandMap.find(commandId);
// if (iter->second.sendReplyTo == NO_COMMAND_ID) {
// return returnvalue::OK;
// }
// uint8_t data[sizeof(gpioState)];
// size_t size = 0;
// result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState),
// SerializeIF::Endianness::BIG);
// if (result != returnvalue::OK) {
// sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" <<
// std::endl;
// }
// result = actionHelper.reportData(iter->second.sendReplyTo, commandId, data,
// sizeof(data)); if (result != returnvalue::OK) {
// sif::warning << "PlocSupervisorHandler: Read GPIO, failed to report data" <<
// std::endl;
// }
break;
}
case supv::SET_TIME_REF: {

View File

@ -501,7 +501,7 @@ ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t result = returnvalue::OK;
resetSpParams();
supv::NoPayloadPacket packet(spParams, Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::PREPARE_UPDATE));
static_cast<uint8_t>(tc::BootManId::PREPARE_UPDATE));
result = packet.buildPacket();
if (result != returnvalue::OK) {
return result;
@ -522,7 +522,7 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
if (result != returnvalue::OK) {
return result;
}
result = handlePacketTransmission(eraseMemory, supv::recv_timeout::ERASE_MEMORY);
result = handlePacketTransmission(eraseMemory, supv::timeout::ERASE_MEMORY);
if (result != returnvalue::OK) {
return result;
}
@ -562,27 +562,28 @@ ReturnValue_t PlocSupvHelper::sendCommand(ploc::SpTcBase& packet) {
ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t result = returnvalue::OK;
result = handleTmReception(supv::SIZE_ACK_REPORT);
if (result != returnvalue::OK) {
triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
<< std::endl;
return result;
}
supv::AcknowledgmentReport ackReport(tmBuf.data(), tmBuf.size());
result = checkReceivedTm(ackReport);
if (result != returnvalue::OK) {
return result;
}
result = ackReport.checkApid();
if (result != returnvalue::OK) {
if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) {
triggerEvent(SUPV_ACK_FAILURE_REPORT, static_cast<uint32_t>(ackReport.getRefApid()));
} else if (result == SupvReturnValuesIF::INVALID_APID) {
triggerEvent(SUPV_ACK_INVALID_APID, static_cast<uint32_t>(rememberApid));
}
return result;
}
// TODO: Fix
// result = handleTmReception(supv::SIZE_ACK_REPORT);
// if (result != returnvalue::OK) {
// triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
// sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
// << std::endl;
// return result;
// }
// supv::AcknowledgmentReport ackReport(tmBuf.data(), tmBuf.size());
// result = checkReceivedTm(ackReport);
// if (result != returnvalue::OK) {
// return result;
// }
// result = ackReport.checkApid();
// if (result != returnvalue::OK) {
// if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) {
// triggerEvent(SUPV_ACK_FAILURE_REPORT, static_cast<uint32_t>(ackReport.getRefApid()));
// } else if (result == SupvReturnValuesIF::INVALID_APID) {
// triggerEvent(SUPV_ACK_INVALID_APID, static_cast<uint32_t>(rememberApid));
// }
// return result;
// }
return returnvalue::OK;
}
@ -601,22 +602,23 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
}
ReturnValue_t PlocSupvHelper::exeReportHandling() {
supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
ReturnValue_t result = checkReceivedTm(exeReport);
if (result != returnvalue::OK) {
return result;
}
result = exeReport.checkApid();
if (result != returnvalue::OK) {
if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) {
triggerEvent(SUPV_EXE_FAILURE_REPORT, static_cast<uint32_t>(exeReport.getRefApid()));
} else if (result == SupvReturnValuesIF::INVALID_APID) {
triggerEvent(SUPV_EXE_INVALID_APID, static_cast<uint32_t>(rememberApid));
}
return result;
}
return result;
// TODO: Fix
// supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
//
// ReturnValue_t result = checkReceivedTm(exeReport);
// if (result != returnvalue::OK) {
// return result;
// }
// result = exeReport.checkApid();
// if (result != returnvalue::OK) {
// if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) {
// triggerEvent(SUPV_EXE_FAILURE_REPORT, static_cast<uint32_t>(exeReport.getRefApid()));
// } else if (result == SupvReturnValuesIF::INVALID_APID) {
// triggerEvent(SUPV_EXE_INVALID_APID, static_cast<uint32_t>(rememberApid));
// }
// return result;
// }
return OK;
}
ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint8_t* readBuf,
@ -753,7 +755,7 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
}
bool exeAlreadyHandled = false;
uint32_t timeout = std::max(CRC_EXECUTION_TIMEOUT, supv::recv_timeout::UPDATE_STATUS_REPORT);
uint32_t timeout = std::max(CRC_EXECUTION_TIMEOUT, supv::timeout::UPDATE_STATUS_REPORT);
result = handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), timeout);
ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size());
if (spReader.getApid() == supv::APID_EXE_FAILURE) {
@ -762,7 +764,7 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
} else if (spReader.getApid() == supv::APID_UPDATE_STATUS_REPORT) {
size_t remBytes = spReader.getPacketDataLen() + 1;
result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN,
supv::recv_timeout::UPDATE_STATUS_REPORT);
supv::timeout::UPDATE_STATUS_REPORT);
if (result != returnvalue::OK) {
sif::warning
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
@ -860,8 +862,8 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception(ploc::SpTmReader& reade
return EVENT_BUFFER_REPLY_INVALID_APID;
}
// TODO: Fix
// file.write(reinterpret_cast<const char*>(reader.getPacketData()),
// reader.getPayloadDataLength());
// file.write(reinterpret_cast<const char*>(reader.getPacketData()),
// reader.getPayloadDataLength());
}
return result;
}

View File

@ -102,7 +102,7 @@ class SpTmReader : public SpacePacketReader {
return setReadOnlyData(buf, maxSize);
}
ReturnValue_t checkCrc() {
ReturnValue_t checkCrc() const {
if (CRC::crc16ccitt(getFullData(), getFullPacketLen()) != 0) {
return returnvalue::FAILED;
}