Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::Packet< len > Class Template Reference

The Packet class is used for packing together messages with variable lengths into a fixed size packet. Useful for telemetry. More...

#include <SyncPacketQueue.h>

Public Member Functions

 Packet ()
 Reserves a fixed length for the packet.
 
 ~Packet ()
 Clears the buffer.
 
size_t append (const uint8_t *msg, size_t msgLen)
 Append a given message to the packet.
 
void markAsReady ()
 Mark the packet as ready.
 
size_t dump (uint8_t *buf)
 Copies the content of the payload at the given address.
 
void clear ()
 Clear the buffer and reset members.
 
bool isFull () const
 
bool isEmpty () const
 
bool isReady () const
 
uint64_t getTimestamp () const
 
size_t size () const
 
unsigned int maxSize () const
 
unsigned int getMsgCount () const
 
void print (std::ostream &os) const
 Print information about this object.
 

Public Attributes

std::vector< uint8_t > content
 

Detailed Description

template<unsigned int len>
class Boardcore::Packet< len >

The Packet class is used for packing together messages with variable lengths into a fixed size packet. Useful for telemetry.

Data can only be appended to the payload. The packet can be marked ready.

Template Parameters
lenPacket's payload length.

Definition at line 55 of file SyncPacketQueue.h.

Constructor & Destructor Documentation

◆ Packet()

template<unsigned int len>
Boardcore::Packet< len >::Packet ( )
inline

Reserves a fixed length for the packet.

Definition at line 61 of file SyncPacketQueue.h.

◆ ~Packet()

template<unsigned int len>
Boardcore::Packet< len >::~Packet ( )
inline

Clears the buffer.

Definition at line 66 of file SyncPacketQueue.h.

Member Function Documentation

◆ append()

template<unsigned int len>
size_t Boardcore::Packet< len >::append ( const uint8_t * msg,
size_t msgLen )

Append a given message to the packet.

If the message can't fit inside the remaining space only the first bytes are copied.

Parameters
msgThe message to be appended.
msgLenLength of the message.
Returns
How many bytes were actually appended.

Definition at line 151 of file SyncPacketQueue.h.

◆ clear()

template<unsigned int len>
void Boardcore::Packet< len >::clear ( )

Clear the buffer and reset members.

Definition at line 171 of file SyncPacketQueue.h.

◆ dump()

template<unsigned int len>
size_t Boardcore::Packet< len >::dump ( uint8_t * buf)

Copies the content of the payload at the given address.

Parameters
bufWhere to copy the content.
Returns
How many bytes where copied, i.e. the size of the packet.

Definition at line 180 of file SyncPacketQueue.h.

◆ getMsgCount()

template<unsigned int len>
unsigned int Boardcore::Packet< len >::getMsgCount ( ) const
inline
Returns
How many times the append() function has been called successfully.

Definition at line 132 of file SyncPacketQueue.h.

◆ getTimestamp()

template<unsigned int len>
uint64_t Boardcore::Packet< len >::getTimestamp ( ) const
inline
Returns
The timestamp of the first successful call to append().

Definition at line 116 of file SyncPacketQueue.h.

◆ isEmpty()

template<unsigned int len>
bool Boardcore::Packet< len >::isEmpty ( ) const
inline
Returns
True if no message has been inserted yet.

Definition at line 106 of file SyncPacketQueue.h.

◆ isFull()

template<unsigned int len>
bool Boardcore::Packet< len >::isFull ( ) const
inline
Returns
True if the packet has reached the maximum length.

Definition at line 101 of file SyncPacketQueue.h.

◆ isReady()

template<unsigned int len>
bool Boardcore::Packet< len >::isReady ( ) const
inline
Returns
True if the packet has been marked as ready.

Definition at line 111 of file SyncPacketQueue.h.

◆ markAsReady()

template<unsigned int len>
void Boardcore::Packet< len >::markAsReady ( )
inline

Mark the packet as ready.

Definition at line 83 of file SyncPacketQueue.h.

◆ maxSize()

template<unsigned int len>
unsigned int Boardcore::Packet< len >::maxSize ( ) const
inline
Returns
The maximum number of bytes in the buffer.

Definition at line 126 of file SyncPacketQueue.h.

◆ print()

template<unsigned int len>
void Boardcore::Packet< len >::print ( std::ostream & os) const

Print information about this object.

Parameters
osFor example, std::cout.

Definition at line 187 of file SyncPacketQueue.h.

◆ size()

template<unsigned int len>
size_t Boardcore::Packet< len >::size ( ) const
inline
Returns
The occupied portion of the buffer [bytes].

Definition at line 121 of file SyncPacketQueue.h.

Member Data Documentation

◆ content

template<unsigned int len>
std::vector<uint8_t> Boardcore::Packet< len >::content

Definition at line 142 of file SyncPacketQueue.h.


The documentation for this class was generated from the following file: