IntrOS
Loading...
Searching...
No Matches
Raw buffer

raw buffers (streams of bytes) More...

Macros

#define OS_RAW_BUFFER(buf, limit, ...)
 define raw data buffer
#define OS_RAW(raw, limit, ...)
 define and initialize a raw buffer object
#define static_RAW(raw, limit, ...)
 static alias of OS_RAW()
#define RAW_INIT(limit, ...)
 create and initialize a raw buffer object
#define RAW_CREATE(limit, ...)
 create and initialize a raw buffer object
#define RAW_NEW   RAW_CREATE
 alias of RAW_CREATE()

Functions

void raw_init (raw_t *raw, void *data, size_t bufsize)
 initialize a raw buffer object
void raw_reset (raw_t *raw)
 reset the raw buffer object and wake up all waiting tasks with 'E_STOPPED' event value
void raw_kill (raw_t *raw)
 alias of raw_reset()
int raw_take (raw_t *raw, void *data, size_t size, size_t *read)
 try to transfer data from the raw buffer object, don't wait if the raw buffer object is empty
int raw_tryWait (raw_t *raw, void *data, size_t size, size_t *read)
 alias of raw_take()
int raw_waitFor (raw_t *raw, void *data, size_t size, size_t *read, cnt_t delay)
 try to transfer data from the raw buffer object, wait for given duration of time while the raw buffer object is empty
int raw_waitUntil (raw_t *raw, void *data, size_t size, size_t *read, cnt_t time)
 try to transfer data from the raw buffer object, wait until given timepoint while the raw buffer object is empty
int raw_wait (raw_t *raw, void *data, size_t size, size_t *read)
 try to transfer data from the raw buffer object, wait indefinitely while the raw buffer object is empty
int raw_give (raw_t *raw, const void *data, size_t size)
 try to transfer data to the raw buffer object, don't wait if the raw buffer object is full
int raw_sendFor (raw_t *raw, const void *data, size_t size, cnt_t delay)
 try to transfer data to the raw buffer object, wait for given duration of time while the raw buffer object is full
int raw_sendUntil (raw_t *raw, const void *data, size_t size, cnt_t time)
 try to transfer data to the raw buffer object, wait until given timepoint while the raw buffer object is full
int raw_send (raw_t *raw, const void *data, size_t size)
 try to transfer data to the raw buffer object, wait indefinitely while the raw buffer object is full
int raw_push (raw_t *raw, const void *data, size_t size)
 try to transfer data to the raw buffer object, remove the oldest data if the raw buffer object is full
size_t raw_count (raw_t *raw)
 return the amount of data contained in the raw buffer
size_t raw_space (raw_t *raw)
 return the amount of free space in the raw buffer
size_t raw_limit (raw_t *raw)
 return the size of the raw buffer

Detailed Description

raw buffers (streams of bytes)

Macro Definition Documentation

◆ OS_RAW_BUFFER

#define OS_RAW_BUFFER ( buf,
limit,
... )
Value:
char buf[_VA_RAW(limit, __VA_ARGS__)]

define raw data buffer

Parameters
bufname of the buffer (passed to the init function)
limitsize of a buffer (max number of stored bytes / objects)
...size: (optional) size of the object (in bytes); default: 1

◆ OS_RAW

#define OS_RAW ( raw,
limit,
... )
Value:
static char raw##__buf[_VA_RAW(limit, __VA_ARGS__)]; \
raw_t raw[] = { _RAW_INIT( _VA_RAW(limit, __VA_ARGS__), raw##__buf ) }

define and initialize a raw buffer object

Parameters
rawname of a pointer to raw buffer object
limitsize of a buffer (max number of stored bytes / objects)
...size: (optional) size of the object (in bytes); default: 1

◆ static_RAW

#define static_RAW ( raw,
limit,
... )
Value:
static char raw##__buf[_VA_RAW(limit, __VA_ARGS__)]; \
static raw_t raw[] = { _RAW_INIT( _VA_RAW(limit, __VA_ARGS__), raw##__buf ) }

static alias of OS_RAW()

◆ RAW_INIT

#define RAW_INIT ( limit,
... )
Value:
_RAW_INIT( _VA_RAW(limit, __VA_ARGS__), _RAW_DATA( _VA_RAW(limit, __VA_ARGS__) ) )

create and initialize a raw buffer object

Parameters
limitsize of a buffer (max number of stored bytes / objects)
...type: (optional) size of the object (in bytes); default: 1
Returns
raw buffer object
Note
use only in 'C' code

◆ RAW_CREATE

#define RAW_CREATE ( limit,
... )
Value:
{ RAW_INIT ( _VA_RAW(limit, __VA_ARGS__) ) }
#define RAW_INIT(limit,...)
create and initialize a raw buffer object
Definition osrawbuffer.h:152

create and initialize a raw buffer object

Parameters
limitsize of a buffer (max number of stored bytes / objects)
...type: (optional) size of the object (in bytes); default: 1
Returns
raw buffer object as array (id)
Note
use only in 'C' code

Function Documentation

◆ raw_init()

void raw_init ( raw_t * raw,
void * data,
size_t bufsize )

initialize a raw buffer object

Parameters
rawpointer to raw buffer object
dataraw buffer data
bufsizesize of the data buffer (in bytes)

◆ raw_reset()

void raw_reset ( raw_t * raw)

reset the raw buffer object and wake up all waiting tasks with 'E_STOPPED' event value

Parameters
rawpointer to raw buffer object
Note
use only in thread mode

◆ raw_take()

int raw_take ( raw_t * raw,
void * data,
size_t size,
size_t * read )

try to transfer data from the raw buffer object, don't wait if the raw buffer object is empty

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
readpointer to the variable getting number of read bytes
Return values
E_SUCCESSvariable 'read' contains the number of bytes read from the raw buffer
E_TIMEOUTraw buffer object is empty, try again

◆ raw_waitFor()

int raw_waitFor ( raw_t * raw,
void * data,
size_t size,
size_t * read,
cnt_t delay )

try to transfer data from the raw buffer object, wait for given duration of time while the raw buffer object is empty

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
readpointer to the variable getting number of read bytes
delayduration of time (maximum number of ticks to wait while the raw buffer object is empty)
  • IMMEDIATE: don't wait if the raw buffer object is empty
  • INFINITE: wait indefinitely while the raw buffer object is empty
Return values
E_SUCCESSvariable 'read' contains the number of bytes read from the raw buffer
E_STOPPEDraw buffer object was reseted before the specified timeout expired
E_TIMEOUTraw buffer object is empty and was not received data before the specified timeout expired

◆ raw_waitUntil()

int raw_waitUntil ( raw_t * raw,
void * data,
size_t size,
size_t * read,
cnt_t time )

try to transfer data from the raw buffer object, wait until given timepoint while the raw buffer object is empty

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
readpointer to the variable getting number of read bytes
timetimepoint value
Return values
E_SUCCESSvariable 'read' contains the number of bytes read from the raw buffer
E_STOPPEDraw buffer object was reseted before the specified timeout expired
E_TIMEOUTraw buffer object is empty and was not received data before the specified timeout expired

◆ raw_wait()

int raw_wait ( raw_t * raw,
void * data,
size_t size,
size_t * read )
inline

try to transfer data from the raw buffer object, wait indefinitely while the raw buffer object is empty

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
readpointer to the variable getting number of read bytes
Return values
E_SUCCESSvariable 'read' contains the number of bytes read from the raw buffer
E_STOPPEDraw buffer object was reseted

◆ raw_give()

int raw_give ( raw_t * raw,
const void * data,
size_t size )

try to transfer data to the raw buffer object, don't wait if the raw buffer object is full

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
Return values
E_SUCCESSdata was successfully transferred to the raw buffer object
E_FAILUREsize of the data is out of the limit
E_TIMEOUTnot enough space in the raw buffer, try again

◆ raw_sendFor()

int raw_sendFor ( raw_t * raw,
const void * data,
size_t size,
cnt_t delay )

try to transfer data to the raw buffer object, wait for given duration of time while the raw buffer object is full

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
delayduration of time (maximum number of ticks to wait while the raw buffer object is full)
  • IMMEDIATE: don't wait if the raw buffer object is full
  • INFINITE: wait indefinitely while the raw buffer object is full
Return values
E_SUCCESSdata was successfully transferred to the raw buffer object
E_FAILUREsize of the data is out of the limit
E_STOPPEDraw buffer object was reseted before the specified timeout expired
E_TIMEOUTraw buffer object is full and was not issued data before the specified timeout expired

◆ raw_sendUntil()

int raw_sendUntil ( raw_t * raw,
const void * data,
size_t size,
cnt_t time )

try to transfer data to the raw buffer object, wait until given timepoint while the raw buffer object is full

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
timetimepoint value
Return values
E_SUCCESSdata was successfully transferred to the raw buffer object
E_FAILUREsize of the data is out of the limit
E_STOPPEDraw buffer object was reseted before the specified timeout expired
E_TIMEOUTraw buffer object is full and was not issued data before the specified timeout expired

◆ raw_send()

int raw_send ( raw_t * raw,
const void * data,
size_t size )
inline

try to transfer data to the raw buffer object, wait indefinitely while the raw buffer object is full

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
Return values
E_SUCCESSdata was successfully transferred to the raw buffer object
E_FAILUREsize of the data is out of the limit
E_STOPPEDraw buffer object was reseted

◆ raw_push()

int raw_push ( raw_t * raw,
const void * data,
size_t size )

try to transfer data to the raw buffer object, remove the oldest data if the raw buffer object is full

Parameters
rawpointer to raw buffer object
datapointer to the buffer
sizesize of the buffer
Return values
E_SUCCESSdata was successfully transferred to the raw buffer object
E_FAILUREsize of the data is out of the limit

◆ raw_count()

size_t raw_count ( raw_t * raw)

return the amount of data contained in the raw buffer

Parameters
rawpointer to raw buffer object
Returns
amount of data contained in the raw buffer

◆ raw_space()

size_t raw_space ( raw_t * raw)

return the amount of free space in the raw buffer

Parameters
rawpointer to raw buffer object
Returns
amount of free space in the raw buffer

◆ raw_limit()

size_t raw_limit ( raw_t * raw)

return the size of the raw buffer

Parameters
rawpointer to raw buffer object
Returns
size of the raw buffer