CHG ringbuffer delimiter to \r

This commit is contained in:
Thomas Kuschel 2024-10-26 23:24:45 +02:00
parent 5e863be2e3
commit 98ae8535af
3 changed files with 6 additions and 2 deletions

View File

@ -26,7 +26,7 @@ extern "C" {
#define STR(x) STR_HELPER(x) #define STR(x) STR_HELPER(x)
#endif #endif
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 5 #define VERSION_MINOR 6
#ifdef DEBUG #ifdef DEBUG
#define VERSION_DEBUG ".D" #define VERSION_DEBUG ".D"
#else #else

View File

@ -8,6 +8,10 @@
#ifndef _INC_RINGBUF_H_ #ifndef _INC_RINGBUF_H_
#define _INC_RINGBUF_H_ #define _INC_RINGBUF_H_
/* Defines */
/* <ENTER> given, was \n, should be \r */
#define RINGBUF_DELIMITER '\r'
#define RING_STATISTICS_ENABLED 1 #define RING_STATISTICS_ENABLED 1
#define RINGBUF_MAX_READ_LEN 80 #define RINGBUF_MAX_READ_LEN 80

View File

@ -135,7 +135,7 @@ int ringbuf_push(struct ringbuf *ring, const uint8_t *data, size_t size) {
ring->head += (uint16_t)size; ring->head += (uint16_t)size;
} }
for (delimiterpos = 0; delimiterpos < size; delimiterpos++) { for (delimiterpos = 0; delimiterpos < size; delimiterpos++) {
if (data[delimiterpos] == '\n' || data[delimiterpos] == 0 ) { if (data[delimiterpos] == RINGBUF_DELIMITER || data[delimiterpos] == 0 ) {
delimiterfound++; delimiterfound++;
ptr = ring->buf + ((head + delimiterpos) % ring->size); ptr = ring->buf + ((head + delimiterpos) % ring->size);
*ptr = 0; *ptr = 0;