MIP_SDK  v3.0.0-736-g212583cf
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 ()
 
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 = "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

Constructor & Destructor Documentation

◆ RecordingConnection()

microstrain::connections::RecordingConnection::RecordingConnection ( Connection connection,
std::ostream *  recvStream = nullptr,
std::ostream *  sendStream = nullptr 
)
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

◆ sendToDevice()

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

◆ 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
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.

◆ isConnected()

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

◆ connect()

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

◆ disconnect()

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

◆ interfaceName()

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

◆ parameter()

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

◆ recvFileBytesWritten()

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

◆ sendFileBytesWritten()

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

Member Data Documentation

◆ TYPE

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

◆ mConnection

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

◆ mRecvFile

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

◆ mSendFile

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

◆ mRecvFileWritten

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

◆ mSendFileWritten

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

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