Merge pull request 'Update CFDP components' (#113) from mueller/update-cfdp-components into develop

Reviewed-on: #113
This commit is contained in:
Robin Müller 2022-10-21 15:27:40 +02:00
commit 754b71a35f
8 changed files with 32 additions and 10 deletions

View File

@ -425,21 +425,31 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() {
store_address_t storeId;
uint8_t* dataPtr = nullptr;
ReturnValue_t result =
fp.tcStore->getFreeElement(&storeId, finishedPdu.getSerializedSize(), &dataPtr);
fp.tmStore->getFreeElement(&storeId, finishedPdu.getSerializedSize(), &dataPtr);
if (result != OK) {
// TODO: Error handling and event, this is a non CFDP specific error (most likely store is full)
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "cfdp::DestHandler:sendFinishedPdu: Getting store slot failed" << std::endl;
#endif
fp.eventReporter->forwardEvent(events::STORE_ERROR, result, 0);
return result;
}
size_t serLen = 0;
result = finishedPdu.serialize(dataPtr, serLen, finishedPdu.getSerializedSize());
if (result != OK) {
// TODO: Error printout, this really should not happen
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "cfdp::DestHandler::sendFinishedPdu: Serializing Finished PDU failed"
<< std::endl;
#endif
fp.eventReporter->forwardEvent(events::SERIALIZATION_ERROR, result, 0);
return result;
}
TmTcMessage msg(storeId);
result = fp.msgQueue->sendMessage(fp.packetDest.getReportReceptionQueue(), &msg);
if (result != OK) {
// TODO: Error handling and event, this is a non CFDP specific error (most likely store is full)
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "cfdp::DestHandler::sendFinishedPdu: Sending PDU failed" << std::endl;
#endif
fp.eventReporter->forwardEvent(events::MSG_QUEUE_ERROR, result, 0);
return result;
}
fsmRes.packetsSent++;

View File

@ -5,5 +5,15 @@ namespace cfdp {
enum class CfdpStates { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
}
static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP;
namespace events {
static constexpr Event STORE_ERROR = event::makeEvent(SSID, 0, severity::LOW);
static constexpr Event MSG_QUEUE_ERROR = event::makeEvent(SSID, 1, severity::LOW);
static constexpr Event SERIALIZATION_ERROR = event::makeEvent(SSID, 2, severity::LOW);
} // namespace events
} // namespace cfdp
#endif // FSFW_CFDP_HANDLER_DEFS_H

View File

@ -17,7 +17,7 @@ ReturnValue_t FinishPduCreator::serialize(uint8_t **buffer, size_t *size, size_t
if (result != returnvalue::OK) {
return result;
}
if (*size + 1 >= maxSize) {
if (*size + 1 > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
**buffer = finishInfo.getConditionCode() << 4 | finishInfo.getDeliveryCode() << 2 |

View File

@ -33,6 +33,7 @@ enum : uint8_t {
PUS_SERVICE_23 = 103,
MGM_LIS3MDL = 106,
MGM_RM3100 = 107,
CFDP = 108,
FW_SUBSYSTEM_ID_RANGE
};

View File

@ -14,6 +14,7 @@ SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHea
: params(SpacePacketParams(PacketId(packetType, secHeaderFlag, apid),
PacketSeqCtrl(seqFlags, seqCount), dataLen)) {
params.version = version;
checkFieldValidity();
}
uint16_t SpacePacketCreator::getPacketIdRaw() const { return params.packetId.raw(); }

View File

@ -21,9 +21,9 @@ class AcceptsTelemetryIF {
* receiving message queue.
* @return The telemetry reception message queue id.
*/
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) = 0;
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0;
virtual MessageQueueId_t getReportReceptionQueue() { return getReportReceptionQueue(0); }
[[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { return getReportReceptionQueue(0); }
};
#endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */

View File

@ -245,7 +245,7 @@ void TmTcBridge::registerCommDisconnect() {
}
}
MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) {
MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) const {
return tmTcReceptionQueue->getId();
}

View File

@ -65,7 +65,7 @@ class TmTcBridge : public AcceptsTelemetryIF,
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/** AcceptsTelemetryIF override */
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) const override;
/** AcceptsTelecommandsIF override */
uint32_t getIdentifier() const override;