MIP_SDK  latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
microstrain::connections::RecordingConnection Class Reference

Can be used with another connection to communicate with a device, and record the data at the same time. More...

#include <recording_connection.hpp>

Inheritance diagram for microstrain::connections::RecordingConnection:
microstrain::Connection microstrain::connections::RecordingConnectionWrapper< ConnectionType >

Public Member Functions

 RecordingConnection (Connection *connection, std::ostream *recvStream=nullptr, std::ostream *sendStream=nullptr)
 Creates a RecordingConnection that will write received bytes to recvStream, and sent bytes to sendStream. More...
 
 ~RecordingConnection () override=default
 
bool sendToDevice (const uint8_t *data, size_t length) override
 Sends bytes to the device. More...
 
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 isConnected () const override
 
bool connect () override
 
bool disconnect () override
 
const char * interfaceName () const override
 
uint32_t parameter () const override
 
uint64_t recvFileBytesWritten () const
 
uint64_t sendFileBytesWritten () const
 
- Public Member Functions inherited from microstrain::Connection
 Connection ()
 
virtual ~Connection ()
 
const char * type () const
 

Static Public Attributes

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

Protected Attributes

ConnectionmConnection
 
std::ostream * mRecvFile
 
std::ostream * mSendFile
 
uint64_t mRecvFileWritten = 0
 
uint64_t mSendFileWritten = 0
 
- Protected Attributes inherited from microstrain::Connection
const char * mType
 

Detailed Description

Can be used with another connection to communicate with a device, and record the data at the same time.

Constructor & Destructor Documentation

◆ RecordingConnection()

microstrain::connections::RecordingConnection::RecordingConnection ( Connection connection,
std::ostream *  recvStream = nullptr,
std::ostream *  sendStream = nullptr 
)

Creates a RecordingConnection that will write received bytes to recvStream, and sent bytes to sendStream.

Parameters
connectionConnection object that will actually communicate with the device
recvStreamThe stream to write to when bytes are received. Null if received bytes should not be written to a stream
sendStreamThe stream to write to when bytes are sent. Null if sent bytes should not be written to a stream

◆ ~RecordingConnection()

microstrain::connections::RecordingConnection::~RecordingConnection ( )
overridedefault

Member Function Documentation

◆ connect()

bool microstrain::connections::RecordingConnection::connect ( )
inlineoverridevirtual

◆ disconnect()

bool microstrain::connections::RecordingConnection::disconnect ( )
inlineoverridevirtual

◆ interfaceName()

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

◆ isConnected()

bool microstrain::connections::RecordingConnection::isConnected ( ) const
inlineoverridevirtual

◆ parameter()

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

◆ recvFileBytesWritten()

uint64_t microstrain::connections::RecordingConnection::recvFileBytesWritten ( ) const
inline

◆ recvFromDevice()

bool microstrain::connections::RecordingConnection::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.

◆ sendFileBytesWritten()

uint64_t microstrain::connections::RecordingConnection::sendFileBytesWritten ( ) const
inline

◆ sendToDevice()

bool microstrain::connections::RecordingConnection::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

◆ mConnection

Connection* microstrain::connections::RecordingConnection::mConnection
protected

◆ mRecvFile

std::ostream* microstrain::connections::RecordingConnection::mRecvFile
protected

◆ mRecvFileWritten

uint64_t microstrain::connections::RecordingConnection::mRecvFileWritten = 0
protected

◆ mSendFile

std::ostream* microstrain::connections::RecordingConnection::mSendFile
protected

◆ mSendFileWritten

uint64_t microstrain::connections::RecordingConnection::mSendFileWritten = 0
protected

◆ TYPE

constexpr const char* microstrain::connections::RecordingConnection::TYPE = "Recording"
staticconstexpr

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