MIP_SDK
v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
|
C++ class representing a MIP field. More...
#include <mip_field.hpp>
Public Types | |
enum | Index : uint8_t { Index::LENGTH = C::MIP_FIELD_INDEX_LENGTH, Index::DESC = C::MIP_FIELD_INDEX_DESC, Index::PAYLOAD = C::MIP_FIELD_INDEX_PAYLOAD } |
Public Member Functions | |
FieldView () | |
Construct an empty MIP field. More... | |
FieldView (uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length) | |
Constructs a field view given the parameters. More... | |
FieldView (const uint8_t *header, uint8_t total_length, uint8_t descriptor_set) | |
Constructs a mip_field from a pointer to the heaader. More... | |
FieldView (const C::mip_field_view &other) | |
Creates a Field class from the mip_field C struct. More... | |
FieldView (CompositeDescriptor descriptor, microstrain::ConstU8ArrayView payload) | |
Construct from descriptor and payload bytes. More... | |
uint8_t | descriptorSet () const |
Returns the descriptor set of the packet containing this field._. More... | |
uint8_t | fieldDescriptor () const |
Returns the field descriptor. More... | |
CompositeDescriptor | descriptor () const |
Returns the descriptor set and field descriptor. More... | |
uint8_t | totalLength () const |
Returns the total length of the field including the header. More... | |
uint8_t | payloadLength () const |
Returns the length of the payload. More... | |
microstrain::ConstU8ArrayView | payload () const |
Get a const view of the payload data. More... | |
uint8_t | payload (size_t index) const |
Index the payload at the given location. More... | |
uint8_t | operator[] (size_t index) const |
microstrain::ConstU8ArrayView | bytes () const |
Gets a view of the entire field, including the header. More... | |
bool | isValid () const |
Returns true if the field has a valid field descriptor. More... | |
FieldView | nextAfter () const |
Gets the next field after the specified field. More... | |
bool | next () |
Updates the mip_field to refer to the next field in a packet. More... | |
template<class FieldType > | |
bool | extract (FieldType &field, bool exact_size=true) const |
Deserializes the field data to specific field struct. More... | |
bool | isData () const |
Determines if the field holds data (and not a command, reply, or response). More... | |
bool | isCommandSet () const |
Determines if the field is from a command descriptor set (a command, reply, or response field). More... | |
bool | isCommand () const |
Determines if the field holds a command. More... | |
bool | isReply () const |
Determines if the field holds an ack/nack reply code. More... | |
bool | isResponse () const |
Determines if the field holds command response data (not an ack/nack reply). More... | |
Static Public Attributes | |
static constexpr size_t | HEADER_LENGTH = C::MIP_FIELD_HEADER_LENGTH |
static constexpr size_t | LENGTH_MIN = C::MIP_FIELD_LENGTH_MIN |
static constexpr size_t | LENGTH_MAX = C::MIP_FIELD_LENGTH_MAX |
static constexpr size_t | PAYLOAD_LENGTH_MIN = C::MIP_FIELD_PAYLOAD_LENGTH_MIN |
static constexpr size_t | PAYLOAD_LENGTH_MAX = C::MIP_FIELD_PAYLOAD_LENGTH_MAX |
This is a thin wrapper around the C mip_field struct.
|
strong |
|
inline |
|
inline |
field | |
descriptor_set | The MIP descriptor set of the packet. |
field_descriptor | The MIP field descriptor. |
payload | A pointer to a buffer containing the field payload, not including the field header. The data must exist while the field is in use. Can be NULL if payload_length is 0. |
payload_length | The length of the payload. Cannot exceed MIP_FIELD_PAYLOAD_LENGTH_MAX. |
|
inline |
Generally you should use mip_field_from_packet() or mip_field_create() instead.
header | A pointer to the header and payload. Usually inside of a MIP packet. |
total_length | The total length of either the field or packet payload, starting from header_ptr and including the header bytes. If total_length is longer than the field (i.e. if it's the packet payload length) then mip_field_next() may be used to iterate fields. |
descriptor_set | The descriptor set for the packet containing this field. May be 0x00 if not used by any function handling the field. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
index | Byte index into payload. 0 <= index < payloadLength(). |
|
inline |
|
inline |
PacketView::firstField()
, for(FieldView field : packet)
, etc. then the whole packet, including all fields and their headers, should exist in the buffer. Standalone FieldViews created from a descriptor and payload array may not have header bytes and this function isn't safe in that case.
|
inline |
|
inline |
|
inline |
|
inline |
FieldType | Any field class from a file in the mip/definitions directory. |
[out] | field | A reference to the field struct to be filled out. Valid only if the function returns true. |
exact_size | If true, the function fails if any bytes remain after deserialization. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |