2016-06-15 23:48:41 +02:00
|
|
|
#ifndef SERIALIZEIF_H_
|
|
|
|
#define SERIALIZEIF_H_
|
|
|
|
|
|
|
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
|
|
|
|
2019-08-28 14:50:24 +02:00
|
|
|
/**
|
2019-12-08 22:57:03 +01:00
|
|
|
* @defgroup serialize Serialization
|
2019-08-28 14:50:24 +02:00
|
|
|
* Contains serialisation services.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2019-12-08 22:57:03 +01:00
|
|
|
* @brief An interface for alle classes which require
|
|
|
|
* translation of objects data into data streams and vice-versa.
|
|
|
|
* @details
|
2019-11-02 23:30:12 +01:00
|
|
|
* If the target architecture is little endian (e.g. ARM), any data types created might
|
2019-10-27 03:21:38 +01:00
|
|
|
* have the wrong endiness if they are to be used for the FSFW.
|
2019-12-08 22:57:03 +01:00
|
|
|
* There are three ways to retrieve data out of a buffer to be used in the FSFW to use
|
|
|
|
* regular aligned (big endian) data. This can also be applied to uint32_t and uint64_t:
|
2019-10-27 03:21:38 +01:00
|
|
|
*
|
|
|
|
* 1. Use the @c AutoSerializeAdapter::deSerialize function with @c bigEndian = true
|
|
|
|
* 2. Perform a bitshift operation
|
2019-11-02 23:30:12 +01:00
|
|
|
* 3. @c memcpy can be used when data is in little-endian format. Otherwise, @c EndianSwapper has to be used in conjuction.
|
2019-10-27 03:21:38 +01:00
|
|
|
*
|
|
|
|
* When serializing for downlink, the packets are generally serialized assuming big endian data format
|
2019-10-25 21:12:11 +02:00
|
|
|
* like seen in TmPacketStored.cpp for example.
|
|
|
|
*
|
2019-12-08 22:57:03 +01:00
|
|
|
* @ingroup serialize
|
2019-08-28 14:50:24 +02:00
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
class SerializeIF {
|
|
|
|
public:
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF;
|
2016-06-15 23:48:41 +02:00
|
|
|
static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1);
|
|
|
|
static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2);
|
|
|
|
static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(3);
|
|
|
|
|
|
|
|
virtual ~SerializeIF() {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
|
|
|
const uint32_t max_size, bool bigEndian) const = 0;
|
|
|
|
|
|
|
|
virtual uint32_t getSerializedSize() const = 0;
|
|
|
|
|
|
|
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
|
|
|
bool bigEndian) = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SERIALIZEIF_H_ */
|