MIP SDK
0.0.1
MicroStrain Communications Library for embedded systems
|
#include "mip_field.h"
#include "mip_packet.h"
#include "mip_offsets.h"
#include "definitions/descriptors.h"
#include <assert.h>
Functions | |
void | mip_field_init (mip_field *field, uint8_t descriptor_set, uint8_t field_descriptor, const uint8_t *payload, uint8_t payload_length) |
Constructs a mip_field given the parameters. More... | |
uint8_t | mip_field_descriptor_set (const mip_field *field) |
Returns the descriptor set of the packet containing this field._. More... | |
uint8_t | mip_field_field_descriptor (const mip_field *field) |
Returns the field descriptor. More... | |
uint8_t | mip_field_payload_length (const mip_field *field) |
Returns the length of the payload. More... | |
const uint8_t * | mip_field_payload (const mip_field *field) |
Returns the payload pointer for the field data. More... | |
bool | mip_field_is_valid (const mip_field *field) |
Returns true if the field has a valid field descriptor. More... | |
void | mip_field_init_empty (mip_field *field) |
Initialize a mip_field struct to an invalid/empty state. More... | |
mip_field | mip_field_from_header_ptr (const uint8_t *header, uint8_t total_length, uint8_t descriptor_set) |
Constructs a mip_field from a pointer to the heaader. More... | |
mip_field | mip_field_first_from_packet (const mip_packet *packet) |
Extracts the first field from a MIP packet. More... | |
mip_field | mip_field_next_after (const mip_field *field) |
Gets the next field after the specified field._. More... | |
bool | mip_field_next (mip_field *field) |
Updates the mip_field to refer to the next field in a packet. More... | |
bool | mip_field_next_in_packet (mip_field *field, const mip_packet *packet) |
Iterates over all fields in a packet. More... | |
uint8_t mip_field_descriptor_set | ( | const mip_field * | field | ) |
Returns the descriptor set of the packet containing this field._.
uint8_t mip_field_field_descriptor | ( | const mip_field * | field | ) |
Returns the field descriptor.
mip_field mip_field_first_from_packet | ( | const mip_packet * | packet | ) |
Extracts the first field from a MIP packet.
Typically this would be used as the first step when iterating through all fields in a received packet. To access each field after the first, call mip_field_next(). You should call mip_field_is_at_end() or mip_field_is_valid() after obtaining each field (including the first) to determine if the field is actually valid.
packet | The mip packet containing 0 or more fields. Assumed to be valid, and the payload pointer and size must be correct. |
mip_field mip_field_from_header_ptr | ( | const uint8_t * | header, |
uint8_t | total_length, | ||
uint8_t | descriptor_set | ||
) |
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. |
void mip_field_init | ( | mip_field * | field, |
uint8_t | descriptor_set, | ||
uint8_t | field_descriptor, | ||
const uint8_t * | payload, | ||
uint8_t | payload_length | ||
) |
Constructs a mip_field 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. |
void mip_field_init_empty | ( | mip_field * | field | ) |
Initialize a mip_field struct to an invalid/empty state.
Intended to be used with mip_field_next_in_packet. The field will not be valid (mip_field_is_valid will return false).
field |
bool mip_field_is_valid | ( | const mip_field * | field | ) |
Returns true if the field has a valid field descriptor.
bool mip_field_next | ( | mip_field * | field | ) |
Updates the mip_field to refer to the next field in a packet.
field | This mip_field struct will be updated to the next field._ Can be an invalid field, in which case the result will be invalid as well. |
mip_field mip_field_next_after | ( | const mip_field * | field | ) |
Gets the next field after the specified field._.
field | An existing MIP field in a packet. Can be invalid, in which case the result will also be invalid. |
bool mip_field_next_in_packet | ( | mip_field * | field, |
const mip_packet * | packet | ||
) |
Iterates over all fields in a packet.
field | An initialized mip_field struct. This will be updated to the next field in the packet, if one exists. Otherwise it will be invalid. |
packet | A valid MIP packet. |
Example usage:
const uint8_t* mip_field_payload | ( | const mip_field * | field | ) |
Returns the payload pointer for the field data.
uint8_t mip_field_payload_length | ( | const mip_field * | field | ) |
Returns the length of the payload.