19 unsigned char*
ringfindChar(
unsigned char* bufPtr,
unsigned char* endPtr,
unsigned char character);
20 unsigned char*
ringfindChar2(
unsigned char* bufPtr,
unsigned char* endPtr,
unsigned char character1,
unsigned char character2);
32 rbuf->
endPtr = buf + bufSize;
89 if (numBytes >= bytesToEnd)
93 memcpy((
void *)rb->
wrPtr, (
void *)buf, bytesToEnd);
98 numBytes -= bytesToEnd;
104 memcpy((
void *)rb->
wrPtr, (
void *)buf, numBytes);
107 rb->
wrPtr += numBytes;
138 int bytesToRead, bytesRead1, bytesRead2;
143 if (len < bytesToRead)
152 bytesRead2 = (int)(bytesToRead - bytesRead1);
155 memcpy((
void *)buf, (
void *)rbuf->
rdPtr, bytesRead1);
156 memcpy((
void *)&buf[bytesRead1], (
void *)rbuf->
startPtr, bytesRead2);
164 memcpy(buf, (
void *)rbuf->
rdPtr, bytesToRead);
167 rbuf->
rdPtr += bytesToRead;
190 int bytesToRead, bytesRead1, bytesRead2;
193 if ((bytesToRead = bytesUsed) <= 0)
197 if (offset >= bytesUsed)
200 if (len < bytesToRead)
203 unsigned char *rdPtr = rbuf->
rdPtr + offset;
205 if (rdPtr >= rbuf->
endPtr) {
211 if (rdPtr > rbuf->
wrPtr && bytesToRead > rbuf->
endPtr - rdPtr)
214 bytesRead1 = (int)(rbuf->
endPtr - rdPtr);
215 bytesRead2 = (int)(bytesToRead - bytesRead1);
218 memcpy((
void *)buf, (
void *)rdPtr, bytesRead1);
219 memcpy((
void *)&buf[bytesRead1], (
void *)rbuf->
startPtr, bytesRead2);
224 memcpy(buf, (
void *)rdPtr, bytesToRead);
240 unsigned char*
ringfindChar(
unsigned char* bufPtr,
unsigned char* endPtr,
unsigned char character)
243 for (; bufPtr < endPtr; bufPtr++)
246 if (*bufPtr == character)
263 unsigned char*
ringfindChar2(
unsigned char* bufPtr,
unsigned char* endPtr,
unsigned char character1,
unsigned char character2)
266 for (; bufPtr < endPtr; bufPtr++)
269 if (*bufPtr == character1 || *bufPtr == character2)
308 int bytesToRead, bytesRead1, bytesRead2;
309 unsigned char* fndPtr;
314 if (len < bytesToRead)
329 bytesRead2 = (int)(bytesToRead - bytesRead1);
339 bytesRead2 = (int)(fndPtr - rbuf->
startPtr);
342 memcpy((
void *)buf, (
void *)rbuf->
rdPtr, bytesRead1);
343 memcpy((
void *)&buf[bytesRead1], (
void *)rbuf->
startPtr, bytesRead2);
348 return bytesRead1 + bytesRead2;
354 if ((fndPtr =
ringfindChar2(rbuf->
rdPtr, rbuf->
rdPtr + bytesToRead, character1, character2)) <= (
unsigned char*)0)
361 bytesToRead = (int)(fndPtr - rbuf->
rdPtr);
364 memcpy(buf, rbuf->
rdPtr, bytesToRead);
367 rbuf->
rdPtr += bytesToRead;
393 unsigned char *buf = (
unsigned char*)(rbuf->
rdPtr);
395 for (i = 0; i <
used; i++)
397 if (buf + len >= rbuf->
endPtr)
400 int len1 = (int)(buf + len - rbuf->
endPtr);
401 int len2 = len - len1;
403 if (!strncmp((
const char*)buf, (
const char*)str, len1) && !strncmp((
const char*)buf, (
const char*)rbuf->
startPtr, len2))
409 if (!strncmp((
const char*)buf, (
const char*)str, len))
441 if (len >= bytesToRemove)
446 return bytesToRemove;
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...
int ringBufUsed(const ring_buf_t *rbuf)
This function returns the number of bytes currently in ring buffer.
void ringBufInit(ring_buf_t *rbuf, unsigned char *buf, int bufSize, int wordByteSize)
Initialize ring buffer pointers.
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.
int ringBufClear(ring_buf_t *rbuf)
Clear the entire buffer.
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...
int ringBufRemove(ring_buf_t *rbuf, int len)
This function removes data from the ring buffer.
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.
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 m...
int ringBufRead(ring_buf_t *rbuf, unsigned char *buf, int len)
This function reads data from the ring buffer.
int ringBufWrite(ring_buf_t *rb, unsigned char *buf, int numBytes)
This function writes data to the ring buffer.
int ringBufEmpty(const ring_buf_t *rbuf)
This function returns 1 if the buffer is empty, 0 if not empty.
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 ...
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 foun...