|
|
@ -31,7 +31,10 @@ bool cbuf_write(CircularBuffer *inst, uint8_t b); |
|
|
|
bool cbuf_read(CircularBuffer *inst, uint8_t *b); |
|
|
|
bool cbuf_read(CircularBuffer *inst, uint8_t *b); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Get byte at the read cursor, without incrementing it. False on empty. */ |
|
|
|
/**
|
|
|
|
|
|
|
|
* Get byte at the read cursor, without incrementing it. |
|
|
|
|
|
|
|
* False on empty. |
|
|
|
|
|
|
|
*/ |
|
|
|
bool cbuf_peek(CircularBuffer *inst, uint8_t *b); |
|
|
|
bool cbuf_peek(CircularBuffer *inst, uint8_t *b); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,28 +50,42 @@ uint16_t cbuf_free_space(CircularBuffer *inst); |
|
|
|
void cbuf_clear(CircularBuffer *inst); |
|
|
|
void cbuf_clear(CircularBuffer *inst); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Write N bytes. Returns success */ |
|
|
|
/** Write N bytes, or none. Returns success */ |
|
|
|
bool cbuf_write_n(CircularBuffer *inst, const uint8_t *b, uint16_t count); |
|
|
|
bool cbuf_write_n(CircularBuffer *inst, const uint8_t *b, uint16_t count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Write a string (without \0) */ |
|
|
|
/** Try to write N bytes. Returns actual number of bytes written. */ |
|
|
|
|
|
|
|
uint16_t cbuf_write_partial(CircularBuffer *inst, const uint8_t *b, uint16_t max); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Write a string (excluding \0) - or nothing. */ |
|
|
|
bool cbuf_write_string(CircularBuffer *inst, const char *str); |
|
|
|
bool cbuf_write_string(CircularBuffer *inst, const char *str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Read N bytes, if available. Returns success. */ |
|
|
|
/**
|
|
|
|
bool cbuf_read_n(CircularBuffer *inst, uint8_t *buf, uint16_t len); |
|
|
|
* Try to write string (excluding \0). |
|
|
|
|
|
|
|
* Returns actual number of chars written. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
uint16_t cbuf_write_string_partial(CircularBuffer *inst, const char *str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Read string of given length, append \0. `str` must be len+1 long */ |
|
|
|
/** Read N bytes, or none. Returns success. */ |
|
|
|
bool cbuf_read_string(CircularBuffer *inst, char *str, uint16_t len); |
|
|
|
bool cbuf_read_n(CircularBuffer *inst, uint8_t *buf, uint16_t len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Read up to N bytes. Returns byte count */ |
|
|
|
/** Read up to N bytes. Returns byte count */ |
|
|
|
uint16_t cbuf_read_upto(CircularBuffer *inst, uint8_t *buf, uint16_t max); |
|
|
|
uint16_t cbuf_read_partial(CircularBuffer *inst, uint8_t *buf, uint16_t max); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Read string of given length, append \0. `str` must be len+1 long */ |
|
|
|
|
|
|
|
bool cbuf_read_string(CircularBuffer *inst, char *str, uint16_t len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Read string up to N chars long, append \0. `str` must be max+1 long */ |
|
|
|
/**
|
|
|
|
uint16_t cbuf_read_string_upto(CircularBuffer *inst, char *str, uint16_t max); |
|
|
|
* Read string up to N chars long, append \0. |
|
|
|
|
|
|
|
* `str` must be max+1 long |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
uint16_t cbuf_read_string_partial(CircularBuffer *inst, char *str, uint16_t max); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|