|
MIP_SDK
v4.0.0-234-g2b06a940
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 Types | |
| 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 } |
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::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... | |
Static Public Member Functions | |
| 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 | |
| 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 |
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:
|
strong |
|
inline |
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 |
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 |
|
inline |
|
inline |
| buffer | Place to store the MIP packet bytes. |
| descriptorSet | Initializes the packet to this descriptor set. |
|
inline |
| buffer | Buffer containing an existing MIP packet. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Creates a mip field with the given descriptor and a copy of the payload.
|
inline |
|
inline |
|
inline |
Returns a forward iterator to the first field in the packet.
|
inline |
Returns a sentry object representing the end of fields in the packet.
|
inline |
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 |
| 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. |
|
inlinestatic |
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. |
| packetBuffer | Buffer to hold the packet bytes. |
| field | Instance of the field to add to the packet. |
| fieldDescriptor | If specified, overrides the field descriptor. |
|
inline |
This packet must be sane (see isSane()). Undefined behavior otherwise due to lookup of totalLength().
| buffer | Data is copied to this buffer. |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
1.8.17