This commit is contained in:
parent
72533f1d14
commit
340ca0618c
@ -191,13 +191,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::WIPE_MRAM): {
|
case(PLOC_SPV::WIPE_MRAM): {
|
||||||
prepareWipeMramCmd(commandData);
|
result = prepareWipeMramCmd(commandData);
|
||||||
result = RETURN_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::DUMP_MRAM): {
|
case(PLOC_SPV::DUMP_MRAM): {
|
||||||
prepareDumpMramCmd(commandData);
|
result = prepareDumpMramCmd(commandData);
|
||||||
result = RETURN_OK;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -439,7 +437,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PLOC_SPV::DUMP_MRAM: {
|
case PLOC_SPV::DUMP_MRAM: {
|
||||||
enabledReplies = expectedMramDumpPackets + 2;
|
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
|
||||||
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
||||||
PLOC_SPV::DUMP_MRAM);
|
PLOC_SPV::DUMP_MRAM);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -1125,18 +1123,21 @@ ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* command
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) {
|
ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) {
|
||||||
uint8_t offset = 0;
|
uint32_t start = 0;
|
||||||
uint32_t start = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
uint32_t stop = 0;
|
||||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
size_t size = sizeof(start) + sizeof(stop);
|
||||||
offset += 4;
|
SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||||
uint32_t stop = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
if ((stop - start) <= 0) {
|
||||||
|
return INVALID_MRAM_ADDRESSES;
|
||||||
|
}
|
||||||
PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE);
|
PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE);
|
||||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) {
|
ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) {
|
||||||
uint32_t start = 0;
|
uint32_t start = 0;
|
||||||
uint32_t stop = 0;
|
uint32_t stop = 0;
|
||||||
size_t size = sizeof(start) + sizeof(stop);
|
size_t size = sizeof(start) + sizeof(stop);
|
||||||
@ -1144,14 +1145,15 @@ void PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) {
|
|||||||
SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG);
|
SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||||
PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP);
|
PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP);
|
||||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||||
|
if ((stop - start) <= 0) {
|
||||||
|
return INVALID_MRAM_ADDRESSES;
|
||||||
|
}
|
||||||
expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY;
|
expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY;
|
||||||
if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) {
|
if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) {
|
||||||
expectedMramDumpPackets++;
|
expectedMramDumpPackets++;
|
||||||
mramLastPktLen = (stop - start) % PLOC_SPV::MAX_DATA_CAPACITY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mramLastPktLen = 0;
|
|
||||||
}
|
}
|
||||||
|
receivedMramDumpPackets = 0;
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) {
|
void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) {
|
||||||
@ -1182,13 +1184,6 @@ void PlocSupervisorHandler::disableAllReplies() {
|
|||||||
info->command = deviceCommandMap.end();
|
info->command = deviceCommandMap.end();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PLOC_SPV::DUMP_MRAM: {
|
|
||||||
iter = deviceReplyMap.find(PLOC_SPV::DUMP_MRAM);
|
|
||||||
info = &(iter->second);
|
|
||||||
info->delayCycles = 0;
|
|
||||||
info->command = deviceCommandMap.end();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1231,7 +1226,9 @@ void PlocSupervisorHandler::disableExeReportReply() {
|
|||||||
|
|
||||||
ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize,
|
ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize,
|
||||||
size_t* foundLen) {
|
size_t* foundLen) {
|
||||||
|
ReturnValue_t result = IGNORE_FULL_PACKET;
|
||||||
uint16_t packetLen = 0;
|
uint16_t packetLen = 0;
|
||||||
|
*foundLen = 0;
|
||||||
|
|
||||||
for (size_t idx = 0; idx < remainingSize; idx++) {
|
for (size_t idx = 0; idx < remainingSize; idx++) {
|
||||||
std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1);
|
std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1);
|
||||||
@ -1244,7 +1241,7 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, siz
|
|||||||
if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) {
|
if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) {
|
||||||
packetInBuffer = true;
|
packetInBuffer = true;
|
||||||
bufferTop = 0;
|
bufferTop = 0;
|
||||||
return RETURN_OK;
|
return checkMramPacketApid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) {
|
if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) {
|
||||||
@ -1255,12 +1252,12 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, siz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IGNORE_FULL_PACKET;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() {
|
ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() {
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
|
|
||||||
// Prepare packet for downlink
|
// Prepare packet for downlink
|
||||||
if (packetInBuffer) {
|
if (packetInBuffer) {
|
||||||
@ -1268,10 +1265,74 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() {
|
|||||||
result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1);
|
result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl;
|
sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
//TODO: Write MRAM dump to SD card handler
|
||||||
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1,
|
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1,
|
||||||
PLOC_SPV::DUMP_MRAM);
|
PLOC_SPV::DUMP_MRAM);
|
||||||
packetInBuffer = false;
|
packetInBuffer = false;
|
||||||
|
receivedMramDumpPackets++;
|
||||||
|
if (expectedMramDumpPackets == receivedMramDumpPackets) {
|
||||||
|
nextReplyId = PLOC_SPV::EXE_REPORT;
|
||||||
|
}
|
||||||
|
increaseExpectedMramReplies();
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlocSupervisorHandler::increaseExpectedMramReplies() {
|
||||||
|
DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(PLOC_SPV::DUMP_MRAM);
|
||||||
|
DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT);
|
||||||
|
if (mramDumpIter == deviceReplyMap.end()) {
|
||||||
|
sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not "
|
||||||
|
<< "in reply map" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (exeReportIter == deviceReplyMap.end()) {
|
||||||
|
sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not "
|
||||||
|
<< "in reply map" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DeviceReplyInfo *mramReplyInfo = &(mramDumpIter->second);
|
||||||
|
if (mramReplyInfo == nullptr) {
|
||||||
|
sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr"
|
||||||
|
<< std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DeviceReplyInfo *exeReplyInfo = &(exeReportIter->second);
|
||||||
|
if (exeReplyInfo == nullptr) {
|
||||||
|
sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info"
|
||||||
|
<< " nullptr" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DeviceCommandInfo* info = &(mramReplyInfo->command->second);
|
||||||
|
if (info == nullptr){
|
||||||
|
sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr"
|
||||||
|
<< std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint8_t sequenceFlags = spacePacketBuffer[2] >> 6;
|
||||||
|
if (sequenceFlags != static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT)) {
|
||||||
|
// Command expects at least one MRAM packet more and the execution report
|
||||||
|
info->expectedReplies = 2;
|
||||||
|
// Wait maximum of 2 cycles for next MRAM packet
|
||||||
|
mramReplyInfo->delayCycles = 2;
|
||||||
|
// Also adapting delay cycles for execution report
|
||||||
|
exeReplyInfo->delayCycles = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Command expects the execution report
|
||||||
|
info->expectedReplies = 1;
|
||||||
|
mramReplyInfo->delayCycles = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
|
||||||
|
uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK;
|
||||||
|
if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) {
|
||||||
|
return NO_MRAM_PACKET;
|
||||||
|
}
|
||||||
|
return APERIODIC_REPLY;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,10 @@ private:
|
|||||||
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA);
|
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA);
|
||||||
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
|
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
|
||||||
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB);
|
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB);
|
||||||
|
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address)
|
||||||
|
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC);
|
||||||
|
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid.
|
||||||
|
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD);
|
||||||
|
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
||||||
|
|
||||||
@ -107,7 +111,7 @@ private:
|
|||||||
|
|
||||||
/** Number of expected replies following the MRAM dump command */
|
/** Number of expected replies following the MRAM dump command */
|
||||||
uint32_t expectedMramDumpPackets = 0;
|
uint32_t expectedMramDumpPackets = 0;
|
||||||
size_t mramLastPktLen = 0;
|
uint32_t receivedMramDumpPackets = 0;
|
||||||
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
|
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
|
||||||
bool packetInBuffer = false;
|
bool packetInBuffer = false;
|
||||||
/** Points to the next free position in the space packet buffer */
|
/** Points to the next free position in the space packet buffer */
|
||||||
@ -237,8 +241,8 @@ private:
|
|||||||
void prepareEnableNvmsCmd(const uint8_t* commandData);
|
void prepareEnableNvmsCmd(const uint8_t* commandData);
|
||||||
void prepareSelectNvmCmd(const uint8_t* commandData);
|
void prepareSelectNvmCmd(const uint8_t* commandData);
|
||||||
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
|
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
|
||||||
void prepareWipeMramCmd(const uint8_t* commandData);
|
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
|
||||||
void prepareDumpMramCmd(const uint8_t* commandData);
|
ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,7 +278,23 @@ private:
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t parseMramPackets(const uint8_t *packet, size_t remainingSize, size_t* foundlen);
|
ReturnValue_t parseMramPackets(const uint8_t *packet, size_t remainingSize, size_t* foundlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function generates the Service 8 packets for the MRAM dump data.
|
||||||
|
*/
|
||||||
ReturnValue_t handleMramDumpPacket();
|
ReturnValue_t handleMramDumpPacket();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief With this function the number of expected replies following an MRAM dump command
|
||||||
|
* will be increased. This is necessary to release the command in case not all replies
|
||||||
|
* have been received.
|
||||||
|
*/
|
||||||
|
void increaseExpectedMramReplies();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function checks if the packet written to the space packet buffer is really a
|
||||||
|
* MRAM dump packet.
|
||||||
|
*/
|
||||||
|
ReturnValue_t checkMramPacketApid();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */
|
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */
|
||||||
|
@ -127,6 +127,8 @@ static const uint16_t APID_REQUEST_LOGGING_DATA = 0xFD;
|
|||||||
|
|
||||||
static const uint16_t APID_GET_HK_REPORT = 0xC6;
|
static const uint16_t APID_GET_HK_REPORT = 0xC6;
|
||||||
|
|
||||||
|
static const uint16_t APID_MASK = 0x3FF;
|
||||||
|
|
||||||
/** Offset from first byte in Space packet to first byte of data field */
|
/** Offset from first byte in Space packet to first byte of data field */
|
||||||
static const uint8_t DATA_FIELD_OFFSET = 6;
|
static const uint8_t DATA_FIELD_OFFSET = 6;
|
||||||
|
|
||||||
@ -137,7 +139,6 @@ static const uint8_t DATA_FIELD_OFFSET = 6;
|
|||||||
static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field
|
static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field
|
||||||
|
|
||||||
/** This is the maximum length of a space packet as defined by the TAS ICD */
|
/** This is the maximum length of a space packet as defined by the TAS ICD */
|
||||||
//static const size_t MAX_REPLY_SIZE = 1024;
|
|
||||||
static const size_t MAX_COMMAND_SIZE = 1024;
|
static const size_t MAX_COMMAND_SIZE = 1024;
|
||||||
static const size_t MAX_DATA_CAPACITY = 1016;
|
static const size_t MAX_DATA_CAPACITY = 1016;
|
||||||
/** This is the maximum size of a space packet for the supervisor */
|
/** This is the maximum size of a space packet for the supervisor */
|
||||||
@ -145,7 +146,7 @@ static const size_t MAX_PACKET_SIZE = 1024;
|
|||||||
|
|
||||||
static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6;
|
static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6;
|
||||||
|
|
||||||
enum SequenceFlags {
|
enum class SequenceFlags: uint8_t {
|
||||||
CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11
|
CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user