2023-05-15 15:15:58 +02:00
|
|
|
#include "plocMpsocHelpers.h"
|
|
|
|
|
2024-04-30 15:14:22 +02:00
|
|
|
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
|
|
|
|
#include "mission/payload/plocSpBase.h"
|
|
|
|
|
2023-05-15 15:15:58 +02:00
|
|
|
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
|
|
|
|
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
|
|
|
|
}
|
|
|
|
std::string mpsoc::getStatusString(uint16_t status) {
|
|
|
|
switch (status) {
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::UNKNOWN_APID): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Unknown APID";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::INCORRECT_LENGTH): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Incorrect length";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_DRIVE_ERROR): {
|
|
|
|
return "flash drive error";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::statusCode::INCORRECT_CRC): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Incorrect crc";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::INCORRECT_PKT_SEQ_CNT): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Incorrect packet sequence count";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::TC_NOT_ALLOWED_IN_MODE): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "TC not allowed in this mode";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::TC_EXEUTION_DISABLED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "TC execution disabled";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_MOUNT_FAILED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash mount failed";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_FILE_ALREADY_OPEN): {
|
2023-05-17 18:33:48 +02:00
|
|
|
return "Flash file already open";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_FILE_ALREADY_CLOSED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash file already closed";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_FILE_OPEN_FAILED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash file open failed";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_FILE_NOT_OPEN): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash file not open";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_UNMOUNT_FAILED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash unmount failed";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::HEAP_ALLOCATION_FAILED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Heap allocation failed";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::INVALID_PARAMETER): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Invalid parameter";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::NOT_INITIALIZED): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Not initialized";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::REBOOT_IMMINENT): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Reboot imminent";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::CORRUPT_DATA): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Corrupt data";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_CORRECTABLE_MISMATCH): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash correctable mismatch";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::FLASH_UNCORRECTABLE_MISMATCH): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Flash uncorrectable mismatch";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
case (mpsoc::statusCode::DEFAULT_ERROR_CODE): {
|
2023-05-15 15:15:58 +02:00
|
|
|
return "Default error code";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "0x" << std::hex << status;
|
|
|
|
return ss.str().c_str();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2024-04-30 15:14:22 +02:00
|
|
|
|
|
|
|
void mpsoc::printRxPacket(const SpacePacketReader& spReader) {
|
|
|
|
if (mpsoc::MPSOC_RX_WIRETAPPING) {
|
|
|
|
sif::debug << "RECV MPSOC packet. APID 0x" << std::hex << std::setw(3) << spReader.getApid()
|
|
|
|
<< std::dec << " Size " << spReader.getFullPacketLen() << " SSC "
|
|
|
|
<< spReader.getSequenceCount() << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mpsoc::printTxPacket(const ploc::SpTcBase& tcBase) {
|
|
|
|
if (mpsoc::MPSOC_TX_WIRETAPPING) {
|
|
|
|
sif::debug << "SEND MPSOC packet. APID 0x" << std::hex << std::setw(3) << tcBase.getApid()
|
|
|
|
<< " Size " << std::dec << tcBase.getFullPacketLen() << " SSC "
|
|
|
|
<< tcBase.getSeqCount() << std::endl;
|
|
|
|
}
|
|
|
|
}
|