35#ifndef STREAMBUFFER_CPP_H
36#define STREAMBUFFER_CPP_H
40#include "stream_buffer.h"
42#if FREERTOSCPP_USE_NAMESPACE
58 size_t send(
const void* data,
size_t len, TickType_t delay = portMAX_DELAY)
59 {
return xStreamBufferSend(streamHandle, data, len, delay);}
60#if FREERTOSCPP_USE_CHRONO
61 size_t send(
const void* data,
size_t len, Time_ms delay)
62 {
return xStreamBufferSend(streamHandle, data, len, ms2ticks(delay));}
64 size_t send_ISR(
const void* data,
size_t len, BaseType_t &wasWoken)
65 {
return xStreamBufferSendFromISR(streamHandle, data, len, &wasWoken);}
67 size_t read(
void* data,
size_t len, TickType_t delay = portMAX_DELAY)
68 {
return xStreamBufferReceive(streamHandle, data, len, delay);}
69#if FREERTOSCPP_USE_CHRONO
70 size_t read(
void* data,
size_t len, Time_ms delay)
71 {
return xStreamBufferReceive(streamHandle, data, len, ms2ticks(delay));}
73 size_t read_ISR(
void* data,
size_t len, BaseType_t &wasWoken)
74 {
return xStreamBufferReceiveFromISR(streamHandle, data, len, &wasWoken);}
78 size_t waiting()
const {
return xStreamBufferBytesAvailable(streamHandle);}
82 size_t available()
const {
return xStreamBufferSpacesAvailable(streamHandle);}
84 bool isEmpty()
const {
return xStreamBufferIsEmpty(streamHandle);}
86 bool isFull()
const {
return xStreamBufferIsFull(streamHandle);}
90 bool reset() {
return xStreamBufferReset(streamHandle);}
95 bool trigger(
size_t trigger) {
return xStreamBufferSetTriggerLevel(streamHandle, trigger);}
106#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
114#if( configSUPPORT_STATIC_ALLOCATION == 1 )
115 xStreamBufferCreateStatic(size, trigger, storage, streamBuff)
117 xStreamBufferCreate(size, trigger)
122#if configUSE_SB_COMPLETED_CALLBACK
123 StreamBuffer(
size_t trigger, StreamBufferCallbackFunction_t sendCallback, StreamBufferCallbackFunction_t recvCallback) :
125#if( configSUPPORT_STATIC_ALLOCATION == 1 )
126 xStreamBufferCreateStaticWithCallback(size, trigger, storage, streamBuff, sendCallback, recvCallback)
128 xStreamBufferCreateWithCallback(size, trigger, sendCallback. recvCallBack)
134#if( configSUPPORT_STATIC_ALLOCATION == 1 )
135 uint8_t storage[size+1];
136 StaticStreamBuffer_t streamBuff;
140#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
151#if configUSE_SB_COMPLETED_CALLBACK
152 StreamBuffer(
size_t size,
size_t trigger, StreamBufferCallbackFunction_t sendCallback, StreamBufferCallbackFunction_t recvCallback) :
153 StreamBufferBase(xStreamBufferCreateWithCallback(size, trigger, sendCallback, recvCallback))
159#if FREERTOS_VERSION_ALL >= 11'001'000
169#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
175 BatchingBuffer(
size_t trigger = 1) :
177#if( configSUPPORT_STATIC_ALLOCATION == 1 )
178 xStreamBatchingBufferCreateStatic(size, trigger, storage, streamBuff)
180 xStreamBatchingBufferCreate(size, trigger)
183 virtual ~BatchBuffer() { vStreamBufferDelete(streamHandle);}
184#if configUSE_SB_COMPLETED_CALLBACK
185 BatchingBuffer(
size_t trigger, StreamBufferCallbackFunction_t sendCallback, StreamBufferCallbackFunction_t recvCallback) :
187#if( configSUPPORT_STATIC_ALLOCATION == 1 )
188 xStreamBatchingBufferCreateStaticWithCallback(size, trigger, storage, streamBuff, sendCallback, recvCallback)
190 xStreamBatchingBufferCreateWithCallback(size, trigger, sendCallback. recvCallBack)
196#if( configSUPPORT_STATIC_ALLOCATION == 1 )
197 uint8_t storage[size+1];
198 StaticStreamBuffer_t streamBuff;
202#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
210 BatchingBuffer(
size_t size,
size_t trigger=1) :
213 virtual ~BatchingBuffer() { vStreamBufferDelete(streamHandle);}
214#if configUSE_SB_COMPLETED_CALLBACK
215 BatchingBuffer(
size_t size,
size_t trigger, StreamBufferCallbackFunction_t sendCallback, StreamBufferCallbackFunction_t recvCallback) :
216 StreamBatchingBufferBase(xStreamBufferCreateWithCallback(size, trigger, sendCallback, recvCallback))
223#if FREERTOSCPP_USE_NAMESPACE
Base class for the Various Stream Buffers.
Definition StreamBufferCPP.h:53
size_t send(const void *data, size_t len, TickType_t delay=portMAX_DELAY)
Definition StreamBufferCPP.h:58
size_t waiting() const
Get number of bytes of data available in the StreamBuffer.
Definition StreamBufferCPP.h:78
virtual ~StreamBufferBase()
Definition StreamBufferCPP.h:56
bool reset()
Resets the buffer to empty.
Definition StreamBufferCPP.h:90
size_t read_ISR(void *data, size_t len, BaseType_t &wasWoken)
Definition StreamBufferCPP.h:73
bool isEmpty() const
Definition StreamBufferCPP.h:84
bool isFull() const
Definition StreamBufferCPP.h:86
StreamBufferHandle_t streamHandle
Definition StreamBufferCPP.h:97
size_t send_ISR(const void *data, size_t len, BaseType_t &wasWoken)
Definition StreamBufferCPP.h:64
bool trigger(size_t trigger)
Sets the Trigger Level for the StreamBuffer.
Definition StreamBufferCPP.h:95
size_t available() const
Get the amount of available space open in the StreamBuffer.
Definition StreamBufferCPP.h:82
StreamBufferBase(StreamBufferHandle_t sbHandle)
Definition StreamBufferCPP.h:55
size_t read(void *data, size_t len, TickType_t delay=portMAX_DELAY)
Definition StreamBufferCPP.h:67
StreamBuffer wrapper.
Definition StreamBufferCPP.h:110
StreamBuffer(size_t trigger=1)
Definition StreamBufferCPP.h:112
virtual ~StreamBuffer()
Definition StreamBufferCPP.h:120
Definition FreeRTOScpp.h:74