fatfs f_read() and f_gets() return incorrect data
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-08 11:52 PM
When reading from an SD card using SPI and FAT32 using either f_read() or f_gets() the data returned does not match the actual file contents.
I am using an STM32F103C8.
fresult = f_open(&fil, "0:test.txt", FA_OPEN_EXISTING | FA_READ | FA_WRITE);
unsigned int bytesWritten = 0;
bufclear(buffer, 1024);
sprintf(buffer, "test TEST test 123");
fresult = f_write(&fil, buffer, bufsize(buffer), &bytesWritten);
char fileBuf[10];
bufclear(fileBuf, 10);
f_gets(fileBuf, 10, &fil);
Solved! Go to Solution.
Labels:
- Labels:
-
FatFS
-
STM32F1 Series
1 ACCEPTED SOLUTION
Accepted Solutions
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-09 12:40 AM
It was actually the "correct" output, just the file was corrupted.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-09 12:40 AM
It was actually the "correct" output, just the file was corrupted.
