BufferedTrace
Library for buffered tracing
Loading...
Searching...
No Matches
BufferedTrace Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ BufferedTrace()

BufferedTrace::BufferedTrace ( )

default constructor

Member Function Documentation

◆ close()

void BufferedTrace::close ( )

sends the buffered information collected since the last open() call and resets the buffer.

◆ init()

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.

Parameters
bufsize- the desired buffer size

◆ itrace()

void BufferedTrace::itrace ( const char * string)

Immediately outputs a string.

Writes a string to the serial interface without affecting the buffer.

Parameters
string- the string to be transmitted.

◆ open()

void BufferedTrace::open ( )

resets the trace buffer, and starts buffering trace info.

◆ setAutoFlush()

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.

Parameters
autoFlush- if true, the buffer is flushed. If false, overflow data will be discarded.

◆ setStream()

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().

Parameters
serial- the serial stream to be used

◆ trace() [1/3]

void BufferedTrace::trace ( const char * string)

buffers a string for output

only works within an open - close bracket.

Parameters
string- the string to be displayed

◆ trace() [2/3]

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.

Parameters
string- the name of the value to be displayed
val- the stringvalue to be displayed

◆ trace() [3/3]

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.

Parameters
string- the name of the value to be displayed
val- the long value to be displayed

The documentation for this class was generated from the following files: