pfodParser  3.61.0
The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections
pfodBufferedStream.h
Go to the documentation of this file.
1 #ifndef pfodBufferedSerial_h
2 #define pfodBufferedSerial_h
9 #include "pfodStream.h"
10 #include "pfodRingBuffer.h"
11 
12 class pfodBufferedStream : public Stream {
13 
14  public:
21  pfodBufferedStream(const uint32_t baudRate, uint8_t *_buf, size_t _bufferSize, bool blocking = true);
22  pfodBufferedStream* connect(Stream* _stream); // where to read and write to
23  virtual size_t write(uint8_t);
24  virtual size_t write(const uint8_t *buf, size_t size);
25  virtual int available();
26  virtual int read();
27  virtual int peek();
28  virtual void flush(); // this blocks until write buffer empty
29  virtual int availableForWrite();
30  void setDebugStream(Print* out);
31  size_t bytesToBeSent(); // bytes in buffer to be sent
32  size_t getSize(); // check on allocation
33  void clearTxBuffer(); // clears outgoing (write) buffer
34  uint32_t getBaudRate();
35  private:
36  unsigned long uS_perByte; // == 1000000 / (baudRate/10) == 10000000 / baudRate
37  Stream* stream;
38  pfodRingBuffer ringBuffer;
39  uint32_t baudRate;
40  void sendNextByte();
41  unsigned long sendTimerStart;
42  bool blocking; // defaults to true;
43  Print* debugOut;
44 };
45 
46 #endif // pfodBufferedSerial_h
(c)2018 Forward Computing and Control Pty.
uint32_t getBaudRate()
virtual int peek()
virtual int available()
void setDebugStream(Print *out)
size_t bytesToBeSent()
virtual void flush()
virtual int availableForWrite()
virtual int read()
virtual size_t write(const uint8_t *buf, size_t size)
pfodBufferedStream(const uint32_t baudRate, uint8_t *_buf, size_t _bufferSize, bool blocking=true)
baudRate – the maximum rate at which the bytes are to be released.
pfodBufferedStream * connect(Stream *_stream)
virtual size_t write(uint8_t)
pfodRingBuffer for Arduino Implements a ring buffer implementation of an Arduino Stream upto 32K buff...