BufferedTrace
Library for buffered tracing
|
Project: BufferedTrace for Arduino. More...
#include <BufferedTrace.h>
Public Member Functions | |
BufferedTrace () | |
default constructor | |
void | setStream (Stream &serial) |
Sets a stream other than the standard Serial. | |
void | init (uint16_t bufsize=80) |
Initializes the serial interface for communication. | |
void | open () |
resets the trace buffer, and starts buffering trace info. | |
void | close () |
sends the buffered information collected since the last open() call and resets the buffer. | |
void | trace (const char *string, long val) |
buffers information consisting of a string name and numeric value. | |
void | trace (const char *string, const char *val) |
buffers information consisting of a string name and string value. | |
void | trace (const char *string) |
buffers a string for output | |
void | setAutoFlush (bool autoFlush) |
whether or not to flush the buffer when full | |
void | itrace (const char *string) |
Immediately outputs a string. |
Project: BufferedTrace for Arduino.
The BufferedTrace class provides a wrapper to the Serial object that allows trace information to be collected in a buffer and send it out through the serial interface.
This header file also provides a shared global object Trace of class BufferedTrace for convenience.
BufferedTrace::BufferedTrace | ( | ) |
default constructor
void BufferedTrace::close | ( | ) |
sends the buffered information collected since the last open() call and resets the buffer.
void BufferedTrace::init | ( | uint16_t | bufsize = 80 | ) |
Initializes the serial interface for communication.
The init method is meant to be called from a central location, for example in the top-level sketch. If init is not called, no tracing will be performed.
bufsize | - the desired buffer size |
void BufferedTrace::itrace | ( | const char * | string | ) |
Immediately outputs a string.
Writes a string to the serial interface without affecting the buffer.
string | - the string to be transmitted. |
void BufferedTrace::open | ( | ) |
resets the trace buffer, and starts buffering trace info.
void BufferedTrace::setAutoFlush | ( | bool | autoFlush | ) |
whether or not to flush the buffer when full
The autoFlush setting controls behavior when output is being buffered and the buffer becomes full. If autoFlush is true, upon becoming full, the buffer will be written to the serial string and emptied so that new information can be traced. If autoFlush is false, any info added after the buffer is full will be discarded.
autoFlush | - if true, the buffer is flushed. If false, overflow data will be discarded. |
void BufferedTrace::setStream | ( | Stream & | serial | ) |
Sets a stream other than the standard Serial.
If you need to use a serial output stream other than the standard Serial object, initialize your stream and pass it to this function before calling init().
serial | - the serial stream to be used |
void BufferedTrace::trace | ( | const char * | string | ) |
buffers a string for output
only works within an open - close bracket.
string | - the string to be displayed |
void BufferedTrace::trace | ( | const char * | string, |
const char * | val ) |
buffers information consisting of a string name and string value.
only works within an open - close bracket.
string | - the name of the value to be displayed |
val | - the stringvalue to be displayed |
void BufferedTrace::trace | ( | const char * | string, |
long | val ) |
buffers information consisting of a string name and numeric value.
only works within an open - close bracket.
string | - the name of the value to be displayed |
val | - the long value to be displayed |