v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
Showing only changes of commit 800cabb8a1 - Show all commits

View File

@ -257,7 +257,7 @@ class TcMemWrite : public TcBase {
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {} : TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected: protected:
// TODO: Confusing, recheck..
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
@ -267,19 +267,28 @@ class TcMemWrite : public TcBase {
std::memcpy(payloadStart, commandData, commandDataLen); std::memcpy(payloadStart, commandData, commandDataLen);
uint16_t memLen = uint16_t memLen =
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1); *(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
spParams.setPayloadLen(FIX_LENGTH + memLen * 4); spParams.setPayloadLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4);
return result; return result;
} }
private: private:
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word) // 4 byte address, 2 byte mem length field
static const size_t MIN_COMMAND_DATA_LENGTH = 10;
static const size_t MEM_ADDRESS_SIZE = 4; static const size_t MEM_ADDRESS_SIZE = 4;
static const size_t FIX_LENGTH = 8; static const size_t MIN_FIXED_PAYLOAD_LENGTH = MEM_ADDRESS_SIZE + 2;
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
static const size_t MIN_COMMAND_DATA_LENGTH = MIN_FIXED_PAYLOAD_LENGTH + 4;
ReturnValue_t lengthCheck(size_t commandDataLen) { ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) { if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl; sif::warning << "TcMemWrite: Length " << commandDataLen << " smaller than minimum " <<
MIN_COMMAND_DATA_LENGTH << std::endl;
return INVALID_LENGTH;
}
if(commandDataLen + CRC_SIZE > spParams.maxSize) {
sif::warning << "TcMemWrite: Length " << commandDataLen << " larger than allowed " <<
spParams.maxSize - CRC_SIZE << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;