v1.14.0 #304
@ -257,7 +257,7 @@ class TcMemWrite : public TcBase {
|
||||
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
// TODO: Confusing, recheck..
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
@ -267,19 +267,28 @@ class TcMemWrite : public TcBase {
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
uint16_t memLen =
|
||||
*(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;
|
||||
}
|
||||
|
||||
private:
|
||||
// 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 = 10;
|
||||
// 4 byte address, 2 byte mem length field
|
||||
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) {
|
||||
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 HasReturnvaluesIF::RETURN_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user