MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
Public Member Functions | List of all members
mip::Interface Class Reference

Represents a connected MIP device. More...

#include <mip_interface.hpp>

Inheritance diagram for mip::Interface:
mip::C::mip_interface

Public Member Functions

 Interface (uint8_t *parseBuffer, size_t parseBufferSize, Timeout parseTimeout, Timeout baseReplyTimeout)
 Initialize the mip_interface components. More...
 
 Interface (microstrain::Connection *connection, uint8_t *parseBuffer, size_t parseBufferSize, Timeout parseTimeout, Timeout baseReplyTimeout)
 Initialize the mip_interface components. More...
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
 ~Interface ()=default
 
C::mip_send_callback sendFunction () const
 
C::mip_recv_callback recvFunction () const
 
C::mip_update_callback updateFunction () const
 
void setSendFunction (C::mip_send_callback callback)
 
void setRecvFunction (C::mip_recv_callback callback)
 
void setUpdateFunction (C::mip_update_callback function)
 
template<bool(*)(Interface &, const uint8_t *, size_t) Send>
void setSendFunction ()
 Sets the send callback function (free function version). More...
 
template<bool(*)(Interface &, uint8_t *, size_t, Timeout, size_t *, Timestamp *) Recv>
void setRecvFunction ()
 Sets the receive callback function (free function version). More...
 
template<bool(*)(Interface &, Timeout) Update>
void setUpdateFunction ()
 Sets the update callback function (free function version). More...
 
template<class Derived , bool(Derived::*)(const uint8_t *, size_t) Send>
void 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 setRecvFunction ()
 Sets the receive callback function (derived member function version). More...
 
template<class Derived , bool(Derived::*)(Timeout) Update>
void 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 setCallbacks (T *object)
 Sets the callback functions to a common class object. More...
 
void setMaxPacketsPerPoll (unsigned int maxPackets)
 
unsigned int maxPacketsPerPoll () const
 
Timeout baseReplyTimeout () const
 
void setBaseReplyTimeout (Timeout timeout)
 
Parserparser ()
 
CmdQueuecmdQueue ()
 
const Parserparser () const
 
const CmdQueuecmdQueue () const
 
bool sendToDevice (const uint8_t *data, size_t length)
 
bool sendToDevice (const C::mip_packet_view &packet)
 
bool recvFromDevice (uint8_t *buffer, size_t max_length, Timeout wait_time, size_t *length_out, Timestamp *timestamp)
 
bool update (Timeout wait_time=0)
 
bool defaultUpdate (Timeout wait_time=0)
 
size_t receiveBytes (const uint8_t *data, size_t length, Timestamp timestamp)
 
void receivePacket (const C::mip_packet_view &packet, Timestamp timestamp)
 
void processUnparsedPackets ()
 
CmdResult waitForReply (C::mip_pending_cmd &cmd)
 
void registerPacketCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, bool afterFields, C::mip_dispatch_packet_callback callback, void *userData)
 
void registerFieldCallback (C::mip_dispatch_handler &handler, uint8_t descriptorSet, uint8_t fieldDescriptor, C::mip_dispatch_field_callback callback, void *userData)
 
template<void(*)(void *, const PacketView &, Timestamp) Callback>
void 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 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 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 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 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 , void(*)(void *, const DataField &, uint8_t, Timestamp) Callback>
void registerDataCallback (C::mip_dispatch_handler &handler, void *userData=nullptr, uint8_t descriptorSet=DataField::DESCRIPTOR_SET)
 
template<class DataField , class Object , void(Object::*)(const DataField &, Timestamp) Callback>
void 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 , class Object , void(Object::*)(const DataField &, uint8_t, Timestamp) Callback>
void registerDataCallback (C::mip_dispatch_handler &handler, Object *object, uint8_t descriptorSet=DataField::DESCRIPTOR_SET)
 
template<class DataField >
void registerExtractor (C::mip_dispatch_handler &handler, DataField *field, uint8_t descriptorSet=DataField::DESCRIPTOR_SET)
 
template<class Cmd >
CmdResult runCommand (const Cmd &cmd, Timeout additionalTime=0)
 
template<class Cmd , class... Args>
CmdResult runCommand (Args &&... args, Timeout additionalTime=0)
 
template<class Cmd >
CmdResult runCommand (const Cmd &cmd, typename Cmd::Response &response, Timeout additionalTime=0)
 
template<class Cmd >
bool startCommand (PendingCmd &pending, const Cmd &cmd, Timeout additionalTime=0)
 

Detailed Description

Represents a connected MIP device.

Constructor & Destructor Documentation

◆ Interface() [1/3]

mip::Interface::Interface ( uint8_t *  parseBuffer,
size_t  parseBufferSize,
Timeout  parseTimeout,
Timeout  baseReplyTimeout 
)
inline

Initialize the mip_interface components.

Parameters
device
parse_bufferA working buffer for the MIP parser. See mip_parser_init().
parse_buffer_sizeSize of the parsing buffer. Must be at least MIP_PACKET_LENGTH_MAX.
parse_timeoutMaximum length of time to wait for the end of a MIP packet. See mip_parser_init().
base_reply_timeoutMinimum time for all commands. See mip_cmd_queue_init().
sendA callback which is called to send data to the device.
recvA callback which is called when data needs to be read from the device.
updateOptional callback which is called to perform routine tasks such as checking for command timeouts. Defaults to mip_interface_default_update.
user_pointerOptional pointer which is passed to the send, recv, and update callbacks. The interface callbacks must be assigned separately (e.g. with Connection::connect_interface())

◆ Interface() [2/3]

mip::Interface::Interface ( microstrain::Connection connection,
uint8_t *  parseBuffer,
size_t  parseBufferSize,
Timeout  parseTimeout,
Timeout  baseReplyTimeout 
)
inline

Initialize the mip_interface components.

Parameters
device
parse_bufferA working buffer for the MIP parser. See mip_parser_init().
parse_buffer_sizeSize of the parsing buffer. Must be at least MIP_PACKET_LENGTH_MAX.
parse_timeoutMaximum length of time to wait for the end of a MIP packet. See mip_parser_init().
base_reply_timeoutMinimum time for all commands. See mip_cmd_queue_init().
sendA callback which is called to send data to the device.
recvA callback which is called when data needs to be read from the device.
updateOptional callback which is called to perform routine tasks such as checking for command timeouts. Defaults to mip_interface_default_update.
user_pointerOptional pointer which is passed to the send, recv, and update callbacks.
connectionThe connection object used to communicate with the device. This object must exist for the life of the Interface object

◆ Interface() [3/3]

mip::Interface::Interface ( const Interface )
delete

◆ ~Interface()

mip::Interface::~Interface ( )
default

Member Function Documentation

◆ baseReplyTimeout()

Timeout mip::Interface::baseReplyTimeout ( ) const
inline

◆ cmdQueue() [1/2]

CmdQueue& mip::Interface::cmdQueue ( )
inline

◆ cmdQueue() [2/2]

const CmdQueue& mip::Interface::cmdQueue ( ) const
inline

◆ defaultUpdate()

bool mip::Interface::defaultUpdate ( Timeout  wait_time = 0)
inline

◆ maxPacketsPerPoll()

unsigned int mip::Interface::maxPacketsPerPoll ( ) const
inline

◆ operator=()

Interface& mip::Interface::operator= ( const Interface )
delete

◆ parser() [1/2]

Parser& mip::Interface::parser ( )
inline

◆ parser() [2/2]

const Parser& mip::Interface::parser ( ) const
inline

◆ processUnparsedPackets()

void mip::Interface::processUnparsedPackets ( )
inline

◆ receiveBytes()

size_t mip::Interface::receiveBytes ( const uint8_t *  data,
size_t  length,
Timestamp  timestamp 
)
inline

◆ receivePacket()

void mip::Interface::receivePacket ( const C::mip_packet_view packet,
Timestamp  timestamp 
)
inline

◆ recvFromDevice()

bool mip::Interface::recvFromDevice ( uint8_t *  buffer,
size_t  max_length,
Timeout  wait_time,
size_t *  length_out,
Timestamp timestamp 
)
inline

◆ recvFunction()

C::mip_recv_callback mip::Interface::recvFunction ( ) const
inline

◆ registerDataCallback() [1/2]

template<class DataField , class Object , void(Object::*)(const DataField &, uint8_t, Timestamp) Callback>
void mip::Interface::registerDataCallback ( C::mip_dispatch_handler handler,
Object *  object,
uint8_t  descriptorSet = DataField::DESCRIPTOR_SET 
)

◆ registerDataCallback() [2/2]

template<class DataField , void(*)(void *, const DataField &, uint8_t, Timestamp) Callback>
void mip::Interface::registerDataCallback ( C::mip_dispatch_handler handler,
void *  userData = nullptr,
uint8_t  descriptorSet = DataField::DESCRIPTOR_SET 
)

◆ registerFieldCallback()

void mip::Interface::registerFieldCallback ( C::mip_dispatch_handler handler,
uint8_t  descriptorSet,
uint8_t  fieldDescriptor,
C::mip_dispatch_field_callback  callback,
void *  userData 
)
inline

◆ registerPacketCallback()

void mip::Interface::registerPacketCallback ( C::mip_dispatch_handler handler,
uint8_t  descriptorSet,
bool  afterFields,
C::mip_dispatch_packet_callback  callback,
void *  userData 
)
inline

◆ runCommand() [1/3]

template<class Cmd , class... Args>
CmdResult mip::Interface::runCommand ( Args &&...  args,
Timeout  additionalTime = 0 
)
inline

◆ runCommand() [2/3]

template<class Cmd >
CmdResult mip::Interface::runCommand ( const Cmd &  cmd,
Timeout  additionalTime = 0 
)
inline

◆ runCommand() [3/3]

template<class Cmd >
CmdResult mip::Interface::runCommand ( const Cmd &  cmd,
typename Cmd::Response &  response,
Timeout  additionalTime = 0 
)
inline

◆ sendFunction()

C::mip_send_callback mip::Interface::sendFunction ( ) const
inline

◆ sendToDevice() [1/2]

bool mip::Interface::sendToDevice ( const C::mip_packet_view packet)
inline

◆ sendToDevice() [2/2]

bool mip::Interface::sendToDevice ( const uint8_t *  data,
size_t  length 
)
inline

◆ setBaseReplyTimeout()

void mip::Interface::setBaseReplyTimeout ( Timeout  timeout)
inline

◆ setMaxPacketsPerPoll()

void mip::Interface::setMaxPacketsPerPoll ( unsigned int  maxPackets)
inline

◆ setRecvFunction()

void mip::Interface::setRecvFunction ( C::mip_recv_callback  callback)
inline

◆ setSendFunction()

void mip::Interface::setSendFunction ( C::mip_send_callback  callback)
inline

◆ setUpdateFunction()

void mip::Interface::setUpdateFunction ( C::mip_update_callback  function)
inline

◆ startCommand()

template<class Cmd >
bool mip::Interface::startCommand ( PendingCmd pending,
const Cmd &  cmd,
Timeout  additionalTime = 0 
)
inline

◆ update()

bool mip::Interface::update ( Timeout  wait_time = 0)
inline

◆ updateFunction()

C::mip_update_callback mip::Interface::updateFunction ( ) const
inline

◆ waitForReply()

CmdResult mip::Interface::waitForReply ( C::mip_pending_cmd cmd)
inline

The documentation for this class was generated from the following file: