example compiles again

This commit is contained in:
Robin Müller 2022-07-27 11:26:47 +02:00
parent 9eb652e585
commit 18ee2ab903
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
17 changed files with 95 additions and 40 deletions

View File

@ -70,6 +70,15 @@ class ProvidesDataPoolSubscriptionIF {
virtual ReturnValue_t subscribeForDiagPeriodicPacket( virtual ReturnValue_t subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) = 0; subdp::DiagnosticsHkPeriodicParams params) = 0;
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval,
bool isDiagnostics) {
return subscribeForPeriodicPacket(sid, enableReporting, collectionInterval, isDiagnostics,
objects::NO_OBJECT);
}
[[deprecated( [[deprecated(
"Please use the new API which takes all arguments as one wrapper " "Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t "struct")]] virtual ReturnValue_t
@ -97,6 +106,12 @@ class ProvidesDataPoolSubscriptionIF {
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0;
virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0;
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) {
return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT);
}
[[deprecated( [[deprecated(
"Please use the new API which takes all arguments as one wrapper " "Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t "struct")]] virtual ReturnValue_t

View File

@ -74,8 +74,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
TO_TIMETAG = 3 TO_TIMETAG = 3
}; };
Service11TelecommandScheduling(object_id_t objectId, uint16_t apid, uint8_t serviceId, Service11TelecommandScheduling(PsbParams params, AcceptsTelecommandsIF* tcRecipient,
AcceptsTelecommandsIF* tcRecipient,
uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN, uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN,
bool debugMode = false); bool debugMode = false);
@ -159,7 +158,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
* @param data The Application data of the TC (get via getApplicationData()). * @param data The Application data of the TC (get via getApplicationData()).
* @return requestId * @return requestId
*/ */
uint64_t getRequestIdFromDataTC(const uint8_t* data) const; [[nodiscard]] uint64_t getRequestIdFromTc() const;
/** /**
* @brief Extracts the Request ID from the Application Data directly, assuming it is packed * @brief Extracts the Request ID from the Application Data directly, assuming it is packed

View File

@ -11,9 +11,9 @@ static constexpr auto DEF_END = SerializeIF::Endianness::BIG;
template <size_t MAX_NUM_TCS> template <size_t MAX_NUM_TCS>
inline Service11TelecommandScheduling<MAX_NUM_TCS>::Service11TelecommandScheduling( inline Service11TelecommandScheduling<MAX_NUM_TCS>::Service11TelecommandScheduling(
object_id_t objectId, uint16_t apid, uint8_t serviceId, AcceptsTelecommandsIF *tcRecipient, PsbParams params, AcceptsTelecommandsIF *tcRecipient, uint16_t releaseTimeMarginSeconds,
uint16_t releaseTimeMarginSeconds, bool debugMode) bool debugMode)
: PusServiceBase(objectId, apid, serviceId), : PusServiceBase(params),
RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds), RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds),
debugMode(debugMode), debugMode(debugMode),
tcRecipient(tcRecipient) {} tcRecipient(tcRecipient) {}
@ -32,8 +32,8 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
#endif #endif
} }
// Get de-serialized Timestamp // Get de-serialized Timestamp
const uint8_t *data = currentPacket.getApplicationData(); const uint8_t *data = currentPacket.getUserData();
size_t size = currentPacket.getApplicationDataSize(); size_t size = currentPacket.getUserDataLen();
if (data == nullptr) { if (data == nullptr) {
return handleInvalidData("handleRequest"); return handleInvalidData("handleRequest");
} }
@ -82,7 +82,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService
if (schedulingEnabled) { if (schedulingEnabled) {
// release tc // release tc
TmTcMessage releaseMsg(it->second.storeAddr); TmTcMessage releaseMsg(it->second.storeAddr);
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); auto sendRet = psbParams.reqQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
if (sendRet != HasReturnvaluesIF::RETURN_OK) { if (sendRet != HasReturnvaluesIF::RETURN_OK) {
return sendRet; return sendRet;
@ -175,7 +175,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivi
// store currentPacket and receive the store address // store currentPacket and receive the store address
store_address_t addr{}; store_address_t addr{};
if (tcStore->addData(&addr, data, size) != RETURN_OK || if (tcStore->addData(&addr, data, size) != RETURN_OK ||
addr.raw == storeId::INVALID_STORE_ADDRESS) { addr.raw == store_address_t::INVALID_RAW) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed" sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed"
<< std::endl; << std::endl;
@ -190,8 +190,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivi
TelecommandStruct tc; TelecommandStruct tc;
tc.seconds = timestamp; tc.seconds = timestamp;
tc.storeAddr = addr; tc.storeAddr = addr;
tc.requestId = tc.requestId = getRequestIdFromTc(); // TODO: Missing sanity check of the returned request id
getRequestIdFromDataTC(data); // TODO: Missing sanity check of the returned request id
auto it = telecommandMap.insert(std::pair<uint32_t, TelecommandStruct>(timestamp, tc)); auto it = telecommandMap.insert(std::pair<uint32_t, TelecommandStruct>(timestamp, tc));
if (it == telecommandMap.end()) { if (it == telecommandMap.end()) {
@ -455,13 +454,10 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doFilterTimesh
} }
template <size_t MAX_NUM_TCS> template <size_t MAX_NUM_TCS>
inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromDataTC( inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromTc() const {
const uint8_t *data) const { uint32_t sourceId = currentPacket.getSourceId();
TcPacketPus mask(data); uint16_t apid = currentPacket.getApid();
uint16_t sequenceCount = currentPacket.getSequenceCount();
uint32_t sourceId = mask.getSourceId();
uint16_t apid = mask.getAPID();
uint16_t sequenceCount = mask.getPacketSequenceCount();
return buildRequestId(sourceId, apid, sequenceCount); return buildRequestId(sourceId, apid, sequenceCount);
} }

View File

@ -33,8 +33,7 @@ class HasReturnvaluesIF {
* @param number * @param number
* @return * @return
*/ */
[[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) {
uint8_t classId, uint8_t number) {
return retval::makeCode(classId, number); return retval::makeCode(classId, number);
} }
}; };

View File

@ -8,8 +8,8 @@
#define PUS_DISTRIBUTOR_DEBUGGING 0 #define PUS_DISTRIBUTOR_DEBUGGING 0
PusDistributor::PusDistributor(StorageManagerIF* store_, uint16_t setApid, object_id_t setObjectId, PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource) object_id_t setPacketSource, StorageManagerIF* store_)
: TcDistributor(setObjectId), : TcDistributor(setObjectId),
store(store_), store(store_),
checker(setApid, ccsds::PacketType::TC), checker(setApid, ccsds::PacketType::TC),
@ -151,5 +151,11 @@ ReturnValue_t PusDistributor::initialize() {
#endif #endif
return RETURN_FAILED; return RETURN_FAILED;
} }
if (store == nullptr) {
store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (store == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
return ccsdsDistributor->registerApplication(this); return ccsdsDistributor->registerApplication(this);
} }

View File

@ -27,8 +27,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* @param setPacketSource Object ID of the source of TC packets. * @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF. * Must implement CCSDSDistributorIF.
*/ */
PusDistributor(StorageManagerIF* store, uint16_t setApid, object_id_t setObjectId, PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource,
object_id_t setPacketSource); StorageManagerIF* store = nullptr);
/** /**
* The destructor is empty. * The destructor is empty.
*/ */

View File

@ -17,7 +17,7 @@ uint16_t ccsds::getPacketLen(const PrimaryHeader &header) {
} }
void ccsds::setPacketId(PrimaryHeader &header, uint16_t packetId) { void ccsds::setPacketId(PrimaryHeader &header, uint16_t packetId) {
header.packetIdHAndVersion = (packetId >> 8) & 0x1F; header.packetIdHAndVersion |= (packetId >> 8) & 0x1F;
header.packetIdL = packetId & 0xff; header.packetIdL = packetId & 0xff;
} }
@ -27,3 +27,8 @@ void ccsds::setApid(PrimaryHeader &header, uint16_t apid) {
packetIdRaw |= apid & 0x7FF; packetIdRaw |= apid & 0x7FF;
setPacketId(header, packetIdRaw); setPacketId(header, packetIdRaw);
} }
void ccsds::setSequenceCount(PrimaryHeader &header, uint16_t seqCount) {
header.packetSeqCtrlH |= (seqCount >> 8) & 0x3F;
header.packetSeqCtrlL = seqCount & 0xFF;
}

View File

@ -24,6 +24,7 @@ uint16_t getPacketLen(const PrimaryHeader& header);
void setPacketId(PrimaryHeader& header, uint16_t packetId); void setPacketId(PrimaryHeader& header, uint16_t packetId);
void setApid(PrimaryHeader& header, uint16_t apid); void setApid(PrimaryHeader& header, uint16_t apid);
void setSequenceCount(PrimaryHeader& header, uint16_t seqCount);
} // namespace ccsds } // namespace ccsds

View File

@ -3,5 +3,6 @@
#include "tm/PusTmCreator.h" #include "tm/PusTmCreator.h"
#include "tm/PusTmReader.h" #include "tm/PusTmReader.h"
#include "tm/PusTmZcWriter.h"
#endif /* FSFW_TMTCPACKET_PUS_TM_H_ */ #endif /* FSFW_TMTCPACKET_PUS_TM_H_ */

View File

@ -1,2 +1,2 @@
target_sources(${LIB_FSFW_NAME} PRIVATE PusTmCreator.cpp PusTmReader.cpp target_sources(${LIB_FSFW_NAME} PRIVATE PusTmCreator.cpp PusTmReader.cpp
PusTmMinimal.cpp) PusTmMinimal.cpp PusTmZcWriter.cpp)

View File

@ -83,8 +83,11 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max
return result; return result;
} }
} }
uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); if (calculateCrcOnSerialization) {
return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT));
return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness);
}
return HasReturnvaluesIF::RETURN_OK;
} }
size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); } size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); }
@ -108,10 +111,6 @@ void PusTmCreator::updateSpLengthField() {
void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); }
ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const {
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
}
void PusTmCreator::setup() { void PusTmCreator::setup() {
updateSpLengthField(); updateSpLengthField();
spCreator.setPacketType(ccsds::PacketType::TM); spCreator.setPacketType(ccsds::PacketType::TM);

View File

@ -63,7 +63,6 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
uint8_t getScTimeRefStatus() override; uint8_t getScTimeRefStatus() override;
uint16_t getMessageTypeCounter() override; uint16_t getMessageTypeCounter() override;
uint16_t getDestId() override; uint16_t getDestId() override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override; Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
@ -76,6 +75,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
private: private:
void setup(); void setup();
PusTmParams pusParams{}; PusTmParams pusParams{};
bool calculateCrcOnSerialization = true;
SpacePacketCreator spCreator; SpacePacketCreator spCreator;
}; };
#endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H #endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H

View File

@ -38,13 +38,15 @@ class PusTmReader : public PusTmIF,
uint16_t getMessageTypeCounter() override; uint16_t getMessageTypeCounter() override;
uint16_t getDestId() override; uint16_t getDestId() override;
private: protected:
ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; ecss::PusPointers pointers{};
ReturnValue_t parseData(bool crcCheck);
SpacePacketReader spReader{}; SpacePacketReader spReader{};
size_t sourceDataLen = 0; size_t sourceDataLen = 0;
TimeReaderIF* timeReader{}; TimeReaderIF* timeReader{};
ecss::PusPointers pointers{}; ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override;
ReturnValue_t parseData(bool crcCheck);
private:
}; };
#endif // FSFW_TMTCPACKET_PUSTMREADER_H #endif // FSFW_TMTCPACKET_PUSTMREADER_H

View File

@ -0,0 +1,18 @@
#include "PusTmZcWriter.h"
#include "fsfw/globalfunctions/CRC.h"
PusTmZeroCopyWriter::PusTmZeroCopyWriter(uint8_t* data, size_t size) : PusTmReader(data, size) {}
void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) {
auto* spHeader =
reinterpret_cast<ccsds::PrimaryHeader*>(const_cast<uint8_t*>((pointers.spHeaderStart)));
ccsds::setSequenceCount(*spHeader, seqCount);
}
void PusTmZeroCopyWriter::updateErrorControl() {
auto* crcStart = reinterpret_cast<uint8_t*>(const_cast<uint8_t*>((pointers.spHeaderStart)));
uint16_t crc16 =
CRC::crc16ccitt(PusTmReader::getFullData(), getFullPacketLen() - sizeof(ecss::PusChecksumT));
crcStart[0] = (crc16 >> 8) & 0xff;
crcStart[1] = crc16 & 0xff;
}

View File

@ -0,0 +1,14 @@
#ifndef FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H
#define FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H
#include "PusTmReader.h"
class PusTmZeroCopyWriter : public PusTmReader {
public:
PusTmZeroCopyWriter(uint8_t* data, size_t size);
void setSequenceCount(uint16_t seqCount);
void updateErrorControl();
private:
};
#endif // FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H

View File

@ -27,7 +27,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PusService " << psbParams.serviceId << ": performService returned with " sif::error << "PusService " << psbParams.serviceId << ": performService returned with "
<< static_cast<uint16_t>(result) << std::endl; << static_cast<uint16_t>(result) << std::endl;
#endif #endif
return RETURN_FAILED; return RETURN_FAILED;
} }

View File

@ -645,7 +645,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData
sid_t sid(this->getObjectId(), td::TEST_SET_ID); sid_t sid(this->getObjectId(), td::TEST_SET_ID);
/* Subscribe for periodic HK packets but do not enable reporting for now. /* Subscribe for periodic HK packets but do not enable reporting for now.
Non-diangostic with a period of one second */ Non-diangostic with a period of one second */
poolManager.subscribeForPeriodicPacket(sid, false, 1.0, false); poolManager.subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams(sid, false, 1.0));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }