insidious bug

This commit is contained in:
2023-08-03 15:13:26 +02:00
parent 0cccf26021
commit daf75547a4
6 changed files with 21 additions and 9 deletions

View File

@ -153,3 +153,5 @@ bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const {
bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const {
return not(*this == other);
}
void cfdp::VarLenField::setWidth(cfdp::WidthInBytes width_) { this->width = width_; }

View File

@ -32,6 +32,7 @@ class VarLenField : public SerializeIF {
bool operator<(const VarLenField &other) const;
ReturnValue_t setValueAndWidth(cfdp::WidthInBytes width, uint64_t value);
void setWidth(cfdp::WidthInBytes width);
ReturnValue_t setValue(uint64_t value);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,

View File

@ -19,12 +19,15 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
: sourceParams(std::move(params)), fsfwParams(fsfwParams) {
// The entity ID portion of the transaction ID will always remain fixed.
transactionParams.id.entityId = sourceParams.cfg.localId;
transactionParams.pduConf.sourceId = sourceParams.cfg.localId;
if (sourceParams.seqCountProvider.bitWidth() == 8) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE;
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::ONE_BYTE);
} else if (sourceParams.seqCountProvider.bitWidth() == 16) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::TWO_BYTES;
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::TWO_BYTES);
} else if (sourceParams.seqCountProvider.bitWidth() == 32) {
transactionParams.seqCountWidth = cfdp::WidthInBytes::FOUR_BYTES;
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::FOUR_BYTES);
} else if (sourceParams.seqCountProvider.bitWidth() == 64) {
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::EIGHT_BYTES);
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "cfdp::SourceHandler: Seq count provider bit width "
@ -34,7 +37,7 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
sourceParams.seqCountProvider.bitWidth());
#endif
// Yeah, what am I supposed to do here? Can't throw an exception in the FSFW..
transactionParams.seqCountWidth = cfdp::WidthInBytes::ONE_BYTE;
transactionParams.pduConf.seqNum.setWidth(cfdp::WidthInBytes::ONE_BYTE);
}
}
@ -172,10 +175,13 @@ ReturnValue_t cfdp::SourceHandler::transactionStart(PutRequest& putRequest, Remo
if (not putRequest.getClosureRequested(transactionParams.closureRequested)) {
transactionParams.closureRequested = cfg.closureRequested;
}
transactionParams.pduConf.destId = putRequest.getDestId();
const EntityId& destId = putRequest.getDestId();
transactionParams.pduConf.destId = destId;
// Adapt source ID width to necessary width. The width of the source and destination ID must be
// the same.
transactionParams.pduConf.sourceId.setWidth(destId.getWidth());
// Only used for PDU forwarding, file is sent to file receiver regularly here.
transactionParams.pduConf.direction = Direction::TOWARDS_RECEIVER;
transactionParams.pduConf.sourceId = sourceParams.cfg.localId;
transactionParams.id.seqNum.setValue(sourceParams.seqCountProvider.getAndIncrement());
if (transactionParams.pduConf.mode == TransmissionMode::ACKNOWLEDGED) {

View File

@ -76,7 +76,7 @@ class SourceHandler {
RemoteEntityCfg remoteCfg;
PduConfig pduConf;
cfdp::TransactionId id{};
cfdp::WidthInBytes seqCountWidth{};
// cfdp::WidthInBytes seqCountWidth{};
void reset() {
sourceNameSize = 0;