pf_read

The pf_read function reads data from the file.

FRESULT pf_read (
  void* Buffer,       /* [OUT] Pointer to the read buffer */
  WORD ByteToRead,    /* [IN]  Number of bytes to read */
  WORD* BytesRead     /* [OUT] Pointer to the variable to return number of bytes read */
);

Parameters

Buffer
Pointer to the buffer to store the read data. A NULL specifies the destination is an outgoing stream.
ByteToRead
Number of bytes to read.
BytesRead
Pointer to the WORD variable to return number of bytes read.

Return Values

FR_OK (0)
The function succeeded.
FR_DISK_ERR
The function failed due to an error in the disk function, a wrong FAT structure or an internal error.
FR_NOT_OPENED
The file has not been opened.
FR_NOT_ENABLED
The volume has not been mounted.

Description

The read pointer in the file system object increases in number of bytes read. After the function succeeded, *BytesRead should be checked to detect end of file. In case of *BytesRead < ByteToRead, it means the read pointer reached end of file during read operation.

If a NULL is given to the Buffer, the read bytes will be forwarded to the outgoing stream instead of the memory. The streaming function will be typically built-in the low level disk read function.

QuickInfo

Available when _USE_READ == 1.

References

pf_open, pf_write, FATFS

Return