|
MIP_SDK
v3.0.0
MicroStrain Communications Library for embedded systems
|
C++ class representing a view of a MIP packet. More...
#include <mip_packet.hpp>
Classes | |
| class | AllocatedField |
| class | FieldIterator |
Public Member Functions | |
| 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::Span< uint8_t > buffer, uint8_t descriptorSet) | |
| Create a new MIP packet in an existing buffer. More... | |
| PacketView (microstrain::Span< const uint8_t > buffer) | |
| Create a reference to an existing MIP packet. More... | |
| bool | isData () const |
| Serializer | createField (uint8_t fieldDescriptor, uint8_t length) |
| microstrain::Span< const uint8_t > | totalSpan () const |
| Gets a span over the whole packet. More... | |
| microstrain::Span< const uint8_t > | payloadSpan () const |
| Gets a span over just the payload. More... | |
| AllocatedField | createField (uint8_t fieldDescriptor) |
| uint8_t | operator[] (unsigned int index) const |
| 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 (uint8_t *buffer, size_t maxLength) |
| Copies this packet to an external buffer. More... | |
| bool | copyPacketTo (microstrain::Span< uint8_t > buffer) |
| Copies this packet to an external buffer (span version). More... | |
Static Public Member Functions | |
| template<class FieldType > | |
| static PacketView | createFromField (uint8_t *buffer, size_t bufferSize, 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 | |
| static constexpr size_t | PAYLOAD_LENGTH_MAX = C::MIP_PACKET_PAYLOAD_LENGTH_MAX |
| static constexpr size_t | PACKET_SIZE_MIN = C::MIP_PACKET_LENGTH_MIN |
| static constexpr size_t | PACKET_SIZE_MAX = C::MIP_PACKET_LENGTH_MAX |
C++ class representing a view of a MIP packet.
This is a thin wrapper around the mip_packet_view C structure. Like the C version, it does not contain or own the data buffer. Any of the C functions can be used with the C++ packet class because it inherits from the C struct.
Fields may be iterated over using the C-style methods, with an iterator, or with a range-based for loop:
|
inline |
Create a brand-new MIP packet in the given buffer.
Use this along with the packet building functions to create MIP packets.
| packet | |
| buffer | This is where the packet bytes will be stored. Must be at least MIP_PACKET_LENGTH_MIN bytes in size. |
| buffer_size | The size of buffer, in bytes. |
| descriptor_set | The MIP descriptor set for the packet. |
|
inline |
Initializes a MIP packet from an existing buffer.
Use this when receiving or parsing MIP packets.
The data in the buffer should be a valid or suspected MIP packet.
| packet | |
| buffer | The data buffer containing the bytes for a MIP packet. Must be at least MIP_PACKET_LENGTH_MIN bytes in size. |
| length | The length of the data pointed to by buffer. |
|
inline |
Constructs a C++ PacketRef class from the base C object.
|
inline |
Constructs a C++ PacketRef class from the base C object.
|
inline |
Create a new MIP packet in an existing buffer.
| buffer | Place to store the MIP packet bytes. |
| descriptorSet | Initializes the packet to this descriptor set. |
|
inline |
Create a reference to an existing MIP packet.
| buffer | Buffer containing an existing MIP packet. |
|
inline |
Adds a field of the given type to the packet.
| FieldType | Any field class from a file in the mip/definitions directory. |
| field | Instance of the field to add to the packet. |
| fieldDescriptor | If specified, overrides the field descriptor. |
|
inline |
Returns a forward iterator to the first field in the packet.
|
inline |
Copies this packet to an external buffer (span version).
This packet must be sane (see isSane()). Undefined behavior otherwise due to lookup of totalLength().
| buffer | Data is copied to this buffer. |
|
inline |
Copies this packet to an external buffer.
This packet must be sane (see isSane()). Undefined behavior otherwise due to lookup of totalLength().
| buffer | Data is copied into this location. |
| maxLength | Maximum number of bytes to copy. |
|
inline |
|
inline |
|
inlinestatic |
Creates a new PacketRef containing a single MIP field from an instance of the field type.
This works just like the addField<FieldType>() function but also initializes and finalizes the packet. It is assumed that the field will fit in an empty packet; otherwise the field can't ever be used. The field classes are predefined so this doesn't need runtime checking.
| FieldType | Any field class from a file in the mip/definitions directory. |
| buffer | Buffer to hold the packet bytes. |
| bufferSize | Size of buffer in bytes. |
| field | Instance of the field to add to the packet. |
| fieldDescriptor | If specified, overrides the field descriptor. |
|
inline |
Returns a sentry object representing the end of fields in the packet.
|
inline |
Returns the first field in the packet.
Subsequent fields can be obtained via the returned Field class, but iteration is best done with begin()/end() or the range-based for loop.
|
inline |
|
inline |
|
inline |
Gets a span over just the payload.
|
inline |
Gets a span over the whole packet.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
1.8.17