improved sequence count
This commit is contained in:
@ -71,7 +71,7 @@ public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA0);
|
||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xC0);
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -212,7 +212,6 @@ public:
|
||||
* @brief Constructor
|
||||
*/
|
||||
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {
|
||||
this->setPacketDataLength(PACKET_LENGTH);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -223,21 +222,22 @@ protected:
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
||||
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE,
|
||||
commandData + MEM_ADDRESS_SIZE, MEM_DATA_SIZE);
|
||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||
uint16_t memLen = *(commandData + MEM_ADDRESS_SIZE) << 8
|
||||
| *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static const size_t COMMAND_LENGTH = 8;
|
||||
static const uint16_t PACKET_LENGTH = 9;
|
||||
// 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;
|
||||
static const size_t MEM_ADDRESS_SIZE = 4;
|
||||
static const size_t MEM_DATA_SIZE = 4;
|
||||
static const size_t FIX_LENGTH = 8;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen != COMMAND_LENGTH) {
|
||||
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return RETURN_OK;
|
||||
|
Reference in New Issue
Block a user