Developer World
Spresense SDK Library v3.2.0-ebc0364
Library for Ring Buffer

Files

file  ringbuffer.h
 

Classes

struct  ringbuf_s
 

Macros

#define EXTERN   extern "C"
 

Functions

FAR struct ringbuf_sringbuf_new (size_t size)
 
void ringbuf_free (FAR struct ringbuf_s *rb)
 
ssize_t ringbuf_read (FAR struct ringbuf_s *rb, FAR void *buf, size_t count)
 
ssize_t ringbuf_write (FAR struct ringbuf_s *rb, FAR void *buf, size_t count)
 
size_t ringbuf_buffersize (FAR struct ringbuf_s *rb)
 
size_t ringbuf_bytesused (FAR struct ringbuf_s *rb)
 
size_t ringbuf_bytesavail (FAR struct ringbuf_s *rb)
 

Detailed Description

Function Documentation

◆ ringbuf_new()

FAR struct ringbuf_s * ringbuf_new ( size_t  size)

Allocates a new Ring Buffer.

Parameters
[in]sizeSize of Ring Buffer to allocate.
Returns
On success, the allocated Ring Buffer is returned. On failure, NULL is returned.

◆ ringbuf_free()

void ringbuf_free ( FAR struct ringbuf_s rb)

Release a Ring Buffer.

Parameters
[in]rbPointer to a Ring Buffer to release.

◆ ringbuf_read()

ssize_t ringbuf_read ( FAR struct ringbuf_s rb,
FAR void *  buf,
size_t  count 
)

Read from a Ring Buffer.

Parameters
[in]rbPointer to a Ring Buffer to read.
[in]bufPointer to buffer to store data that read from a Ring Buffer.
[in]countBytes to read.
Returns
On success, The number of bytes read. On failure, negative value is returned according to <errno.h>.

◆ ringbuf_write()

ssize_t ringbuf_write ( FAR struct ringbuf_s rb,
FAR void *  buf,
size_t  count 
)

Write to a Ring Buffer.

Parameters
[in]rbPointer to a Ring Buffer to write.
[in]bufPointer to buffer to stored data that write to a Ring Buffer.
[in]countBytes to write.
Returns
On success, The number of bytes written. On failure, negative value is returned according to <errno.h>.

◆ ringbuf_buffersize()

size_t ringbuf_buffersize ( FAR struct ringbuf_s rb)

Gets the buffer size.

Parameters
[in]rbPointer to a Ring Buffer.
Returns
The buffer size.

◆ ringbuf_bytesused()

size_t ringbuf_bytesused ( FAR struct ringbuf_s rb)

Gets the number of bytes used.

Parameters
[in]rbPointer to a Ring Buffer.
Returns
The number of bytes used.

◆ ringbuf_bytesavail()

size_t ringbuf_bytesavail ( FAR struct ringbuf_s rb)

Gets the number of bytes free.

Parameters
[in]rbPointer to a Ring Buffer.
Returns
The number of bytes free.