dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Circular Byte-Buffer Structure and Function Library (buffer.c)

Classes

struct  struct_cBuffer
 cBuffer structure More...
 

Typedefs

typedef struct struct_cBuffer cBuffer
 cBuffer structure More...
 

Functions

void bufferInit (cBuffer *buffer, unsigned char *start, unsigned short size)
 initialize a buffer to start at a given address and have given size More...
 
unsigned char bufferGetFromFront (cBuffer *buffer)
 get the first byte from the front of the buffer More...
 
void bufferDumpFromFront (cBuffer *buffer, unsigned short numbytes)
 dump (discard) the first numbytes from the front of the buffer More...
 
unsigned char bufferGetAtIndex (cBuffer *buffer, unsigned short index)
 get a byte at the specified index in the buffer (kind of like array access) More...
 
unsigned char bufferAddToEnd (cBuffer *buffer, unsigned char data)
 add a byte to the end of the buffer More...
 
unsigned char bufferIsNotFull (cBuffer *buffer)
 check if the buffer is full/not full (returns non-zero value if not full) More...
 
void bufferFlush (cBuffer *buffer)
 flush (clear) the contents of the buffer More...
 

Detailed Description

#include "buffer.h"
Overview
This byte-buffer structure provides an easy and efficient way to store and process a stream of bytes.  You can create as many buffers as you like (within memory limits), and then use this common set of functions to access each buffer.  The buffers are designed for FIFO operation (first in, first out).  This means that the first byte you put in the buffer will be the first one you get when you read out the buffer.  Supported functions include buffer initialize, get byte from front of buffer, add byte to end of buffer, check if buffer is full, and flush buffer.  The buffer uses a circular design so no copying of data is ever necessary. This buffer is not dynamically allocated, it has a user-defined fixed maximum size.  This buffer is used in many places in the avrlib code.

Typedef Documentation

typedef struct struct_cBuffer cBuffer

cBuffer structure

Function Documentation

unsigned char bufferAddToEnd ( cBuffer buffer,
unsigned char  data 
)

add a byte to the end of the buffer

Definition at line 105 of file buffer.cpp.

void bufferDumpFromFront ( cBuffer buffer,
unsigned short  numbytes 
)

dump (discard) the first numbytes from the front of the buffer

Definition at line 82 of file buffer.cpp.

void bufferFlush ( cBuffer buffer)

flush (clear) the contents of the buffer

Definition at line 126 of file buffer.cpp.

unsigned char bufferGetAtIndex ( cBuffer buffer,
unsigned short  index 
)

get a byte at the specified index in the buffer (kind of like array access)

Definition at line 99 of file buffer.cpp.

unsigned char bufferGetFromFront ( cBuffer buffer)

get the first byte from the front of the buffer

Definition at line 63 of file buffer.cpp.

void bufferInit ( cBuffer buffer,
unsigned char *  start,
unsigned short  size 
)

initialize a buffer to start at a given address and have given size

Definition at line 52 of file buffer.cpp.

unsigned char bufferIsNotFull ( cBuffer buffer)

check if the buffer is full/not full (returns non-zero value if not full)

Definition at line 119 of file buffer.cpp.