Stream

From chipKIT
Jump to: navigation, search
Stream
Quick Look
Hardware (External hardware)
Core Stream.h

Stream is a base class for character-based streams.

Detailed Introduction

The Stream class is a base class which provides functions to handle data streams and assist in parsing streams. It is not called directly, but it is used from within other libraries.

Full class usage

Stream

Virtual Public Functions


available()

    virtual int available() = 0;

read()

    virtual int read() = 0;

peek()

    virtual int flush() = 0;

available()

    virtual void flush() = 0;


Public Functions


setTimeout(unsigned long timeout)

  void setTimeout(unsigned long timeout);

Sets the maximum milliseconds to wait for stream data, default is 1 second.

find(const char *target)

  bool find(const char *target);

Reads data from the stream until the target string is found.

find(const uint8_t *target)

  bool find(const uint8_t *target);

Returns true if target string is found, false if timed out (see setTimeout)

find(const char *target, size_t length)

  bool find(const char *target, size_t length);

Reads data from the stream until the target string of given length is found

find(const uint8_t *target, size_t length))

	bool find(const uint8_t *target, size_t length);

Returns true if target string is found, false if timed out

findUntil(const char *target, const char *terminator)

	bool findUntil(const char *target, const char *terminator);

Same as find but the search ends if the terminator string is found.

findUntil(const uint8_t *target, const char *terminator)

	findUntil(const uint8_t *target, const char *terminator);

Same as find but the search ends if the terminator string is found.

findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen)

	findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);

Reads data from the stream until the target string of the given length is found. Search is terminated if the terminator string is found. Returns true if target string is found, false if terminated or timed out.

findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)

	findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen);

Reads data from the stream until the target string of the given length is found. Search is terminated if the terminator string is found. Returns true if target string is found, false if terminated or timed out.

parseInt()

	long parseInt();

Returns the first valid (long) integer value from the current position. Initial characters that are not digits (or the minus sign) are skipped. Integer is terminated by the first character that is not a digit.

parseFloat()

	float parseFloat();

Returns the first valid floating point value from the current position. Initial characters that are not digits (or the minus sign) are skipped. Integer is terminated by the first character that is not a digit.

readBytes( char *buffer, size_t length)

	size_t readBytes( char *buffer, size_t length);

Read chars from stream into buffer.

size_t readBytes( uint8_t *buffer, size_t length)

	size_t readBytes( uint8_t *buffer, size_t length);

Read chars from stream into buffer. Terminates if length characters have been read or timeout (see setTimeout). Returns the number of characters placed in the buffer (0 means no valid data found).

readBytesUntil( char terminator, char *buffer, size_t length)

	size_t readBytesUntil( char terminator, char *buffer, size_t length);

Read chars from stream into buffer with a terminator character.

readBytesUntil( char terminator, uint8_t *buffer, size_t length))

	size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length);

Terminates if length characters have been read, timeout, or if the terminator character detected. Returns the number of characters placed in the buffer (0 means no valid data found)

String readString()

	String readString();

Arduino String function.

String readStringUntil(char terminator)

	String readStringUntil(char terminator);

Arduino String function.


External Links