iodrivers_base
Public Member Functions | List of all members
iodrivers_base::TestStream Class Reference

#include <TestStream.hpp>

Inheritance diagram for iodrivers_base::TestStream:
iodrivers_base::IOStream

Public Member Functions

 TestStream ()
 
void pushDataToDriver (std::vector< uint8_t > const &data)
 
std::vector< uint8_t > readDataFromDriver ()
 
void EXPECT_REPLY (std::vector< uint8_t > const &expectation, std::vector< uint8_t > const &reply)
 
void waitRead (base::Time const &timeout)
 
void waitWrite (base::Time const &timeout)
 
size_t read (uint8_t *buffer, size_t buffer_size)
 
size_t write (uint8_t const *buffer, size_t buffer_size)
 
void clear ()
 
bool expectationsAreEmpty ()
 
void setMockMode (bool mode)
 
void clearExpectations ()
 
- Public Member Functions inherited from iodrivers_base::IOStream
virtual ~IOStream ()
 
virtual int getFileDescriptor () const
 

Detailed Description

A IOStream meant to be used to test iodrivers_base functionality from outside

It maintains two vectors, one the "to device" buffer and one the "from buffer" device. All communications are synchronous, that is waitRead will throw right away if no data is available. waitWrite never fails.

Constructor & Destructor Documentation

◆ TestStream()

iodrivers_base::TestStream::TestStream ( )
inline

Member Function Documentation

◆ clear()

void TestStream::clear ( )
virtual

◆ clearExpectations()

void TestStream::clearExpectations ( )

◆ EXPECT_REPLY()

void TestStream::EXPECT_REPLY ( std::vector< uint8_t > const &  expectation,
std::vector< uint8_t > const &  reply 
)

Set a expectation and reply pair and also puts the driver in mock mode. Should be used after setting up IODRIVERS_BASE_MOCK().

Parameters
expecationis the message that is expected to be sent by the driver
replyreply message to be received by the driver

◆ expectationsAreEmpty()

bool TestStream::expectationsAreEmpty ( )

◆ pushDataToDriver()

void TestStream::pushDataToDriver ( std::vector< uint8_t > const &  data)

Push data to the driver "as-if" it was coming from the device

Push data to the driver

◆ read()

size_t TestStream::read ( uint8_t *  buffer,
size_t  buffer_size 
)
virtual

◆ readDataFromDriver()

vector< uint8_t > TestStream::readDataFromDriver ( )

Read data that the driver sent to the device

This contains only data sent since the last call to readDataFromDriver

Read all data that the device driver has written since the last call to readDataFromDriver

◆ setMockMode()

void TestStream::setMockMode ( bool  mode)

◆ waitRead()

void TestStream::waitRead ( base::Time const &  timeout)
virtual

◆ waitWrite()

void TestStream::waitWrite ( base::Time const &  timeout)
virtual

◆ write()

size_t TestStream::write ( uint8_t const *  buffer,
size_t  buffer_size 
)
virtual

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