improved sequence count
This commit is contained in:
parent
0f0f5e2fcb
commit
f0bf743f88
@ -71,7 +71,7 @@ public:
|
|||||||
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
|
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
|
||||||
|
|
||||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
//! [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
|
* @brief Constructor
|
||||||
@ -212,7 +212,6 @@ public:
|
|||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {
|
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {
|
||||||
this->setPacketDataLength(PACKET_LENGTH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -223,21 +222,22 @@ protected:
|
|||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||||
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE,
|
uint16_t memLen = *(commandData + MEM_ADDRESS_SIZE) << 8
|
||||||
commandData + MEM_ADDRESS_SIZE, MEM_DATA_SIZE);
|
| *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||||
|
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static const size_t COMMAND_LENGTH = 8;
|
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
|
||||||
static const uint16_t PACKET_LENGTH = 9;
|
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 MEM_DATA_SIZE = 4;
|
static const size_t FIX_LENGTH = 8;
|
||||||
|
|
||||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||||
if (commandDataLen != COMMAND_LENGTH) {
|
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
|
@ -4,5 +4,4 @@ target_sources(${TARGET_NAME} PRIVATE
|
|||||||
PlocMemoryDumper.cpp
|
PlocMemoryDumper.cpp
|
||||||
PlocMPSoCHandler.cpp
|
PlocMPSoCHandler.cpp
|
||||||
PlocMPSoCHelper.cpp
|
PlocMPSoCHelper.cpp
|
||||||
MPSoCSequenceCount.cpp
|
|
||||||
)
|
)
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#include "fsfw/serviceInterface/ServiceInterfaceStream.h"
|
|
||||||
#include "MPSoCSequenceCount.h"
|
|
||||||
|
|
||||||
MPSoCSequenceCount::MPSoCSequenceCount() : SourceSequenceCounter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t MPSoCSequenceCount::compare(uint16_t recvSeqCount) {
|
|
||||||
if (recvSeqCount != *this) {
|
|
||||||
sif::warning << "MPSoCSequenceCount::compare: Packet sequence count mismatch. Received: "
|
|
||||||
<< recvSeqCount << ", Expected: " << *this << std::endl;
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
MPSoCSequenceCount::~MPSoCSequenceCount() {
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
#ifndef BSP_Q7S_DEVICES_PLOC_MPSOCSEQUENCECOUNT_H_
|
|
||||||
#define BSP_Q7S_DEVICES_PLOC_MPSOCSEQUENCECOUNT_H_
|
|
||||||
|
|
||||||
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Class to manage the sequence count of the space packets exchanged with the MPSoC of the
|
|
||||||
* PLOC.
|
|
||||||
*
|
|
||||||
* @author J. Meier
|
|
||||||
*/
|
|
||||||
class MPSoCSequenceCount : public SourceSequenceCounter {
|
|
||||||
public:
|
|
||||||
MPSoCSequenceCount();
|
|
||||||
virtual ~MPSoCSequenceCount();
|
|
||||||
|
|
||||||
ReturnValue_t compare(uint16_t recvSeqCount);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* BSP_Q7S_DEVICES_PLOC_MPSOCSEQUENCECOUNT_H_ */
|
|
@ -207,10 +207,10 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
|
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
|
||||||
result = sequenceCount.compare(recvSeqCnt);
|
if (recvSeqCnt != sequenceCount) {
|
||||||
if (result != RETURN_OK) {
|
|
||||||
triggerEvent(SEQ_CNT_MISMATCH, sequenceCount, recvSeqCnt);
|
triggerEvent(SEQ_CNT_MISMATCH, sequenceCount, recvSeqCnt);
|
||||||
sequenceCount = recvSeqCnt;
|
sequenceCount = recvSeqCnt;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||||
#include "fsfw/ipc/QueueFactory.h"
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
|
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||||
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||||
#include "MPSoCSequenceCount.h"
|
|
||||||
#include "PlocMPSoCHelper.h"
|
#include "PlocMPSoCHelper.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +93,7 @@ private:
|
|||||||
|
|
||||||
MessageQueueIF* eventQueue = nullptr;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
|
|
||||||
MPSoCSequenceCount sequenceCount;
|
SourceSequenceCounter sequenceCount;
|
||||||
|
|
||||||
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
|
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) {
|
|||||||
comCookie = comCookie_;
|
comCookie = comCookie_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHelper::setSequenceCount(MPSoCSequenceCount* sequenceCount_) {
|
void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||||
sequenceCount = sequenceCount_;
|
sequenceCount = sequenceCount_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,8 +214,7 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint16_t recvSeqCnt = tmPacket->getPacketSequenceCount();
|
uint16_t recvSeqCnt = tmPacket->getPacketSequenceCount();
|
||||||
result = sequenceCount->compare(recvSeqCnt);
|
if (recvSeqCnt != *sequenceCount) {
|
||||||
if (result != RETURN_OK) {
|
|
||||||
triggerEvent(SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
|
triggerEvent(SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
|
||||||
*sequenceCount = recvSeqCnt;
|
*sequenceCount = recvSeqCnt;
|
||||||
return result;
|
return result;
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
#include "fsfw_hal/linux/uart/UartComIF.h"
|
#include "fsfw_hal/linux/uart/UartComIF.h"
|
||||||
#include "fsfw/devicehandlers/CookieIF.h"
|
#include "fsfw/devicehandlers/CookieIF.h"
|
||||||
|
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||||
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
#include "bsp_q7s/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||||
#include "MPSoCSequenceCount.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper class for MPSoC of PLOC intended to accelerate large data transfers between
|
* @brief Helper class for MPSoC of PLOC intended to accelerate large data transfers between
|
||||||
@ -91,7 +91,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Sets the sequence count object responsible for the sequence count handling
|
* @brief Sets the sequence count object responsible for the sequence count handling
|
||||||
*/
|
*/
|
||||||
void setSequenceCount(MPSoCSequenceCount* sequenceCount_);
|
void setSequenceCount(SourceSequenceCounter* sequenceCount_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ private:
|
|||||||
// Communication cookie. Must be set by the MPSoC Handler
|
// Communication cookie. Must be set by the MPSoC Handler
|
||||||
CookieIF* comCookie = nullptr;
|
CookieIF* comCookie = nullptr;
|
||||||
// Sequence count, must be set by Ploc MPSoC Handler
|
// Sequence count, must be set by Ploc MPSoC Handler
|
||||||
MPSoCSequenceCount* sequenceCount;
|
SourceSequenceCounter* sequenceCount;
|
||||||
|
|
||||||
ReturnValue_t performFlashWrite();
|
ReturnValue_t performFlashWrite();
|
||||||
ReturnValue_t sendCommand(mpsoc::TcBase* tc);
|
ReturnValue_t sendCommand(mpsoc::TcBase* tc);
|
||||||
|
Loading…
Reference in New Issue
Block a user