stm32duino / STM32SD

Enables reading and writing on SD card using SD card slot of the STM32 Board.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error in SD.cpp int File::read(void *buf, size_t len)

Hoek67 opened this issue · comments

bytesread was a uint8_t.... which sort of made my code that returns 512 bytes die. Changed to UINT same as return type.

int File::read()
{
UINT byteread; // changed type... not critical here as should be 1
int8_t data;
f_read(_fil, (void *)&data, 1, (UINT *)&byteread);
return data;
}

/**

  • @brief Read an amount of data from the file
  • @param buf: an array to store the read data from the file
  • @param len: the number of elements to read
  • @RetVal Number of bytes read
    */
    int File::read(void *buf, size_t len)
    {
    UINT bytesread; // was error only allowed for uint8_t!!!!

f_read(_fil, buf, len, (UINT *)&bytesread);
return bytesread;

}

fixed code below :- when reading the number of bytes was trunctated to 255.