implemented the last tricky parts

This commit is contained in:
2022-11-08 16:26:30 +01:00
parent f564fb5c1a
commit 28cd78db96
5 changed files with 297 additions and 264 deletions

View File

@ -70,6 +70,8 @@ static const ReturnValue_t UPDATE_CRC_FAILURE = MAKE_RETURN_CODE(0xB2);
static const ReturnValue_t SUPV_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB3);
static constexpr ReturnValue_t BUF_TOO_SMALL = MAKE_RETURN_CODE(0xC0);
static constexpr ReturnValue_t NO_REPLY_TIMEOUT = MAKE_RETURN_CODE(0xC1);
}; // namespace result
static constexpr uint16_t DEFAULT_SEQ_COUNT = 0;
@ -270,6 +272,7 @@ 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;
static const uint32_t CRC_EXECUTION_TIMEOUT = 60000;
} // namespace timeout
static constexpr size_t TIMESTAMP_LEN = 7;
@ -421,6 +424,8 @@ class TcBase : public ploc::SpTcBase {
payloadStart[supv::PAYLOAD_OFFSET] = id;
}
uint8_t getServiceId() const { return payloadStart[supv::PAYLOAD_OFFSET]; }
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
}
@ -1168,19 +1173,11 @@ class AcknowledgmentReport : public VerificationReport {
AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {}
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;
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::NAK)) {
return returnvalue::FAILED;
}
return VerificationReport::parse();
}
void printStatusInformation() {
@ -1244,78 +1241,12 @@ class ExecutionReport : public VerificationReport {
ExecutionReport(TmBase& readerBase) : VerificationReport(readerBase) {}
ReturnValue_t parse() override {
if (readerBase.getServiceId() == static_cast<uint8_t>(tm::TmtcId::EXEC_NAK)) {
printStatusInformation();
return result::RECEIVED_EXE_FAILURE;
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_NAK)) {
return returnvalue::FAILED;
}
/* 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;
return VerificationReport::parse();
}
private:
static constexpr char STATUS_PRINTOUT_PREFIX[] = "Supervisor execution failure report status: ";
enum class StatusCode : uint16_t {
OK = 0x0,
INIT_ERROR = 0x1,
BAD_PARAM = 0x2,
NOT_INITIALIZED = 0x3,
BAD_PERIPH_ID = 0x4,
TIMEOUT = 0x5,
RX_ERROR = 0x6,
TX_ERROR = 0x7,
BUF_EMPTY = 0x8,
BUF_FULL = 0x9,
NAK = 0xA,
ARB_LOST = 0xB,
BUSY = 0xC,
NOT_IMPLEMENTED = 0xD,
ALIGNEMENT_ERROR = 0xE,
PERIPH_ERR = 0xF,
FAILED_LATCH = 0x10,
GPIO_HIGH = 0x11,
GPIO_LOW = 0x12,
TEST_PASSED = 0x13,
TEST_FAILED = 0x14,
NOTHING_TODO = 0x100,
POWER_FAULT = 0x101,
INVALID_LENGTH = 0x102,
OUT_OF_RANGE = 0x103,
OUT_OF_HEAP_MEMORY = 0x104,
INVALID_STATE_TRANSITION = 0x105,
MPSOC_ALREADY_BOOTING = 0x106,
MPSOC_ALREADY_OPERATIONAL = 0x107,
MPSOC_BOOT_FAILED = 0x108,
SP_NOT_AVAILABLE = 0x200,
SP_DATA_INSUFFICIENT = 0x201,
SP_MEMORY_ID_INVALID = 0x202,
MPSOC_NOT_IN_RESET = 0x203,
FLASH_INIT_FAILED = 0x204,
FLASH_ERASE_FAILED = 0x205,
FLASH_WRITE_FAILED = 0x206,
FLASH_VERIFY_FAILED = 0x207,
CANNOT_ACCESS_TM = 0x208,
CANNOT_SEND_TM = 0x209,
PG_LOW = 0x300,
PG_5V_LOW = 0x301,
PG_0V85_LOW = 0x302,
PG_1V8_LOW = 0x303,
PG_MISC_LOW = 0x304,
PG_3V3_LOW = 0x305,
PG_MB_VAIO_LOW = 0x306,
PG_MB_MPSOCIO_LOW = 0x307
};
void printStatusInformation() {
StatusCode statusCode = static_cast<StatusCode>(getStatusCode());
switch (statusCode) {
@ -1520,6 +1451,60 @@ class ExecutionReport : public VerificationReport {
break;
}
}
private:
static constexpr char STATUS_PRINTOUT_PREFIX[] = "Supervisor execution failure report status: ";
enum class StatusCode : uint16_t {
OK = 0x0,
INIT_ERROR = 0x1,
BAD_PARAM = 0x2,
NOT_INITIALIZED = 0x3,
BAD_PERIPH_ID = 0x4,
TIMEOUT = 0x5,
RX_ERROR = 0x6,
TX_ERROR = 0x7,
BUF_EMPTY = 0x8,
BUF_FULL = 0x9,
NAK = 0xA,
ARB_LOST = 0xB,
BUSY = 0xC,
NOT_IMPLEMENTED = 0xD,
ALIGNEMENT_ERROR = 0xE,
PERIPH_ERR = 0xF,
FAILED_LATCH = 0x10,
GPIO_HIGH = 0x11,
GPIO_LOW = 0x12,
TEST_PASSED = 0x13,
TEST_FAILED = 0x14,
NOTHING_TODO = 0x100,
POWER_FAULT = 0x101,
INVALID_LENGTH = 0x102,
OUT_OF_RANGE = 0x103,
OUT_OF_HEAP_MEMORY = 0x104,
INVALID_STATE_TRANSITION = 0x105,
MPSOC_ALREADY_BOOTING = 0x106,
MPSOC_ALREADY_OPERATIONAL = 0x107,
MPSOC_BOOT_FAILED = 0x108,
SP_NOT_AVAILABLE = 0x200,
SP_DATA_INSUFFICIENT = 0x201,
SP_MEMORY_ID_INVALID = 0x202,
MPSOC_NOT_IN_RESET = 0x203,
FLASH_INIT_FAILED = 0x204,
FLASH_ERASE_FAILED = 0x205,
FLASH_WRITE_FAILED = 0x206,
FLASH_VERIFY_FAILED = 0x207,
CANNOT_ACCESS_TM = 0x208,
CANNOT_SEND_TM = 0x209,
PG_LOW = 0x300,
PG_5V_LOW = 0x301,
PG_0V85_LOW = 0x302,
PG_1V8_LOW = 0x303,
PG_MISC_LOW = 0x304,
PG_3V3_LOW = 0x305,
PG_MB_VAIO_LOW = 0x306,
PG_MB_MPSOCIO_LOW = 0x307
};
};
/**