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(
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(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
@ -97,6 +106,12 @@ class ProvidesDataPoolSubscriptionIF {
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams 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(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t

View File

@ -74,8 +74,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
TO_TIMETAG = 3
};
Service11TelecommandScheduling(object_id_t objectId, uint16_t apid, uint8_t serviceId,
AcceptsTelecommandsIF* tcRecipient,
Service11TelecommandScheduling(PsbParams params, AcceptsTelecommandsIF* tcRecipient,
uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN,
bool debugMode = false);
@ -159,7 +158,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
* @param data The Application data of the TC (get via getApplicationData()).
* @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

View File

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

View File

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

View File

@ -8,8 +8,8 @@
#define PUS_DISTRIBUTOR_DEBUGGING 0
PusDistributor::PusDistributor(StorageManagerIF* store_, uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource)
PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource, StorageManagerIF* store_)
: TcDistributor(setObjectId),
store(store_),
checker(setApid, ccsds::PacketType::TC),
@ -151,5 +151,11 @@ ReturnValue_t PusDistributor::initialize() {
#endif
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);
}

View File

@ -27,8 +27,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
PusDistributor(StorageManagerIF* store, uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource);
PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource,
StorageManagerIF* store = nullptr);
/**
* 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) {
header.packetIdHAndVersion = (packetId >> 8) & 0x1F;
header.packetIdHAndVersion |= (packetId >> 8) & 0x1F;
header.packetIdL = packetId & 0xff;
}
@ -27,3 +27,8 @@ void ccsds::setApid(PrimaryHeader &header, uint16_t apid) {
packetIdRaw |= apid & 0x7FF;
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 setApid(PrimaryHeader& header, uint16_t apid);
void setSequenceCount(PrimaryHeader& header, uint16_t seqCount);
} // namespace ccsds

View File

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

View File

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

View File

@ -83,9 +83,12 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max
return result;
}
}
if (calculateCrcOnSerialization) {
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(); }
ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size,
@ -108,10 +111,6 @@ void PusTmCreator::updateSpLengthField() {
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() {
updateSpLengthField();
spCreator.setPacketType(ccsds::PacketType::TM);

View File

@ -63,7 +63,6 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
uint8_t getScTimeRefStatus() override;
uint16_t getMessageTypeCounter() 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,
Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override;
@ -76,6 +75,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF
private:
void setup();
PusTmParams pusParams{};
bool calculateCrcOnSerialization = true;
SpacePacketCreator spCreator;
};
#endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H

View File

@ -38,13 +38,15 @@ class PusTmReader : public PusTmIF,
uint16_t getMessageTypeCounter() override;
uint16_t getDestId() override;
private:
ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override;
ReturnValue_t parseData(bool crcCheck);
protected:
ecss::PusPointers pointers{};
SpacePacketReader spReader{};
size_t sourceDataLen = 0;
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

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

@ -645,7 +645,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData
sid_t sid(this->getObjectId(), td::TEST_SET_ID);
/* Subscribe for periodic HK packets but do not enable reporting for now.
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;
}