SafeString  4.1.27
SafeString is a safe, robust and debuggable replacement for string processing in Arduino
BufferedInput Class Reference

To create a BufferedInput use the macro createBufferedInput see the detailed description. More...

#include <BufferedInput.h>

Inherits Stream.

Public Member Functions

 BufferedInput (size_t _bufferSize, uint8_t *_buf)
 use createBufferedOutput(name, size); instead BufferedInput(size_t _bufferSize, uint8_t *_buf); More...
 
void connect (Stream &_stream)
 void connect(Stream& _stream); // the stream to read from, can also write to stream – the stream to buffer input for More...
 
void nextByteIn ()
 
virtual size_t write (uint8_t)
 
virtual size_t write (const uint8_t *buf, size_t size)
 
virtual int available ()
 
virtual int read ()
 
virtual int peek ()
 
virtual void flush ()
 
virtual int availableForWrite ()
 
size_t getSize ()
 
int maxStreamAvailable ()
 
int maxBufferUsed ()
 

Detailed Description

To create a BufferedInput use the macro createBufferedInput see the detailed description.

The createBufferedInput macro takes 2 arguments.
createBufferedInput(name, bufferSize); creates a BufferedInput called name with a buffer size of bufferSize.
e.g. to create a BufferedInput called bufferedInput with a buffer size of 128 use
createBufferedInput(bufferedInput, 128)

Add a call to
bufferedInput.nextByteIn();
at the top of the loop() to read more chars from the input. You can add more of these calls through out the loop() code if needed.
Most BufferedInput methods also read more chars from the input

See Arduino Serial I/O for the Real World - BufferedInput for an example of its use.

Definition at line 61 of file BufferedInput.h.

Constructor & Destructor Documentation

◆ BufferedInput()

BufferedInput::BufferedInput ( size_t  _bufferSize,
uint8_t *  _buf 
)

use createBufferedOutput(name, size); instead BufferedInput(size_t _bufferSize, uint8_t *_buf);

buf – the user allocated buffer to store the bytes, must be at least bufferSize long. Defaults to an internal 8 char buffer if buf is omitted or NULL bufferSize – number of bytes to buffer,max bufferSize is limited to 32766. Defaults to an internal 8 char buffer if bufferSize is < 8 or is omitted

Member Function Documentation

◆ available()

virtual int BufferedInput::available ( )
virtual

◆ availableForWrite()

virtual int BufferedInput::availableForWrite ( )
virtual

◆ connect()

void BufferedInput::connect ( Stream &  _stream)

void connect(Stream& _stream); // the stream to read from, can also write to stream – the stream to buffer input for

◆ flush()

virtual void BufferedInput::flush ( )
virtual

◆ getSize()

size_t BufferedInput::getSize ( )

◆ maxBufferUsed()

int BufferedInput::maxBufferUsed ( )

◆ maxStreamAvailable()

int BufferedInput::maxStreamAvailable ( )

◆ nextByteIn()

void BufferedInput::nextByteIn ( )

◆ peek()

virtual int BufferedInput::peek ( )
virtual

◆ read()

virtual int BufferedInput::read ( )
virtual

◆ write() [1/2]

virtual size_t BufferedInput::write ( const uint8_t *  buf,
size_t  size 
)
virtual

◆ write() [2/2]

virtual size_t BufferedInput::write ( uint8_t  )
virtual