max777
#1
Hi
Here is my code to save data with SDcard ; I can’t overwrite at the begining of the file : only append.
seek seems not working.
any idea ?
thx
Serial.print(periFile);
if(fperi=SD.open(periFile,FILE_WRITE)){
sta=SDOK;
fperi.seek(0);
for(i=0;i<PERIRECLEN;i++){fperi.write(periRec[i]);}
fperi.close();
Serial.print(" ok ");
}
else{sta=SDKO;Serial.print(" ko ");}
pylon
#2
Use "O_WRITE" instead of "FILE_WRITE".
max777
#3
pylon:
Use "O_WRITE" instead of "FILE_WRITE".
Thx
Reference mentions only FILE_READ and FILE_WRITE... pls, where can I find informations about other parameters ?
max777
#4
SD lib doesnt like 'O_WRITE' : SD_open said 'false'...
pylon
#5
My SD.h (IDE 1.8.9) file contains
#define FILE_READ O_READ
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)
Are you using another library?
max777
#6
No...
I just read Arduino - SD
I will check lib.h files in the future
Thx
pylon
#7
SD lib doesnt like 'O_WRITE' : SD_open said 'false'...
Does the target file already exist? If it doesn't, you have to use O_WRITE | O_CREAT.