theCore C++ embedded framework
ecl::console_pipe< GBus > Class Template Reference

Console pipe (blocking) adapter. More...

#include </home/travis/build/forGGe/theCore/dev/bus/export/dev/console_pipe.hpp>

Public Member Functions

 console_pipe ()
 Constructs a pipe. More...
 
 ~console_pipe ()
 Destructs a pipe. More...
 
ecl::err init ()
 Inits a pipe. More...
 
ssize_t write (const uint8_t *data, size_t count)
 Writes a data to a pipe. More...
 
ssize_t read (uint8_t *buffer, size_t size)
 Reads a data from a pipe. More...
 
ecl::err last_error () const
 Gets last error occurred. More...
 

Detailed Description

template<class GBus>
class ecl::console_pipe< GBus >

Console pipe (blocking) adapter.

This adapter provides functionality of a blocking pipe built over generic bus interface. It echoes each byte received. Temporary solution, until 'serial' driver will be supported in each platform.

Template Parameters
GBusGeneric bus driver.
See also
generic_bus

Constructor & Destructor Documentation

◆ console_pipe()

template<class GBus >
ecl::console_pipe< GBus >::console_pipe ( )

Constructs a pipe.

◆ ~console_pipe()

template<class GBus >
ecl::console_pipe< GBus >::~console_pipe ( )

Destructs a pipe.

Member Function Documentation

◆ init()

template<class GBus >
ecl::err ecl::console_pipe< GBus >::init ( )

Inits a pipe.

Lazy initialization. Inits a bus.

Returns
Status of operation.

◆ write()

template<class GBus >
ssize_t ecl::console_pipe< GBus >::write ( const uint8_t *  data,
size_t  count 
)

Writes a data to a pipe.

If error is occurred before transfer has started then this method will immediately exit and return negative integer value to notify about error. If error occur during transaction then return value will be less than bytes requested or zero, indicating amount of bytes that were successfully written to a pipe. Last error can be obtained via

See also
last_error() call Caller will be blocked until all bytes will be transferred or error will occur.
Precondition
Bus is initialized.
Parameters
[in]dataData to write. Must not be null.
[in]countCount of bytes that must be written to a pipe. Can be zero.
Returns
Value indicating either error if negative or amount of bytes transferred if positive.

◆ read()

template<class GBus >
ssize_t ecl::console_pipe< GBus >::read ( uint8_t *  buffer,
size_t  size 
)

Reads a data from a pipe.

If error is occurred before transfer has started then this method will immediately exit and return negative integer value to notify about error. If error occur during transaction or there is less data than request then return value will be less than size of provided buffer, indicating amount of bytes that were successfully read from a pipe. Last error can be obtained via

See also
last_error() call. Caller will be blocked until all bytes will be written to a buffer or error will occur.
Precondition
Bus is initialized and buffer is valid.
Parameters
[out]bufferData buffer to read to. Must not be null.
[in]sizeSize of a buffer. Can be zero.
Returns
Value indicating an error if negative or bytes stored to a buffer if positive.

◆ last_error()

template<class GBus >
err ecl::console_pipe< GBus >::last_error ( ) const

Gets last error occurred.

Returns
Error defined in ecl::err

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