i have following code (very paraphrased, guards removed ease. real code attached).
using greiman's sdfat here: https://github.com/greiman/sdfat
i output:
init: 83
loop: 0
it seems opennext failing in loop.
anyone have ideas?
using greiman's sdfat here: https://github.com/greiman/sdfat
code: [select]
#include <sdfat.h>
sdfat sd;
sdfile file;
void setup()
{
sd.begin(chipselect, spispeed);
int maxfiles = 0;
while (file.opennext(sd.vwd(), o_read)) {
maxfiles++;
file.close();
}
cout << "init: " << maxfiles << endl;
}
void loop()
{
int maxfiles = 0;
while (file.opennext(sd.vwd(), o_read)) {
maxfiles++;
file.close();
}
cout << "loop: " << maxfiles << endl;
}
i output:
init: 83
loop: 0
it seems opennext failing in loop.
anyone have ideas?
i figured out.
if isopen() fails opennext()
you need close() first. :/
(or create macro close if open before opening next.)
if isopen() fails opennext()
you need close() first. :/
(or create macro close if open before opening next.)
Arduino Forum > Using Arduino > Storage > SdFat not reading in the loop
arduino
Comments
Post a Comment