Functions
Field Iteration [C]

Functions for iterating over fields in a MIP packet. More...

Collaboration diagram for Field Iteration [C]:

Functions

mip_field mip_field_first_from_packet (const mip_packet *packet)
 Extracts the first field from a MIP packet. 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...
 
void mip_field_init_empty (mip_field *field)
 Initialize a mip_field struct to an invalid/empty state. More...
 
bool mip_field_next (mip_field *field)
 Updates the mip_field to refer to the next field in a 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_in_packet (mip_field *field, const mip_packet *packet)
 Iterates over all fields in a packet. More...
 

Detailed Description

Functions for iterating over fields in a MIP packet.

Use these functions to iterate over the fields in a MIP packet.

Example:

// Iterate over fields, starting with the first in the packet.
// Continue as long as a valid field is found.
for(mip_field field = mip_field_from_packet(packet); mip_field_is_valid(&field); mip_field_next(&field))
{
// Check the field descriptor for what kind of data it holds.
switch( mip_field_field_desriptor(&field) )
{
case MIP_DATA_DESC_SENSOR_SCALED_ACCEL:
break;
}
}

Function Documentation

◆ mip_field_first_from_packet()

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.

Parameters
packetThe mip packet containing 0 or more fields. Assumed to be valid, and the payload pointer and size must be correct.
Returns
A mip_field struct with the first field from the packet.

Definition at line 164 of file mip_field.c.

◆ mip_field_from_header_ptr()

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.

Parameters
headerA pointer to the header and payload. Usually inside of a MIP packet.
total_lengthThe 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_setThe descriptor set for the packet containing this field. May be 0x00 if not used by any function handling the field.
Returns
a mip_field struct with the field data.

Definition at line 116 of file mip_field.c.

◆ mip_field_init_empty()

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).

Parameters
field

Definition at line 93 of file mip_field.c.

◆ mip_field_next()

bool mip_field_next ( mip_field field)

Updates the mip_field to refer to the next field in a packet.

Parameters
fieldThis 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.
Returns
true if the field exists and is valid.

Definition at line 198 of file mip_field.c.

◆ mip_field_next_after()

mip_field mip_field_next_after ( const mip_field field)

Gets the next field after the specified field._.

Parameters
fieldAn existing MIP field in a packet. Can be invalid, in which case the result will also be invalid.
Returns
A mip_field struct referencing the next field after the input field._ Check mip_field_is_valid() to see if the field exists.

Definition at line 179 of file mip_field.c.

◆ mip_field_next_in_packet()

bool mip_field_next_in_packet ( mip_field field,
const mip_packet packet 
)

Iterates over all fields in a packet.

Parameters
fieldAn initialized mip_field struct. This will be updated to the next field in the packet, if one exists. Otherwise it will be invalid.
packetA valid MIP packet.
Returns
true if another field exists.
false if there are no more fields.

Example usage:

struct mip_field field;
while( mip_field_next_in_packet(&field, packet) )
{
// Do something with the field.
}

Definition at line 227 of file mip_field.c.

mip_field_next_in_packet
bool mip_field_next_in_packet(mip_field *field, const mip_packet *packet)
Iterates over all fields in a packet.
Definition: mip_field.c:227
mip_field
A structure representing a MIP field.
Definition: mip_field.h:52
mip_field_next
bool mip_field_next(mip_field *field)
Updates the mip_field to refer to the next field in a packet.
Definition: mip_field.c:198
mip_field_is_valid
bool mip_field_is_valid(const mip_field *field)
Returns true if the field has a valid field descriptor.
Definition: mip_field.c:78
mip_field_init_empty
void mip_field_init_empty(mip_field *field)
Initialize a mip_field struct to an invalid/empty state.
Definition: mip_field.c:93


microstrain_inertial_driver
Author(s): Brian Bingham, Parker Hannifin Corp
autogenerated on Fri May 24 2024 06:48:22