SdFAT rewrite

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
asleepinverona
 
Posts: 16
Joined: Mon Nov 01, 2010 4:02 pm

SdFAT rewrite

Post by asleepinverona »

Hi all!

I am trying to move within a file on an SD card and it just doesn't seem to be working. Here is my code to move inside the file:

Code: Select all

  file_size=f.fileSize();
              f.seekSet(file_size-200);
Then I am trying a simple write operation:

Code: Select all

 f.write(data);
where data is some data I've gotten from the ADC. No matter what happens, I am only able to print at the end of the file, and not a previously written section. Any Ideas?

I've looked at the SDFATLIB Rewrite example and it didn't clear up anything for me. I'm clearing the write error. I tried using "print" instead of "write"

Thanks!

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: SdFAT rewrite

Post by fat16lib »

It would help if you posted more code.

Before posting the code try this to get more information. Replace the seekSet call with

Code: Select all

  if (!f.seekSet(file_size-200)) Serial.println("seekSet failed");
Also check writeError after the write

Code: Select all

  if (f.writeError) Serial.println("write failed");

asleepinverona
 
Posts: 16
Joined: Mon Nov 01, 2010 4:02 pm

Re: SdFAT rewrite

Post by asleepinverona »

I found out what the problem was. I was not opening the file correctly:

Code: Select all

f.open(&root,file_title_buffer,O_APPEND|O_WRITE);
versus

Code: Select all

f.open(&root,file_title_buffer,O_RDWR);
Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”