# SFBByteBuffer.h File Reference

Support circular byte buffering between UART interrupt level and background packet dispatching. More...

`#include "SFBTypes.h"`
`#include "SFBConstants.h"`

Include dependency graph for SFBByteBuffer.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
class | SFBByteBuffer
| Base class providing services common to SFBRxByteBuffer and SFBTxByteBuffer. More...
class | SFBRxByteBuffer
| A specialized SFBByteBuffer that handles asynchronous data reception, i.e., data is added to the buffer at interrupt level (IL), and removed from the buffer in the background process (BG). More...
class | SFBTxByteBuffer
| A specialized SFBByteBuffer that handles asynchronous data transmission, i.e., data is added to the buffer in the background process (BG), and removed from the buffer at interrupt level (IL). More...

## Detailed Description

Support circular byte buffering between UART interrupt level and background packet dispatching.

The main goals of this code are:

1. To provide fast basic buffer functionality, including O(1) store and fetch
2. To provide limited advanced buffer functionality, specifically:
   - On the inbound/rx side, deliver H/W error and buffer overflow status reports in order of occurrence with respect to delivered data bytes; and
   - On the outbound/tx side, accept data from background processing one byte at a time, but defer shipping any of them until they are 'committed' by background processing, to support all-or-none shipment of blocked data (a.k.a. 'packets') regardless of potential buffer overflows.
3. To be as simple and auditable as possible consistent with those functions, to make it easier to avoid races between interrupt and background processing; but also
4. To leave interrupts enabled during all frequently-used background buffer accesses.

Note that, except for the tx side 'commit' concept, SFBByteBuffer does not deal with packet framing or deframing; it simply buffers a stream of uninterpreted data bytes (with interleaved status information where needed). So received packets must be deframed by background processing as bytes are removed from an SFBRxByteBuffer, and bytes must be packet framed by background process as bytes are stored in an SFBTxByteBuffer.

Author:
  David H. Ackley.

Date:
  (C) 2009 All rights reserved.

Code License:
  The GNU Lesser General Public License

License Note:
  All code samples shown in documentation are placed into the public domain.