MIP_SDK
v3.0.0-736-g212583cf
MicroStrain Communications Library for embedded systems
|
Example setup program for streaming IMU data on 7-series devices using C. More...
Functions | |
static void | log_callback (void *_user, const microstrain_log_level _level, const char *_format, va_list _args) |
Custom logging callback for MIP SDK message formatting and output. More... | |
static mip_timestamp | get_current_timestamp () |
Gets the current system timestamp in milliseconds. More... | |
static bool | mip_interface_user_send_to_device (mip_interface *_device, const uint8_t *_data, size_t _length) |
Handles sending packets to the device. More... | |
static bool | mip_interface_user_recv_from_device (mip_interface *_device, uint8_t *_buffer, size_t _max_length, mip_timeout _wait_time, bool _from_cmd, size_t *_length_out, mip_timestamp *_timestamp_out) |
Handles receiving packets from the device. More... | |
static void | initialize_device (mip_interface *_device, serial_port *_device_port, const uint32_t _baudrate) |
Initializes and configures a MIP device interface. More... | |
static bool | is_descriptor_supported (const uint8_t _descriptor_set, const uint8_t _field_descriptor, const uint16_t *_supported_descriptors, const uint8_t _supported_descriptor_count) |
Determines if the device supports a specific descriptor. More... | |
static void | configure_sensor_message_format (mip_interface *_device, const uint16_t *_supported_descriptors, const uint8_t _supported_descriptor_count) |
Configures message format for sensor data streaming. More... | |
static void | packet_callback (void *_user, const mip_packet_view *_packet_view, mip_timestamp _timestamp) |
Callback function that processes received MIP packets. More... | |
static void | accel_field_callback (void *_user, const mip_field_view *_field_view, mip_timestamp _timestamp) |
Callback handler for accelerometer data fields. More... | |
static void | gyro_field_callback (void *_user, const mip_field_view *_field_view, mip_timestamp _timestamp) |
Callback handler for gyroscope data fields. More... | |
static void | mag_field_callback (void *_user, const mip_field_view *_field_view, mip_timestamp _timestamp) |
Callback handler for magnetometer data fields. More... | |
static void | terminate (serial_port *_device_port, const char *_message, const bool _successful) |
Handles graceful program termination and cleanup. More... | |
static void | exit_from_command (const mip_interface *_device, const mip_cmd_result _cmd_result, const char *_format,...) |
Handles graceful program termination and command failure cleanup. More... | |
Variables | |
static const char * | PORT_NAME = "/dev/ttyACM0" |
Set the port name for the connection (Serial/USB) More... | |
static const uint32_t | BAUDRATE = 115200 |
Set the baudrate for the connection (Serial/USB) More... | |
static const uint16_t | SAMPLE_RATE_HZ = 1 |
Streaming rate in Hz. More... | |
static const uint32_t | RUN_TIME_SECONDS = 30 |
Example run time. More... | |
This example shows a basic setup for streaming IMU data on 7-series devices using C. This is not an exhaustive example of all streaming options for those devices. If this example does not meet your specific setup needs, please consult the MIP SDK API documentation for the proper commands.
|
static |
Processes and formats log messages from the MIP SDK based on severity level. Routes messages to appropriate output streams - errors and fatal messages go to stderr while other levels go to stdout. Each message is prefixed with its severity level name.
_user | Pointer to user data (unused in this implementation) |
_level | Log message severity level from microstrain_log_level enum |
_format | Printf-style format string for the message |
_args | Variable argument list containing message parameters |
|
static |
Provides basic timestamping using system time:
|
static |
Implements the MIP device interface send callback:
_device | MIP device interface containing the connection |
_data | Buffer containing packet data to send |
_length | Number of bytes to send |
|
static |
Implements the MIP device interface receive callback:
_device | MIP device interface containing the connection |
_buffer | Buffer to store received data |
_max_length | Maximum number of bytes to read |
_wait_time | How long to wait for data in milliseconds |
_from_cmd | Whether this read is from a command response (unused) |
_length_out | Number of bytes actually read |
_timestamp_out | Timestamp when data was received |
|
static |
Performs a complete device initialization sequence:
_device | Pointer to a MIP device interface to initialize |
_device_port | Pointer to an initialized serial port for device communication |
_baudrate | Serial communication baudrate for the device |
|
static |
Checks if a given descriptor set and field descriptor combination is supported by comparing against an array of supported descriptors. The device returns descriptors as composite values (e.g., 0x8001 from 0x80,0x01).
_descriptor_set | The high byte of the composite descriptor |
_field_descriptor | The low byte of the composite descriptor |
_supported_descriptors | Array of supported composite descriptors |
_supported_descriptor_count | Number of entries in the array |
|
static |
Sets up sensor data output by:
_device | Pointer to the initialized MIP device interface |
_supported_descriptors | Array of descriptors supported by the device |
_supported_descriptor_count | Number of descriptors in the array |
|
static |
This function is called whenever a MIP packet is received from the device. It processes the packet by:
_user | Pointer to user data (unused in this implementation) |
_packet_view | Pointer to the received MIP packet |
_timestamp | Timestamp when the packet was received |
|
static |
Processes scaled accelerometer data fields by:
_user | Pointer to user data (unused in this implementation) |
_field_view | Pointer to the field containing accelerometer data |
_timestamp | Timestamp indicating when the field was received from the device (unused in this implementation) |
|
static |
Processes scaled gyroscope data fields by:
_user | Pointer to user data (unused in this implementation) |
_field_view | Pointer to the field containing gyroscope data |
_timestamp | Timestamp indicating when the field was received from the device (unused in this implementation) |
|
static |
Processes scaled magnetometer data fields by:
_user | Pointer to user data (unused in this implementation) |
_field_view | Pointer to the field containing magnetometer data |
_timestamp | Timestamp indicating when the field was received from the device (unused in this implementation) |
|
static |
Handles graceful shutdown when errors occur:
_device_port | Serial port connection to close |
_message | Error message to display |
_successful | Whether termination is due to success or failure |
|
static |
Handles command failure scenarios:
_device | MIP device interface for the command that failed |
_cmd_result | Result code from a failed command |
_format | Printf-style format string for error message |
... | Variable arguments for format string |
|
static |
|
static |
|
static |
|
static |