fread fails very often
Posted: Fri Jan 18, 2019 11:19 am
Hi everybody!
I'm using SPIFFS file system to store some intermediate data in files. So I use fopen/fread/fwrite/fclose functions to manipulate file contents. Generally everything works OK, but fread fails in about 10% of cases. When it happens ferror returns 1 and errno is equal to 5. I've tried to repeat read operations in such cases, but it does not help at all (if I try to call fread 5 times it fails all 5 times).
I expect that this happens because of some sort of conflict on SPI bus (I also use HSPI to access several peripheral devices from different threads) but I have no proofs for that.
Is where any way to make fread be successful in 100% of calls?
I'm using SPIFFS file system to store some intermediate data in files. So I use fopen/fread/fwrite/fclose functions to manipulate file contents. Generally everything works OK, but fread fails in about 10% of cases. When it happens ferror returns 1 and errno is equal to 5. I've tried to repeat read operations in such cases, but it does not help at all (if I try to call fread 5 times it fails all 5 times).
I expect that this happens because of some sort of conflict on SPI bus (I also use HSPI to access several peripheral devices from different threads) but I have no proofs for that.
Is where any way to make fread be successful in 100% of calls?