7 #ifndef ZRTOS_CBUFFER_H 8 #define ZRTOS_CBUFFER_H 24 #ifndef ZRTOS_CBUFFER__CFG_DATA_LENGTH 25 #define ZRTOS_CBUFFER__CFG_DATA_LENGTH 16 28 #ifndef ZRTOS_CBUFFER__CFG_MALLOC_LIMIT 29 #define ZRTOS_CBUFFER__CFG_MALLOC_LIMIT 200 32 #ifdef ZRTOS_MALLOC__CFG_DISABLE_FREE 33 #error "ZRTOS_MALLOC__CFG_DISABLE_FREE not supported with cbuffer" 99 &zrtos_cbuffer__malloc_limit
248 ,
void (*callback)(
void *callback_args,
uint8_t ch)
255 while(node && length){
259 while(tail != head && length--){
260 callback(callback_args,node->
data[tail++]);
294 va_start(args,outlen);
300 data_len = va_arg(args,
size_t);
449 void zrtos_cbuffer_node__debug(
452 Serial.println(
"zrtos_cbuffer_node{");
453 Serial.println(
"head:");
454 Serial.print(thiz->
head);
455 Serial.println(
"tail:");
456 Serial.print(thiz->
tail);
457 Serial.println(
"data:[");
462 Serial.print(length);
464 Serial.print(thiz->
data[length],HEX);
465 Serial.println(
"],");
468 Serial.println(
"]}");
471 void zrtos_cbuffer__debug(
475 Serial.print(
"zrtos_cbuffer{");
477 zrtos_cbuffer_node__debug(node);
#define ZRTOS_CAST(type, value)
bool zrtos_cbuffer__is_empty(zrtos_cbuffer_t *thiz)
#define ZRTOS_CBUFFER__CFG_DATA_LENGTH
struct _zrtos_cbuffer_t zrtos_cbuffer_t
bool zrtos_cbuffer_node__init(zrtos_cbuffer_node_t *thiz, zrtos_cbuffer_t *ctx)
ZRTOS_ASSERT__STATIC_IS_POWER_OF_TWO(ZRTOS_CBUFFER__CFG_DATA_LENGTH)
void zrtos_cbuffer__rollback_write_transaction(zrtos_cbuffer_t *thiz, zrtos_cbuffer_write_transaction_t *txn)
void zrtos_list__delete(zrtos_list_t *thiz, zrtos_list_node_t *node)
zrtos_error_t zrtos_cbuffer__can_read(zrtos_cbuffer_t *thiz)
zrtos_error_t zrtos_cbuffer__get_ex(zrtos_cbuffer_t *thiz, void *data, size_t len, size_t *outlen)
zrtos_list_node_t * zrtos_list__get_last_node(zrtos_list_t *thiz)
zrtos_error_t zrtos_cbuffer__put(zrtos_cbuffer_t *thiz, uint8_t val)
zrtos_cbuffer_node_t * zrtos_cbuffer_node__new(zrtos_cbuffer_t *ctx)
bool zrtos_list_node__has_next_node(zrtos_list_node_t *node)
bool zrtos_list__init(zrtos_list_t *thiz)
void zrtos_cbuffer__deinit(zrtos_cbuffer_t *thiz)
void zrtos_malloc_limit__free(zrtos_malloc_limit_t *thiz, void *ptr)
zrtos_error_t zrtos_cbuffer__get(zrtos_cbuffer_t *thiz, uint8_t *out)
zrtos_malloc_limit_t zrtos_cbuffer__malloc_limit
zrtos_list_node_t * zrtos_list__get_first_node(zrtos_list_t *thiz)
zrtos_list_node_t * zrtos_list_node__get_next_node(zrtos_list_node_t *node)
#define zrtos_types__get_container_of(ptr, type, member)
#define ZRTOS_MALLOC_LIMIT__INIT()
bool zrtos_error__is_error(zrtos_error_t thiz)
bool zrtos_list_node__init(zrtos_list_node_t *thiz)
#define ZRTOS_CBUFFER__CFG_MALLOC_LIMIT
zrtos_error_t zrtos_cbuffer__pop(zrtos_cbuffer_t *thiz)
bool zrtos_list__push(zrtos_list_t *thiz, zrtos_list_node_t *node)
zrtos_cbuffer_node_t * zrtos_cbuffer__get_first_node(zrtos_cbuffer_t *thiz)
struct _zrtos_cbuffer_node_t zrtos_cbuffer_node_t
void zrtos_cbuffer__start_write_transaction(zrtos_cbuffer_t *thiz, zrtos_cbuffer_write_transaction_t *txn)
zrtos_error_t zrtos_cbuffer__peek(zrtos_cbuffer_t *thiz, uint8_t *out)
bool zrtos_error__is_success(zrtos_error_t thiz)
#define ZRTOS_TYPES__MIN(a, b)
zrtos_error_t zrtos_cbuffer_node__get(zrtos_cbuffer_node_t *thiz, zrtos_cbuffer_t *ctx, uint8_t *out)
size_t zrtos_cbuffer__get_length(zrtos_cbuffer_t *thiz)
size_t zrtos_types__ptr_get_byte_distance(void *bigger, void *smaller)
Successful program execution status.
void zrtos_cbuffer__deinit_callback(zrtos_list_t *thiz, zrtos_list_node_t *node)
static size_t zrtos_cbuffer_node__get_free_space(zrtos_cbuffer_node_t *thiz)
struct _zrtos_cbuffer_write_transaction_t zrtos_cbuffer_write_transaction_t
bool zrtos_cbuffer_node__is_empty(zrtos_cbuffer_node_t *thiz)
uint8_t data[ZRTOS_CBUFFER__CFG_DATA_LENGTH]
bool zrtos_cbuffer__can_read_length(zrtos_cbuffer_t *thiz, size_t length)
zrtos_cbuffer_node_t * zrtos_cbuffer__get_last_node(zrtos_cbuffer_t *thiz)
zrtos_error_t zrtos_cbuffer_node__put(zrtos_cbuffer_node_t *thiz, zrtos_cbuffer_t *ctx, uint8_t val)
void * zrtos_malloc_limit__malloc(zrtos_malloc_limit_t *thiz, size_t length, size_t limit)
zrtos_cbuffer_node_t * zrtos_cbuffer_node__get_next_node(zrtos_cbuffer_node_t *thiz)
zrtos_error_t zrtos_cbuffer__put_ex(zrtos_cbuffer_t *thiz, size_t len, size_t *outlen,...)
bool zrtos_cbuffer__init(zrtos_cbuffer_t *thiz)
void zrtos_cbuffer_node__free(zrtos_cbuffer_node_t *thiz, zrtos_cbuffer_t *ctx)
void zrtos_cbuffer__clear(zrtos_cbuffer_t *thiz)
zrtos_error_t zrtos_cbuffer__can_write(zrtos_cbuffer_t *thiz)
static size_t zrtos_cbuffer_node__get_length(zrtos_cbuffer_node_t *thiz)
void zrtos_list__deinit(zrtos_list_t *thiz, void(*callback)(zrtos_list_t *thiz, zrtos_list_node_t *node))
zrtos_error_t zrtos_cbuffer_node__peek(zrtos_cbuffer_node_t *thiz, uint8_t *out)
zrtos_error_t zrtos_cbuffer__pipe(zrtos_cbuffer_t *thiz, zrtos_cbuffer_t *src, size_t length, size_t *outlen)
zrtos_error_t zrtos_cbuffer__hash(zrtos_cbuffer_t *thiz, size_t length, void(*callback)(void *callback_args, uint8_t ch), void *callback_args)