f_read

The f_read reads data from a file.

FRESULT f_read (
  FIL* FileObject,    // Pointer to the file object structure
  BYTE* Buffer,       // Pointer to the buffer to store read data
  WORD ByteToRead,    // Number of bytes to read
  WORD* ByteRead      // Pointer to the variable to return number of bytes read
);

Parameters

FileObject
Pointer to the valid file object structure.
Buffer
Pointer to the buffer to store read data
ByteToRead
Number of bytes to read
ByteRead
Pointer to the WORD variable to return number of bytes read.

Return Values

FR_OK
The function succeeded.
FR_DENIED
The function denied due to the file has been opened in write only mode.
FR_ALIGN_ERROR
The file has been opened in unbufferred mode but unaligned access was detected.
FR_RW_ERROR
Any error occured in low level disk I/O.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_NOT_ENABLED
FatFs module has not been enabled.

Description

The read/write pointer increases in number of bytes read. The ByteRead will be smaller than ByteToRead when the read pointer reached to end of the file or alignment error occured during the read operation. In unbufferred mode, last fractional bytes cannot be read due to FR_ALIGN_ERROR.

References

f_open, f_write, f_close, FIL

Return