Skip to content

Arduino library implementing a Stream that reads and writes from a single/common buffer. Mainly used for testing/debugging purposes.

License

Notifications You must be signed in to change notification settings

SofaPirate/MemoryStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino library providing a simple Stream class that allows to read and write to a common buffer. It can be used to simulate streaming such as serial communication, typically for debugging and testing purposes.

Example usage:

#include <MemoryStream.h>

// Create MemoryStream object.
MemoryStream stream;

void setup() {
  Serial.begin(115200);
}

void loop() {
  // Write value.
  stream.write(123);

  // Read value.
  int val = stream1.read(); // variable "val" will contain value 123
  Serial.println(val); // will print "123"

  // Write string.
  stream.println("Hello!");
  Serial.println(stream.readString()); // will print "Hello!"
}

By default, the size of the buffer is 128 bytes. This can be changed by defining MEMORY_STREAM_BUFFER_SIZE before including the library:

#define MEMORY_STREAM_BUFFER_SIZE 64
#include <MemoryStream.h>

About

Arduino library implementing a Stream that reads and writes from a single/common buffer. Mainly used for testing/debugging purposes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages