2020-08-13 20:53:35 +02:00
|
|
|
#include "../serialize/SerializeAdapter.h"
|
2020-12-14 21:30:39 +01:00
|
|
|
#include "../tmtcservices/PusVerificationReport.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
PusVerificationMessage::PusVerificationMessage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
PusVerificationMessage::PusVerificationMessage(uint8_t set_report_id,
|
|
|
|
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
|
|
|
|
ReturnValue_t set_error_code, uint8_t set_step, uint32_t parameter1,
|
|
|
|
uint32_t parameter2) {
|
2020-04-21 22:28:43 +02:00
|
|
|
uint8_t *data = this->getBuffer();
|
2016-06-15 23:48:41 +02:00
|
|
|
data[messageSize] = set_report_id;
|
|
|
|
messageSize += sizeof(set_report_id);
|
|
|
|
data[messageSize] = ackFlags;
|
|
|
|
messageSize += sizeof(ackFlags);
|
|
|
|
memcpy(&data[messageSize], &tcPacketId, sizeof(tcPacketId));
|
|
|
|
messageSize += sizeof(tcPacketId);
|
|
|
|
memcpy(&data[messageSize], &tcSequenceControl, sizeof(tcSequenceControl));
|
|
|
|
messageSize += sizeof(tcSequenceControl);
|
|
|
|
data[messageSize] = set_step;
|
|
|
|
messageSize += sizeof(set_step);
|
|
|
|
memcpy(&data[messageSize], &set_error_code, sizeof(set_error_code));
|
|
|
|
messageSize += sizeof(set_error_code);
|
|
|
|
memcpy(&data[messageSize], ¶meter1, sizeof(parameter1));
|
|
|
|
messageSize += sizeof(parameter1);
|
|
|
|
memcpy(&data[messageSize], ¶meter2, sizeof(parameter2));
|
|
|
|
messageSize += sizeof(parameter2);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t PusVerificationMessage::getReportId() {
|
|
|
|
|
|
|
|
return getContent()->reportId;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t PusVerificationMessage::getAckFlags() {
|
|
|
|
|
|
|
|
return getContent()->ackFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t PusVerificationMessage::getTcPacketId() {
|
|
|
|
|
|
|
|
uint16_t tcPacketId;
|
|
|
|
memcpy(&tcPacketId, &getContent()->packetId_0, sizeof(tcPacketId));
|
|
|
|
return tcPacketId;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t PusVerificationMessage::getTcSequenceControl() {
|
|
|
|
|
|
|
|
uint16_t tcSequenceControl;
|
|
|
|
memcpy(&tcSequenceControl, &getContent()->tcSequenceControl_0,
|
|
|
|
sizeof(tcSequenceControl));
|
|
|
|
return tcSequenceControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t PusVerificationMessage::getStep() {
|
|
|
|
|
|
|
|
return getContent()->step;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PusVerificationMessage::getErrorCode() {
|
|
|
|
ReturnValue_t errorCode;
|
|
|
|
memcpy(&errorCode, &getContent()->error_code_0, sizeof(errorCode));
|
|
|
|
return errorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
PusVerificationMessage::verifciationMessageContent* PusVerificationMessage::getContent() {
|
|
|
|
return (verifciationMessageContent*) this->getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PusVerificationMessage::getParameter1() {
|
|
|
|
uint32_t parameter;
|
|
|
|
memcpy(¶meter, &getContent()->parameter1_0, sizeof(parameter));
|
|
|
|
return parameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PusVerificationMessage::getParameter2() {
|
|
|
|
uint32_t parameter;
|
|
|
|
memcpy(¶meter, &getContent()->parameter2_0, sizeof(parameter));
|
|
|
|
return parameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
PusSuccessReport::PusSuccessReport(uint16_t setPacketId,
|
|
|
|
uint16_t setSequenceControl, uint8_t setStep) :
|
|
|
|
reportSize(0), pBuffer(reportBuffer) {
|
|
|
|
//Serialization won't fail, because we know the necessary max-size of the buffer.
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(&setPacketId, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
|
|
|
SerializeAdapter::serialize(&setSequenceControl, &pBuffer, &reportSize,
|
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2016-06-15 23:48:41 +02:00
|
|
|
if (setStep != 0) {
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PusSuccessReport::~PusSuccessReport() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PusSuccessReport::getSize() {
|
|
|
|
return reportSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* PusSuccessReport::getReport() {
|
|
|
|
return reportBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
PusFailureReport::PusFailureReport(uint16_t setPacketId,
|
|
|
|
uint16_t setSequenceControl, ReturnValue_t setErrorCode,
|
|
|
|
uint8_t setStep, uint32_t parameter1, uint32_t parameter2) :
|
|
|
|
reportSize(0), pBuffer(reportBuffer) {
|
|
|
|
//Serialization won't fail, because we know the necessary max-size of the buffer.
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(&setPacketId, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
|
|
|
SerializeAdapter::serialize(&setSequenceControl, &pBuffer, &reportSize,
|
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2016-06-15 23:48:41 +02:00
|
|
|
if (setStep != 0) {
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
2020-04-21 22:28:43 +02:00
|
|
|
SerializeAdapter::serialize(&setErrorCode, &pBuffer, &reportSize,
|
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(¶meter1, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2020-04-21 21:34:03 +02:00
|
|
|
SerializeAdapter::serialize(¶meter2, &pBuffer, &reportSize,
|
2020-04-21 22:28:43 +02:00
|
|
|
sizeof(reportBuffer), SerializeIF::Endianness::BIG);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PusFailureReport::~PusFailureReport() {
|
|
|
|
}
|
|
|
|
|
2020-04-21 22:28:43 +02:00
|
|
|
size_t PusFailureReport::getSize() {
|
2016-06-15 23:48:41 +02:00
|
|
|
return reportSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* PusFailureReport::getReport() {
|
|
|
|
return reportBuffer;
|
|
|
|
}
|