documentation related stuff #4

Closed
muellerr wants to merge 1 commits from mueller_documentationBranch into master
15 changed files with 290 additions and 43 deletions

View File

@ -7,8 +7,10 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/ipc/MessageQueueIF.h>
/**
* \brief Interface for component which uses actions
* @brief
* Interface for component which uses actions
*
* @details
* This interface is used to execute actions in the component. Actions, in the sense of this interface, are activities with a well-defined beginning and
* end in time. They may adjust sub-states of components, but are not supposed to change
* the main mode of operation, which is handled with the HasModesIF described below.
@ -23,6 +25,8 @@
* parameters and immediately start execution of the action. It is, however, not required to
* immediately finish execution. Instead, this may be deferred to a later point in time, at
* which the component needs to inform the caller about finished or failed execution.
*
* \ingroup interfaces
*/
class HasActionsIF {
public:

View File

@ -4,12 +4,41 @@
#include <framework/container/RingBufferBase.h>
#include <stddef.h>
/**
* @brief Circular buffer implementation, useful for buffering into data streams.
* @details Note that the deleteData() has to be called to increment the read pointer
* @ingroup containers
*/
class SimpleRingBuffer: public RingBufferBase<> {
public:
SimpleRingBuffer(uint32_t size, bool overwriteOld);
virtual ~SimpleRingBuffer();
/**
* Write to circular buffer and increment write pointer by amount
* @param data
* @param amount
* @return
*/
ReturnValue_t writeData(const uint8_t* data, uint32_t amount);
/**
* Read from circular buffer at read pointer
* @param data
* @param amount
* @param readRemaining
* @param trueAmount
* @return
*/
ReturnValue_t readData(uint8_t* data, uint32_t amount, bool readRemaining = false, uint32_t* trueAmount = NULL);
/**
* Delete data starting by incrementing read pointer
* @param amount
* @param deleteRemaining
* @param trueAmount
* @return
*/
ReturnValue_t deleteData(uint32_t amount, bool deleteRemaining = false, uint32_t* trueAmount = NULL);
private:
// static const uint8_t TEMP_READ_PTR = 1;

View File

@ -112,8 +112,7 @@ public:
* corresponds to.
* \param dataSet The data set in which the variable shall register itself. If NULL,
* the variable is not registered.
* \param setWritable If this flag is set to true, changes in the value attribute can be
* written back to the data pool, otherwise not.
* \param setReadWriteMode
*/
PoolVariable(uint32_t set_id, DataSetIF* dataSet,
ReadWriteMode_t setReadWriteMode) :

View File

@ -1,6 +1,15 @@
#ifndef COOKIE_H_
#define COOKIE_H_
/**
* @brief This datatype is used to identify different connection over a single interface
* (like RMAP or I2C)
* @details
* To use this class, implement a communication specific child cookie. This cookie
* can be used in the device communication interface by performing
* a C++ dynamic cast. The cookie can be used to store all kinds of information
* about the communication between read and send calls.
*/
class Cookie{
public:
virtual ~Cookie(){}

View File

@ -31,7 +31,7 @@ public:
* \brief This attribute defines when a device handler object is executed.
*
* \details The pollingTime attribute identifies the time the handler is executed in ms. It must be
* smaller than the period length of the polling sequence, what is ensured by automated calculation
* smaller than the period length of the polling sequence, which is ensured by automated calculation
* from a database.
*/
uint32_t pollingTimeMs;

View File

@ -104,7 +104,7 @@ protected:
* \brief This list contains all OPUSPollingSlot objects, defining order and execution time of the
* device handler objects.
*
* \details The slot list is a std:list object that contains all created OPUSPollingSlot instances.
* @details The slot list is a std:list object that contains all created PollingSlot instances.
* They are NOT ordered automatically, so by adding entries, the correct order needs to be ensured.
* By iterating through this list the polling sequence is executed. Two entries with identical
* polling times are executed immediately one after another.

View File

@ -27,8 +27,8 @@ public:
/**
* ctor
*
* @param owner
* @param objectId the object Id to use when communication with the HealthTable
* @param useAsFrom id to use as from id when sending replies, can be set to 0
*/
HealthHelper(HasHealthIF* owner, object_id_t objectId);

View File

@ -3,12 +3,16 @@
// COULDDO: We could support blocking calls
/**
* @defgroup message_queue Message Queue
* @brief Message Queue related software components
*/
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/ipc/MessageQueueSenderIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
class MessageQueueIF {
public:
static const MessageQueueId_t NO_QUEUE = MessageQueueSenderIF::NO_QUEUE; //!< Ugly hack.
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
@ -54,6 +58,8 @@ public:
* lastPartner attribute. Else, the lastPartner information remains untouched, the
* message's content is cleared and the function returns immediately.
* @param message A pointer to a message in which the received data is stored.
* @return -@c RETURN_OK on success
* -@c MessageQueueIF::EMPTY if queue is empty
*/
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) = 0;
/**
@ -72,33 +78,38 @@ public:
virtual MessageQueueId_t getId() const = 0;
/**
* \brief With the sendMessage call, a queue message is sent to a receiving queue.
* \details This method takes the message provided, adds the sentFrom information and passes
* @brief With the sendMessage call, a queue message is sent to a receiving queue.
* @details This method takes the message provided, adds the sentFrom information and passes
* it on to the destination provided with an operating system call. The OS's return
* value is returned.
* \param sendTo This parameter specifies the message queue id to send the message to.
* \param message This is a pointer to a previously created message, which is sent.
* \param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* @param sendTo This parameter specifies the message queue id to send the message to.
* @param message This is a pointer to a previously created message, which is sent.
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* This variable is set to zero by default.
* \param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full (if implemented).
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full (if implemented).
* @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full
*/
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, MessageQueueMessage* message, MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
/**
* @brief This operation sends a message to the given destination.
* @details It directly uses the sendMessage call of the MessageQueueSender parent, but passes its
* queue id as "sentFrom" parameter.
* @param sendTo This parameter specifies the message queue id of the destination message queue.
* @param message A pointer to a previously created message, which is sent.
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
*/
* @brief This operation sends a message to the given destination.
* @details It directly uses the sendMessage call of the MessageQueueSender parent, but passes its
* queue id as "sentFrom" parameter.
* @param sendTo This parameter specifies the message queue id of the destination message queue.
* @param message A pointer to a previously created message, which is sent.
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
*/
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, MessageQueueMessage* message, bool ignoreFault = false ) = 0;
/**
* \brief The sendToDefaultFrom method sends a queue message to the default destination.
* \details In all other aspects, it works identical to the sendMessage method.
* \param message This is a pointer to a previously created message, which is sent.
* \param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* @brief The sendToDefaultFrom method sends a queue message to the default destination.
* @details In all other aspects, it works identical to the sendMessage method.
* @param message This is a pointer to a previously created message, which is sent.
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* This variable is set to zero by default.
* @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full
*/
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message, MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
/**
@ -106,6 +117,8 @@ public:
* @details As in the sendMessage method, this function uses the sendToDefault call of the
* Implementation class and adds its queue id as "sentFrom" information.
* @param message A pointer to a previously created message, which is sent.
* @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full
*/
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) = 0;
/**

View File

@ -3,6 +3,13 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
/**
* @brief Common interface for OS Mutex objects which provide MUTual EXclusion.
*
* @details https://en.wikipedia.org/wiki/Lock_(computer_science)
* @ingroup osal
* @ingroup interface
*/
class MutexIF {
public:
static const uint32_t NO_TIMEOUT; //!< Needs to be defined in implementation.

View File

@ -5,14 +5,46 @@
#include <framework/serialize/SerializeAdapter.h>
/**
* This adapter provides an interface for SerializeIF to serialize or deserialize
* buffers with no length header but a known size.
*
* Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer.
*
* Can be used with SerialLinkedListAdapter by declaring a SerializeElement with
* SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement.
* Right now, the SerialBufferAdapter must always be initialized with the buffer and size !
*
* \ingroup serialize
*/
template<typename T>
class SerialBufferAdapter: public SerializeIF {
public:
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLenght = false);
SerialBufferAdapter(uint8_t* buffer, T bufferLength,
bool serializeLenght = false);
/**
* Constructor for constant uint8_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLength = false);
/**
* Constructor for non-constant uint8_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(uint8_t* buffer, T bufferLength, bool serializeLength = false);
/**
* Constructoor for non-constant uint32_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
* @param buffer
* @param bufferLength
* @param serializeLength
*/
SerialBufferAdapter(uint32_t* buffer,T bufferLength, bool serializeLength = false);
virtual ~SerialBufferAdapter();
@ -23,7 +55,19 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian);
uint8_t * getBuffer();
const uint8_t * getConstBuffer();
void setBuffer(uint8_t * buffer_, T bufferLength_);
void setBuffer(uint32_t * buffer_, T bufferLength_);
private:
enum bufferType {
NORMAL,
CONST
};
bufferType currentBufferType;
bool serializeLength;
const uint8_t *constBuffer;
uint8_t *buffer;

View File

@ -5,24 +5,48 @@
#include <framework/serialize/SerialArrayListAdapter.h>
/**
* \ingroup serialize
* @brief This adapter provides an interface for SerializeIF to serialize and deserialize
* buffers with a header containing the buffer length.
* @details
*
* Can be used by SerialLinkedListAdapter by declaring
* as a linked element with SerializeElement<SerialFixedArrayListAdapter<...>>.
* The sequence of objects is defined in the constructor by using the setStart and setNext functions.
*
* 1. Buffers with a size header inside that class can be declared with
* SerialFixedArrayListAdapter<BUFFER_TYPE, MAX_BUFFER_LENGTH, LENGTH_FIELD_TYPE>.
* 2. MAX_BUFFER_LENGTH specifies the maximum allowed number of elements in FixedArrayList
* 3. LENGTH_FIELD_TYPE specifies the data type of the buffer header containing the buffer size
* (defaults to 1 byte length field) that follows
*
* @ingroup serialize
*/
template<typename T, uint32_t MAX_SIZE, typename count_t = uint8_t>
class SerialFixedArrayListAdapter : public FixedArrayList<T, MAX_SIZE, count_t>, public SerializeIF {
template<typename BUFFER_TYPE, uint32_t MAX_SIZE, typename count_t = uint8_t>
class SerialFixedArrayListAdapter : public FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>, public SerializeIF {
public:
/**
* Constructor Arguments are forwarded to FixedArrayList constructor
* @param args
*/
template<typename... Args>
SerialFixedArrayListAdapter(Args... args) : FixedArrayList<T, MAX_SIZE, count_t>(std::forward<Args>(args)...) {
SerialFixedArrayListAdapter(Args... args) : FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(std::forward<Args>(args)...) {
}
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const {
return SerialArrayListAdapter<T, count_t>::serialize(this, buffer, size, max_size, bigEndian);
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this, buffer, size, max_size, bigEndian);
}
uint32_t getSerializedSize() const {
return SerialArrayListAdapter<T, count_t>::getSerializedSize(this);
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::getSerializedSize(this);
}
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) {
return SerialArrayListAdapter<T, count_t>::deSerialize(this, buffer, size, bigEndian);
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this, buffer, size, bigEndian);
}
void swapArrayListEndianness() {
SerialArrayListAdapter<BUFFER_TYPE, count_t>::swapArrayListEndianness(this);
}
};

View File

@ -13,8 +13,30 @@
#include <framework/serialize/SerializeIF.h>
//This is where we need the SerializeAdapter!
/**
* \ingroup serialize
/**
* @brief Implement the conversion of object data to data streams
* or vice-versa, using linked lists.
* @details
* An alternative to the AutoSerializeAdapter functions
* - All object members with a datatype are declared as SerializeElement<element_type>
* members inside the class implementing this adapter.
* - The element type can also be a SerialBufferAdapter to de-/serialize buffers,
* with a known size, where the size can also be serialized
* - The element type can also be a SerialFixedArrayListAdapter to de-/serialize buffers
* with a size header, which is scanned automatically
*
* The sequence of objects is defined in the constructor by using
* the setStart and setNext functions.
*
* - The serialization process is done by instantiating the class and
* calling serializ after all SerializeElement entries have been set by
* using the constructor or setter functions. An additional size variable can be supplied
* which is calculated/incremented automatically
* - The deserialization process is done by instantiating the class and supplying
* a buffer with the data which is converted into an object. The size of
* data to serialize can be supplied and is decremented in the function
*
* @ingroup serialize
*/
template<typename T, typename count_t = uint8_t>
class SerialLinkedListAdapter: public SinglyLinkedList<T>, public SerializeIF {
@ -31,6 +53,16 @@ public:
SinglyLinkedList<T>(), printCount(printCount) {
}
/**
* Serialize object implementing this adapter into the supplied buffer
* and calculate the serialized size
* @param buffer [out] Object is serialized into this buffer. Note that the buffer pointer
* *buffer is incremented automatically inside the respective serialize functions
* @param size [out] Calculated serialized size. Don't forget to set to 0.
* @param max_size
* @param bigEndian Specify endianness
* @return
*/
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const {
if (printCount) {
@ -73,6 +105,13 @@ public:
return size;
}
/**
* Deserialize supplied buffer with supplied size into object implementing this adapter
* @param buffer
* @param size Decremented in respective deSerialize functions automatically
* @param bigEndian Specify endianness
* @return
*/
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) {
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian);

View File

@ -7,8 +7,53 @@
#include <framework/serialize/SerializeIF.h>
#include <string.h>
/**
* \ingroup serialize
/**
* @brief This adapter provides an interface to use the SerializeIF functions
* with arbitrary template objects to facilitate and simplify the serialization of classes
* with different multiple different data types into buffers and vice-versa.
* @details
* Examples:
* A report class is converted into a TM buffer. The report class implements a serialize functions and calls
* the AutoSerializeAdapter::serialize function repeatedly on all object data fields.
* The getSerializedSize function is implemented by calling the
* AutoSerializeAdapter::getSerializedSize function repeatedly on all data fields.
*
* The AutoSerializeAdapter functions can also be used as an alternative to memcpy
* to retrieve data out of a buffer directly into a class variable with data type T while being able to specify endianness.
* The boolean bigEndian specifies whether an endian swap is performed on the data before
* serialization or deserialization.
*
* If the target architecture is little endian (ARM), any data types created might
* have the wrong endiness if they are to be used for the FSFW.
* 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:
*
* 1. Use the AutoSerializeAdapter::deSerialize function
* The pointer *buffer will be incremented automatically by the typeSize of the object,
* so this function can be called on &buffer repeatedly without adjusting pointer position.
* Set bigEndian parameter to true to perform endian swapping.
*
* uint16_t data;
* int32_t dataLen = sizeof(data);
* ReturnValue_t result = AutoSerializeAdapter::deSerialize(&data,&buffer,&dataLen,true);
*
* 2. Perform a bitshift operation. Perform endian swapping if necessary:
*
* uint16_t data;
* data = buffer[targetByte1] << 8 | buffer[targetByte2];
* data = EndianSwapper::swap(data);
*
* 3. Memcpy can be used when data is little-endian. Perform endian-swapping if necessary.
*
* uint16_t data;
* memcpy(&data,buffer + positionOfTargetByte1,sizeof(data));
* data = EndianSwapper::swap(data);
*
* When serializing for downlink, the packets are generally serialized assuming big endian data format
* like seen in TmPacketStored.cpp for example.
*
* @ingroup serialize
*/
template<typename T, int>
class SerializeAdapter_ {
@ -35,6 +80,14 @@ public:
}
}
/**
* Deserialize buffer into object
* @param object [out] Object to be deserialized with buffer data
* @param buffer buffer containing the data. Non-Const pointer to non-const pointer to const buffer.
* @param size int32_t type to allow value to be values smaller than 0, needed for range/size checking
* @param bigEndian Specify endianness
* @return
*/
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
bool bigEndian) {
T tmp;
@ -100,7 +153,7 @@ public:
}
};
// No type specification necessary here.
class AutoSerializeAdapter {
public:
template<typename T>

View File

@ -6,11 +6,23 @@
#include <utility>
/**
* \ingroup serialize
* @brief This class is used to mark datatypes for serialization with the
* SerialLinkedListAdapter
* @details
* Used by declaring any arbitrary datatype with SerializeElement<T> myVariable,
* inside a SerialLinkedListAdapter implementation and setting the sequence
* of objects with setNext() and setStart().
* Serilization and Deserialization is then performed automatically in
* specified sequence order.
* @ingroup serialize
*/
template<typename T>
class SerializeElement : public SerializeIF, public LinkedElement<SerializeIF> {
public:
/**
* Arguments are forwarded to the element datatype constructor
* @param args
*/
template<typename... Args>
SerializeElement(Args... args) : LinkedElement<SerializeIF>(this), entry(std::forward<Args>(args)...) {

View File

@ -4,13 +4,27 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
/**
* \defgroup serialize Serialization
* @defgroup serialize Serialization
* Contains serialisation services.
*/
/**
* Translation of objects into data streams.
* \ingroup serialize
* @brief An interface for alle classes which require
* translation of objects data into data streams and vice-versa.
* @details
* If the target architecture is little endian (e.g. ARM), any data types created might
* have the wrong endiness if they are to be used for the FSFW.
* 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:
*
* 1. Use the @c AutoSerializeAdapter::deSerialize function with @c bigEndian = true
* 2. Perform a bitshift operation
* 3. @c memcpy can be used when data is in little-endian format. Otherwise, @c EndianSwapper has to be used in conjuction.
*
* When serializing for downlink, the packets are generally serialized assuming big endian data format
* like seen in TmPacketStored.cpp for example.
*
* @ingroup serialize
*/
class SerializeIF {
public: