dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
buffer.h
Go to the documentation of this file.
1 
15 //*****************************************************************************
16 //
17 // File Name : 'buffer.h'
18 // Title : Multipurpose byte buffer structure and methods
19 // Author : Pascal Stang - Copyright (C) 2001-2002
20 // Created : 9/23/2001
21 // Revised : 11/16/2002
22 // Version : 1.1
23 // Target MCU : any
24 // Editor Tabs : 4
25 //
41 //
42 // This code is distributed under the GNU Public License
43 // which can be found at http://www.gnu.org/licenses/gpl.txt
44 //
45 //*****************************************************************************
47 
48 #ifndef BUFFER_HPP
49 #define BUFFER_HPP
50 
51 // structure/typdefs
52 
54 typedef struct struct_cBuffer
55 {
56  unsigned char *dataptr;
57  unsigned short size;
58  unsigned short datalength;
59  unsigned short dataindex;
60 } cBuffer;
61 
62 // function prototypes
63 
65 void bufferInit(cBuffer *buffer, unsigned char *start, unsigned short size);
66 
68 unsigned char bufferGetFromFront(cBuffer *buffer);
69 
71 void bufferDumpFromFront(cBuffer *buffer, unsigned short numbytes);
72 
74 // ** note: this does not remove the byte that was read from the buffer
75 unsigned char bufferGetAtIndex(cBuffer *buffer, unsigned short index);
76 
78 unsigned char bufferAddToEnd(cBuffer *buffer, unsigned char data);
79 
81 unsigned char bufferIsNotFull(cBuffer *buffer);
82 
85 
86 #endif
87 
unsigned short datalength
the length of the data currently in the buffer
Definition: buffer.h:58
struct struct_cBuffer cBuffer
cBuffer structure
unsigned short dataindex
the index into the buffer where the data starts
Definition: buffer.h:59
void bufferInit(cBuffer *buffer, unsigned char *start, unsigned short size)
initialize a buffer to start at a given address and have given size
Definition: buffer.cpp:52
end buffer
unsigned char * dataptr
the physical memory address where the buffer is stored
Definition: buffer.h:56
void bufferDumpFromFront(cBuffer *buffer, unsigned short numbytes)
dump (discard) the first numbytes from the front of the buffer
Definition: buffer.cpp:82
DataFields data
unsigned char bufferGetFromFront(cBuffer *buffer)
get the first byte from the front of the buffer
Definition: buffer.cpp:63
void bufferFlush(cBuffer *buffer)
flush (clear) the contents of the buffer
Definition: buffer.cpp:126
unsigned short size
the allocated size of the buffer
Definition: buffer.h:57
unsigned char bufferGetAtIndex(cBuffer *buffer, unsigned short index)
get a byte at the specified index in the buffer (kind of like array access)
Definition: buffer.cpp:99
cBuffer structure
Definition: buffer.h:54
unsigned char bufferAddToEnd(cBuffer *buffer, unsigned char data)
add a byte to the end of the buffer
Definition: buffer.cpp:105
unsigned char bufferIsNotFull(cBuffer *buffer)
check if the buffer is full/not full (returns non-zero value if not full)
Definition: buffer.cpp:119