bfsRead()

PROTOTYPE

#include <bfs.h>

int bfsRead(void *buf, unsigned int nbytes);

DESCRIPTION

bfsRead() reads user data from the currently open file. buf points to a receive buffer. Bytes are copied from the file to the buffer until nbytes bytes are read or end-of-file is reached.

If any data is successfully read, bfsRead() returns number of bytes read. If no bytes were read, it sets errno and returns -1.

ERROR CODES

EACCES File is not open in read mode.
EFAULT buf equals NULL.
other An I/O error occurred while reading a flash page.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Try to read the CPU0 application file. Return if error.           */
  /*-------------------------------------------------------------------*/
  rc = bfsRead((void *)APP0_BEG, APP0_END - APP0_BEG + 1);
  bfsClose();
  if (rc < 0)
  {
    puts("\"app0.elf\" read failed");
    return;
  }