open and Files information do not comply with Posix specifications
Posted: Wed May 08, 2019 1:59 pm
Hello,
this is the rework of my previous post "Incorrect File object information after file creation on a SD card and on SPIFFS"
I extended the investigation and modified the test program that lead me to conclude that the implementation of the Arduino ESP32 file manipulation do not comply with Posix specifications. As I was not able to find any documentation related to File for Arduino ESP32, I am supposing that Posix could be a good model.
The fact that the SD and SPIFFS implementation are different in behaviors tend also to prove that the implementations are incorrect.
The suppression of the truncate function do not help to my humble opinion, that's also the reason why I went to do this investigation ==> how to empty a file.
I have started to look at the Arduino ESP32 code, but obviously, I am not knowledgeable enough to correct that.
You will find at the end of this thread the new test program as well as the results I got.
Does somebody knows to who should I send this information to get it challenged ?
Thanks for your reading.
==================== old post =========================================
Just after creating a File on a SD card, the values returned by size() and available() are incorrect to me, they should be zero.
After a first write everything is back to normal, as you can see in the output below.
Is it a potential bug in the ESP32 package ?
for information, the same code running on a ESP8266 return zero.
thanks for your help.
Output :
this is the rework of my previous post "Incorrect File object information after file creation on a SD card and on SPIFFS"
I extended the investigation and modified the test program that lead me to conclude that the implementation of the Arduino ESP32 file manipulation do not comply with Posix specifications. As I was not able to find any documentation related to File for Arduino ESP32, I am supposing that Posix could be a good model.
The fact that the SD and SPIFFS implementation are different in behaviors tend also to prove that the implementations are incorrect.
The suppression of the truncate function do not help to my humble opinion, that's also the reason why I went to do this investigation ==> how to empty a file.
I have started to look at the Arduino ESP32 code, but obviously, I am not knowledgeable enough to correct that.
You will find at the end of this thread the new test program as well as the results I got.
Does somebody knows to who should I send this information to get it challenged ?
Thanks for your reading.
==================== old post =========================================
Just after creating a File on a SD card, the values returned by size() and available() are incorrect to me, they should be zero.
After a first write everything is back to normal, as you can see in the output below.
Is it a potential bug in the ESP32 package ?
for information, the same code running on a ESP8266 return zero.
thanks for your help.
Code: Select all
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
File MFile;
void setup() {
Serial.begin(9600);
delay(3000);
while (!Serial) {}
Serial.println("Initializing SD card");
if (!SD.begin(5)) {
Serial.println("... initialization failed");
return;
}
Serial.println("initialization done");
SD.remove("/f3.txt");
MFile = SD.open("/f3.txt", "w+");
if (!MFile)
return;
Serial.println("Just after open");
Serial.print("Size : "); Serial.println(MFile.size());
Serial.print("Position : "); Serial.println(MFile.position());
Serial.print("Available data : "); Serial.println(MFile.available());
MFile.println("nothing");
MFile.flush();
Serial.println("After the first write");
Serial.print("Size : "); Serial.println(MFile.size());
Serial.print("Position : "); Serial.println(MFile.position());
Serial.print("Available data : "); Serial.println(MFile.available());
}
void loop() {
}
- Initializing SD card
initialization done
Just after open
Size : 4278124286
Position : 0
Available data : -16843010
After the first write
Size : 9
Position : 9
Available data : 0