extended serialize if further
This commit is contained in:
@ -62,6 +62,20 @@ class SerializeIF {
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const = 0;
|
||||
|
||||
/**
|
||||
* Forwards to regular @serialize call with network endianness
|
||||
*/
|
||||
virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) {
|
||||
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
/**
|
||||
* If endianness is not explicitly specified, use machine endianness
|
||||
*/
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) {
|
||||
return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of a object if it would be serialized in a buffer
|
||||
* @return Size of serialized object
|
||||
@ -90,6 +104,18 @@ class SerializeIF {
|
||||
*/
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) = 0;
|
||||
/**
|
||||
* Forwards to regular @deSerialize call with network endianness
|
||||
*/
|
||||
virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size, size_t maxSize) {
|
||||
return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
/**
|
||||
* If endianness is not explicitly specified, use machine endianness
|
||||
*/
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, size_t maxSize) {
|
||||
return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method which can be used if serialization should be performed without any additional
|
||||
|
@ -48,9 +48,6 @@ ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *si
|
||||
}
|
||||
bool SpacePacketCreator::isValid() const { return valid; }
|
||||
|
||||
ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const {
|
||||
return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
void SpacePacketCreator::setApid(uint16_t apid) {
|
||||
if (apid < ccsds::LIMIT_APID) {
|
||||
params.packetId.apid = apid;
|
||||
@ -83,3 +80,4 @@ SpacePacketParams &SpacePacketCreator::getParams() { return params; }
|
||||
void SpacePacketCreator::setPacketType(ccsds::PacketType type) {
|
||||
params.packetId.packetType = type;
|
||||
}
|
||||
bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; }
|
||||
|
@ -24,6 +24,9 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
|
||||
public:
|
||||
SpacePacketCreator() = default;
|
||||
explicit SpacePacketCreator(SpacePacketParams params);
|
||||
|
||||
bool operator==(const SpacePacketCreator &other) const;
|
||||
|
||||
SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid,
|
||||
ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen,
|
||||
uint8_t version = 0);
|
||||
@ -41,7 +44,6 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
|
||||
void setSeqFlags(ccsds::SequenceFlags flags);
|
||||
void setDataLen(uint16_t dataLen);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -43,7 +43,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max
|
||||
if (*size + getSerializedSize() > maxSize) {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
}
|
||||
ReturnValue_t result = spCreator.serialize(buffer, size, maxSize);
|
||||
ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user