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

48 lines
1.5 KiB
C++
Raw Normal View History

#include "EofInfo.h"
2022-09-15 18:41:15 +02:00
EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
2022-02-02 10:29:30 +01:00
EntityIdTlv* faultLoc)
: conditionCode(conditionCode), checksum(checksum), fileSize(fileSize), faultLoc(faultLoc) {}
2022-02-02 10:29:30 +01:00
EofInfo::EofInfo(EntityIdTlv* faultLoc)
2022-09-15 18:41:15 +02:00
: conditionCode(cfdp::ConditionCode::NO_CONDITION_FIELD),
2022-02-02 10:29:30 +01:00
checksum(0),
fileSize(0),
faultLoc(faultLoc) {}
2022-02-02 10:29:30 +01:00
uint32_t EofInfo::getChecksum() const { return checksum; }
2022-09-15 18:41:15 +02:00
cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; }
2022-02-02 10:29:30 +01:00
EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; }
2022-02-02 10:29:30 +01:00
cfdp::FileSize& EofInfo::getFileSize() { return fileSize; }
2022-02-02 10:29:30 +01:00
void EofInfo::setChecksum(uint32_t checksum) { this->checksum = checksum; }
2022-09-15 18:41:15 +02:00
void EofInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
2022-02-02 10:29:30 +01:00
this->conditionCode = conditionCode;
}
2022-02-02 10:29:30 +01: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.
2022-09-15 18:41:15 +02:00
if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
2022-02-02 10:29:30 +01:00
size += faultLoc->getSerializedSize();
}
return size;
}
ReturnValue_t EofInfo::setFileSize(size_t fileSize, bool isLarge) {
2022-02-02 10:29:30 +01:00
return this->fileSize.setFileSize(fileSize, isLarge);
}