MIP_SDK  v4.0.0-224-g55f11fa2
MicroStrain Communications Library for embedded systems
Public Member Functions | Static Public Attributes | List of all members
microstrain::connections::TcpConnection Class Reference

Can be used on Windows, OSX, or linux to communicate with a MIP device over TCP. More...

#include <tcp_connection.hpp>

Inheritance diagram for microstrain::connections::TcpConnection:
microstrain::Connection

Public Member Functions

 TcpConnection ()=default
 
 TcpConnection (const std::string &hostname, uint16_t port)
 Creates a TcpConnection that will communicate with a device over TCP. More...
 
 ~TcpConnection () override
 Closes the underlying TCP socket. More...
 
 TcpConnection (const TcpConnection &)=delete
 
TcpConnectionoperator= (const TcpConnection &)=delete
 
bool recvFromDevice (uint8_t *buffer, size_t max_length, unsigned int wait_time_ms, size_t *length_out, EmbeddedTimestamp *timestamp_out) override
 Receives bytes from the device. More...
 
bool sendToDevice (const uint8_t *data, size_t length) override
 Sends bytes to the device. More...
 
bool isConnected () const override
 Check if the socket is connected. More...
 
bool connect () override
 Connect to the socket. More...
 
bool disconnect () override
 Disconnect from the socket. More...
 
void connectionInfo (std::string &host_name, uint32_t &port) const
 
const char * interfaceName () const override
 
uint32_t parameter () const override
 
- Public Member Functions inherited from microstrain::Connection
 Connection ()
 
virtual ~Connection ()
 
bool sendBufferToDevice (microstrain::ConstU8ArrayView data)
 
bool recvBufferFromDevice (microstrain::U8ArrayView buffer, unsigned int wait_time_ms, size_t *length_out, EmbeddedTimestamp *timestamp_out)
 
bool recvFromDeviceAndUpdateUint8ArrayView (microstrain::U8ArrayView &buffer, unsigned int wait_time_ms, EmbeddedTimestamp *timestamp_out)
 
const char * type () const
 

Static Public Attributes

static constexpr const char * TYPE = "TCP"
 
- Static Public Attributes inherited from microstrain::Connection
static constexpr const char * TYPE = "None"
 

Additional Inherited Members

- Protected Attributes inherited from microstrain::Connection
const char * mType
 

Detailed Description

Constructor & Destructor Documentation

◆ TcpConnection() [1/3]

microstrain::connections::TcpConnection::TcpConnection ( )
default

◆ TcpConnection() [2/3]

microstrain::connections::TcpConnection::TcpConnection ( const std::string &  hostname,
uint16_t  port 
)
Parameters
hostnameHost name or IP address to connect to
portPort on hostName to connect to

◆ ~TcpConnection()

microstrain::connections::TcpConnection::~TcpConnection ( )
override

◆ TcpConnection() [3/3]

microstrain::connections::TcpConnection::TcpConnection ( const TcpConnection )
delete

Member Function Documentation

◆ operator=()

TcpConnection& microstrain::connections::TcpConnection::operator= ( const TcpConnection )
delete

◆ recvFromDevice()

bool microstrain::connections::TcpConnection::recvFromDevice ( uint8_t *  buffer,
size_t  max_length,
unsigned int  wait_time_ms,
size_t *  length_out,
EmbeddedTimestamp timestamp_out 
)
overridevirtual
Parameters
bufferBuffer to store the received data in
max_lengthMax number of bytes that can be read. Should be at most the length of buffer.
wait_time_msTime to wait for data in milliseconds.
length_outNumber of bytes actually read.
timestamp_outTimestamp of when the data was received

Implements microstrain::Connection.

◆ sendToDevice()

bool microstrain::connections::TcpConnection::sendToDevice ( const uint8_t *  data,
size_t  length 
)
overridevirtual
Parameters
dataThe data to send to the device
lengthLength of data in bytes

Implements microstrain::Connection.

◆ isConnected()

bool microstrain::connections::TcpConnection::isConnected ( ) const
overridevirtual

◆ connect()

bool microstrain::connections::TcpConnection::connect ( )
overridevirtual

◆ disconnect()

bool microstrain::connections::TcpConnection::disconnect ( )
overridevirtual

◆ connectionInfo()

void microstrain::connections::TcpConnection::connectionInfo ( std::string &  host_name,
uint32_t &  port 
) const
inline

◆ interfaceName()

const char* microstrain::connections::TcpConnection::interfaceName ( ) const
inlineoverridevirtual

◆ parameter()

uint32_t microstrain::connections::TcpConnection::parameter ( ) const
inlineoverridevirtual

Member Data Documentation

◆ TYPE

constexpr const char* microstrain::connections::TcpConnection::TYPE = "TCP"
staticconstexpr

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