Description

readBytes() reads characters from a stream into a buffer. The function terminates if the specified length has been read, or it times out (see Stream.setTimeout()).

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.readBytes(buffer, length)

Parameters

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

Returns

The number of bytes placed in the buffer, or 0 if no valid data was found. Data type: size_t.