MIP_SDK  v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
Public Member Functions | List of all members
mip::SizedPacketBuf< BufferSize > Class Template Reference

A mip packet with a self-contained buffer (useful with std::vector). More...

#include <mip_packet.hpp>

Inheritance diagram for mip::SizedPacketBuf< BufferSize >:
mip::PacketView mip::C::mip_packet_view

Public Member Functions

 SizedPacketBuf (uint8_t descriptorSet=INVALID_DESCRIPTOR_SET)
 
 SizedPacketBuf (microstrain::ConstU8ArrayView data)
 Construct by copying an existing buffer. More...
 
 SizedPacketBuf (const PacketView &packet)
 Creates a PacketBuf by copying an existing packet. More...
 
 SizedPacketBuf (const SizedPacketBuf &other)
 Copy constructor. More...
 
template<size_t OtherSize>
 SizedPacketBuf (const SizedPacketBuf< OtherSize > &other)
 Copy constructor (required to insert packets into std::vector in some cases). More...
 
SizedPacketBufoperator= (const SizedPacketBuf &other)
 Copy assignment operator. More...
 
template<size_t OtherSize>
SizedPacketBufoperator= (const SizedPacketBuf< OtherSize > &other)
 Assignment operator, copies data from another buffer to this one. More...
 
template<class FieldType >
 SizedPacketBuf (const FieldType &field, uint8_t fieldDescriptor=INVALID_FIELD_DESCRIPTOR, typename std::enable_if< std::is_class< FieldType >::value, void >::type *=nullptr)
 Create a packet containing just the given field. More...
 
PacketView ref ()
 Explicitly obtains a reference to the packet data. More...
 
const PacketViewref () const
 Explicitly obtains a const reference to the packet data. More...
 
microstrain::ArrayView< uint8_t, BufferSize > buffer ()
 Returns an ArrayView covering the entire buffer. More...
 
void copyFrom (microstrain::ConstU8ArrayView data)
 Copies the data from a U8ArrayView to this buffer. The data is not inspected. More...
 
void copyFrom (const PacketView &packet)
 Copies an existing packet. The packet is assumed to be valid (undefined behavior otherwise). More...
 
- Public Member Functions inherited from mip::PacketView
 PacketView (uint8_t *buffer, size_t bufferSize, uint8_t descriptorSet)
 Create a brand-new MIP packet in the given buffer. More...
 
 PacketView (const uint8_t *buffer, size_t length)
 Initializes a MIP packet from an existing buffer. More...
 
 PacketView (const C::mip_packet_view *other)
 Constructs a C++ PacketRef class from the base C object. More...
 
 PacketView (const C::mip_packet_view &other)
 Constructs a C++ PacketRef class from the base C object. More...
 
 PacketView (microstrain::U8ArrayView buffer, uint8_t descriptorSet)
 Create a new MIP packet in an existing buffer. More...
 
 PacketView (microstrain::ConstU8ArrayView buffer)
 Create a reference to an existing MIP packet. More...
 
microstrain::ConstU8ArrayView buffer () const
 
microstrain::U8ArrayView buffer_w ()
 Gets the entire storage buffer for the packet. More...
 
microstrain::ConstU8ArrayView data () const
 
microstrain::ConstU8ArrayView payload () const
 
microstrain::U8ArrayView payload_w ()
 Get the payload as raw bytes. More...
 
Serializer createField (uint8_t fieldDescriptor, uint8_t length)
 
uint8_t dataAt (const size_t i) const
 
uint8_t & dataAt (const size_t i)
 
uint8_t dataAt (const Index i) const
 
uint8_t & dataAt (const Index i)
 
uint8_t payloadAt (const size_t i) const
 
uint8_t & payloadAt (const size_t i)
 Get payload byte at index i. More...
 
bool addField (uint8_t fieldDescriptor, microstrain::ConstU8ArrayView payload)
 Get writable payload byte at index i. More...
 
bool addField (const FieldView &field)
 Copies the given mip field to the packet. More...
 
AllocatedField createField (uint8_t fieldDescriptor)
 
FieldIterator begin () const
 
FieldIterator end () const
 
FieldView firstField () const
 Returns the first field in the packet. More...
 
template<class FieldType >
bool addField (const FieldType &field, uint8_t fieldDescriptor=INVALID_FIELD_DESCRIPTOR)
 Adds a field of the given type to the packet. More...
 
bool copyPacketTo (microstrain::U8ArrayView buffer) const
 Copies this packet to an external buffer (span version). More...
 

Additional Inherited Members

- Public Types inherited from mip::PacketView
enum  Index : uint8_t {
  Index::SYNC_1 = C::MIP_PACKET_INDEX_SYNC_1, Index::SYNC_2 = C::MIP_PACKET_INDEX_SYNC_2, Index::DESC_SET = C::MIP_PACKET_INDEX_DESC_SET, Index::LENGTH = C::MIP_PACKET_INDEX_LENGTH,
  Index::PAYLOAD = C::MIP_PACKET_INDEX_PAYLOAD
}
 
- Static Public Member Functions inherited from mip::PacketView
template<class FieldType >
static PacketView createFromField (microstrain::U8ArrayView packetBuffer, const FieldType &field, uint8_t fieldDescriptor=INVALID_FIELD_DESCRIPTOR)
 Creates a new PacketRef containing a single MIP field from an instance of the field type. More...
 
- Static Public Attributes inherited from mip::PacketView
static constexpr uint8_t SYNC_1 = C::MIP_SYNC_1
 
static constexpr uint8_t SYNC_2 = C::MIP_SYNC_2
 
static constexpr size_t HEADER_LENGTH = C::MIP_PACKET_HEADER_LENGTH
 
static constexpr size_t CHECKSUM_LENGTH = C::MIP_PACKET_CHECKSUM_LENGTH
 
static constexpr size_t LENGTH_MIN = C::MIP_PACKET_LENGTH_MIN
 
static constexpr size_t LENGTH_MAX = C::MIP_PACKET_LENGTH_MAX
 
static constexpr size_t PAYLOAD_LENGTH_MIN = C::MIP_PACKET_PAYLOAD_LENGTH_MIN
 
static constexpr size_t PAYLOAD_LENGTH_MAX = C::MIP_PACKET_PAYLOAD_LENGTH_MAX
 

Detailed Description

template<size_t BufferSize>
class mip::SizedPacketBuf< BufferSize >

Constructor & Destructor Documentation

◆ SizedPacketBuf() [1/6]

template<size_t BufferSize>
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( uint8_t  descriptorSet = INVALID_DESCRIPTOR_SET)
inlineexplicit

◆ SizedPacketBuf() [2/6]

template<size_t BufferSize>
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( microstrain::ConstU8ArrayView  data)
inlineexplicit

◆ SizedPacketBuf() [3/6]

template<size_t BufferSize>
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( const PacketView packet)
inlineexplicit

◆ SizedPacketBuf() [4/6]

template<size_t BufferSize>
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( const SizedPacketBuf< BufferSize > &  other)
inline

◆ SizedPacketBuf() [5/6]

template<size_t BufferSize>
template<size_t OtherSize>
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( const SizedPacketBuf< OtherSize > &  other)
inlineexplicit

◆ SizedPacketBuf() [6/6]

template<size_t BufferSize>
template<class FieldType >
mip::SizedPacketBuf< BufferSize >::SizedPacketBuf ( const FieldType &  field,
uint8_t  fieldDescriptor = INVALID_FIELD_DESCRIPTOR,
typename std::enable_if< std::is_class< FieldType >::value, void >::type *  = nullptr 
)
inline
Template Parameters
FieldTypeType of the MIP field. This can't be explicitly specified due to being a constructor.
Parameters
fieldThe field object to serialize.
fieldDescriptorIf specified (not INVALID_FIELD_DESCRIPTOR), overrides the field descriptor.

Member Function Documentation

◆ operator=() [1/2]

template<size_t BufferSize>
SizedPacketBuf& mip::SizedPacketBuf< BufferSize >::operator= ( const SizedPacketBuf< BufferSize > &  other)
inline

◆ operator=() [2/2]

template<size_t BufferSize>
template<size_t OtherSize>
SizedPacketBuf& mip::SizedPacketBuf< BufferSize >::operator= ( const SizedPacketBuf< OtherSize > &  other)
inline

◆ ref() [1/2]

template<size_t BufferSize>
PacketView mip::SizedPacketBuf< BufferSize >::ref ( )
inline

◆ ref() [2/2]

template<size_t BufferSize>
const PacketView& mip::SizedPacketBuf< BufferSize >::ref ( ) const
inline

◆ buffer()

template<size_t BufferSize>
microstrain::ArrayView<uint8_t, BufferSize> mip::SizedPacketBuf< BufferSize >::buffer ( )
inline

◆ copyFrom() [1/2]

template<size_t BufferSize>
void mip::SizedPacketBuf< BufferSize >::copyFrom ( microstrain::ConstU8ArrayView  data)
inline
Parameters
dataPacket data to copy.

◆ copyFrom() [2/2]

template<size_t BufferSize>
void mip::SizedPacketBuf< BufferSize >::copyFrom ( const PacketView packet)
inline
Parameters
packetA "sane" (isSane()) mip packet.

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