corrections in plocHandler, endianness

This commit is contained in:
Robin Müller 2021-04-26 11:28:19 +02:00 committed by IRS Cleanroom Laptop
parent ff11fa4904
commit 4c146b27c9
6 changed files with 44 additions and 23 deletions

View File

@ -1,5 +1,9 @@
#!/bin/sh #!/bin/sh
export PATH=$PATH:"/c/Xilinx/SDK/2018.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin" export PATH=/c/Users/integration/Documents/EIVE/gcc-arm-linux-gnueabi/bin:${PATH}
export CROSS_COMPILE="arm-linux-gnueabihf" export CROSS_COMPILE=arm-linux-gnueabihf
export Q7S_SYSROOT="/c/Xilinx/SDK/2018.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/arm-linux-gnueabihf/libc" export CMAKE_ASM_COMPILER=arm-linux-gnueabihf-as
export CMAKE_C_COMPILER=arm-linux-gnueabihf-gcc
export CMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++
export Q7S_SYSROOT=/c/Users/integration/Documents/EIVE/cortexa9hf-neon-xiphos-linux-gnueabi

@ -1 +1 @@
Subproject commit 7a3190e5b6980ad2addc5e8a76d21994b542f0e0 Subproject commit c47d39964fcdc08f6ab93a5e6b6e3b63d4a21abb

View File

@ -151,7 +151,10 @@ ReturnValue_t PlocHandler::prepareTcMemWriteCommand(const uint8_t * commandData,
| *(commandData + 2) << 8 | *(commandData + 3); | *(commandData + 2) << 8 | *(commandData + 3);
const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16
| *(commandData + 6) << 8 | *(commandData + 7); | *(commandData + 6) << 8 | *(commandData + 7);
PLOC::TcMemWrite tcMemWrite(memoryAddress, memoryData); if (subsequenceCount != 0) {
subsequenceCount++;
}
PLOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, subsequenceCount);
if (tcMemWrite.getFullSize() > PLOC::MAX_COMMAND_SIZE) { if (tcMemWrite.getFullSize() > PLOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocHandler::prepareTcMemWriteCommand: Command too big" << std::endl; sif::debug << "PlocHandler::prepareTcMemWriteCommand: Command too big" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
@ -167,7 +170,10 @@ ReturnValue_t PlocHandler::prepareTcMemReadCommand(const uint8_t * commandData,
size_t commandDataLen) { size_t commandDataLen) {
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16
| *(commandData + 2) << 8 | *(commandData + 3); | *(commandData + 2) << 8 | *(commandData + 3);
PLOC::TcMemRead tcMemRead(memoryAddress); if (subsequenceCount != 0) {
subsequenceCount++;
}
PLOC::TcMemRead tcMemRead(memoryAddress, subsequenceCount);
if (tcMemRead.getFullSize() > PLOC::MAX_COMMAND_SIZE) { if (tcMemRead.getFullSize() > PLOC::MAX_COMMAND_SIZE) {
sif::debug << "PlocHandler::prepareTcMemReadCommand: Command too big" << std::endl; sif::debug << "PlocHandler::prepareTcMemReadCommand: Command too big" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
@ -176,6 +182,7 @@ ReturnValue_t PlocHandler::prepareTcMemReadCommand(const uint8_t * commandData,
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = tcMemRead.getFullSize(); rawPacketLen = tcMemRead.getFullSize();
nextReplyId = PLOC::ACK_REPORT; nextReplyId = PLOC::ACK_REPORT;
return RETURN_OK; return RETURN_OK;
} }
@ -183,7 +190,7 @@ ReturnValue_t PlocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2, 0); uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
if (receivedCrc != recalculatedCrc) { if (receivedCrc != recalculatedCrc) {
return CRC_FAILURE; return CRC_FAILURE;
@ -221,10 +228,12 @@ ReturnValue_t PlocHandler::handleAckReport(const uint8_t* data) {
disableAllReplies(); disableAllReplies();
nextReplyId = PLOC::NONE; nextReplyId = PLOC::NONE;
result = IGNORE_REPLY_DATA; result = IGNORE_REPLY_DATA;
subsequenceCount = ((*(data + 2) & 0x3F) << 8) | *(data + 3);
break; break;
} }
case PLOC::APID_ACK_SUCCESS: { case PLOC::APID_ACK_SUCCESS: {
setNextReplyId(); setNextReplyId();
subsequenceCount = ((*(data + 2) & 0x3F) << 8) | *(data + 3);
break; break;
} }
default: { default: {
@ -252,6 +261,7 @@ ReturnValue_t PlocHandler::handleExecutionReport(const uint8_t* data) {
switch (apid) { switch (apid) {
case (PLOC::APID_EXE_SUCCESS): { case (PLOC::APID_EXE_SUCCESS): {
subsequenceCount = ((*(data + 2) & 0x3F) << 8) | *(data + 3);
break; break;
} }
case (PLOC::APID_EXE_FAILURE): { case (PLOC::APID_EXE_FAILURE): {
@ -268,6 +278,7 @@ ReturnValue_t PlocHandler::handleExecutionReport(const uint8_t* data) {
sendFailureReport(PLOC::EXE_REPORT, RECEIVED_EXE_FAILURE); sendFailureReport(PLOC::EXE_REPORT, RECEIVED_EXE_FAILURE);
disableExeReportReply(); disableExeReportReply();
result = IGNORE_REPLY_DATA; result = IGNORE_REPLY_DATA;
subsequenceCount = ((*(data + 2) & 0x3F) << 8) | *(data + 3);
break; break;
} }
default: { default: {
@ -298,6 +309,8 @@ ReturnValue_t PlocHandler::handleMemoryReadReport(const uint8_t* data) {
nextReplyId = PLOC::EXE_REPORT; nextReplyId = PLOC::EXE_REPORT;
subsequenceCount = ((*(data + 2) & 0x3F) << 8) | *(data + 3);
return result; return result;
} }

View File

@ -65,6 +65,11 @@ private:
uint8_t commandBuffer[PLOC::MAX_COMMAND_SIZE]; uint8_t commandBuffer[PLOC::MAX_COMMAND_SIZE];
/**
* This object counts takes the subsequence count of the PLOC space packets.
*/
uint16_t subsequenceCount = 0;
/** /**
* This variable is used to store the id of the next reply to receive. This is necessary * This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution * because the PLOC sends as reply to each command at least one acknowledgment and execution

View File

@ -63,8 +63,8 @@ namespace PLOC {
* *
* @param memAddr The memory address to read from. * @param memAddr The memory address to read from.
*/ */
TcMemRead(const uint32_t memAddr) : TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) :
SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ) { SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) {
fillPacketDataField(&memAddr); fillPacketDataField(&memAddr);
} }
@ -80,22 +80,21 @@ namespace PLOC {
size_t serializedSize = 0; size_t serializedSize = 0;
uint8_t* memoryAddressPos = this->localData.fields.buffer; uint8_t* memoryAddressPos = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize, SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE);
/* Add memLen to packet data field */ /* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 0; this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 1; this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/* Calculate crc */ /* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE, 0); sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE);
/* Add crc to packet data field of space packet */ /* Add crc to packet data field of space packet */
serializedSize = 0; serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
sizeof(crc), SerializeIF::Endianness::BIG); sizeof(crc), SerializeIF::Endianness::BIG);
memcpy(this->localData.fields.buffer + CRC_OFFSET, &crc, sizeof(crc));
} }
static const uint8_t OFFSET_MEM_LEN_FIELD = 4; static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
@ -117,9 +116,10 @@ namespace PLOC {
* *
* @param memAddr The PLOC memory address where to write to. * @param memAddr The PLOC memory address where to write to.
* @param memoryData The data to write to the specified memory address. * @param memoryData The data to write to the specified memory address.
* @param sequenceCount The subsequence count. Must be incremented with each new packet.
*/ */
TcMemWrite(const uint32_t memAddr, const uint32_t memoryData) : TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) :
SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE) { SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) {
fillPacketDataField(&memAddr, &memoryData); fillPacketDataField(&memAddr, &memoryData);
} }
@ -140,8 +140,8 @@ namespace PLOC {
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); sizeof(*memAddrPtr), SerializeIF::Endianness::BIG);
/* Add memLen to packet data field */ /* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 0; this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 1; this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
/* Add memData to packet data field */ /* Add memData to packet data field */
serializedSize = 0; serializedSize = 0;
@ -151,14 +151,13 @@ namespace PLOC {
/* Calculate crc */ /* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE, 0); sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE);
serializedSize = 0; serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
/* Add crc to packet data field of space packet */ /* Add crc to packet data field of space packet */
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
sizeof(crc), SerializeIF::Endianness::BIG); sizeof(crc), SerializeIF::Endianness::BIG);
memcpy(this->localData.fields.buffer + CRC_OFFSET, &crc, sizeof(crc));
} }
/** Offsets from base address of packet data field */ /** Offsets from base address of packet data field */

2
tmtc

@ -1 +1 @@
Subproject commit 79e897b0353acacf0f986f22f57e9cd8cf30a0da Subproject commit b464648f53b8b9b41f1ee00c94c095c55ee673e1