BufferedTrace
Library for buffered tracing
Loading...
Searching...
No Matches
BufferedTrace.h
Go to the documentation of this file.
1#include "Arduino.h"
2#include <stdint.h>
3#include <avr/pgmspace.h>
4#ifndef BufferedTrace_h
5#define BufferedTrace_h
6
20
22public:
23
28
36 void setStream(Stream& serial);
37
45 void init(uint16_t bufsize=80);
46
50 void open();
51
55 void close();
56
63 void trace(const char* string, long val);
64
65
72 void trace(const char* string, const char* val);
73
74
80 void trace(const char* string);
81
82
91 void setAutoFlush(bool autoFlush);
92
93
99 void itrace(const char* string);
100
101private:
102 char* buffer = NULL;
103 uint16_t buflen = 0;
104 bool traceOn = false;
105 bool isOpen = false;
106 bool autoFlush = true;
107 Stream& ser = Serial;
108
109 // helper funtion to add string to buffer only if there is room
110 void add2Buffer(const char* string);
111};
112
113// global trace object for convenience
114extern BufferedTrace Trace;
115
116// **********************
117#endif
BufferedTrace Trace
Definition BufferedTrace.cpp:7
Project: BufferedTrace for Arduino.
Definition BufferedTrace.h:21
void init(uint16_t bufsize=80)
Initializes the serial interface for communication.
Definition BufferedTrace.cpp:16
void setStream(Stream &serial)
Sets a stream other than the standard Serial.
Definition BufferedTrace.cpp:12
void open()
resets the trace buffer, and starts buffering trace info.
Definition BufferedTrace.cpp:32
void trace(const char *string, long val)
buffers information consisting of a string name and numeric value.
Definition BufferedTrace.cpp:50
void itrace(const char *string)
Immediately outputs a string.
Definition BufferedTrace.cpp:88
void setAutoFlush(bool autoFlush)
whether or not to flush the buffer when full
Definition BufferedTrace.cpp:96
void close()
sends the buffered information collected since the last open() call and resets the buffer.
Definition BufferedTrace.cpp:38
BufferedTrace()
default constructor
Definition BufferedTrace.cpp:9