MIP_SDK
v3.0.0
MicroStrain Communications Library for embedded systems
|
C++ class representing a MIP field. More...
#include <mip_field.hpp>
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... | |
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 | payloadLength () const |
Returns the length of the payload. More... | |
const uint8_t * | payload () const |
Returns the payload pointer for the field data. More... | |
uint8_t | payload (unsigned int index) const |
Index the payload at the given location. More... | |
uint8_t | operator[] (unsigned int index) const |
microstrain::Span< const uint8_t > | payloadSpan () const |
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 | MAX_PAYLOAD_LENGTH = C::MIP_FIELD_PAYLOAD_LENGTH_MAX |
C++ class representing a MIP field.
This is a thin wrapper around the C mip_field struct.
|
inline |
Construct an empty MIP field.
|
inline |
Constructs a field view given the parameters.
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 |
Constructs a mip_field from a pointer to the heaader.
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 |
Creates a Field class from the mip_field C struct.
|
inline |
Returns the descriptor set and field descriptor.
|
inline |
Returns the descriptor set of the packet containing this field._.
|
inline |
Deserializes the field data to specific field struct.
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 |
Returns the field descriptor.
|
inline |
Determines if the field holds a command.
|
inline |
Determines if the field is from a command descriptor set (a command, reply, or response field).
|
inline |
Determines if the field holds data (and not a command, reply, or response).
|
inline |
Determines if the field holds an ack/nack reply code.
|
inline |
Determines if the field holds command response data (not an ack/nack reply).
|
inline |
Returns true if the field has a valid field descriptor.
|
inline |
Updates the mip_field to refer to the next field in a packet.
|
inline |
Gets the next field after the specified field.
|
inline |
|
inline |
Returns the payload pointer for the field data.
|
inline |
Index the payload at the given location.
index |
|
inline |
Returns the length of the payload.
|
inline |
|
staticconstexpr |