chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko

Stream

Stream
Quick Look
Hardware (External hardware)
Core Stream.h

Stream is a base class for character-based streams.

  1. Detailed Introduction

  2. Full class usage

    1. Stream

      1. Virtual Public Functions

        1. available()

        2. read()

        3. peek()

        4. available()

      2. Public Functions

        1. setTimeout(unsigned long timeout)

        2. find(const char *target)

        3. find(const uint8_t *target)

        4. find(const char *target, size_t length)

        5. find(const uint8_t *target, size_t length))

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

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

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

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

        10. parseInt()

        11. parseFloat()

        12. readBytes( char *buffer, size_t length)

        13. size_t readBytes( uint8_t *buffer, size_t length)

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

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

        16. String readString()

        17. String readStringUntil(char terminator)

  3. External Links

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