improved TcPacketPus API

This commit is contained in:
Robin Müller 2022-05-17 10:14:34 +02:00
parent ee2f8d6956
commit 618f76ae78
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 33 additions and 11 deletions

View File

@ -97,3 +97,15 @@ ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args)
tcData = reinterpret_cast<TcPacketPointer *>(const_cast<uint8_t *>(dataPtr)); tcData = reinterpret_cast<TcPacketPointer *>(const_cast<uint8_t *>(dataPtr));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void TcPacketPus::setApplicationData(const uint8_t *data, size_t len, bool updateSpLenField) {
if(data == nullptr) {
len = 0;
}
if(data != nullptr) {
std::memcpy(&tcData->appData, data, len);
}
if(updateSpLenField) {
setPacketDataLength(calculateFullPacketLength(len) - sizeof(CCSDSPrimaryHeader) - 1);
}
}

View File

@ -49,6 +49,27 @@ class TcPacketPus : public TcPacketPusBase {
*/ */
TcPacketPus(const uint8_t* setData); TcPacketPus(const uint8_t* setData);
/**
* Initializes the Tc Packet header.
* @param apid APID used.
* @param sequenceCount Sequence Count in the primary header.
* @param ack Which acknowledeges are expected from the receiver.
* @param service PUS Service
* @param subservice PUS Subservice
*/
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service,
uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0);
/**
* Set the application data field by copying the provided data to the application data field.
* This function can also update the space packet length
* field. To only update the SP length field with empty application data, simply pass 0 as
* length of nullptr as data.
* @param data
* @param len
* @param updateSpLenField
*/
void setApplicationData(const uint8_t* data, size_t len, bool updateSpLenField);
// Base class overrides // Base class overrides
uint8_t getSecondaryHeaderFlag() const override; uint8_t getSecondaryHeaderFlag() const override;
uint8_t getPusVersionNumber() const override; uint8_t getPusVersionNumber() const override;
@ -65,17 +86,6 @@ class TcPacketPus : public TcPacketPusBase {
protected: protected:
ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override; ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override;
/**
* Initializes the Tc Packet header.
* @param apid APID used.
* @param sequenceCount Sequence Count in the primary header.
* @param ack Which acknowledeges are expected from the receiver.
* @param service PUS Service
* @param subservice PUS Subservice
*/
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service,
uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0);
/** /**
* A pointer to a structure which defines the data structure of * A pointer to a structure which defines the data structure of
* the packet's data. * the packet's data.