I see. In this case, the content is read from memory buffer (cache). In FileX, the memory buffer is used to cache sectors. If the sector to read is already cached, then there is no need to access underlayer media to read again. Data from cache will be returned. If you want to make sure data are flushed to media already, you can enable the fault tolerant feature. But anyway, as long as the data to read are cached, the content from cache will be returned.
fx_file_read reading data from cache or card?
Hello.
I have a question about the behavior of fx_file_read.
Basically, I'm doing the next thing:
Opening one file for both reading and writing to verify that data is written on the card.
fx_file_open(&sd_disk, &my_file_1, FILENAME, FX_OPEN_FOR_WRITE);
fx_file_open(&sd_disk, &my_file_2, FILENAME, FX_OPEN_FOR_READ);
fx_file_write(&my_file_1, &write_buffer, BUFFER_SIZE);
fx_media_flush(&sd_disk);
fx_file_read(&my_file_2, &read_buffer, BUFFER_SIZE, &actual_bytes);
I have a suspicion that fx_file_read will get data from the cache (even if I used flush), is that right?
And if yes, do I need to open-close the file to read every time to get data from the card?
-
Tiejun Zhou 1,126 Reputation points Microsoft Employee
2022-09-19T10:24:45.703+00:00