MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Metadata

The MIP SDK includes an additional set of definitions for each MIP field which contain additional information beyond that needed for the core functionality of sending commands and receiving data. It includes human-readable field names and information on each parameter, such as name, type, size, etc. This information is accessible at compile time and can be used for things like pretty-printing, CSV generation, and more.

Metadata is currently an experimental feature and is subject to changes. It requires C++17 or later.

Usage:

  1. Include the metadata definition header for the corresponding descriptor set.
  2. Get a reference or pointer to the metadata for your field.
  3. Access members of the reference.
#include <cstdio>
template<class FieldType>
void print_parameters()
{
// Obtain a reference for easier access.
// Print field name and descriptor.
std::printf("Field (0x%02X,%02X) %s:\n", field.descriptor.descriptorSet, field.descriptor.fieldDescriptor, field.title);
// Iterate each parameter.
unsigned int p=0;
for(const mip::metadata::ParameterInfo& param : field.parameters)
{
// Single element (most parameters)?
if(param.count.count == 1)
std::printf(" Parameter %u: %s\n", p, param.name);
// Fixed-size array?
else if(param.count.isFixed())
std::printf(" Parameter %u: %s[%u]\n", p, param.name, param.count.count);
// Variable-sized array with another parameter holding the count?
else if(param.count.hasCounter())
std::printf(" Parameter %u: %s[%s]\n", p, param.name, field.parameters[param.count.counter.index()].name);
// Variable-length array which is determined by the payload length.
else
std::printf(" Parameter %u: %s[]\n", p, param.name);
p++;
}
std::printf("\n");
}
int main()
{
print_parameters<mip::commands_3dm::MessageFormat>();
print_parameters<mip::commands_3dm::PpsSource>();
print_parameters<mip::data_sensor::ScaledAccel>();
return 0;
}
mip::metadata::ParameterInfo::Count::isFixed
constexpr bool isFixed() const
Definition: mip_structures.hpp:138
mip::metadata::ParameterInfo::Count::count
uint8_t count
Fixed size if paramIdx unassigned.
Definition: mip_structures.hpp:135
mip::metadata::ParameterInfo::name
const char * name
Programmatic name (e.g. for printing or language bindings).
Definition: mip_structures.hpp:161
mip::metadata::MetadataFor
Definition: mip_metadata.hpp:15
mip::metadata::ParameterInfo
Definition: mip_structures.hpp:127
mip::metadata::ParameterInfo::count
Count count
Number of instances for arrays.
Definition: mip_structures.hpp:166
mip::metadata::FieldInfo
Definition: mip_structures.hpp:182
data_sensor.hpp
mip::metadata::ParameterInfo::Count::hasCounter
constexpr bool hasCounter() const
Definition: mip_structures.hpp:139
commands_3dm.hpp