Skip to content

readByteArray

Signatures

  • bool SPIFlash::readByteArray(uint32_t _addr, uint8_t *data_buffer, size_t bufferSize, bool fastRead = false)
  • bool SPIFram::readByteArray(uint32_t _addr, uint8_t *data_buffer, size_t bufferSize, bool fastRead = false)

What It Is For

Read a uint8_t span from memory into a caller-provided buffer.

Parameters

  • _addr: Start address to read.
  • data_buffer: Output buffer pointer.
  • bufferSize: Number of bytes requested.
  • fastRead: Optional performance mode.

Behavior Details

Always size destination buffer to at least bufferSize bytes.

Return Semantics

Returns true when requested bytes were read into buffer.

Failure Behavior

If used as C-strings, ensure null termination is handled explicitly by your code.

Common Mistakes

  • Reading more bytes than destination buffer can hold.
  • Using wrong start address and mis-parsing shifted data.
  • Assuming data is valid without checking application-level framing/CRC.

Choosing Between Similar APIs

  • Use readByteArray() when you need raw bytes.
  • Use typed read APIs for direct scalar conversion.
  • Use readCharArray() when treating output as text.

Example

uint8_t rx[8] = {0};
if (flash.readByteArray(addr, rx, sizeof(rx))) {
  // parse rx
}