SD_uFAT

Sign in or create your account | Project List | Help

Issue 10: EOF not appended when data written to file fill exactly a sector

Reported by Aurelio Bignoli, Aug 17, 2009

I've noticed a strange behaviour of the library: the EOF character 
is not appended at the end of the file when written data fill 
exactly a sector. A test case sketch is attached. 

After the first print, in the file there are 256 'A' followed by 256 
EOF.

After the second print, in the file there are 256 'A', followed by 
256 'B', followed by spaces and a few LF. No EOF.

The string "ciao" is never written to the file, because 
SDuFAT can't find EOF in it.

Regards,
Aurelio

Comment 1 by Aurelio Bignoli, Aug 17, 2009

Sorry, I had a problem with file attachment, the test sketch is the 
following:

#include <mmc.h>
#include <SDuFAT.h>
#include <microfat.h>

char myBuffer[257];

void setup (void) {
  Serial.begin (9600);

  Serial.println ("In order to run this test, hola.txt must be 
empty.");
  Serial.println ("You can use the hola.txt file included in 
SDuFAT.zip\n");

  Serial.println ("Send a character to write first 
block");
  while (Serial.available() == 0);
  Serial.read();
  for (int i=0; i<=256; i++) {
    myBuffer[i] = 'A';
  }
  myBuffer[256] = 0;
  int result = SD.print ("hola.txt", myBuffer);
  Serial.print ("First block written, result = ");
  Serial.println (result, DEC);

  Serial.println ("Send a character to write second 
block");
  while (Serial.available() == 0);
  Serial.read();
  for (int i=0; i<=256; i++) {
    myBuffer[i] = 'B';
  }
  myBuffer[256] = 0;
  result = SD.print ("hola.txt", myBuffer);
  Serial.print ("Second block written, result = ");
  Serial.println (result, DEC);

  Serial.println ("Send a character to write the final 
string");
  while (Serial.available() == 0);
  result = SD.print ("hola.txt", "ciao");
  Serial.print ("Final result = ");
  Serial.println (result, DEC);
}

void loop () {}

Comment 2 by Aurelio Bignoli, Aug 17, 2009

My environment: Linux, Arduino 0016 and 0017, avr-gcc 4.3.3, 
ATmega328.

Created: 1 year 23 days ago by Aurelio Bignoli

Updated: 1 year 23 days ago

Status: New

Labels:
Priority:Medium
Type:Defect

Commissioned by BLUSHINGBOY