Functions
ring_buffer.c File Reference
#include <string.h>
#include "ring_buffer.h"
Include dependency graph for ring_buffer.c:

Go to the source code of this file.

Functions

int ringBufClear (ring_buf_t *rbuf)
 Clear the entire buffer. More...
 
int ringBufEmpty (const ring_buf_t *rbuf)
 This function returns 1 if the buffer is empty, 0 if not empty. More...
 
int ringBufFind (const ring_buf_t *rbuf, const unsigned char *str, int len)
 This function finds the index of the first matching string in the ring buffer. Returns -1 if not found. More...
 
int ringBufFree (const ring_buf_t *rbuf)
 This function returns the number of bytes free in UART Rx buffer. Important: Buffer size is one less than init buffer size so pointers don't wrap. More...
 
void ringBufInit (ring_buf_t *rbuf, unsigned char *buf, int bufSize, int wordByteSize)
 Initialize ring buffer pointers. More...
 
int ringBufPeek (const ring_buf_t *rbuf, unsigned char *buf, int len, int offset)
 This function reads data from the ring buffer without removing any data. Same as ringBufPop without moving pointers. More...
 
int ringBufRead (ring_buf_t *rbuf, unsigned char *buf, int len)
 This function reads data from the ring buffer. More...
 
int ringBufReadToChar (ring_buf_t *rbuf, unsigned char *buf, int len, unsigned char character)
 This function returns everything up to and including the first occurrence of a character. If the character is not found, then nothing (zero) is returned. More...
 
int ringBufReadToChar2 (ring_buf_t *rbuf, unsigned char *buf, int len, unsigned char character1, unsigned char character2)
 This function returns everything up to and including the first occurrence of a character. If the character is not found, then nothing (zero) is returned. More...
 
int ringBufRemove (ring_buf_t *rbuf, int len)
 This function removes data from the ring buffer. More...
 
int ringBufUsed (const ring_buf_t *rbuf)
 This function returns the number of bytes currently in ring buffer. More...
 
int ringBufWrite (ring_buf_t *rb, unsigned char *buf, int numBytes)
 This function writes data to the ring buffer. More...
 
unsigned char * ringfindChar (unsigned char *bufPtr, unsigned char *endPtr, unsigned char character)
 This function returns a pointer to one past the first occurrence of the character in the string. More...
 
unsigned char * ringfindChar2 (unsigned char *bufPtr, unsigned char *endPtr, unsigned char character1, unsigned char character2)
 This function returns a pointer to one past the first occurrence of the character in the string. More...
 

Function Documentation

◆ ringBufClear()

int ringBufClear ( ring_buf_t rbuf)

Clear the entire buffer.

Returns
Number of bytes removed.

Definition at line 467 of file ring_buffer.c.

◆ ringBufEmpty()

int ringBufEmpty ( const ring_buf_t rbuf)

This function returns 1 if the buffer is empty, 0 if not empty.

Definition at line 481 of file ring_buffer.c.

◆ ringBufFind()

int ringBufFind ( const ring_buf_t rbuf,
const unsigned char *  str,
int  len 
)

This function finds the index of the first matching string in the ring buffer. Returns -1 if not found.

Parameters
rbufRing buffer struct pointer.
lenLength of data to attempt reading.
strCharacter string to search for.
Returns
Index of the first matching string. -1 if not found.

Definition at line 387 of file ring_buffer.c.

◆ ringBufFree()

int ringBufFree ( const ring_buf_t rbuf)

This function returns the number of bytes free in UART Rx buffer. Important: Buffer size is one less than init buffer size so pointers don't wrap.

Definition at line 61 of file ring_buffer.c.

◆ ringBufInit()

void ringBufInit ( ring_buf_t rbuf,
unsigned char *  buf,
int  bufSize,
int  wordByteSize 
)

Initialize ring buffer pointers.

Definition at line 29 of file ring_buffer.c.

◆ ringBufPeek()

int ringBufPeek ( const ring_buf_t rbuf,
unsigned char *  buf,
int  len,
int  offset 
)

This function reads data from the ring buffer without removing any data. Same as ringBufPop without moving pointers.

Parameters
rbufRing buffer struct pointer.
bufBuffer to copy data to.
lenLength of data to attempt reading.
Returns
Actual number of bytes read.

Definition at line 188 of file ring_buffer.c.

◆ ringBufRead()

int ringBufRead ( ring_buf_t rbuf,
unsigned char *  buf,
int  len 
)

This function reads data from the ring buffer.

Parameters
rbufRing buffer struct pointer.
bufBuffer to copy data to.
lenLength of data to attempt reading.
Returns
Actual number of bytes read.

Definition at line 136 of file ring_buffer.c.

◆ ringBufReadToChar()

int ringBufReadToChar ( ring_buf_t rbuf,
unsigned char *  buf,
int  len,
unsigned char  character 
)

This function returns everything up to and including the first occurrence of a character. If the character is not found, then nothing (zero) is returned.

Parameters
rbufRing buffer struct pointer.
bufBuffer to copy data to.
lenLength of data to attempt reading.
characterValue to search for.
Returns
Number of bytes read.

Definition at line 288 of file ring_buffer.c.

◆ ringBufReadToChar2()

int ringBufReadToChar2 ( ring_buf_t rbuf,
unsigned char *  buf,
int  len,
unsigned char  character1,
unsigned char  character2 
)

This function returns everything up to and including the first occurrence of a character. If the character is not found, then nothing (zero) is returned.

Parameters
rbufRing buffer struct pointer.
bufBuffer to copy data to.
lenLength of data to attempt reading.
character1Value to search for.
character2Value to search for.
Returns
Number of bytes read.

Definition at line 306 of file ring_buffer.c.

◆ ringBufRemove()

int ringBufRemove ( ring_buf_t rbuf,
int  len 
)

This function removes data from the ring buffer.

Parameters
rbufRing buffer struct pointer.
lenNumber of bytes to remove.
Returns
Actual number of bytes removed.

Definition at line 432 of file ring_buffer.c.

◆ ringBufUsed()

int ringBufUsed ( const ring_buf_t rbuf)

This function returns the number of bytes currently in ring buffer.

Definition at line 43 of file ring_buffer.c.

◆ ringBufWrite()

int ringBufWrite ( ring_buf_t rb,
unsigned char *  buf,
int  numBytes 
)

This function writes data to the ring buffer.

Parameters
rbufRing buffer struct pointer.
bufBuffer to copy data from.
lenLength of data to copy.
Returns
0 on success, 1 on overflow.

Definition at line 76 of file ring_buffer.c.

◆ ringfindChar()

unsigned char * ringfindChar ( unsigned char *  bufPtr,
unsigned char *  endPtr,
unsigned char  character 
)

This function returns a pointer to one past the first occurrence of the character in the string.

Parameters
bufPtrPointer to start of string.
endPtrPointer to one past end of string to be searched.
valValue to be located.
Returns
Pointer to one past the first occurrence of character in string. NULL if not found.

Definition at line 240 of file ring_buffer.c.

◆ ringfindChar2()

unsigned char * ringfindChar2 ( unsigned char *  bufPtr,
unsigned char *  endPtr,
unsigned char  character1,
unsigned char  character2 
)

This function returns a pointer to one past the first occurrence of the character in the string.

Parameters
bufPtrPointer to start of string.
endPtrPointer to one past end of string to be searched.
valValue to be located.
Returns
Pointer to one past the first occurrence of character in string. NULL if not found.

Definition at line 263 of file ring_buffer.c.



inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:06