Go Down

Topic: SDFat open/close files (Read 2735 times) previous topic - next topic

aster94

hello, i am experimenting with this library and i noticed that it has some strange behaviour when i use simultaneously the Serial and when i open/close files

i made this fast bench test and it can't open/clone even the first file

Code: [Select]
for (byte a = 10; a >= 1; a--) {
      file = sd.open(a, FILE_WRITE); //create file
      delay(10);
      if (file) {
        file.println("stress test");
      } else {
        delay(10);
        Serial.print("stress test failed n#"); Serial.println(a);
      }
      delay(10);
      file.close();
      delay(10 * a);
    }


any suggestion?

PaulS

Quote
any suggestion?
RTFM. In particular, look at what the first argument to sd.open() is, and compare that to what you are supplying.

aster94

#2
Apr 26, 2017, 12:49 pm Last Edit: Apr 26, 2017, 12:55 pm by aster94
I know it needs an unsigned char,  in the main sketch i m using it correctly. But this is pointless, i am not able to open and close a file without resetting the board

If you think that the problem is this, well then supply the correct argument and tell me if it works  :)

PaulS

Quote
I know it needs an unsigned char
No, it does not. It needs an unsigned char ARRAY.

Quote
But this is pointless, i am not able to open and close a file without resetting the board
Well, you would be able to if you passed valid data to open().

Code: [Select]
for (byte a = 10; a >= 1; a--)
{
    char fileName[12];
    sprintf(fileName, "%d.txt", a);
    file = sd.open(fileName, FILE_WRITE); //create file

Go Up