# SFBTxByteBuffer Class Reference

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...

`#include <SFBByteBuffer.h>`

Inheritance diagram for SFBTxByteBuffer:

[legend]
Collaboration diagram for SFBTxByteBuffer:

[legend]

## Public Member Functions
| SFBTxByteBuffer (u8(&buffer)[BYTE_BUFFER_BYTES])
void | resetBG ()
| Called in background to reset a tx buffer.
void | storeByteBG (u8 data)
| Called in background to store a byte at new end of tx buf, if possible.
bool | canStoreBytesBG (u32 count)
| Called in background to check if count more bytes can be stored at new end of tx buf, without a buffer overrun.
bool | shipBytesBG ()
| Called in background to either start the transmission of, or discard, all bytes stored via storeByteBG since the last call on shipBytesBG or resetBG.
int | fetchByteIL ()
| Called at interrupt level to fetch next byte from old end of tx buf, if any.

## Detailed Description

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).

An SFBTxByteBuffer promises to BG that its spaceAvailable() will never decrease during IL processing. So if BG observes that spaceAvailable() is large enough to do something (e.g., store one byte), BG can then go ahead and perform that action without locking or disabling interrupts.

## Member Function Documentation

int SFBTxByteBuffer::fetchByteIL | ( |  | ) |

Called at interrupt level to fetch next byte from old end of tx buf, if any.

Returns -1 if no bytes available.

bool SFBTxByteBuffer::shipBytesBG | ( |  | ) |

Called in background to either start the transmission of, or discard, all bytes stored via storeByteBG since the last call on shipBytesBG or resetBG.

If the buffer overflowed during one or more of those storeByteBG calls, then all pending bytes will be discarded, otherwise all pending bytes will be released for transmission.

Returns:
  `true` if all pending bytes were released for transmission, and `false` if all pending bytes were discarded.

void SFBTxByteBuffer::storeByteBG | ( | u8 | data | ) |

Called in background to store a byte at new end of tx buf, if possible.

Note that bytes stored in this manner will not actually ship until the next shipBytesBG call.

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

- src/include/SFBByteBuffer.h
- src/components/library/SFBByteBuffer.cpp