MIP_SDK
v3.0.0
MicroStrain Communications Library for embedded systems
|
This module contains functions and classes for communicating with a MIP device in C++. More...
Modules | |
Mip Commands | |
Contains all MIP command definitions. | |
Mip Data | |
Contains all MIP data definitions. | |
Classes | |
struct | mip::DescriptorRate |
struct | mip::Vector< T, N > |
Vector is a wrapper around an array of some type T, usually float or double. More... | |
struct | mip::CmdQueue |
C++ wrapper around a command queue. More... | |
struct | mip::PendingCmd |
C++ class representing the state of a MIP command. More... | |
struct | mip::CompositeDescriptor |
Convenience struct holding both descriptor set and field descriptor. More... | |
struct | mip::FieldStruct |
struct | mip::Bitfield< DerivedT > |
A dummy struct which is used to mark bitfield objects. More... | |
struct | mip::TypedResult< MipCmd > |
A CmdResult that knows the corresponding command type. More... | |
class | mip::FieldView |
C++ class representing a MIP field. More... | |
struct | mip::Dispatcher |
class | mip::Interface |
Represents a connected MIP device. More... | |
class | mip::PacketView |
C++ class representing a view of a MIP packet. More... | |
class | mip::SizedPacketBuf< BufferSize > |
A mip packet with a self-contained buffer (useful with std::vector). More... | |
class | mip::Parser |
C++ class representing a MIP parser. More... | |
struct | mip::CmdResult |
Represents the status of a MIP command. More... | |
Typedefs | |
using | mip::Vector3f = Vector< float, 3 > |
using | mip::Vector4f = Vector< float, 4 > |
using | mip::Matrix3f = Vector< float, 9 > |
using | mip::Vector3d = Vector< double, 3 > |
using | mip::Vector4d = Vector< double, 4 > |
using | mip::Matrix3d = Vector< double, 9 > |
using | mip::Quatf = Vector4f |
template<class T > | |
using | mip::isField = std::is_base_of< FieldStruct, T > |
template<class T > | |
using | mip::EnableForFieldTypes = std::enable_if< isField< T >::value, T > |
using | mip::DispatchHandler = C::mip_dispatch_handler |
typedef SizedPacketBuf< mip::PACKET_LENGTH_MAX > | mip::PacketBuf |
Typedef for SizedPacketBuf of max possible size. More... | |
Enumerations | |
enum | mip::FunctionSelector : uint8_t { mip::FunctionSelector::WRITE = C::MIP_FUNCTION_WRITE, mip::FunctionSelector::READ = C::MIP_FUNCTION_READ, mip::FunctionSelector::SAVE = C::MIP_FUNCTION_SAVE, mip::FunctionSelector::LOAD = C::MIP_FUNCTION_LOAD, mip::FunctionSelector::RESET = C::MIP_FUNCTION_RESET } |
Functions | |
template<typename T , size_t N> | |
size_t | mip::insert (Serializer &serializer, const Vector< T, N > &v) |
template<typename T , size_t N> | |
size_t | mip::extract (Serializer &serializer, Vector< T, N > &v) |
template<class Derived > | |
size_t | mip::insert (Serializer &serializer, const Bitfield< Derived > &bitfield) |
template<class Derived > | |
size_t | mip::extract (Serializer &serializer, Bitfield< Derived > &bitfield) |
bool | mip::isValidDescriptorSet (uint8_t descriptorSet) |
bool | mip::isDataDescriptorSet (uint8_t descriptorSet) |
bool | mip::isCommandDescriptorSet (uint8_t descriptorSet) |
bool | mip::isReservedDescriptorSet (uint8_t descriptorSet) |
bool | mip::isGnssDataDescriptorSet (uint8_t descriptorSet) |
bool | mip::isValidFieldDescriptor (uint8_t fieldDescriptor) |
bool | mip::isCommandFieldDescriptor (uint8_t fieldDescriptor) |
bool | mip::isReplyFieldDescriptor (uint8_t fieldDescriptor) |
bool | mip::isResponseFieldDescriptor (uint8_t fieldDescriptor) |
bool | mip::isReservedFieldDescriptor (uint8_t fieldDescriptor) |
bool | mip::isSharedDataFieldDescriptor (uint8_t fieldDescriptor) |
void | mip::connect_interface (mip::Interface &device, microstrain::Connection &conn) |
Sets up the mip interface callbacks to point at this object. More... | |
template<class Cmd > | |
CmdResult | mip::runCommand (C::mip_interface &device, const Cmd &cmd, Timeout additionalTime=0) |
template<class Cmd > | |
CmdResult | mip::runCommand (C::mip_interface &device, const Cmd &cmd, typename Cmd::Response &response, Timeout additionalTime=0) |
template<class Cmd , class... Args> | |
CmdResult | mip::runCommand (C::mip_interface &device, const Args &&... args, Timeout additionalTime) |
template<class Cmd > | |
bool | mip::startCommand (C::mip_interface &device, C::mip_pending_cmd &pending, const Cmd &cmd, Timeout additionalTime) |
template<class Function > | |
bool | mip::parseMipDataFromSource (C::mip_parser &parser, Function reader, size_t maxPackets) |
Read data from a source into the internal parsing buffer. More... | |
template<bool(*)(Interface &, const uint8_t *, size_t) Send> | |
void | mip::Interface::setSendFunction () |
Sets the send callback function (free function version). More... | |
template<bool(*)(Interface &, uint8_t *, size_t, Timeout, size_t *, Timestamp *) Recv> | |
void | mip::Interface::setRecvFunction () |
Sets the receive callback function (free function version). More... | |
template<bool(*)(Interface &, Timeout) Update> | |
void | mip::Interface::setUpdateFunction () |
Sets the update callback function (free function version). More... | |
template<class Derived , bool(Derived::*)(const uint8_t *, size_t) Send> | |
void | mip::Interface::setSendFunction () |
Sets the send callback function (derived member function version). More... | |
template<class Derived , bool(Derived::*)(uint8_t *, size_t, Timeout, size_t *, Timestamp *) Recv> | |
void | mip::Interface::setRecvFunction () |
Sets the receive callback function (derived member function version). More... | |
template<class Derived , bool(Derived::*)(Timeout) Update> | |
void | mip::Interface::setUpdateFunction () |
Sets the update callback function (derived member function version). More... | |
template<class T , bool(T::*)(const uint8_t *, size_t) Send, bool(T::*)(uint8_t *, size_t, Timeout, size_t *, Timestamp *) Recv, bool(T::*)(Timeout) Update = nullptr> | |
void | mip::Interface::setCallbacks (T *object) |
Sets the callback functions to a common class object. More... | |
template<void(*)(void *, const PacketView &, Timestamp) Callback> | |
void | mip::Interface::registerPacketCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, bool afterFields, void *userData=nullptr) |
Registers a packet callback (free function version). More... | |
template<class Object , void(Object::*)(const PacketView &, Timestamp) Callback> | |
void | mip::Interface::registerPacketCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, bool afterFields, Object *object) |
Registers a packet callback (member function version). More... | |
template<void(*)(void *, const FieldView &, Timestamp) Callback> | |
void | mip::Interface::registerFieldCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, uint8_t fieldDescriptor, void *userData=nullptr) |
Registers a field callback (free function version). More... | |
template<class Object , void(Object::*)(const FieldView &field, Timestamp) Callback> | |
void | mip::Interface::registerFieldCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, uint8_t fieldDescriptor, Object *object) |
Registers a field callback (member function version). More... | |
template<class DataField , void(*)(void *, const DataField &, Timestamp) Callback> | |
void | mip::Interface::registerDataCallback (C::mip_dispatch_handler &handler, void *userData=nullptr, uint8_t descriptorSet=DataField::DESCRIPTOR_SET) |
Registers a data callback (free function version). More... | |
template<class DataField , class Object , void(Object::*)(const DataField &, Timestamp) Callback> | |
void | mip::Interface::registerDataCallback (C::mip_dispatch_handler &handler, Object *object, uint8_t descriptorSet=DataField::DESCRIPTOR_SET) |
Registers a data callback (member function version). More... | |
template<class DataField > | |
void | mip::Interface::registerExtractor (C::mip_dispatch_handler &handler, DataField *field, uint8_t descriptorSet=DataField::DESCRIPTOR_SET) |
template<class T , bool(T::*)(const PacketView &, Timestamp) Callback> | |
void | mip::Parser::setCallback (T &object) |
Initializes the MIP Parser. More... | |
This module contains functions and classes for communicating with a MIP device in C++.
using mip::DispatchHandler = typedef C::mip_dispatch_handler |
using mip::EnableForFieldTypes = typedef std::enable_if<isField<T>::value, T> |
using mip::isField = typedef std::is_base_of<FieldStruct, T> |
using mip::Matrix3d = typedef Vector<double,9> |
using mip::Matrix3f = typedef Vector<float,9> |
typedef SizedPacketBuf<mip::PACKET_LENGTH_MAX> mip::PacketBuf |
Typedef for SizedPacketBuf of max possible size.
Generally you should use this instead of SizedPacketBuf directly, unless you know the maximum size of your packet will be less than PACKET_LENGTH_MAX.
using mip::Quatf = typedef Vector4f |
using mip::Vector3d = typedef Vector<double,3> |
using mip::Vector3f = typedef Vector<float,3> |
using mip::Vector4d = typedef Vector<double,4> |
using mip::Vector4f = typedef Vector<float,4> |
|
strong |
void mip::connect_interface | ( | mip::Interface & | device, |
microstrain::Connection & | conn | ||
) |
Sets up the mip interface callbacks to point at this object.
device | Device to configure. |
conn | The connection to set |
size_t mip::extract | ( | Serializer & | serializer, |
Bitfield< Derived > & | bitfield | ||
) |
size_t mip::extract | ( | Serializer & | serializer, |
Vector< T, N > & | v | ||
) |
size_t mip::insert | ( | Serializer & | serializer, |
const Bitfield< Derived > & | bitfield | ||
) |
size_t mip::insert | ( | Serializer & | serializer, |
const Vector< T, N > & | v | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool mip::parseMipDataFromSource | ( | C::mip_parser & | parser, |
Function | reader, | ||
size_t | maxPackets | ||
) |
Read data from a source into the internal parsing buffer.
Function | A function-like object with the following signature: bool read(size_t maxCount, size_t* count_out, Timestamp* timestamp_out); The parameters are as follows:
|
parser | |
reader | A callback function, lambda, or similar which will read data into the buffer and capture the timestamp. It should return true if successful or false otherwise. If it returns false, parsing is skipped. The read function may also throw an exception instead of returning false. |
maxPackets | Maximum number of packets to parse, just like for Parser::parse(). |
void mip::Interface::registerDataCallback | ( | C::mip_dispatch_handler & | handler, |
Object * | object, | ||
uint8_t | descriptorSet = DataField::DESCRIPTOR_SET |
||
) |
Registers a data callback (member function version).
Callback | A pointer to the function to call. This must be a constant member function pointer. |
handler | This must exist as long as the handler remains registered. |
object | A pointer to the object. The object must exist while the handler remains registered. |
descriptorSet | If specified, overrides the descriptor set. Intended to be used with shared data quantities. |
Example usage:
Callback | A pointer to the function to call. This must be a constant member function pointer. |
handler | This must exist as long as the handler remains registered. |
object | A pointer to the object. The object must exist while the handler remains registered. |
descriptorSet | If specified, overrides the descriptor set. Intended to be used with shared data quantities. |
Example usage:
void mip::Interface::registerDataCallback | ( | C::mip_dispatch_handler & | handler, |
void * | userData = nullptr , |
||
uint8_t | descriptorSet = DataField::DESCRIPTOR_SET |
||
) |
Registers a data callback (free function version).
Callback | A pointer to the function to call. This must be a constant function pointer. |
handler | This must exist as long as the handler remains registered. |
userData | Optional data to pass to the callback function. |
descriptorSet | If specified, overrides the descriptor set. Intended to be used with shared data quantities. |
Example usage:
Callback | A pointer to the function to call. This must be a constant function pointer. |
handler | This must exist as long as the handler remains registered. |
userData | Optional data to pass to the callback function. |
descriptorSet | If specified, overrides the descriptor set. Intended to be used with shared data quantities. |
Example usage:
void mip::Interface::registerExtractor | ( | C::mip_dispatch_handler & | handler, |
DataField * | field, | ||
uint8_t | descriptorSet = DataField::DESCRIPTOR_SET |
||
) |
void mip::Interface::registerFieldCallback | ( | C::mip_dispatch_handler & | handler, |
uint8_t | descriptorSet, | ||
uint8_t | fieldDescriptor, | ||
Object * | object | ||
) |
Registers a field callback (member function version).
Callback | A pointer to the function to call. This must be a constant member function pointer. |
handler | |
descriptorSet | |
fieldDescriptor | |
object | Example usage: class MySystem
{
{
}
void setup()
{
// setup device...
device.registerFieldHandler<MySystem, &MySystem::handleField>(fieldHandler, descriptorSet, fieldDescriptor, this);
}
Interface device;
DispatchHandler fieldHandler;
};
|
void mip::Interface::registerFieldCallback | ( | C::mip_dispatch_handler & | handler, |
uint8_t | descriptorSet, | ||
uint8_t | fieldDescriptor, | ||
void * | userData = nullptr |
||
) |
Registers a field callback (free function version).
Callback | A pointer to the function to call. This must be a constant function pointer. |
handler | |
descriptorSet | |
fieldDescriptor | |
userData | Example usage: {
// Use the field data
}
Interface device;
DispatchHandler handler;
void setup()
{
// Set up device...
device.registerFieldCallback<&handle_field>(handler, descriptorSet, nullptr);
}
|
void mip::Interface::registerPacketCallback | ( | C::mip_dispatch_handler & | handler, |
uint8_t | descriptorSet, | ||
bool | afterFields, | ||
Object * | object | ||
) |
Registers a packet callback (member function version).
Callback | A pointer to the function to call. This must be a constant member function pointer. |
handler | |
descriptorSet | |
afterFields | |
object | Example usage: class MySystem
{
{
}
void setup()
{
// setup device...
device.registerPacketHandler<MySystem, &MySystem::handlePacket>(packetHandler, descriptorSet, this);
}
Interface device;
DispatchHandler packetHandler;
};
|
void mip::Interface::registerPacketCallback | ( | C::mip_dispatch_handler & | handler, |
uint8_t | descriptorSet, | ||
bool | afterFields, | ||
void * | userData = nullptr |
||
) |
Registers a packet callback (free function version).
Callback | A pointer to the function to call. This must be a constant function pointer. |
handler | |
descriptorSet | |
afterFields | |
userData | Example usage: {
// Use the packet data
}
Interface device;
DispatchHandler handler;
void setup()
{
// Set up device...
device.registerPacketCallback<&handle_packet>(handler, descriptorSet, nullptr);
}
|
CmdResult mip::runCommand | ( | C::mip_interface & | device, |
const Args &&... | args, | ||
Timeout | additionalTime | ||
) |
CmdResult mip::runCommand | ( | C::mip_interface & | device, |
const Cmd & | cmd, | ||
Timeout | additionalTime = 0 |
||
) |
CmdResult mip::runCommand | ( | C::mip_interface & | device, |
const Cmd & | cmd, | ||
typename Cmd::Response & | response, | ||
Timeout | additionalTime = 0 |
||
) |
void mip::Parser::setCallback | ( | T & | object | ) |
Initializes the MIP Parser.
This version allows binding a member function instead of a C-style callback. Example:
T | Class type containing the member function to be called. |
Callback | A pointer to a member function on a T to be called when a packet is parsed. |
object | Instance of T to call the callback. |
void mip::Interface::setCallbacks | ( | T * | object | ) |
Sets the callback functions to a common class object.
T | A class type. |
Send | A member function pointer for sending bytes to the device. May be NULL. |
Recv | A member function pointer for receiving bytes from the device. May be NULL. |
Update | A member function pointer for updating the device. If both this and Recv are NULL, no update function is set. If Update is NULL but Recv is not, the default update function is used instead. |
object | An instance of T. The interface's user pointer will be set to this value. All of the callbacks will be invoked on this instance. |
void mip::Interface::setRecvFunction |
Sets the receive callback function (free function version).
Recv | A compile-time pointer to the callback function. |
void mip::Interface::setRecvFunction |
Sets the receive callback function (derived member function version).
Derived | Derived class type. Must inherit from Interface. |
Recv | Compile-time pointer to member function of Derived. |
void mip::Interface::setSendFunction |
Sets the send callback function (free function version).
Send | A compile-time pointer to the callback function. |
void mip::Interface::setSendFunction |
Sets the send callback function (derived member function version).
Derived | Derived class type. Must inherit from Interface. |
Send | Compile-time pointer to member function of Derived. |
void mip::Interface::setUpdateFunction |
Sets the update callback function (free function version).
Update | A compile-time pointer to the callback function. |
void mip::Interface::setUpdateFunction |
Sets the update callback function (derived member function version).
Derived | Derived class type. Must inherit from Interface. |
Update | Compile-time pointer to member function of Derived. |
bool mip::startCommand | ( | C::mip_interface & | device, |
C::mip_pending_cmd & | pending, | ||
const Cmd & | cmd, | ||
Timeout | additionalTime | ||
) |