Description

readBytesUntil() reads characters from a stream into a buffer. The function terminates if the terminator character is detected, the specified length has been read, or it times out (see Stream.setTimeout()). The terminator character is not included in the buffer.

This function is part of the Stream class, and can be called by any class that inherits from it (Wire, Serial, etc). See the Stream class main page for more information.

Syntax

stream.readBytesUntil(character, buffer, length)

Parameters

  • character: the terminator character to search for. Allowed data types: char.
  • buffer: the buffer to store the bytes in. Allowed data types: array of char or byte.
  • length: the maximum number of bytes to read. Allowed data types: int.

Returns

The number of bytes placed in the buffer (excluding the terminator character), or 0 if the terminator was not found or no data was available. Data type: size_t.

Notes and Warnings

The terminator character is discarded from the stream and is not included in the returned count.