MIP_SDK  latest-2-g34f3e39
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 (Timeout parseTimeout, Timeout baseReplyTimeout)
 Initialize the mip_interface components. More...
 
 Interface (microstrain::Connection *connection, 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, bool) 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, bool) 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::*)(Timeout, bool, Timestamp *) Recv, bool(T::*)(Timeout, bool) Update = nullptr>
void setCallbacks (T *object)
 Sets the callback functions to a common class object. More...
 
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 (Timeout wait_time, size_t *length_out, Timestamp *timestamp_out)
 
bool update (Timeout wait_time=0, bool from_cmd=false)
 
bool defaultUpdate (Timeout wait_time=0, bool from_cmd=false)
 
void inputBytes (const uint8_t *data, size_t length, Timestamp timestamp)
 
void inputPacket (const C::mip_packet_view &packet, Timestamp timestamp)
 
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 ( Timeout  parseTimeout,
Timeout  baseReplyTimeout 
)
inline

Initialize the mip_interface components.

Parameters
device
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,
Timeout  parseTimeout,
Timeout  baseReplyTimeout 
)
inline

Initialize the mip_interface components.

Parameters
device
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 DeviceInterface 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,
bool  from_cmd = false 
)
inline

◆ inputBytes()

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

◆ inputPacket()

void mip::Interface::inputPacket ( const C::mip_packet_view packet,
Timestamp  timestamp 
)
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

◆ recvFromDevice()

bool mip::Interface::recvFromDevice ( Timeout  wait_time,
size_t *  length_out,
Timestamp timestamp_out 
)
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

◆ 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,
bool  from_cmd = false 
)
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: