sparkfun / SparkFun_Qwiic_OpenLog_Arduino_Library

Control the I2C based Qwiic OpenLog with ease! This library makes reading, writing, and even arithmetic easy.
Other
17 stars 9 forks source link

Unable to get file size within a search loop #19

Open nigeljohnson73 opened 2 years ago

nigeljohnson73 commented 2 years ago

Subject of the issue

As well as the file names, I want to see the file sizes (so I can delete them if they are zero, but one thing at a time). Using example 7 and adding this inside the while loop (and nothing else)

long sizeOfFile = myLog.size(fileName);

Crashes the logger and you need a restart.

Your workbench

Steps to reproduce

Get example 7 working. Then add the line above in the while loop. It should look more like this:

  String fileName = myLog.getNextDirectoryItem();
  while (fileName != "") //getNextDirectoryItem() will return "" when we've hit the end of the directory
  {
    long sizeOfFile = myLog.size(fileName); // <<<<--- here we are
    Serial.println(fileName);
    fileName = myLog.getNextDirectoryItem();
  }
  Serial.println(F("Done!"));

Expected behavior

I would expect to get the file size back and be able to continue with the while loop

Actual behavior

Before the update:

OpenLog Read Directory Test
List of things in this directory:
config.txt
LOG00259.TXT
20220708/
LOG00244.TXT
LOG00245.TXT
LOG00246.TXT
LOG00247.TXT
LOG00248.TXT
LOG00249.TXT
LOG00250.TXT
LOG00251.TXT
LOG00252.TXT
... etc

After the update:

OpenLog Read Directory Test
List of things in this directory:
config.txt
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Done!