tc replay stop wip
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
2022-03-21 11:05:41 +01:00
parent be45d21486
commit 664670573a
5 changed files with 101 additions and 3 deletions

View File

@ -85,6 +85,8 @@ public:
//! [EXPORT] : [COMMENT] Received command with invalid length
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xC0);
//! [EXPORT] : [COMMENT] Command has invalid parameter
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xC1);
/**
* @brief Constructor
@ -364,11 +366,93 @@ public:
return RETURN_FAILED;
}
std::memcpy(this->getPacketData(), writeData, writeLen);
addCrc();
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
return RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayStart: public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {
}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != RETURN_OK) {
return result;
}
result = lengthData(commandData);
if (result != RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
return result;
}
private:
static const size_t COMMAND_DATA_LENGTH = 1;
static const uint8_t REPEATING = 0;
static const uint8_t ONCE = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return RETURN_OK;
}
ReturnValue_t checkData(uint8_t replay) {
if (replay != REPEATING && replay != ONCE) {
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
return INVALID_PARAMETER;
}
return RETURN_OK;
}
};
/**
* @brief This class helps to build the replay stop command.
*/
class TcReplayStart: public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {
}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != RETURN_OK) {
return result;
}
result = lengthData(commandData);
if (result != RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
return result;
}
};
}
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */