MIP_SDK  v3.0.0
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 (const std::string &hostname, uint16_t port)
 Creates a TcpConnection that will communicate with a device over TCP. More...
 
 ~TcpConnection ()
 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 ()
 
const char * type () const
 

Static Public Attributes

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

Additional Inherited Members

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

Detailed Description

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

Constructor & Destructor Documentation

◆ TcpConnection() [1/2]

microstrain::connections::TcpConnection::TcpConnection ( const std::string &  hostname,
uint16_t  port 
)

Creates a TcpConnection that will communicate with a device over TCP.

Parameters
hostnameHost name or IP address to connect to
portPort on hostName to connect to

◆ ~TcpConnection()

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

Closes the underlying TCP socket.

◆ TcpConnection() [2/2]

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

Member Function Documentation

◆ connect()

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

Connect to the socket.

Implements microstrain::Connection.

◆ connectionInfo()

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

◆ disconnect()

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

Disconnect from the socket.

Implements microstrain::Connection.

◆ interfaceName()

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

◆ isConnected()

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

Check if the socket is connected.

Implements microstrain::Connection.

◆ operator=()

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

◆ parameter()

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

◆ 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

Receives bytes from the device.

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

Sends bytes to the device.

Parameters
dataThe data to send to the device
lengthLength of data in bytes

Implements microstrain::Connection.

Member Data Documentation

◆ TYPE

constexpr auto microstrain::connections::TcpConnection::TYPE = "TCP"
staticconstexpr

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