Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
SerialBuffer Struct Reference

FIFO buffer used for both receive and transmit data. More...

#include <SerialBuffer.h>

Public Member Functions

size_t getSize ()
 
__forceinline size_t available ()
 get number of bytes stored in the buffer More...
 
__forceinline size_t getFreeSpace ()
 get number of bytes of space available in this buffer More...
 
__forceinline bool isEmpty ()
 
__forceinline bool isFull ()
 
__forceinline int peekChar ()
 see if there's anything in the buffer More...
 
__forceinline int peekLastChar ()
 
__forceinline int readChar ()
 
__forceinline size_t writeChar (uint8_t c)
 
int find (uint8_t c)
 find a character in the buffer More...
 
size_t resize (size_t newSize)
 
void clear ()
 
__forceinline size_t getReadData (void *&data)
 Access data directly within buffer. More...
 
__forceinline void skipRead (size_t length)
 Skip a number of chars starting at the given read position. More...
 

Detailed Description

FIFO buffer used for both receive and transmit data.

Note
For receive operations, data is written via ISR and read via task For transmit operations, data is written via task and read via ISR Only routines marked with __forceinline or IRAM_ATTR may be called from interrupt context.

Member Function Documentation

__forceinline size_t SerialBuffer::available ( )
inline

get number of bytes stored in the buffer

Return values
size_t
int SerialBuffer::find ( uint8_t  c)

find a character in the buffer

Parameters
c
Return values
intposition relative to current read pointer, -1 if character not found
__forceinline size_t SerialBuffer::getFreeSpace ( )
inline

get number of bytes of space available in this buffer

Return values
size_t
__forceinline size_t SerialBuffer::getReadData ( void *&  data)
inline

Access data directly within buffer.

Parameters
void*&OUT: the data
Return values
size_tnumber of chars available
__forceinline int SerialBuffer::peekChar ( )
inline

see if there's anything in the buffer

Return values
intfirst available character, or -1 if buffer's empty
__forceinline void SerialBuffer::skipRead ( size_t  length)
inline

Skip a number of chars starting at the given read position.

Parameters
lengthMUST be <= value returned from peek()
Note
Provided for efficient buffer access