Go Down

Topic: SD Library Version 1.2.0 problem (Read 785 times) previous topic - next topic

samoif

Hello,

it seems that the new version 1.2.0 of the SD library recently released has changed the modality to write file data to the SD card.
If I run the Datalogger example, with the version 1.1.1 new data are appended to the previous ones in a new text line, but with the new version  every writing cicle overwrites the data on the same (first) text line.

Did anybody have a similar problem?

pert

I suspect this was the cause of the change:
https://github.com/arduino-libraries/SD/pull/36/commits/74fcc2a09d9bf7a7deeaed7cf846d2b2c13351f4


Try this, change line 62 from:
Code: [Select]
File dataFile = SD.open("datalog.txt", FILE_WRITE);
to:
Code: [Select]
File dataFile = SD.open("datalog.txt", O_APPEND);

Let me know what the results are of that. If this is causing the sketch to not work as expected then I'll try to get it fixed. At the very least the library documentation needs to be updated since it only mentions FILE_READ and FILE_WRITE as valid values for the mode parameter of SD.open().


samoif

Replacing:
Code: [Select]
File dataFile = SD.open("datalog.txt", FILE_WRITE);

with:
Code: [Select]
File dataFile = SD.open("datalog.txt", O_APPEND);

is not the solution, sketch stops and the Serial monitor shows:
"error opening datalog.txt"

pert

Try this:
Code: [Select]
File dataFile = SD.open("datalog.txt", O_READ | O_APPEND | O_CREAT);

amdkt7

I had the same problem. My code stopped working this weekend and it took me a while to realize that the library updated. I just rolled back to 1.1.0 as it should not be necessary to modify my code. I can see where it would be nice to have the added options, but default should work the same way it has always had.

samoif

suggested code:
Code: [Select]
File dataFile = SD.open("datalog.txt", O_READ | O_APPEND | O_CREAT);
neither fix the problem.
I've downgraded as well to Version 1.1.1, I will stick with it until new documentation is available


samoif

Nothing, no error but also no writing to file

baran2k

I have this problem too!
I'm back to use the 1.1.1 version...

baran2k

Version 1.2.1 released! and work fine!

samoif

I can confirm, problem fixed with Version 1.2.1, thanks!

Go Up