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* label, long val);
64
72 void trace(const __FlashStringHelper* label, long val);
73
74
81 void trace(const char* label, const char* val);
82
90 void trace(const __FlashStringHelper* label, const char* val);
91
92
98 void trace(const char* string);
99
105 void trace(const __FlashStringHelper* string);
106
107
116 void setAutoFlush(bool autoFlush);
117
118
124 void itrace(const char* string);
125
126
132 void itrace(const __FlashStringHelper* string);
133
134private:
135 char* buffer = NULL;
136 uint16_t buflen = 0;
137 bool traceOn = false;
138 bool isOpen = false;
139 bool autoFlush = true;
140 Stream& ser = Serial;
141
142 // helper funtion to add string to buffer only if there is room
143 void add2Buffer(const char* string);
144
148 template<typename StoredString>
149 void itrace(StoredString getChar);
150
154 template<typename StoredString>
155 void trace(StoredString getChar);
156
160 template<typename StoredString>
161 void trace(StoredString getChar, long val);
162
166 template<typename StoredString>
167 void trace(StoredString getChar, const char *val);
168
169};
170
171// global trace object for convenience
172extern BufferedTrace Trace;
173
174// **********************
175#endif
BufferedTrace Trace
Definition BufferedTrace.cpp:11
Project: BufferedTrace for Arduino.
Definition BufferedTrace.h:21
void init(uint16_t bufsize=80)
Initializes the serial interface for communication.
Definition BufferedTrace.cpp:20
void trace(const char *label, long val)
buffers information consisting of a string label and numeric value.
Definition BufferedTrace.cpp:109
void setStream(Stream &serial)
Sets a stream other than the standard Serial.
Definition BufferedTrace.cpp:16
void open()
resets the trace buffer, and starts buffering trace info.
Definition BufferedTrace.cpp:44
void itrace(const char *string)
Immediately outputs a string.
Definition BufferedTrace.cpp:167
void setAutoFlush(bool autoFlush)
whether or not to flush the buffer when full
Definition BufferedTrace.cpp:183
void close()
sends the buffered information collected since the last open() call and resets the buffer.
Definition BufferedTrace.cpp:50
BufferedTrace()
default constructor
Definition BufferedTrace.cpp:13