MIP SDK
0.0.1
MicroStrain Communications Library for embedded systems
|
This module contains functions and classes for communicating with a MIP device in C++. More...
Classes | |
class | mip::Field |
C++ class representing a MIP field. More... | |
class | mip::Packet |
C++ class representing a MIP Packet. More... | |
class | mip::Parser |
C++ class representing a MIP parser. More... | |
struct | mip::Dispatcher |
struct | mip::CmdQueue |
C++ wrapper around a command queue. More... | |
struct | mip::PendingCmd |
C++ class representing the state of a MIP command. More... | |
class | mip::Connection |
Represents a type of connection to a MIP device. More... | |
class | mip::DeviceInterface |
Represents a connected MIP device. More... | |
Typedefs | |
using | mip::DispatchHandler = C::mip_dispatch_handler |
Functions | |
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<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 T , bool(T::*)(const Packet &, Timestamp) Callback> | |
void | mip::Parser::setCallback (T &object) |
Initializes the MIP Parser. More... | |
template<bool(*)(DeviceInterface &, bool) Function> | |
void | mip::DeviceInterface::setUpdateFunction () |
Sets the update function to a function taking a MipDevice reference. More... | |
template<void(*)(void *, const Packet &, Timestamp) Callback> | |
void | mip::DeviceInterface::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 Packet &, Timestamp) Callback> | |
void | mip::DeviceInterface::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 Field &, Timestamp) Callback> | |
void | mip::DeviceInterface::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 Field &field, Timestamp) Callback> | |
void | mip::DeviceInterface::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::DeviceInterface::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::DeviceInterface::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::DeviceInterface::registerExtractor (C::mip_dispatch_handler &handler, DataField *field, uint8_t descriptorSet=DataField::DESCRIPTOR_SET) |
This module contains functions and classes for communicating with a MIP device in C++.
using mip::DispatchHandler = typedef C::mip_dispatch_handler |
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::DeviceInterface::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 hander 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 with shared data quantities. |
Example usage:
void mip::DeviceInterface::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 hander remains registered. |
userData | Optional data to pass to the callback function. |
descriptorSet | If specified, overrides the descriptor set. Intended to be used with with shared data quantities. |
Example usage:
void mip::DeviceInterface::registerExtractor | ( | C::mip_dispatch_handler & | handler, |
DataField * | field, | ||
uint8_t | descriptorSet = DataField::DESCRIPTOR_SET |
||
) |
void mip::DeviceInterface::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);
}
DeviceInterface device;
DispatchHandler fieldHandler;
};
|
void mip::DeviceInterface::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
}
DeviceInterface device;
DispatchHandler handler;
void setup()
{
// Set up device...
device.registerFieldCallback<&handle_field>(handler, descriptorSet, nullptr);
}
|
void mip::DeviceInterface::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);
}
DeviceInterface device;
DispatchHandler packetHandler;
};
|
void mip::DeviceInterface::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
}
DeviceInterface 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::DeviceInterface::setUpdateFunction |
Sets the update function to a function taking a MipDevice reference.
bool mip::startCommand | ( | C::mip_interface & | device, |
C::mip_pending_cmd & | pending, | ||
const Cmd & | cmd, | ||
Timeout | additionalTime | ||
) |