MIP_SDK
v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
|
Example program to create raw and buffered MIP packets using C. More...
Functions | |
static void | print_packet (const mip_packet_view *_packet_view) |
Prints detailed information about a MIP packet's structure and contents. More... | |
static void | initialize_empty_packet (mip_packet_view *_packet_view, uint8_t *_buffer, const size_t _buffer_size, const uint8_t _descriptor_set) |
Initializes an empty MIP packet with the specified descriptor set. More... | |
static void | add_checksum_to_packet (mip_packet_view *_packet_view) |
Computes and adds a checksum to a MIP packet. More... | |
static void | add_ping_command_to_packet (mip_packet_view *_packet_view) |
Adds a Ping command field to a MIP packet. More... | |
static void | add_comm_speed_bytes_to_packet (mip_packet_view *_packet_view) |
Adds a Comm Speed command field using raw bytes. More... | |
static void | add_comm_speed_field_to_packet (mip_packet_view *_packet_view) |
Adds a Comm Speed command field using a field struct. More... | |
static void | add_comm_speed_serializer_bytes_to_packet (mip_packet_view *_packet_view) |
Adds a Comm Speed command field using manual serialization. More... | |
static void | add_message_format_field_to_packet (mip_packet_view *_packet_view) |
Adds a Message Format command field using a field struct definition. More... | |
static void | add_poll_data_field_to_packet (mip_packet_view *_packet_view) |
Adds a Poll Data command field using manual serialization. More... | |
static void | extract_shared_reference_time_field (microstrain_serializer *_serializer) |
Extracts and displays shared reference time field data. More... | |
static void | extract_shared_reference_time_delta_field (microstrain_serializer *_serializer) |
Extracts and displays shared reference time delta field data. More... | |
static void | extract_sensor_accel_scaled_field (microstrain_serializer *_serializer) |
Extracts and displays scaled accelerometer data. More... | |
static void | extract_sensor_gyro_scaled_field (microstrain_serializer *_serializer) |
Extracts and displays scaled gyroscope data. More... | |
static void | extract_sensor_delta_theta_field (microstrain_serializer *_serializer) |
Extracts and displays delta theta (angular displacement) data. More... | |
static void | extract_sensor_delta_velocity_field (const mip_field_view *_field_view) |
Extracts and displays delta velocity data. More... | |
static void | create_from_scratch_packet_1 () |
Creates a MIP packet from scratch with multiple fields. More... | |
static void | create_from_scratch_packet_2_and_3 () |
Creates two MIP packets from scratch for demonstration purposes. More... | |
static void | create_from_raw_buffer_packet_4 () |
Demonstrates creating and working with a MIP packet from raw buffer data. More... | |
For this example, we have broken down each piece into separate functions for easier documentation and is not necessary in practice. This is not an exhaustive example of all MIP packet features. If this example does not meet your specific setup needs, please consult the MIP SDK API documentation for the proper commands.
|
static |
This function inspects and displays:
_packet_view | Pointer to the MIP packet view to inspect |
|
static |
Creates a new MIP packet in the provided buffer and initializes it with the given descriptor set. The packet is initially empty and invalid until fields are added.
_packet_view | Pointer to packet view to initialize |
_buffer | Buffer to store the packet data |
_buffer_size | Size of the buffer in bytes |
_descriptor_set | Descriptor set to use for the packet |
|
static |
Finalizes the packet by computing and appending the checksum. This should be called after all fields have been added to the packet.
_packet_view | Pointer to the packet to finalize with checksum |
|
static |
Creates a field with the Base Ping command descriptor (0x01) with no payload data.
_packet_view | Pointer to the packet to add the field to |
|
static |
Demonstrates adding a field using pre-serialized payload data. This is the most efficient method when payload data is already available.
_packet_view | Pointer to the packet to add the field to |
|
static |
Shows how to add a field using the field struct definitions, which is the recommended approach for creating fields from parameter values.
_packet_view | Pointer to the packet to add the field to |
|
static |
Demonstrates low-level field creation by manually serializing parameters. Shows the underlying process that happens with struct-based methods.
_packet_view | Pointer to the packet to add the field to |
|
static |
Creates a field for configuring the message format with multiple descriptors, showing how to handle variable-length payloads.
_packet_view | Pointer to the packet to add the field to |
|
static |
Shows how to create a field with a variable-length payload by manually serializing parameters and handling field length updates.
_packet_view | Pointer to the packet to add the field to |
|
static |
Deserializes a 64-bit nanosecond timestamp from the field payload and displays it if successfully extracted. This represents the device's reference time.
_serializer | Pointer to the serializer containing the field data |
|
static |
Deserializes a 64-bit nanosecond time difference from the field payload and displays it if successfully extracted. This represents the time elapsed since the last reference time.
_serializer | Pointer to the serializer containing the field data |
|
static |
Deserializes a 3D vector of float values representing scaled accelerometer measurements in m/s^2 and displays them if successfully extracted.
_serializer | Pointer to the serializer containing the field data |
|
static |
Deserializes a 3D vector of float values representing scaled gyroscope measurements in rad/s using the field structure. Displays the values if successfully extracted.
_serializer | Pointer to the serializer containing the field data |
|
static |
Deserializes a 3D vector of float values representing angular displacement measurements in radians using the field structure. Displays the values if successfully extracted.
_serializer | Pointer to the serializer containing the field data |
|
static |
Deserializes a 3D vector of float values representing velocity change measurements in m/s using the field structure. Displays the values if successfully extracted.
_field_view | Pointer to the field view containing the data |
|
static |
This function demonstrates how to create a MIP packet containing multiple fields and a checksum. It creates a packet with the following structure:
The function shows several important concepts:
|
static |
This function demonstrates how to create two different types of MIP packets:
The function shows the process of:
|
static |
This function shows how to: