fsfw/src/fsfw/cfdp/pdu/EofInfo.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

#include "EofInfo.h"
2023-07-19 14:02:03 +02:00
#include <utility>
2023-07-19 13:44:52 +02:00
EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::Fss fileSize,
2022-02-02 10:29:30 +01:00
EntityIdTlv* faultLoc)
2023-07-19 14:02:03 +02:00
: conditionCode(conditionCode),
checksum(checksum),
fileSize(std::move(fileSize)),
faultLoc(faultLoc) {}
2022-02-02 10:29:30 +01:00
EofInfo::EofInfo(EntityIdTlv* faultLoc)
: conditionCode(cfdp::ConditionCode::NO_CONDITION_FIELD),
checksum(0),
fileSize(0),
faultLoc(faultLoc) {}
2022-02-02 10:29:30 +01:00
uint32_t EofInfo::getChecksum() const { return checksum; }
2022-02-02 10:29:30 +01:00
cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; }
2022-02-02 10:29:30 +01:00
EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; }
2023-07-19 13:44:52 +02:00
cfdp::Fss& EofInfo::getFileSize() { return fileSize; }
2023-07-19 14:02:03 +02:00
void EofInfo::setChecksum(uint32_t checksum_) { this->checksum = checksum_; }
2023-07-19 14:02:03 +02:00
void EofInfo::setConditionCode(cfdp::ConditionCode conditionCode_) {
this->conditionCode = conditionCode_;
}
2023-07-19 14:02:03 +02:00
void EofInfo::setFaultLoc(EntityIdTlv* faultLoc_) { this->faultLoc = faultLoc_; }
size_t EofInfo::getSerializedSize(bool fssLarge) {
2022-02-02 10:29:30 +01:00
// Condition code + spare + 4 byte checksum
size_t size = 5;
if (fssLarge) {
size += 8;
} else {
size += 4;
}
// Do not account for fault location if the condition code is NO_ERROR. We assume that
// a serializer will not serialize the fault location here.
if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
size += faultLoc->getSerializedSize();
}
return size;
}
2023-07-19 14:02:03 +02:00
ReturnValue_t EofInfo::setFileSize(size_t fileSize_, bool isLarge) {
return this->fileSize.setFileSize(fileSize_, isLarge);
}