pfodParser 5.0.1 The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections

pfodRingBuffer.h
Go to the documentation of this file.
1 #ifndef pfodRingBuffer_h
2 #define pfodRingBuffer_h
14 /*
15 (c)2014-2017 Forward Computing and Control Pty. Ltd.
16 NSW Australia, www.forward.com.au
17 This code is not warranted to be fit for any purpose. You may only use it at your own risk.
18 This code may be freely used for both private and commercial use
19 Provide this copyright is maintained.
20 */
21
22 #include <Arduino.h>
23 #include "pfodStream.h"
24
25 class pfodRingBuffer: public Stream {
26 public:
27 pfodRingBuffer(); // if using this constructor need to call init(..) also
32 void init(uint8_t* _buf, size_t _size);
33 pfodRingBuffer(uint8_t* _buf, size_t _size);
34
35 void clear();
36 void markWrite();
37 void resetWrite();
43 void copyTo(Print *outputPtr);
44
45 // from Stream
46 int available();
47 int peek();
48 int read();
49 void flush();
50 size_t write(uint8_t b); // does not block, drops bytes if buffer full
51 size_t write(const uint8_t *buffer, size_t size); // does not block, drops bytes if buffer full
52 int availableForWrite();
53 size_t getSize(); // size of ring buffer
54
55 private:
56 uint8_t* buf;
57 uint16_t bufSize;
58 uint16_t buffer_head;
59 uint16_t buffer_tail;
60 uint16_t buffer_count;
61 uint16_t wrapBufferIdx(uint16_t idx);
62 uint16_t writeMark;
63 uint16_t writeMarkCount;
64 bool isWriteMarked;
65
66 };
67 #endif
pfodRingBuffer
pfodRingBuffer for Arduino Implements a ring buffer implementation of an Arduino Stream upto 32K buff...
Definition: pfodRingBuffer.h:25
pfodRingBuffer::copyTo
void copyTo(Print *outputPtr)
copyTo() copies contents to the print stream unlike read() copyTo does not remove any data from the b...
pfodRingBuffer::clear
void clear()
pfodRingBuffer::availableForWrite
int availableForWrite()
pfodRingBuffer::pfodRingBuffer
pfodRingBuffer(uint8_t *_buf, size_t _size)
pfodRingBuffer::write
size_t write(const uint8_t *buffer, size_t size)
pfodRingBuffer::flush
void flush()
pfodRingBuffer::available
int available()
pfodRingBuffer::getSize
size_t getSize()
pfodRingBuffer::markWrite
void markWrite()
pfodRingBuffer::pfodRingBuffer
pfodRingBuffer()
pfodRingBuffer::init
void init(uint8_t *_buf, size_t _size)
_buf must be at least _size in length _size is limited to 32766
pfodRingBuffer::resetWrite
void resetWrite()
pfodRingBuffer::read
int read()
pfodRingBuffer::peek
int peek()
pfodRingBuffer::write
size_t write(uint8_t b)
pfodStream.h