Example program to print device information for any MIP-enabled MicroStrain device using C++.
More...
|
static constexpr const char * | PORT_NAME = "/dev/ttyACM0" |
| Set the port name for the connection (Serial/USB) More...
|
|
static constexpr uint32_t | BAUDRATE = 115200 |
| Set the baudrate for the connection (Serial/USB) More...
|
|
This example shows a basic setup for any MIP-enabled MicroStrain device to demonstrate how to get and print device information using C++. This is not an exhaustive example of all settings for those devices. If this example does not meet your specific setup needs, please consult the MIP SDK API documentation for the proper commands.
License
- Copyright
- Copyright (c) 2025 MicroStrain by HBK Licensed under MIT License
◆ logCallback()
static void logCallback |
( |
void * |
_user, |
|
|
const microstrain_log_level |
_level, |
|
|
const char * |
_format, |
|
|
va_list |
_args |
|
) |
| |
|
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.
- Parameters
-
_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 |
◆ initializeDevice()
Performs a complete device initialization sequence:
- Verifies device communication with a ping command
- Sets the device to idle mode to ensure reliable configuration
- Queries and displays detailed device information
- Parameters
-
_device | Reference to a MIP device interface to initialize |
◆ terminate() [1/2]
Handles graceful shutdown when errors occur:
- Outputs provided error message
- Closes device connection if open
- Exits with appropriate status code
- Parameters
-
_connection | Pointer to the device connection to close |
_message | Error message to display |
_successful | Whether termination is due to success or failure |
◆ terminate() [2/2]
Handles command failure scenarios:
- Formats and displays an error message with command result
- Closes device connection
- Exits with failure status
- Parameters
-
_device | MIP device interface for the command that failed |
_cmdResult | Result code from a failed command |
_format | Printf-style format string for error message |
... | Variable arguments for format string |
◆ PORT_NAME
constexpr const char* PORT_NAME = "/dev/ttyACM0" |
|
staticconstexpr |
◆ BAUDRATE
constexpr uint32_t BAUDRATE = 115200 |
|
staticconstexpr |
- Note
- For native serial connections this needs to be 115200 due to the device default settings command Use mip::commands_base::*CommSpeed() or mip::commands_3dm::*UartBaudrate() to write and save the baudrate on the device