Hello my friends,
I'm really confused about the Chan's FatFS read-function!
I'm able to write and do loggings etc... but reading a file greater than
1 kB doesn't work! I can read up to 1 kB (not including 1 kB).
The problem is I see only 0 (zero) above 1 kB!
My buffer is 2 kB, so it's not the bufferproblem.
1 | int main()
|
2 | {
|
3 | FATFS Fs;
|
4 | FIL FileObject;
|
5 | char data[2048];
|
6 | const char* FileName = "0:Basic.bin";
|
7 | unsigned int ByteToRead = sizeof(data);
|
8 | unsigned int ByteRead;
|
9 | unsigned char SD = 0;
|
10 |
|
11 | memset(data, 0, sizeof(data));
|
12 |
|
13 | if( f_mount(SD, &Fs) != FR_OK )
|
14 | return 0;
|
15 |
|
16 | if(f_open(&FileObject, FileName, FA_OPEN_EXISTING|FA_READ) != FR_OK)
|
17 | return 0;
|
18 |
|
19 | FRESULT res;
|
20 | int f, e; f = e = 0;
|
21 | while(1)
|
22 | {
|
23 | res = f_read(&FileObject, data, ByteToRead, &ByteRead);
|
24 |
|
25 | if(res == FR_OK)
|
26 | {
|
27 | f++; //just to check number of cycles
|
28 | if(ByteRead == 0) break;
|
29 | e++;
|
30 | }
|
31 | }
|
32 |
|
33 | return 0;
|
34 | }
|